71 std::optional<Library *> ,
86 pointcloud_dst->
runtime->bounds_cache = pointcloud_src->
runtime->bounds_cache;
87 pointcloud_dst->
runtime->bounds_with_radius_cache =
88 pointcloud_src->
runtime->bounds_with_radius_cache;
89 pointcloud_dst->
runtime->bvh_cache = pointcloud_src->
runtime->bvh_cache;
90 if (pointcloud_src->
runtime->bake_materials) {
91 pointcloud_dst->
runtime->bake_materials =
92 std::make_unique<blender::bke::bake::BakeMaterialsList>(
93 *pointcloud_src->
runtime->bake_materials);
113 for (
int i = 0;
i < pointcloud->
totcol;
i++) {
128 pointcloud->
attribute_storage.wrap(), {{AttrDomain::Point, &point_layers}}, attribute_data);
130 pointcloud->pdata,
AttrDomain::Point, pointcloud->totpoint, point_layers, attribute_data);
131 if (attribute_data.attributes.is_empty()) {
132 pointcloud->attribute_storage.dna_attributes =
nullptr;
133 pointcloud->attribute_storage.dna_attributes_num = 0;
136 pointcloud->attribute_storage.dna_attributes = attribute_data.attributes.data();
137 pointcloud->attribute_storage.dna_attributes_num = attribute_data.attributes.size();
148 pointcloud->totpoint,
151 pointcloud->attribute_storage.wrap().blend_write(*writer, attribute_data);
206 const T default_value)
211 if (
data !=
nullptr) {
223 if (
data ==
nullptr) {
232 const T default_value =
T())
241 if (
data !=
nullptr) {
247 if (pointcloud.
totpoint > 0 && span.
first() != default_value) {
248 span.
fill(default_value);
287 pointcloud->attributes_for_write().add<
float3>(
302 pointcloud_dst->
runtime->bounds_cache = pointcloud_src->
runtime->bounds_cache;
303 pointcloud_dst->
runtime->bounds_with_radius_cache =
304 pointcloud_src->
runtime->bounds_with_radius_cache;
305 pointcloud_dst->
runtime->bvh_cache = pointcloud_src->
runtime->bvh_cache;
309std::optional<blender::Bounds<float3>> PointCloud::bounds_min_max(
const bool use_radius)
const
311 using namespace blender;
312 using namespace blender::bke;
317 this->
runtime->bounds_with_radius_cache.ensure([&](Bounds<float3> &r_bounds) {
318 const VArray<float> radius = this->radius();
319 if (
const std::optional radius_single = radius.
get_if_single()) {
320 r_bounds = *this->bounds_min_max(
false);
321 r_bounds.
pad(*radius_single);
325 r_bounds = *bounds::min_max_with_radii(this->positions(), radius_span);
329 this->
runtime->bounds_cache.ensure(
330 [&](Bounds<float3> &r_bounds) { r_bounds = *bounds::min_max(this->positions()); });
332 return use_radius ? this->
runtime->bounds_with_radius_cache.data() :
333 this->
runtime->bounds_cache.data();
336std::optional<int> PointCloud::material_index_max()
const
345 if (max_material_index.has_value()) {
346 max_material_index = std::clamp(*max_material_index, 0,
MAXMAT);
348 return max_material_index;
358 return blender::bke::AttributeAccessor(
this,
364 return blender::bke::MutableAttributeAccessor(
410 for (; md; md = md->
next) {
434 if (pointcloud !=
nullptr) {
459 if (pointcloud_eval ==
nullptr) {
464 const bool eval_is_owned = pointcloud_eval != pointcloud;
469void PointCloud::tag_positions_changed()
471 this->
runtime->bounds_cache.tag_dirty();
472 this->
runtime->bounds_with_radius_cache.tag_dirty();
473 this->
runtime->bvh_cache.tag_dirty();
476void PointCloud::tag_radii_changed()
478 this->
runtime->bounds_with_radius_cache.tag_dirty();
void BKE_animdata_free(ID *id, bool do_id_user)
CustomData interface, see also DNA_customdata_types.h.
void CustomData_blend_write_prepare(CustomData &data, blender::bke::AttrDomain domain, int domain_size, blender::Vector< CustomDataLayer, 16 > &layers_to_write, blender::bke::AttributeStorage::BlendWriteData &write_data)
void CustomData_count_memory(const CustomData &data, int totelem, blender::MemoryCounter &memory)
void * CustomData_get_layer_named_for_write(CustomData *data, eCustomDataType type, blender::StringRef name, int totelem)
const void * CustomData_get_layer_named(const CustomData *data, eCustomDataType type, blender::StringRef name)
void * CustomData_add_layer_named(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem, blender::StringRef name)
void CustomData_reset(CustomData *data)
void CustomData_blend_write(BlendWriter *writer, CustomData *data, blender::Span< CustomDataLayer > layers_to_write, int count, eCustomDataMask cddata_mask, ID *id)
void CustomData_free(CustomData *data)
void CustomData_init_from(const CustomData *source, CustomData *dest, eCustomDataMask mask, int totelem)
void CustomData_blend_read(BlendDataReader *reader, CustomData *data, int count)
const char * BKE_idtype_idcode_to_name(short idcode)
@ IDTYPE_FLAGS_APPEND_IS_REUSABLE
void * BKE_libblock_alloc(Main *bmain, short type, const char *name, int flag) ATTR_WARN_UNUSED_RESULT
void BKE_id_free(Main *bmain, void *idv)
void BKE_libblock_init_empty(ID *id) ATTR_NONNULL(1)
ID * BKE_id_copy_ex(Main *bmain, const ID *id, ID **new_id_p, int flag)
void * BKE_id_new(Main *bmain, short type, const char *name)
void * BKE_id_new_nomain(short type, const char *name)
void BKE_id_blend_write(BlendWriter *writer, ID *id)
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER(data_, id_super_, cb_flag_)
void BKE_modifiers_clear_errors(Object *ob)
bool BKE_modifier_is_enabled(const Scene *scene, ModifierData *md, int required_mode)
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
ModifierData * BKE_modifiers_get_virtual_modifierlist(const Object *ob, VirtualModifierData *data)
General operations, lookup, etc. for blender objects.
void BKE_object_eval_assign_data(Object *object, ID *data, bool is_owned)
void BKE_object_free_derived_caches(Object *ob)
General operations for point clouds.
void(* BKE_pointcloud_batch_cache_free_cb)(PointCloud *pointcloud)
void(* BKE_pointcloud_batch_cache_dirty_tag_cb)(PointCloud *pointcloud, int mode)
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define BLO_write_id_struct(writer, struct_name, id_address, id)
void BLO_write_pointer_array(BlendWriter *writer, int64_t num, const void *data_ptr)
void BLO_read_pointer_array(BlendDataReader *reader, int64_t array_size, void **ptr_p)
#define BLT_I18NCONTEXT_ID_POINTCLOUD
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
#define DNA_struct_default_get(struct_name)
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
static const char * ATTR_POSITION
BMesh const char void * data
BPy_StructRNA * depsgraph
static const CPPType & get()
static VArray ForSingle(T value, const int64_t size)
static VArray ForSpan(Span< T > values)
constexpr void fill(const T &value) const
constexpr T & first() const
constexpr void copy_from(Span< T > values) const
std::optional< T > get_if_single() const
Span< T > get_internal_span() const
void replace(PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_dupallocN(const void *vmemh)
eCustomDataType cpp_type_to_custom_data_type(const CPPType &type)
void pointcloud_convert_storage_to_customdata(PointCloud &pointcloud)
const AttributeAccessorFunctions & pointcloud_attribute_accessor_functions()
PointCloud * pointcloud_new_no_attributes(int totpoint)
void attribute_storage_blend_write_prepare(AttributeStorage &data, const Map< AttrDomain, Vector< CustomDataLayer, 16 > * > &layers_to_write, AttributeStorage::BlendWriteData &write_data)
std::optional< T > max(const VArray< T > &values)
VecBase< float, 3 > float3
PointCloud * BKE_pointcloud_add(Main *bmain, const char *name)
static void pointcloud_init_data(ID *id)
PointCloud * BKE_pointcloud_copy_for_eval(const PointCloud *pointcloud_src)
void BKE_pointcloud_nomain_to_pointcloud(PointCloud *pointcloud_src, PointCloud *pointcloud_dst)
static void pointcloud_free_data(ID *id)
static Span< T > get_span_attribute(const PointCloud &pointcloud, const StringRef name)
static void pointcloud_foreach_id(ID *id, LibraryForeachIDData *data)
static VArray< T > get_varray_attribute(const PointCloud &pointcloud, const StringRef name, const T default_value)
PointCloud * BKE_pointcloud_new_nomain(const int totpoint)
void BKE_pointcloud_batch_cache_dirty_tag(PointCloud *pointcloud, int mode)
void BKE_pointcloud_batch_cache_free(PointCloud *pointcloud)
static PointCloud * take_pointcloud_ownership_from_geometry_set(blender::bke::GeometrySet &geometry_set)
static MutableSpan< T > get_mutable_attribute(PointCloud &pointcloud, const StringRef name, const T default_value=T())
static void pointcloud_blend_write(BlendWriter *writer, ID *id, const void *id_address)
void BKE_pointcloud_data_update(Depsgraph *depsgraph, Scene *scene, Object *object)
static void pointcloud_blend_read_data(BlendDataReader *reader, ID *id)
void pointcloud_copy_parameters(const PointCloud &src, PointCloud &dst)
static void pointcloud_copy_data(Main *, std::optional< Library * >, ID *id_dst, const ID *id_src, const int)
void(* BKE_pointcloud_batch_cache_free_cb)(PointCloud *pointcloud)
static void pointcloud_evaluate_modifiers(Depsgraph *depsgraph, Scene *scene, Object *object, blender::bke::GeometrySet &geometry_set)
void(* BKE_pointcloud_batch_cache_dirty_tag_cb)(PointCloud *pointcloud, int mode)
bool BKE_pointcloud_attribute_required(const PointCloud *, const blender::StringRef name)
void pad(const PaddingT &padding)
struct ModifierData * next
void(* modify_geometry_set)(ModifierData *md, const ModifierEvalContext *ctx, blender::bke::GeometrySet *geometry_set)
PointCloudRuntimeHandle * runtime
struct AttributeStorage attribute_storage
GeometryComponent & get_component_for_write(GeometryComponent::Type component_type)
bool has(const GeometryComponent::Type component_type) const
static GeometrySet from_pointcloud(PointCloud *pointcloud, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void remove(const GeometryComponent::Type component_type)