forked from blender/blender
realize-depth #5
@ -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
|
||||||
|
@ -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__));
|
||||||
|
@ -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*/,
|
||||||
|
Loading…
Reference in New Issue
Block a user