realize-depth #5

Merged
Arye Ramaty merged 43 commits from David-Haver/blender:realize-depth into WIP-realize-depth 2024-03-31 17:22:49 +02:00
3 changed files with 24 additions and 8 deletions
Showing only changes of commit 73cc27b988 - Show all commits

View File

@ -510,22 +510,38 @@ bool BuiltinCustomDataLayerProvider::try_create(void *owner,
return false; return false;
} }
auto update = [&]() {
if (update_on_change_ != nullptr) {
update_on_change_(owner);
}
};
const int element_num = custom_data_access_.get_element_num(owner); const int element_num = custom_data_access_.get_element_num(owner);
if (stored_as_named_attribute_) { if (stored_as_named_attribute_) {
if (CustomData_has_layer_named(custom_data, data_type_, name_)) { if (CustomData_has_layer_named(custom_data, data_type_, name_)) {
/* Exists already. */ /* Exists already. */
return false; return false;
} }
return add_custom_data_layer_from_attribute_init( if (add_custom_data_layer_from_attribute_init(
name_, *custom_data, stored_type_, element_num, initializer); name_, *custom_data, stored_type_, element_num, initializer))
{
update();
return true;
}
return false;
} }
if (CustomData_get_layer(custom_data, stored_type_) != nullptr) { if (CustomData_get_layer(custom_data, stored_type_) != nullptr) {
/* Exists already. */ /* Exists already. */
return false; return false;
} }
return add_builtin_type_custom_data_layer_from_init( if (add_builtin_type_custom_data_layer_from_init(
*custom_data, stored_type_, element_num, initializer); *custom_data, stored_type_, element_num, initializer))
{
update();
return true;
}
return false;
} }
bool BuiltinCustomDataLayerProvider::exists(const void *owner) const bool BuiltinCustomDataLayerProvider::exists(const void *owner) const

View File

@ -58,6 +58,8 @@ CurvesGeometry::CurvesGeometry() : CurvesGeometry(0, 0) {}
CurvesGeometry::CurvesGeometry(const int point_num, const int curve_num) CurvesGeometry::CurvesGeometry(const int point_num, const int curve_num)
{ {
this->runtime = MEM_new<CurvesGeometryRuntime>(__func__);
this->point_num = point_num; this->point_num = point_num;
this->curve_num = curve_num; this->curve_num = curve_num;
CustomData_reset(&this->point_data); CustomData_reset(&this->point_data);
@ -67,8 +69,6 @@ CurvesGeometry::CurvesGeometry(const int point_num, const int curve_num)
this->attributes_for_write().add<float3>( this->attributes_for_write().add<float3>(
"position", AttrDomain::Point, AttributeInitConstruct()); "position", AttrDomain::Point, AttributeInitConstruct());
this->runtime = MEM_new<CurvesGeometryRuntime>(__func__);
if (curve_num > 0) { if (curve_num > 0) {
this->curve_offsets = static_cast<int *>( this->curve_offsets = static_cast<int *>(
MEM_malloc_arrayN(this->curve_num + 1, sizeof(int), __func__)); MEM_malloc_arrayN(this->curve_num + 1, sizeof(int), __func__));

View File

@ -62,11 +62,11 @@ static void pointcloud_init_data(ID *id)
MEMCPY_STRUCT_AFTER(pointcloud, DNA_struct_default_get(PointCloud), id); MEMCPY_STRUCT_AFTER(pointcloud, DNA_struct_default_get(PointCloud), id);
pointcloud->runtime = new blender::bke::PointCloudRuntime();
CustomData_reset(&pointcloud->pdata); CustomData_reset(&pointcloud->pdata);
pointcloud->attributes_for_write().add<float3>( pointcloud->attributes_for_write().add<float3>(
"position", blender::bke::AttrDomain::Point, blender::bke::AttributeInitConstruct()); "position", blender::bke::AttrDomain::Point, blender::bke::AttributeInitConstruct());
pointcloud->runtime = new blender::bke::PointCloudRuntime();
} }
static void pointcloud_copy_data(Main * /*bmain*/, static void pointcloud_copy_data(Main * /*bmain*/,