Blender V5.0
draw_hair_private.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2017 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
12#include "draw_pass.hh"
13
14namespace blender::bke {
15class CurvesGeometry;
16}
17
18namespace blender::draw {
19
20struct CurvesEvalCache;
21
23 public:
24 CurveRefinePass(const char *name) : PassSimple(name) {};
25};
26
27using CurvesInfosBuf = UniformBuffer<CurvesInfos>;
28
31 int used = 0;
32
33 void reset()
34 {
35 used = 0;
36 /* Allocate dummy. */
37 alloc();
38 ubos.first()->push_update();
39 }
40
42 {
43 return *ubos.first();
44 }
45
47};
48
51 CurveRefinePass refine = {"CurvesEvalPass"};
52 /* Contains all transient input buffers contained inside `refine`.
53 * Cleared after update. */
55
56 gpu::VertBuf *dummy_vbo = drw_curves_ensure_dummy_vbo();
57
62
63 void init()
64 {
65 ubo_pool.reset();
66
67 refine.init();
68 refine.state_set(DRW_STATE_NO_DRAW);
69 }
70
71 /* Record evaluation inside `refine`.
72 * Output will be ready once `refine` pass has been submitted. */
73 void evaluate_curve_attribute(bool has_catmull,
74 bool has_bezier,
75 bool has_poly,
76 bool has_nurbs,
77 bool has_cyclic,
78 int curve_count,
79 CurvesEvalCache &cache,
80 CurvesEvalShader shader_type,
81 gpu::VertBufPtr input_buf,
82 gpu::VertBufPtr &output_buf,
83 /* For radius during position evaluation. */
84 gpu::VertBuf *input2_buf = nullptr,
85 /* For baking a transform during position evaluation. */
87
88 void evaluate_positions(bool has_catmull,
89 bool has_bezier,
90 bool has_poly,
91 bool has_nurbs,
92 bool has_cyclic,
93 int curve_count,
94 CurvesEvalCache &cache,
95 gpu::VertBufPtr input_pos_buf,
96 gpu::VertBufPtr input_rad_buf,
97 gpu::VertBufPtr &output_pos_buf,
99 {
100 evaluate_curve_attribute(has_catmull,
101 has_bezier,
102 has_poly,
103 has_nurbs,
104 has_cyclic,
105 curve_count,
106 cache,
108 std::move(input_pos_buf),
109 output_pos_buf,
110 /* Transfer ownership through optional argument. */
111 input_rad_buf.release(),
112 transform);
113 }
114
115 void evaluate_curve_length_intercept(bool has_cyclic, int curve_count, CurvesEvalCache &cache);
116
118 const int point_count,
119 CurvesEvalCache &cache,
120 bool is_ribbon,
121 bool has_cyclic);
122
123 private:
124 gpu::VertBuf *drw_curves_ensure_dummy_vbo();
125
126 void dispatch(int curve_count, PassSimple::Sub &pass);
127};
128
129} // namespace blender::draw
130
131#define MAX_LAYER_NAME_CT 4 /* `u0123456789, u, au, a0123456789`. */
132#define MAX_LAYER_NAME_LEN (GPU_MAX_SAFE_ATTR_NAME + 2)
133#define MAX_THICKRES 2 /* see eHairType */
134#define MAX_HAIR_SUBDIV 4 /* see hair_subdiv rna */
135
140
141struct ModifierData;
142struct Object;
143struct ParticleHairCache;
144struct ParticleSystem;
145
146namespace blender::draw {
147
148void drw_particle_update_ptcache(Object *object_eval, ParticleSystem *psys);
150 ParticleSystem *psys,
151 ModifierData *md,
152 PTCacheEdit *edit,
153 int additional_subdivision);
154
156
157} // namespace blender::draw
struct PTCacheEdit PTCacheEdit
struct ModifierData ModifierData
struct Object Object
struct ParticleSystem ParticleSystem
#define GPU_VERTBUF_DISCARD_SAFE(verts)
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
detail::PassBase< command::DrawCommandBuf > Sub
Definition draw_pass.hh:499
ParticleRefineShader
@ PART_REFINE_MAX_SHADER
@ PART_REFINE_CATMULL_ROM
@ DRW_STATE_NO_DRAW
Definition draw_state.hh:27
void drw_particle_update_ptcache(Object *object_eval, ParticleSystem *psys)
CurvesEvalCache & hair_particle_get_eval_cache(ParticleDrawSource &src)
detail::Pass< command::DrawCommandBuf > PassSimple
ParticleDrawSource drw_particle_get_hair_source(Object *object, ParticleSystem *psys, ModifierData *md, PTCacheEdit *edit, const int additional_subdivision)
UniformBuffer< CurvesInfos > CurvesInfosBuf
std::unique_ptr< gpu::VertBuf, gpu::VertBufDeleter > VertBufPtr
MatBase< float, 4, 4 > float4x4
const char * name
CurvesUniformBufPool ubo_pool
void evaluate_curve_attribute(bool has_catmull, bool has_bezier, bool has_poly, bool has_nurbs, bool has_cyclic, int curve_count, CurvesEvalCache &cache, CurvesEvalShader shader_type, gpu::VertBufPtr input_buf, gpu::VertBufPtr &output_buf, gpu::VertBuf *input2_buf=nullptr, float4x4 transform=float4x4::identity())
void evaluate_positions(bool has_catmull, bool has_bezier, bool has_poly, bool has_nurbs, bool has_cyclic, int curve_count, CurvesEvalCache &cache, gpu::VertBufPtr input_pos_buf, gpu::VertBufPtr input_rad_buf, gpu::VertBufPtr &output_pos_buf, float4x4 transform=float4x4::identity())
Vector< gpu::VertBufPtr > transient_buffers
gpu::VertBufPtr evaluate_topology_indirection(const int curve_count, const int point_count, CurvesEvalCache &cache, bool is_ribbon, bool has_cyclic)
void evaluate_curve_length_intercept(bool has_cyclic, int curve_count, CurvesEvalCache &cache)
Vector< std::unique_ptr< CurvesInfosBuf > > ubos