100 if (cache ==
nullptr) {
114 cache = MEM_new<PointCloudBatchCache>(__func__);
131 if (cache ==
nullptr) {
197 bool do_discard =
false;
242 for (int p : range) {
243 for (int i : IndexRange(tri_count_per_point)) {
244 data[p * tri_count_per_point + i] = uint3(half_octahedron_tris[i]) | (p << 3);
250 &builder, 0, primitive_len * 3,
false, cache.eval_cache.geom_indices);
258 const VArray<float> radii = *attributes.lookup<
float>(
"radius");
260 if (
format.attr_len == 0) {
272 for (const int i : range) {
273 vbo_data[i].x = positions[i].x;
274 vbo_data[i].y = positions[i].y;
275 vbo_data[i].z = positions[i].z;
277 vbo_data[i].w = radii_span[i] * 100.0f;
282 threading::parallel_for(vbo_data.index_range(), 4096, [&](
IndexRange range) {
283 for (const int i : range) {
284 vbo_data[i].x = positions[i].x;
285 vbo_data[i].y = positions[i].y;
286 vbo_data[i].z = positions[i].z;
287 vbo_data[i].w = 1.0f;
311 if (
format.attr_len == 0) {
345 const char *name = gpu_attr->name;
416 if (request_i == -1) {
General operations for point clouds.
@ BKE_POINTCLOUD_BATCH_DIRTY_ALL
#define LISTBASE_FOREACH(type, var, list)
MINLINE int max_ii(int a, int b)
Object is a sort of wrapper for general info.
#define GPU_BATCH_DISCARD_SAFE(batch)
void GPU_indexbuf_build_in_place_ex(GPUIndexBufBuilder *builder, uint index_min, uint index_max, bool uses_restart_indices, blender::gpu::IndexBuf *elem)
blender::MutableSpan< uint32_t > GPU_indexbuf_get_data(GPUIndexBufBuilder *)
#define GPU_INDEXBUF_DISCARD_SAFE(elem)
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len)
ListBase GPU_material_attributes(const GPUMaterial *material)
#define GPU_VERTBUF_DISCARD_SAFE(verts)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
void GPU_vertbuf_init_with_format_ex(blender::gpu::VertBuf &verts, const GPUVertFormat &format, GPUUsageType)
@ GPU_USAGE_FLAG_BUFFER_TEXTURE_ONLY
Read Guarded memory(de)allocation.
constexpr MutableSpan< NewT > cast() const
constexpr IndexRange index_range() const
Utilities for rendering attributes.
bool DRW_batch_requested(blender::gpu::Batch *batch, GPUPrimType prim_type)
blender::gpu::Batch * DRW_batch_request(blender::gpu::Batch **batch)
void DRW_vbo_request(blender::gpu::Batch *batch, blender::gpu::VertBuf **vbo)
bool DRW_vbo_requested(blender::gpu::VertBuf *vbo)
void DRW_ibo_request(blender::gpu::Batch *batch, blender::gpu::IndexBuf **ibo)
bool DRW_ibo_requested(blender::gpu::IndexBuf *ibo)
void *(* MEM_callocN)(size_t len, const char *str)
static PointCloudBatchCache * pointcloud_batch_cache_get(PointCloud &pointcloud)
gpu::Batch * pointcloud_surface_get(PointCloud *pointcloud)
void drw_attributes_clear(DRW_Attributes *attributes)
static void pointcloud_extract_position_and_radius(const PointCloud &pointcloud, PointCloudBatchCache &cache)
static void pointcloud_discard_attributes(PointCloudBatchCache &cache)
void DRW_pointcloud_batch_cache_dirty_tag(PointCloud *pointcloud, int mode)
bool drw_custom_data_match_attribute(const CustomData &custom_data, const char *name, int *r_layer_index, eCustomDataType *r_type)
static void pointcloud_batch_cache_init(PointCloud &pointcloud)
gpu::Batch ** pointcloud_surface_shaded_get(PointCloud *pointcloud, GPUMaterial **gpu_materials, int mat_len)
blender::gpu::Batch * DRW_pointcloud_batch_cache_get_dots(Object *ob)
static void pointcloud_batch_cache_clear(PointCloud &pointcloud)
static void pointcloud_extract_indices(const PointCloud &pointcloud, PointCloudBatchCache &cache)
void DRW_pointcloud_batch_cache_free_old(PointCloud *pointcloud, int ctime)
static const uint half_octahedron_tris[4][3]
void DRW_pointcloud_batch_cache_create_requested(Object *ob)
void DRW_pointcloud_batch_cache_validate(PointCloud *pointcloud)
int DRW_pointcloud_material_count_get(const PointCloud *pointcloud)
void drw_attributes_merge(DRW_Attributes *dst, const DRW_Attributes *src, std::mutex &render_mutex)
static bool pointcloud_batch_cache_valid(PointCloud &pointcloud)
gpu::VertBuf ** DRW_pointcloud_evaluated_attribute(PointCloud *pointcloud, const char *name)
static void pointcloud_extract_attribute(const PointCloud &pointcloud, PointCloudBatchCache &cache, const DRW_AttributeRequest &request, int index)
void DRW_pointcloud_batch_cache_free(PointCloud *pointcloud)
void drw_attributes_add_request(DRW_Attributes *attrs, const char *name, const eCustomDataType type, const int layer_index, const blender::bke::AttrDomain domain)
gpu::VertBuf * pointcloud_position_and_radius_get(PointCloud *pointcloud)
gpu::VertBuf * DRW_pointcloud_position_and_radius_buffer_get(Object *ob)
bool drw_attributes_overlap(const DRW_Attributes *a, const DRW_Attributes *b)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
blender::bke::AttrDomain domain
DRW_AttributeRequest requests[GPU_MAX_ATTR]
PointCloudEvalCache eval_cache
DRW_Attributes attr_used_over_time
gpu::VertBuf * attr_viewer
int last_attr_matching_time
gpu::IndexBuf * geom_indices
gpu::VertBuf * attributes_buf[GPU_MAX_ATTR]
gpu::Batch ** surface_per_mat