69 return (cache && cache->
is_dirty ==
false);
77 cache = MEM_cnew<CurvesBatchCache>(__func__);
78 curves.batch_cache = cache;
81 memset(cache, 0,
sizeof(*cache));
159 if (cache ==
nullptr) {
182 if (cache ==
nullptr) {
186 bool do_discard =
false;
234 for (
const int i_curve :
IndexRange(curve_num)) {
240 float total_len = 0.0f;
241 for (
const int i_point : curve_positions.
index_range()) {
244 curve_positions[i_point]);
246 curve_posTime_data[i_point].position = curve_positions[i_point];
247 curve_posTime_data[i_point].parameter = total_len;
249 hairLength_data[i_curve] = total_len;
252 if (total_len > 0.0f) {
253 const float factor = 1.0f / total_len;
255 for (
const int i_point : curve_positions.
index_range()) {
256 curve_posTime_data[i_point].parameter *= factor;
312 BLI_snprintf(r_sampler_name, 32,
"a%s", attr_safe_name);
346 char sampler_name[32];
359 curves.geometry.curve_num);
462 const int curves_num =
curves.geometry.curve_num;
466 for ([[maybe_unused]]
const int i :
IndexRange(curves_num)) {
467 for (
int k = 0; k < res; k++) {
476 const int thickness_res,
487 int element_count = (verts_per_curve + 1) * cache.
strands_len;
523 const char *name = gpu_attr->name;
552 bool need_tf_update =
false;
562 need_tf_update =
true;
568 return need_tf_update;
575 const int thickness_res)
577 bool need_ft_update =
false;
583 (*r_hair_cache)->final[subdiv].strands_res = 1 << (
steps + subdiv);
586 if ((*r_hair_cache)->proc_point_buf ==
nullptr) {
589 need_ft_update =
true;
593 if ((*r_hair_cache)->strand_tex ==
nullptr) {
598 if ((*r_hair_cache)->final[subdiv].proc_buf ==
nullptr) {
600 need_ft_update =
true;
602 if ((*r_hair_cache)->final[subdiv].proc_hairs[thickness_res - 1] ==
nullptr) {
609 return need_ft_update;
635 std::optional<blender::bke::AttributeMetaData> meta_data =
643 curves.geometry.curve_data;
653 bool *r_is_point_domain)
670 if (request_i == -1) {
671 *r_is_point_domain =
false;
676 *r_is_point_domain =
true;
679 *r_is_point_domain =
false;
@ BKE_CURVES_BATCH_DIRTY_ALL
Low-level operations for curves.
int CustomData_get_named_layer(const struct CustomData *data, int type, const char *name)
#define BLI_assert_unreachable()
#define LISTBASE_FOREACH(type, var, list)
MINLINE int max_ii(int a, int b)
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void BLI_mutex_end(ThreadMutex *mutex)
void BLI_mutex_init(ThreadMutex *mutex)
pthread_mutex_t ThreadMutex
Object is a sort of wrapper for general info.
#define DRW_TEXTURE_FREE_SAFE(tex)
#define GPU_BATCH_DISCARD_SAFE(batch)
GPUBatch * GPU_batch_create_ex(GPUPrimType prim, GPUVertBuf *vert, GPUIndexBuf *elem, eGPUBatchFlag owns_flag)
void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder *)
GPUIndexBuf * GPU_indexbuf_build(GPUIndexBufBuilder *)
void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder *, uint v)
void GPU_indexbuf_init_ex(GPUIndexBufBuilder *, GPUPrimType, uint index_len, uint vertex_len)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
ListBase GPU_material_attributes(GPUMaterial *material)
struct GPUTexture GPUTexture
GPUTexture * GPU_texture_create_from_vertbuf(const char *name, struct GPUVertBuf *vert)
#define GPU_vertbuf_create_with_format(format)
struct GPUVertBuf GPUVertBuf
void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len)
void * GPU_vertbuf_get_data(const GPUVertBuf *verts)
#define GPU_VERTBUF_DISCARD_SAFE(verts)
void GPU_vertbuf_use(GPUVertBuf *)
GPUVertBuf * GPU_vertbuf_create_with_format_ex(const GPUVertFormat *, GPUUsageType)
GPU_INLINE void * GPU_vertbuf_raw_step(GPUVertBufRaw *a)
void GPU_vertbuf_attr_get_raw_data(GPUVertBuf *, uint a_idx, GPUVertBufRaw *access)
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color attribute
constexpr int64_t size() const
constexpr int64_t start() const
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
constexpr IndexRange index_range() const
int domain_size(const eAttrDomain domain) const
std::optional< AttributeMetaData > lookup_meta_data(const AttributeIDRef &attribute_id) const
GVArray lookup_or_default(const AttributeIDRef &attribute_id, const eAttrDomain domain, const eCustomDataType data_type, const void *default_value=nullptr) const
static CurvesGeometry & wrap(::CurvesGeometry &dna_struct)
AttributeAccessor attributes() const
void drw_attributes_merge(DRW_Attributes *dst, const DRW_Attributes *src, ThreadMutex *render_mutex)
bool drw_custom_data_match_attribute(const CustomData *custom_data, const char *name, int *r_layer_index, eCustomDataType *r_type)
DRW_AttributeRequest * drw_attributes_add_request(DRW_Attributes *attrs, const char *name, const eCustomDataType type, const int layer_index, const eAttrDomain domain)
bool drw_attributes_overlap(const DRW_Attributes *a, const DRW_Attributes *b)
void drw_attributes_clear(DRW_Attributes *attributes)
Utilities for rendering attributes.
static void ensure_seg_pt_count(const Curves &curves, CurvesEvalCache &curves_cache)
int DRW_curves_material_count_get(Curves *curves)
bool curves_ensure_procedural_data(Curves *curves, CurvesEvalCache **r_hair_cache, GPUMaterial *gpu_material, const int subdiv, const int thickness_res)
static void curves_discard_attributes(CurvesEvalCache &curves_cache)
static void curves_batch_cache_fill_segments_indices(const Curves &curves, const int res, GPUIndexBufBuilder &elb)
static bool curves_ensure_attributes(const Curves &curves, CurvesBatchCache &cache, GPUMaterial *gpu_material, int subdiv)
static void curves_batch_cache_ensure_procedural_final_attr(CurvesEvalCache &cache, const GPUVertFormat *format, const int subdiv, const int index, const char *name)
void drw_curves_get_attribute_sampler_name(const char *layer_name, char r_sampler_name[32])
static void curves_batch_cache_ensure_procedural_final_points(CurvesEvalCache &cache, int subdiv)
void DRW_curves_batch_cache_validate(Curves *curves)
static void curves_batch_cache_fill_segments_proc_pos(const Curves &curves_id, MutableSpan< PositionAndParameter > posTime_data, MutableSpan< float > hairLength_data)
static void curves_batch_cache_ensure_procedural_pos(const Curves &curves, CurvesEvalCache &cache, GPUMaterial *gpu_material)
void DRW_curves_batch_cache_free_old(Curves *curves, int ctime)
static CurvesBatchCache & curves_batch_cache_get(Curves &curves)
static bool curves_batch_cache_valid(const Curves &curves)
GPUTexture ** DRW_curves_texture_for_evaluated_attribute(Curves *curves, const char *name, bool *r_is_point_domain)
static void curves_batch_cache_ensure_procedural_indices(Curves &curves, CurvesEvalCache &cache, const int thickness_res, const int subdiv)
static void curves_batch_cache_ensure_procedural_strand_data(Curves &curves, CurvesEvalCache &cache)
static void request_attribute(Curves &curves, const char *name)
void DRW_curves_batch_cache_free(Curves *curves)
GPUBatch * DRW_curves_batch_cache_get_edit_points(Curves *curves)
static void curves_batch_cache_init(Curves &curves)
static void curves_batch_cache_clear(Curves &curves)
void DRW_curves_batch_cache_dirty_tag(Curves *curves, int mode)
void DRW_curves_batch_cache_create_requested(Object *ob)
static void curves_batch_cache_clear_data(CurvesEvalCache &curves_cache)
static void curves_batch_ensure_attribute(const Curves &curves, CurvesEvalCache &cache, const DRW_AttributeRequest &request, const int subdiv, const int index)
static void curves_batch_cache_fill_strands_data(const Curves &curves_id, GPUVertBufRaw &data_step, GPUVertBufRaw &seg_step)
BLI_INLINE void DRW_vbo_request(GPUBatch *batch, GPUVertBuf **vbo)
BLI_INLINE bool DRW_vbo_requested(GPUVertBuf *vbo)
BLI_INLINE bool DRW_batch_requested(GPUBatch *batch, GPUPrimType prim_type)
BLI_INLINE GPUBatch * DRW_batch_request(GPUBatch **batch)
const DRWContextState * DRW_context_state_get(void)
T distance(const T &a, const T &b)
vec_base< float, 3 > float3
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
MutableSpan< float3 > positions
CurvesEvalCache curves_cache
GPUVertBuf * proc_strand_seg_buf
CurvesEvalFinalCache final[MAX_HAIR_SUBDIV]
GPUVertBuf * proc_attributes_buf[GPU_MAX_ATTR]
GPUTexture * proc_attributes_tex[GPU_MAX_ATTR]
GPUVertBuf * proc_strand_buf
GPUVertBuf * proc_point_buf
GPUVertBuf * proc_length_buf
GPUTexture * strand_seg_tex
DRW_Attributes attr_used_over_time
GPUBatch * proc_hairs[MAX_THICKRES]
GPUVertBuf * attributes_buf[GPU_MAX_ATTR]
int last_attr_matching_time
GPUTexture * attributes_tex[GPU_MAX_ATTR]
DRW_AttributeRequest requests[GPU_MAX_ATTR]