Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-08-30 22:54:53 +0300
committerHans Goudey <h.goudey@me.com>2022-08-30 22:56:05 +0300
commit25237d2625078c6d14d744f288776299efd3c7c8 (patch)
tree17d11451a5b816b15905e34402aa1b046d666c7a
parentd81e947c591ec6f3de2bc407b9f837b2efa36890 (diff)
Attributes: Improve custom data initialization options
When allocating new `CustomData` layers, often we do redundant initialization of arrays. For example, it's common that values are allocated, set to their default value, and then set to some other value. This is wasteful, and it negates the benefits of optimizations to the allocator like D15082. There are two reasons for this. The first is array-of-structs storage that makes it annoying to initialize values manually, and the second is confusing options in the Custom Data API. This patch addresses the latter. The `CustomData` "alloc type" options are rearranged. Now, besides the options that use existing layers, there are two remaining: * `CD_SET_DEFAULT` sets the default value. * Usually zeroes, but for colors this is white (how it was before). * Should be used when you add the layer but don't set all values. * `CD_CONSTRUCT` refers to the "default construct" C++ term. * Only necessary or defined for non-trivial types like vertex groups. * Doesn't do anything for trivial types like `int` or `float3`. * Should be used every other time, when all values will be set. The attribute API's `AttributeInit` types are updated as well. To update code, replace `CD_CALLOC` with `CD_SET_DEFAULT` and `CD_DEFAULT` with `CD_CONSTRUCT`. This doesn't cause any functional changes yet. Follow-up commits will change to avoid initializing new layers where the correctness is clear. Differential Revision: https://developer.blender.org/D15617
m---------release/datafiles/locale0
m---------release/scripts/addons0
-rw-r--r--source/blender/blenkernel/BKE_attribute.hh43
-rw-r--r--source/blender/blenkernel/BKE_customdata.h11
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.cc42
-rw-r--r--source/blender/blenkernel/intern/attribute.cc2
-rw-r--r--source/blender/blenkernel/intern/attribute_access.cc30
-rw-r--r--source/blender/blenkernel/intern/curves_geometry.cc4
-rw-r--r--source/blender/blenkernel/intern/customdata.cc171
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c18
-rw-r--r--source/blender/blenkernel/intern/deform.c9
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c6
-rw-r--r--source/blender/blenkernel/intern/editmesh_tangent.c2
-rw-r--r--source/blender/blenkernel/intern/geometry_component_curve.cc11
-rw-r--r--source/blender/blenkernel/intern/mball_tessellate.c7
-rw-r--r--source/blender/blenkernel/intern/mesh.cc28
-rw-r--r--source/blender/blenkernel/intern/mesh_boolean_convert.cc8
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.cc5
-rw-r--r--source/blender/blenkernel/intern/mesh_legacy_convert.cc21
-rw-r--r--source/blender/blenkernel/intern/mesh_normals.cc2
-rw-r--r--source/blender/blenkernel/intern/mesh_remap.c2
-rw-r--r--source/blender/blenkernel/intern/mesh_remesh_voxel.cc6
-rw-r--r--source/blender/blenkernel/intern/mesh_tangent.c5
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.cc4
-rw-r--r--source/blender/blenkernel/intern/multires.c4
-rw-r--r--source/blender/blenkernel/intern/multires_reshape.c3
-rw-r--r--source/blender/blenkernel/intern/multires_reshape_subdivide.c3
-rw-r--r--source/blender/blenkernel/intern/multires_unsubdivide.c6
-rw-r--r--source/blender/blenkernel/intern/object.cc2
-rw-r--r--source/blender/blenkernel/intern/object_deform.c3
-rw-r--r--source/blender/blenkernel/intern/paint.cc14
-rw-r--r--source/blender/blenkernel/intern/particle_system.c2
-rw-r--r--source/blender/blenkernel/intern/pbvh.c2
-rw-r--r--source/blender/blenkernel/intern/pointcloud.cc8
-rw-r--r--source/blender/blenkernel/intern/subdiv_mesh.cc4
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c6
-rw-r--r--source/blender/blenlib/intern/BLI_memarena.c1
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c26
-rw-r--r--source/blender/bmesh/intern/bmesh_interp.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_convert.cc48
-rw-r--r--source/blender/editors/curves/intern/curves_add.cc2
-rw-r--r--source/blender/editors/geometry/geometry_attributes.cc4
-rw-r--r--source/blender/editors/mesh/mesh_data.cc27
-rw-r--r--source/blender/editors/mesh/meshtools.cc16
-rw-r--r--source/blender/editors/object/object_facemap_ops.c2
-rw-r--r--source/blender/editors/object/object_modifier.cc10
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_dyntopo.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c2
-rw-r--r--source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp16
-rw-r--r--source/blender/io/alembic/intern/abc_customdata.cc2
-rw-r--r--source/blender/io/alembic/intern/abc_reader_mesh.cc4
-rw-r--r--source/blender/io/collada/MeshImporter.cpp15
-rw-r--r--source/blender/io/stl/importer/stl_import_mesh.cc6
-rw-r--r--source/blender/io/usd/intern/usd_reader_mesh.cc5
-rw-r--r--source/blender/io/wavefront_obj/importer/obj_import_mesh.cc4
-rw-r--r--source/blender/io/wavefront_obj/tests/obj_importer_tests.cc2
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c13
-rw-r--r--source/blender/makesrna/intern/rna_mesh_api.c4
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c2
-rw-r--r--source/blender/modifiers/intern/MOD_nodes.cc8
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c2
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c12
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c2
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c2
-rw-r--r--source/blender/modifiers/intern/MOD_solidify_extrude.c2
-rw-r--r--source/blender/modifiers/intern/MOD_solidify_nonmanifold.c2
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weighted_normal.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc2
74 files changed, 429 insertions, 331 deletions
diff --git a/release/datafiles/locale b/release/datafiles/locale
-Subproject a2eb507891449a0b67582be9561840075513661
+Subproject 1b891478f44dd047c3a92fda3ebd17fae1c3acd
diff --git a/release/scripts/addons b/release/scripts/addons
-Subproject 7a8502871c34db0343cc7de52d6b49b15a84238
+Subproject 25ffc6f430fc995b1c046b01acba1c3e6c1896b
diff --git a/source/blender/blenkernel/BKE_attribute.hh b/source/blender/blenkernel/BKE_attribute.hh
index c2f65c93cbe..6284cce9dc0 100644
--- a/source/blender/blenkernel/BKE_attribute.hh
+++ b/source/blender/blenkernel/BKE_attribute.hh
@@ -73,8 +73,13 @@ struct AttributeKind {
*/
struct AttributeInit {
enum class Type {
- Default,
+ /** #AttributeInitConstruct. */
+ Construct,
+ /** #AttributeInitDefaultValue. */
+ DefaultValue,
+ /** #AttributeInitVArray. */
VArray,
+ /** #AttributeInitMoveArray. */
MoveArray,
};
Type type;
@@ -84,11 +89,20 @@ struct AttributeInit {
};
/**
- * Create an attribute using the default value for the data type.
- * The default values may depend on the attribute provider implementation.
+ * Default construct new attribute values. Does nothing for trivial types. This should be used
+ * if all attribute element values will be set by the caller after creating the attribute.
*/
-struct AttributeInitDefault : public AttributeInit {
- AttributeInitDefault() : AttributeInit(Type::Default)
+struct AttributeInitConstruct : public AttributeInit {
+ AttributeInitConstruct() : AttributeInit(Type::Construct)
+ {
+ }
+};
+
+/**
+ * Create an attribute using the default value for the data type (almost always "zero").
+ */
+struct AttributeInitDefaultValue : public AttributeInit {
+ AttributeInitDefaultValue() : AttributeInit(Type::DefaultValue)
{
}
};
@@ -96,14 +110,11 @@ struct AttributeInitDefault : public AttributeInit {
/**
* Create an attribute by copying data from an existing virtual array. The virtual array
* must have the same type as the newly created attribute.
- *
- * Note that this can be used to fill the new attribute with the default
*/
struct AttributeInitVArray : public AttributeInit {
- blender::GVArray varray;
+ GVArray varray;
- AttributeInitVArray(blender::GVArray varray)
- : AttributeInit(Type::VArray), varray(std::move(varray))
+ AttributeInitVArray(GVArray varray) : AttributeInit(Type::VArray), varray(std::move(varray))
{
}
};
@@ -119,10 +130,10 @@ struct AttributeInitVArray : public AttributeInit {
* The array must be allocated with MEM_*, since `attribute_try_create` will free the array if it
* can't be used directly, and that is generally how Blender expects custom data to be allocated.
*/
-struct AttributeInitMove : public AttributeInit {
+struct AttributeInitMoveArray : public AttributeInit {
void *data = nullptr;
- AttributeInitMove(void *data) : AttributeInit(Type::MoveArray), data(data)
+ AttributeInitMoveArray(void *data) : AttributeInit(Type::MoveArray), data(data)
{
}
};
@@ -579,7 +590,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const eCustomDataType data_type,
- const AttributeInit &initializer = AttributeInitDefault());
+ const AttributeInit &initializer = AttributeInitDefaultValue());
/**
* Same as above, but returns a type that makes it easier to work with the attribute as a span.
@@ -590,7 +601,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
const eCustomDataType data_type,
- const AttributeInit &initializer = AttributeInitDefault());
+ const AttributeInit &initializer = AttributeInitDefaultValue());
/**
* Same as above, but should be used when the type is known at compile time.
@@ -599,7 +610,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
AttributeWriter<T> lookup_or_add_for_write(
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
- const AttributeInit &initializer = AttributeInitDefault())
+ const AttributeInit &initializer = AttributeInitDefaultValue())
{
const CPPType &cpp_type = CPPType::get<T>();
const eCustomDataType data_type = cpp_type_to_custom_data_type(cpp_type);
@@ -613,7 +624,7 @@ class MutableAttributeAccessor : public AttributeAccessor {
SpanAttributeWriter<T> lookup_or_add_for_write_span(
const AttributeIDRef &attribute_id,
const eAttrDomain domain,
- const AttributeInit &initializer = AttributeInitDefault())
+ const AttributeInit &initializer = AttributeInitDefaultValue())
{
AttributeWriter<T> attribute = this->lookup_or_add_for_write<T>(
attribute_id, domain, initializer);
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 3db75fff12c..44a4f4b5395 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -55,14 +55,17 @@ extern const CustomData_MeshMasks CD_MASK_EVERYTHING;
typedef enum eCDAllocType {
/** Use the data pointer. */
CD_ASSIGN = 0,
- /** Allocate blank memory. */
- CD_CALLOC = 1,
- /** Allocate and set to default. */
- CD_DEFAULT = 2,
+ /** Allocate and set to default, which is usually just zeroed memory. */
+ CD_SET_DEFAULT = 2,
/** Use data pointers, set layer flag NOFREE. */
CD_REFERENCE = 3,
/** Do a full copy of all layers, only allowed if source has same number of elements. */
CD_DUPLICATE = 4,
+ /**
+ * Default construct new layer values. Does nothing for trivial types. This should be used
+ * if all layer values will be set by the caller after creating the layer.
+ */
+ CD_CONSTRUCT = 5,
} eCDAllocType;
#define CD_TYPE_AS_MASK(_type) (eCustomDataMask)((eCustomDataMask)1 << (eCustomDataMask)(_type))
diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc
index 2ce5863c176..3afdbccb1f4 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.cc
+++ b/source/blender/blenkernel/intern/DerivedMesh.cc
@@ -95,7 +95,7 @@ static MVert *dm_getVertArray(DerivedMesh *dm)
if (!mvert) {
mvert = (MVert *)CustomData_add_layer(
- &dm->vertData, CD_MVERT, CD_CALLOC, nullptr, dm->getNumVerts(dm));
+ &dm->vertData, CD_MVERT, CD_SET_DEFAULT, nullptr, dm->getNumVerts(dm));
CustomData_set_layer_flag(&dm->vertData, CD_MVERT, CD_FLAG_TEMPORARY);
dm->copyVertArray(dm, mvert);
}
@@ -109,7 +109,7 @@ static MEdge *dm_getEdgeArray(DerivedMesh *dm)
if (!medge) {
medge = (MEdge *)CustomData_add_layer(
- &dm->edgeData, CD_MEDGE, CD_CALLOC, nullptr, dm->getNumEdges(dm));
+ &dm->edgeData, CD_MEDGE, CD_SET_DEFAULT, nullptr, dm->getNumEdges(dm));
CustomData_set_layer_flag(&dm->edgeData, CD_MEDGE, CD_FLAG_TEMPORARY);
dm->copyEdgeArray(dm, medge);
}
@@ -123,7 +123,7 @@ static MLoop *dm_getLoopArray(DerivedMesh *dm)
if (!mloop) {
mloop = (MLoop *)CustomData_add_layer(
- &dm->loopData, CD_MLOOP, CD_CALLOC, nullptr, dm->getNumLoops(dm));
+ &dm->loopData, CD_MLOOP, CD_SET_DEFAULT, nullptr, dm->getNumLoops(dm));
CustomData_set_layer_flag(&dm->loopData, CD_MLOOP, CD_FLAG_TEMPORARY);
dm->copyLoopArray(dm, mloop);
}
@@ -137,7 +137,7 @@ static MPoly *dm_getPolyArray(DerivedMesh *dm)
if (!mpoly) {
mpoly = (MPoly *)CustomData_add_layer(
- &dm->polyData, CD_MPOLY, CD_CALLOC, nullptr, dm->getNumPolys(dm));
+ &dm->polyData, CD_MPOLY, CD_SET_DEFAULT, nullptr, dm->getNumPolys(dm));
CustomData_set_layer_flag(&dm->polyData, CD_MPOLY, CD_FLAG_TEMPORARY);
dm->copyPolyArray(dm, mpoly);
}
@@ -284,11 +284,11 @@ void DM_from_template(DerivedMesh *dm,
int numPolys)
{
const CustomData_MeshMasks *mask = &CD_MASK_DERIVEDMESH;
- CustomData_copy(&source->vertData, &dm->vertData, mask->vmask, CD_CALLOC, numVerts);
- CustomData_copy(&source->edgeData, &dm->edgeData, mask->emask, CD_CALLOC, numEdges);
- CustomData_copy(&source->faceData, &dm->faceData, mask->fmask, CD_CALLOC, numTessFaces);
- CustomData_copy(&source->loopData, &dm->loopData, mask->lmask, CD_CALLOC, numLoops);
- CustomData_copy(&source->polyData, &dm->polyData, mask->pmask, CD_CALLOC, numPolys);
+ CustomData_copy(&source->vertData, &dm->vertData, mask->vmask, CD_SET_DEFAULT, numVerts);
+ CustomData_copy(&source->edgeData, &dm->edgeData, mask->emask, CD_SET_DEFAULT, numEdges);
+ CustomData_copy(&source->faceData, &dm->faceData, mask->fmask, CD_SET_DEFAULT, numTessFaces);
+ CustomData_copy(&source->loopData, &dm->loopData, mask->lmask, CD_SET_DEFAULT, numLoops);
+ CustomData_copy(&source->polyData, &dm->polyData, mask->pmask, CD_SET_DEFAULT, numPolys);
dm->cd_flag = source->cd_flag;
@@ -584,7 +584,7 @@ static void add_orco_mesh(Object *ob, BMEditMesh *em, Mesh *mesh, Mesh *mesh_orc
}
if (!(layerorco = (float(*)[3])CustomData_get_layer(&mesh->vdata, layer))) {
- CustomData_add_layer(&mesh->vdata, layer, CD_CALLOC, nullptr, mesh->totvert);
+ CustomData_add_layer(&mesh->vdata, layer, CD_SET_DEFAULT, nullptr, mesh->totvert);
BKE_mesh_update_customdata_pointers(mesh, false);
layerorco = (float(*)[3])CustomData_get_layer(&mesh->vdata, layer);
@@ -826,7 +826,7 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
}
float3 *rest_positions = static_cast<float3 *>(CustomData_add_layer_named(&mesh_final->vdata,
CD_PROP_FLOAT3,
- CD_DEFAULT,
+ CD_SET_DEFAULT,
nullptr,
mesh_final->totvert,
"rest_position"));
@@ -1007,11 +1007,11 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
((nextmask.vmask | nextmask.emask | nextmask.pmask) & CD_MASK_ORIGINDEX)) {
/* calc */
CustomData_add_layer(
- &mesh_final->vdata, CD_ORIGINDEX, CD_CALLOC, nullptr, mesh_final->totvert);
+ &mesh_final->vdata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, mesh_final->totvert);
CustomData_add_layer(
- &mesh_final->edata, CD_ORIGINDEX, CD_CALLOC, nullptr, mesh_final->totedge);
+ &mesh_final->edata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, mesh_final->totedge);
CustomData_add_layer(
- &mesh_final->pdata, CD_ORIGINDEX, CD_CALLOC, nullptr, mesh_final->totpoly);
+ &mesh_final->pdata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, mesh_final->totpoly);
/* Not worth parallelizing this,
* gives less than 0.1% overall speedup in best of best cases... */
@@ -1047,8 +1047,11 @@ static void mesh_calc_modifiers(struct Depsgraph *depsgraph,
/* add an origspace layer if needed */
if ((md_datamask->mask.lmask) & CD_MASK_ORIGSPACE_MLOOP) {
if (!CustomData_has_layer(&mesh_final->ldata, CD_ORIGSPACE_MLOOP)) {
- CustomData_add_layer(
- &mesh_final->ldata, CD_ORIGSPACE_MLOOP, CD_CALLOC, nullptr, mesh_final->totloop);
+ CustomData_add_layer(&mesh_final->ldata,
+ CD_ORIGSPACE_MLOOP,
+ CD_SET_DEFAULT,
+ nullptr,
+ mesh_final->totloop);
mesh_init_origspace(mesh_final);
}
}
@@ -1510,8 +1513,11 @@ static void editbmesh_calc_modifiers(struct Depsgraph *depsgraph,
if (mask.lmask & CD_MASK_ORIGSPACE_MLOOP) {
if (!CustomData_has_layer(&mesh_final->ldata, CD_ORIGSPACE_MLOOP)) {
- CustomData_add_layer(
- &mesh_final->ldata, CD_ORIGSPACE_MLOOP, CD_CALLOC, nullptr, mesh_final->totloop);
+ CustomData_add_layer(&mesh_final->ldata,
+ CD_ORIGSPACE_MLOOP,
+ CD_SET_DEFAULT,
+ nullptr,
+ mesh_final->totloop);
mesh_init_origspace(mesh_final);
}
}
diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc
index ccaa6e56f08..394f9e738d4 100644
--- a/source/blender/blenkernel/intern/attribute.cc
+++ b/source/blender/blenkernel/intern/attribute.cc
@@ -247,7 +247,7 @@ CustomDataLayer *BKE_id_attribute_new(
return nullptr;
}
- attributes->add(uniquename, domain, eCustomDataType(type), AttributeInitDefault());
+ attributes->add(uniquename, domain, eCustomDataType(type), AttributeInitDefaultValue());
const int index = CustomData_get_named_layer_index(customdata, type, uniquename);
return (index == -1) ? nullptr : &(customdata->layers[index]);
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 313e6a172ac..aed55c5db45 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -160,12 +160,19 @@ static bool add_builtin_type_custom_data_layer_from_init(CustomData &custom_data
const AttributeInit &initializer)
{
switch (initializer.type) {
- case AttributeInit::Type::Default: {
- void *data = CustomData_add_layer(&custom_data, data_type, CD_DEFAULT, nullptr, domain_num);
+ case AttributeInit::Type::Construct: {
+ void *data = CustomData_add_layer(
+ &custom_data, data_type, CD_CONSTRUCT, nullptr, domain_num);
+ return data != nullptr;
+ }
+ case AttributeInit::Type::DefaultValue: {
+ void *data = CustomData_add_layer(
+ &custom_data, data_type, CD_SET_DEFAULT, nullptr, domain_num);
return data != nullptr;
}
case AttributeInit::Type::VArray: {
- void *data = CustomData_add_layer(&custom_data, data_type, CD_DEFAULT, nullptr, domain_num);
+ void *data = CustomData_add_layer(
+ &custom_data, data_type, CD_CONSTRUCT, nullptr, domain_num);
if (data == nullptr) {
return false;
}
@@ -174,7 +181,7 @@ static bool add_builtin_type_custom_data_layer_from_init(CustomData &custom_data
return true;
}
case AttributeInit::Type::MoveArray: {
- void *source_data = static_cast<const AttributeInitMove &>(initializer).data;
+ void *source_data = static_cast<const AttributeInitMoveArray &>(initializer).data;
void *data = CustomData_add_layer(
&custom_data, data_type, CD_ASSIGN, source_data, domain_num);
if (data == nullptr) {
@@ -215,14 +222,19 @@ static bool add_custom_data_layer_from_attribute_init(const AttributeIDRef &attr
{
const int old_layer_num = custom_data.totlayer;
switch (initializer.type) {
- case AttributeInit::Type::Default: {
+ case AttributeInit::Type::Construct: {
+ add_generic_custom_data_layer(
+ custom_data, data_type, CD_CONSTRUCT, nullptr, domain_num, attribute_id);
+ break;
+ }
+ case AttributeInit::Type::DefaultValue: {
add_generic_custom_data_layer(
- custom_data, data_type, CD_DEFAULT, nullptr, domain_num, attribute_id);
+ custom_data, data_type, CD_SET_DEFAULT, nullptr, domain_num, attribute_id);
break;
}
case AttributeInit::Type::VArray: {
void *data = add_generic_custom_data_layer(
- custom_data, data_type, CD_DEFAULT, nullptr, domain_num, attribute_id);
+ custom_data, data_type, CD_CONSTRUCT, nullptr, domain_num, attribute_id);
if (data != nullptr) {
const GVArray &varray = static_cast<const AttributeInitVArray &>(initializer).varray;
varray.materialize_to_uninitialized(varray.index_range(), data);
@@ -230,7 +242,7 @@ static bool add_custom_data_layer_from_attribute_init(const AttributeIDRef &attr
break;
}
case AttributeInit::Type::MoveArray: {
- void *source_data = static_cast<const AttributeInitMove &>(initializer).data;
+ void *source_data = static_cast<const AttributeInitMoveArray &>(initializer).data;
void *data = add_generic_custom_data_layer(
custom_data, data_type, CD_ASSIGN, source_data, domain_num, attribute_id);
if (source_data != nullptr && data == nullptr) {
@@ -722,7 +734,7 @@ bool CustomDataAttributes::create(const AttributeIDRef &attribute_id,
const eCustomDataType data_type)
{
void *result = add_generic_custom_data_layer(
- data, data_type, CD_DEFAULT, nullptr, size_, attribute_id);
+ data, data_type, CD_SET_DEFAULT, nullptr, size_, attribute_id);
return result != nullptr;
}
diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc
index fe9f6775995..618ff8fa97a 100644
--- a/source/blender/blenkernel/intern/curves_geometry.cc
+++ b/source/blender/blenkernel/intern/curves_geometry.cc
@@ -58,7 +58,7 @@ CurvesGeometry::CurvesGeometry(const int point_num, const int curve_num)
CustomData_add_layer_named(&this->point_data,
CD_PROP_FLOAT3,
- CD_DEFAULT,
+ CD_SET_DEFAULT,
nullptr,
this->point_num,
ATTR_POSITION.c_str());
@@ -222,7 +222,7 @@ static MutableSpan<T> get_mutable_attribute(CurvesGeometry &curves,
return {data, num};
}
data = (T *)CustomData_add_layer_named(
- &custom_data, type, CD_CALLOC, nullptr, num, name.c_str());
+ &custom_data, type, CD_SET_DEFAULT, nullptr, num, name.c_str());
MutableSpan<T> span = {data, num};
if (num > 0 && span.first() != default_value) {
span.fill(default_value);
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index 1f70ab587bf..447921b6d84 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -154,9 +154,15 @@ struct LayerTypeInfo {
void (*swap)(void *data, const int *corner_indices);
/**
- * a function to set a layer's data to default values. if null, the
- * default is assumed to be all zeros */
- void (*set_default)(void *data, int count);
+ * Set values to the type's default. If undefined, the default is assumed to be zeroes.
+ * Memory pointed to by #data is expected to be uninitialized.
+ */
+ void (*set_default_value)(void *data, int count);
+ /**
+ * Construct and fill a valid value for the type. Necessary for non-trivial types.
+ * Memory pointed to by #data is expected to be uninitialized.
+ */
+ void (*construct)(void *data, int count);
/** A function used by mesh validating code, must ensures passed item has valid data. */
cd_validate validate;
@@ -312,6 +318,11 @@ static void layerInterp_mdeformvert(const void **sources,
}
}
+static void layerConstruct_mdeformvert(void *data, const int count)
+{
+ memset(data, 0, sizeof(MDeformVert) * count);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -497,11 +508,6 @@ static bool layerValidate_propFloat(void *data, const uint totitems, const bool
/** \name Callbacks for (#MIntProperty, #CD_PROP_INT32)
* \{ */
-static void layerCopy_propInt(const void *source, void *dest, const int count)
-{
- memcpy(dest, source, sizeof(MIntProperty) * count);
-}
-
static void layerInterp_propInt(const void **sources,
const float *weights,
const float *UNUSED(sub_weights),
@@ -671,6 +677,11 @@ static void layerFree_mdisps(void *data, const int count, const int UNUSED(size)
}
}
+static void layerConstruct_mdisps(void *data, const int count)
+{
+ memset(data, 0, sizeof(MDisps) * count);
+}
+
static bool layerRead_mdisps(CDataFile *cdf, void *data, const int count)
{
MDisps *d = static_cast<MDisps *>(data);
@@ -803,6 +814,11 @@ static void layerFree_grid_paint_mask(void *data, const int count, const int UNU
}
}
+static void layerConstruct_grid_paint_mask(void *data, const int count)
+{
+ memset(data, 0, sizeof(GridPaintMask) * count);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -1645,30 +1661,23 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerFree_mdeformvert,
layerInterp_mdeformvert,
nullptr,
+ layerConstruct_mdeformvert,
nullptr},
/* 3: CD_MEDGE */
{sizeof(MEdge), "MEdge", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr},
/* 4: CD_MFACE */
{sizeof(MFace), "MFace", 1, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr},
/* 5: CD_MTFACE */
- {sizeof(MTFace), "MTFace", 1,
- N_("UVMap"), layerCopy_tface, nullptr,
- layerInterp_tface, layerSwap_tface, layerDefault_tface,
- nullptr, nullptr, nullptr,
- nullptr, nullptr, nullptr,
- nullptr, nullptr, nullptr,
- nullptr, layerMaxNum_tface},
- /* 6: CD_MCOL */
- /* 4 MCol structs per face */
- {sizeof(MCol[4]),
- "MCol",
- 4,
- N_("Col"),
+ {sizeof(MTFace),
+ "MTFace",
+ 1,
+ N_("UVMap"),
+ layerCopy_tface,
nullptr,
+ layerInterp_tface,
+ layerSwap_tface,
nullptr,
- layerInterp_mcol,
- layerSwap_mcol,
- layerDefault_mcol,
+ layerDefault_tface,
nullptr,
nullptr,
nullptr,
@@ -1679,7 +1688,16 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
nullptr,
nullptr,
nullptr,
- layerMaxNum_mloopcol},
+ layerMaxNum_tface},
+ /* 6: CD_MCOL */
+ /* 4 MCol structs per face */
+ {sizeof(MCol[4]), "MCol", 4,
+ N_("Col"), nullptr, nullptr,
+ layerInterp_mcol, layerSwap_mcol, layerDefault_mcol,
+ nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr,
+ nullptr, nullptr, layerMaxNum_mloopcol},
/* 7: CD_ORIGINDEX */
{sizeof(int), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, layerDefault_origindex},
/* 8: CD_NORMAL */
@@ -1699,6 +1717,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
nullptr,
nullptr,
nullptr,
+ nullptr,
layerCopyValue_normal},
/* 9: CD_FACEMAP */
{sizeof(int), "", 0, nullptr, nullptr, nullptr, nullptr, nullptr, layerDefault_fmap, nullptr},
@@ -1712,13 +1731,14 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerInterp_propFloat,
nullptr,
nullptr,
+ nullptr,
layerValidate_propFloat},
/* 11: CD_PROP_INT32 */
{sizeof(MIntProperty),
"MIntProperty",
1,
N_("Int"),
- layerCopy_propInt,
+ nullptr,
nullptr,
layerInterp_propInt,
nullptr},
@@ -1757,6 +1777,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerInterp_mloopuv,
nullptr,
nullptr,
+ nullptr,
layerValidate_mloopuv,
layerEqual_mloopuv,
layerMultiply_mloopuv,
@@ -1779,6 +1800,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
nullptr,
layerDefault_mloopcol,
nullptr,
+ nullptr,
layerEqual_mloopcol,
layerMultiply_mloopcol,
layerInitMinMax_mloopcol,
@@ -1801,6 +1823,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
nullptr,
layerSwap_mdisps,
nullptr,
+ layerConstruct_mdisps,
nullptr,
nullptr,
nullptr,
@@ -1870,6 +1893,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
nullptr,
nullptr,
nullptr,
+ nullptr,
layerEqual_mloop_origspace,
layerMultiply_mloop_origspace,
layerInitMinMax_mloop_origspace,
@@ -1887,6 +1911,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
nullptr,
layerDefault_mloopcol,
nullptr,
+ nullptr,
layerEqual_mloopcol,
layerMultiply_mloopcol,
layerInitMinMax_mloopcol,
@@ -1914,7 +1939,8 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerFree_grid_paint_mask,
nullptr,
nullptr,
- nullptr},
+ nullptr,
+ layerConstruct_grid_paint_mask},
/* 36: CD_MVERT_SKIN */
{sizeof(MVertSkin),
"MVertSkin",
@@ -1972,6 +1998,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
nullptr,
layerDefault_propcol,
nullptr,
+ nullptr,
layerEqual_propcol,
layerMultiply_propcol,
layerInitMinMax_propcol,
@@ -1992,6 +2019,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerInterp_propfloat3,
nullptr,
nullptr,
+ nullptr,
layerValidate_propfloat3,
nullptr,
layerMultiply_propfloat3,
@@ -2007,6 +2035,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
layerInterp_propfloat2,
nullptr,
nullptr,
+ nullptr,
layerValidate_propfloat2,
nullptr,
layerMultiply_propfloat2,
@@ -2765,48 +2794,60 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
const LayerTypeInfo *typeInfo = layerType_getInfo(type);
int flag = 0;
- /* Passing a layer-data to copy from with an alloctype that won't copy is
- * most likely a bug */
- BLI_assert(!layerdata || ELEM(alloctype, CD_ASSIGN, CD_DUPLICATE, CD_REFERENCE));
-
if (!typeInfo->defaultname && CustomData_has_layer(data, type)) {
return &data->layers[CustomData_get_layer_index(data, type)];
}
void *newlayerdata = nullptr;
- if (ELEM(alloctype, CD_ASSIGN, CD_REFERENCE)) {
- newlayerdata = layerdata;
- }
- else if (totelem > 0 && typeInfo->size > 0) {
- if (alloctype == CD_DUPLICATE && layerdata) {
- newlayerdata = MEM_malloc_arrayN((size_t)totelem, typeInfo->size, layerType_getName(type));
- }
- else {
- newlayerdata = MEM_calloc_arrayN((size_t)totelem, typeInfo->size, layerType_getName(type));
- }
-
- if (!newlayerdata) {
- return nullptr;
- }
- }
-
- if (alloctype == CD_DUPLICATE && layerdata) {
- if (totelem > 0) {
- if (typeInfo->copy) {
- typeInfo->copy(layerdata, newlayerdata, totelem);
+ switch (alloctype) {
+ case CD_SET_DEFAULT:
+ if (totelem > 0) {
+ if (typeInfo->set_default_value) {
+ newlayerdata = MEM_malloc_arrayN(totelem, typeInfo->size, layerType_getName(type));
+ typeInfo->set_default_value(newlayerdata, totelem);
+ }
+ else {
+ newlayerdata = MEM_calloc_arrayN(totelem, typeInfo->size, layerType_getName(type));
+ }
+ }
+ break;
+ case CD_CONSTRUCT:
+ if (totelem > 0) {
+ newlayerdata = MEM_malloc_arrayN(totelem, typeInfo->size, layerType_getName(type));
+ if (typeInfo->construct) {
+ typeInfo->construct(newlayerdata, totelem);
+ }
+ }
+ break;
+ case CD_ASSIGN:
+ if (totelem > 0) {
+ BLI_assert(layerdata != nullptr);
+ newlayerdata = layerdata;
}
else {
- memcpy(newlayerdata, layerdata, (size_t)totelem * typeInfo->size);
+ MEM_SAFE_FREE(layerdata);
}
- }
- }
- else if (alloctype == CD_DEFAULT) {
- if (typeInfo->set_default) {
- typeInfo->set_default(newlayerdata, totelem);
- }
- }
- else if (alloctype == CD_REFERENCE) {
- flag |= CD_FLAG_NOFREE;
+ break;
+ case CD_REFERENCE:
+ if (totelem > 0) {
+ BLI_assert(layerdata != nullptr);
+ newlayerdata = layerdata;
+ flag |= CD_FLAG_NOFREE;
+ }
+ break;
+ case CD_DUPLICATE:
+ if (totelem > 0) {
+ newlayerdata = MEM_malloc_arrayN(totelem, typeInfo->size, layerType_getName(type));
+ if (typeInfo->copy) {
+ typeInfo->copy(layerdata, newlayerdata, totelem);
+ }
+ else {
+ BLI_assert(layerdata != nullptr);
+ BLI_assert(newlayerdata != nullptr);
+ memcpy(newlayerdata, layerdata, totelem * typeInfo->size);
+ }
+ }
+ break;
}
int index = data->totlayer;
@@ -3850,8 +3891,8 @@ static void CustomData_bmesh_set_default_n(CustomData *data, void **block, const
int offset = data->layers[n].offset;
const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[n].type);
- if (typeInfo->set_default) {
- typeInfo->set_default(POINTER_OFFSET(*block, offset), 1);
+ if (typeInfo->set_default_value) {
+ typeInfo->set_default_value(POINTER_OFFSET(*block, offset), 1);
}
else {
memset(POINTER_OFFSET(*block, offset), 0, typeInfo->size);
@@ -4558,8 +4599,8 @@ static bool CustomData_layer_ensure_data_exists(CustomDataLayer *layer, size_t c
case CD_MLOOPUV: /* See T90620. */
layer->data = MEM_calloc_arrayN(count, typeInfo->size, layerType_getName(layer->type));
BLI_assert(layer->data);
- if (typeInfo->set_default) {
- typeInfo->set_default(layer->data, count);
+ if (typeInfo->set_default_value) {
+ typeInfo->set_default_value(layer->data, count);
}
return true;
break;
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index be686635d3e..02b5175f65f 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -280,7 +280,8 @@ static void data_transfer_dtdata_type_preprocess(Mesh *me_src,
loop_nors_dst = CustomData_get_layer(ldata_dst, CD_NORMAL);
const bool do_loop_nors_dst = (loop_nors_dst == NULL);
if (do_loop_nors_dst) {
- loop_nors_dst = CustomData_add_layer(ldata_dst, CD_NORMAL, CD_CALLOC, NULL, num_loops_dst);
+ loop_nors_dst = CustomData_add_layer(
+ ldata_dst, CD_NORMAL, CD_SET_DEFAULT, NULL, num_loops_dst);
CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
}
if (dirty_nors_dst || do_loop_nors_dst) {
@@ -333,7 +334,7 @@ static void data_transfer_dtdata_type_postprocess(Object *UNUSED(ob_src),
if (!custom_nors_dst) {
custom_nors_dst = CustomData_add_layer(
- ldata_dst, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, num_loops_dst);
+ ldata_dst, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, NULL, num_loops_dst);
}
/* Note loop_nors_dst contains our custom normals as transferred from source... */
@@ -561,7 +562,7 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
if (use_create) {
/* Create as much data layers as necessary! */
for (; idx_dst < idx_src; idx_dst++) {
- CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
+ CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst);
}
}
else {
@@ -622,7 +623,8 @@ static bool data_transfer_layersmapping_cdlayers_multisrc_to_dst(ListBase *r_map
if ((idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name)) == -1) {
if (use_create) {
- CustomData_add_layer_named(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst, name);
+ CustomData_add_layer_named(
+ cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst, name);
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
}
else {
@@ -710,7 +712,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
if (!use_create) {
return true;
}
- data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
+ data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst);
}
else if (use_dupref_dst && r_map) {
/* If dest is a evaluated mesh (from modifier),
@@ -763,7 +765,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
if (!use_create) {
return true;
}
- data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
+ data_dst = CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst);
}
else {
/* If dest is a evaluated mesh (from modifier),
@@ -786,7 +788,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
}
/* Create as much data layers as necessary! */
for (; num <= idx_dst; num++) {
- CustomData_add_layer(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst);
+ CustomData_add_layer(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst);
}
}
/* If dest is a evaluated mesh (from modifier),
@@ -805,7 +807,7 @@ static bool data_transfer_layersmapping_cdlayers(ListBase *r_map,
if (!use_create) {
return true;
}
- CustomData_add_layer_named(cd_dst, cddata_type, CD_CALLOC, NULL, num_elem_dst, name);
+ CustomData_add_layer_named(cd_dst, cddata_type, CD_SET_DEFAULT, NULL, num_elem_dst, name);
idx_dst = CustomData_get_named_layer(cd_dst, cddata_type, name);
}
/* If dest is a evaluated mesh (from modifier),
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index ebe06fa85eb..d904744995d 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -1243,7 +1243,8 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
/* At this stage, we **need** a valid CD_MDEFORMVERT layer on dest!
* Again, use_create is not relevant in this case */
if (!data_dst) {
- data_dst = CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_CALLOC, NULL, num_elem_dst);
+ data_dst = CustomData_add_layer(
+ cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, num_elem_dst);
}
while (idx_src--) {
@@ -1303,7 +1304,8 @@ static bool data_transfer_layersmapping_vgroups_multisrc_to_dst(ListBase *r_map,
/* At this stage, we **need** a valid CD_MDEFORMVERT layer on dest!
* use_create is not relevant in this case */
if (!data_dst) {
- data_dst = CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_CALLOC, NULL, num_elem_dst);
+ data_dst = CustomData_add_layer(
+ cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, num_elem_dst);
}
data_transfer_layersmapping_add_item(r_map,
@@ -1442,7 +1444,8 @@ bool data_transfer_layersmapping_vgroups(ListBase *r_map,
/* At this stage, we **need** a valid CD_MDEFORMVERT layer on dest!
* use_create is not relevant in this case */
if (!data_dst) {
- data_dst = CustomData_add_layer(cd_dst, CD_MDEFORMVERT, CD_CALLOC, NULL, num_elem_dst);
+ data_dst = CustomData_add_layer(
+ cd_dst, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, num_elem_dst);
}
data_transfer_layersmapping_add_item(r_map,
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 423e76fce8c..8a41b2294f5 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -1944,7 +1944,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
if (!mloopcol && dynamicPaint_outputLayerExists(surface, ob, 0)) {
mloopcol = CustomData_add_layer_named(&result->ldata,
CD_PROP_BYTE_COLOR,
- CD_CALLOC,
+ CD_SET_DEFAULT,
NULL,
totloop,
surface->output_name);
@@ -1957,7 +1957,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
if (!mloopcol_wet && dynamicPaint_outputLayerExists(surface, ob, 1)) {
mloopcol_wet = CustomData_add_layer_named(&result->ldata,
CD_PROP_BYTE_COLOR,
- CD_CALLOC,
+ CD_SET_DEFAULT,
NULL,
totloop,
surface->output_name2);
@@ -1988,7 +1988,7 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
/* apply weights into a vertex group, if doesn't exists add a new layer */
if (defgrp_index != -1 && !dvert && (surface->output_name[0] != '\0')) {
dvert = CustomData_add_layer(
- &result->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, sData->total_points);
+ &result->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, sData->total_points);
/* Make the dvert layer easily accessible from the mesh data. */
result->dvert = dvert;
}
diff --git a/source/blender/blenkernel/intern/editmesh_tangent.c b/source/blender/blenkernel/intern/editmesh_tangent.c
index 0a3107eee24..ec608f79e66 100644
--- a/source/blender/blenkernel/intern/editmesh_tangent.c
+++ b/source/blender/blenkernel/intern/editmesh_tangent.c
@@ -304,7 +304,7 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
if ((tangent_mask & DM_TANGENT_MASK_ORCO) &&
CustomData_get_named_layer_index(loopdata_out, CD_TANGENT, "") == -1) {
CustomData_add_layer_named(
- loopdata_out, CD_TANGENT, CD_CALLOC, NULL, (int)loopdata_out_len, "");
+ loopdata_out, CD_TANGENT, CD_SET_DEFAULT, NULL, (int)loopdata_out_len, "");
}
if (calc_act && act_uv_name[0]) {
BKE_mesh_add_loop_tangent_named_layer_for_uv(
diff --git a/source/blender/blenkernel/intern/geometry_component_curve.cc b/source/blender/blenkernel/intern/geometry_component_curve.cc
index 22f105af0f1..56a7e38b2fc 100644
--- a/source/blender/blenkernel/intern/geometry_component_curve.cc
+++ b/source/blender/blenkernel/intern/geometry_component_curve.cc
@@ -547,7 +547,8 @@ static GVArray varray_from_initializer(const AttributeInit &initializer,
const Span<SplinePtr> splines)
{
switch (initializer.type) {
- case AttributeInit::Type::Default:
+ case AttributeInit::Type::Construct:
+ case AttributeInit::Type::DefaultValue:
/* This function shouldn't be called in this case, since there
* is no need to copy anything to the new custom data array. */
BLI_assert_unreachable();
@@ -560,7 +561,7 @@ static GVArray varray_from_initializer(const AttributeInit &initializer,
total_num += spline->size();
}
return GVArray::ForSpan(GSpan(*bke::custom_data_type_to_cpp_type(data_type),
- static_cast<const AttributeInitMove &>(initializer).data,
+ static_cast<const AttributeInitMoveArray &>(initializer).data,
total_num));
}
BLI_assert_unreachable();
@@ -580,7 +581,7 @@ static bool create_point_attribute(CurveEval *curve,
/* First check the one case that allows us to avoid copying the input data. */
if (splines.size() == 1 && initializer.type == AttributeInit::Type::MoveArray) {
- void *source_data = static_cast<const AttributeInitMove &>(initializer).data;
+ void *source_data = static_cast<const AttributeInitMoveArray &>(initializer).data;
if (!splines.first()->attributes.create_by_move(attribute_id, data_type, source_data)) {
MEM_freeN(source_data);
return false;
@@ -600,7 +601,7 @@ static bool create_point_attribute(CurveEval *curve,
}
/* With a default initializer type, we can keep the values at their initial values. */
- if (initializer.type == AttributeInit::Type::Default) {
+ if (ELEM(initializer.type, AttributeInit::Type::DefaultValue, AttributeInit::Type::Construct)) {
return true;
}
@@ -616,7 +617,7 @@ static bool create_point_attribute(CurveEval *curve,
write_attribute.finish();
if (initializer.type == AttributeInit::Type::MoveArray) {
- MEM_freeN(static_cast<const AttributeInitMove &>(initializer).data);
+ MEM_freeN(static_cast<const AttributeInitMoveArray &>(initializer).data);
}
return true;
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c
index 61f5a5f315f..bfa11b74782 100644
--- a/source/blender/blenkernel/intern/mball_tessellate.c
+++ b/source/blender/blenkernel/intern/mball_tessellate.c
@@ -1444,7 +1444,7 @@ Mesh *BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob)
Mesh *mesh = (Mesh *)BKE_id_new_nomain(ID_ME, ((ID *)ob->data)->name + 2);
mesh->totvert = (int)process.curvertex;
- MVert *mvert = CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_DEFAULT, NULL, mesh->totvert);
+ MVert *mvert = CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CONSTRUCT, NULL, mesh->totvert);
for (int i = 0; i < mesh->totvert; i++) {
copy_v3_v3(mvert[i].co, process.co[i]);
mvert->bweight = 0;
@@ -1453,8 +1453,9 @@ Mesh *BKE_mball_polygonize(Depsgraph *depsgraph, Scene *scene, Object *ob)
MEM_freeN(process.co);
mesh->totpoly = (int)process.curindex;
- MPoly *mpoly = CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_DEFAULT, NULL, mesh->totpoly);
- MLoop *mloop = CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_DEFAULT, NULL, mesh->totpoly * 4);
+ MPoly *mpoly = CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CONSTRUCT, NULL, mesh->totpoly);
+ MLoop *mloop = CustomData_add_layer(
+ &mesh->ldata, CD_MLOOP, CD_CONSTRUCT, NULL, mesh->totpoly * 4);
int loop_offset = 0;
for (int i = 0; i < mesh->totpoly; i++) {
diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc
index 0c109e6ef04..0a5eddfd319 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -822,7 +822,7 @@ void BKE_mesh_ensure_skin_customdata(Mesh *me)
else {
if (!CustomData_has_layer(&me->vdata, CD_MVERT_SKIN)) {
vs = (MVertSkin *)CustomData_add_layer(
- &me->vdata, CD_MVERT_SKIN, CD_DEFAULT, nullptr, me->totvert);
+ &me->vdata, CD_MVERT_SKIN, CD_SET_DEFAULT, nullptr, me->totvert);
/* Mark an arbitrary vertex as root */
if (vs) {
@@ -844,7 +844,7 @@ bool BKE_mesh_ensure_facemap_customdata(struct Mesh *me)
}
else {
if (!CustomData_has_layer(&me->pdata, CD_FACEMAP)) {
- CustomData_add_layer(&me->pdata, CD_FACEMAP, CD_DEFAULT, nullptr, me->totpoly);
+ CustomData_add_layer(&me->pdata, CD_FACEMAP, CD_SET_DEFAULT, nullptr, me->totpoly);
changed = true;
}
}
@@ -987,20 +987,20 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name)
static void mesh_ensure_cdlayers_primary(Mesh *mesh, bool do_tessface)
{
if (!CustomData_get_layer(&mesh->vdata, CD_MVERT)) {
- CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CALLOC, nullptr, mesh->totvert);
+ CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, mesh->totvert);
}
if (!CustomData_get_layer(&mesh->edata, CD_MEDGE)) {
- CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_CALLOC, nullptr, mesh->totedge);
+ CustomData_add_layer(&mesh->edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, mesh->totedge);
}
if (!CustomData_get_layer(&mesh->ldata, CD_MLOOP)) {
- CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CALLOC, nullptr, mesh->totloop);
+ CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, mesh->totloop);
}
if (!CustomData_get_layer(&mesh->pdata, CD_MPOLY)) {
- CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CALLOC, nullptr, mesh->totpoly);
+ CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, mesh->totpoly);
}
if (do_tessface && !CustomData_get_layer(&mesh->fdata, CD_MFACE)) {
- CustomData_add_layer(&mesh->fdata, CD_MFACE, CD_CALLOC, nullptr, mesh->totface);
+ CustomData_add_layer(&mesh->fdata, CD_MFACE, CD_SET_DEFAULT, nullptr, mesh->totface);
}
}
@@ -1097,12 +1097,12 @@ Mesh *BKE_mesh_new_nomain_from_template_ex(const Mesh *me_src,
me_dst->cd_flag = me_src->cd_flag;
BKE_mesh_copy_parameters_for_eval(me_dst, me_src);
- CustomData_copy(&me_src->vdata, &me_dst->vdata, mask.vmask, CD_CALLOC, verts_len);
- CustomData_copy(&me_src->edata, &me_dst->edata, mask.emask, CD_CALLOC, edges_len);
- CustomData_copy(&me_src->ldata, &me_dst->ldata, mask.lmask, CD_CALLOC, loops_len);
- CustomData_copy(&me_src->pdata, &me_dst->pdata, mask.pmask, CD_CALLOC, polys_len);
+ CustomData_copy(&me_src->vdata, &me_dst->vdata, mask.vmask, CD_SET_DEFAULT, verts_len);
+ CustomData_copy(&me_src->edata, &me_dst->edata, mask.emask, CD_SET_DEFAULT, edges_len);
+ CustomData_copy(&me_src->ldata, &me_dst->ldata, mask.lmask, CD_SET_DEFAULT, loops_len);
+ CustomData_copy(&me_src->pdata, &me_dst->pdata, mask.pmask, CD_SET_DEFAULT, polys_len);
if (do_tessface) {
- CustomData_copy(&me_src->fdata, &me_dst->fdata, mask.fmask, CD_CALLOC, tessface_len);
+ CustomData_copy(&me_src->fdata, &me_dst->fdata, mask.fmask, CD_SET_DEFAULT, tessface_len);
}
else {
mesh_tessface_clear_intern(me_dst, false);
@@ -1203,7 +1203,7 @@ static void ensure_orig_index_layer(CustomData &data, const int size)
if (CustomData_has_layer(&data, CD_ORIGINDEX)) {
return;
}
- int *indices = (int *)CustomData_add_layer(&data, CD_ORIGINDEX, CD_DEFAULT, nullptr, size);
+ int *indices = (int *)CustomData_add_layer(&data, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, size);
range_vn_i(indices, size, 0);
}
@@ -1882,7 +1882,7 @@ static float (*ensure_corner_normal_layer(Mesh &mesh))[3]
}
else {
r_loopnors = (float(*)[3])CustomData_add_layer(
- &mesh.ldata, CD_NORMAL, CD_CALLOC, nullptr, mesh.totloop);
+ &mesh.ldata, CD_NORMAL, CD_SET_DEFAULT, nullptr, mesh.totloop);
CustomData_set_layer_flag(&mesh.ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
}
return r_loopnors;
diff --git a/source/blender/blenkernel/intern/mesh_boolean_convert.cc b/source/blender/blenkernel/intern/mesh_boolean_convert.cc
index a1ef2d2e6b5..903198e249a 100644
--- a/source/blender/blenkernel/intern/mesh_boolean_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_boolean_convert.cc
@@ -663,15 +663,15 @@ static void merge_vertex_loop_poly_customdata_layers(Mesh *target, MeshesToIMesh
const Mesh *me = mim.meshes[mesh_index];
if (me->totvert) {
CustomData_merge(
- &me->vdata, &target->vdata, CD_MASK_MESH.vmask, CD_DEFAULT, target->totvert);
+ &me->vdata, &target->vdata, CD_MASK_MESH.vmask, CD_SET_DEFAULT, target->totvert);
}
if (me->totloop) {
CustomData_merge(
- &me->ldata, &target->ldata, CD_MASK_MESH.lmask, CD_DEFAULT, target->totloop);
+ &me->ldata, &target->ldata, CD_MASK_MESH.lmask, CD_SET_DEFAULT, target->totloop);
}
if (me->totpoly) {
CustomData_merge(
- &me->pdata, &target->pdata, CD_MASK_MESH.pmask, CD_DEFAULT, target->totpoly);
+ &me->pdata, &target->pdata, CD_MASK_MESH.pmask, CD_SET_DEFAULT, target->totpoly);
}
}
}
@@ -682,7 +682,7 @@ static void merge_edge_customdata_layers(Mesh *target, MeshesToIMeshInfo &mim)
const Mesh *me = mim.meshes[mesh_index];
if (me->totedge) {
CustomData_merge(
- &me->edata, &target->edata, CD_MASK_MESH.emask, CD_DEFAULT, target->totedge);
+ &me->edata, &target->edata, CD_MASK_MESH.emask, CD_SET_DEFAULT, target->totedge);
}
}
}
diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc
index 3806ea76cfe..cb72e09af16 100644
--- a/source/blender/blenkernel/intern/mesh_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_convert.cc
@@ -195,7 +195,7 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
MPoly *mpoly = polys.data();
MLoop *mloop = loops.data();
MLoopUV *mloopuv = static_cast<MLoopUV *>(CustomData_add_layer_named(
- &mesh->ldata, CD_MLOOPUV, CD_CALLOC, nullptr, mesh->totloop, "UVMap"));
+ &mesh->ldata, CD_MLOOPUV, CD_SET_DEFAULT, nullptr, mesh->totloop, "UVMap"));
/* verts and faces */
vertcount = 0;
@@ -676,7 +676,8 @@ void BKE_mesh_from_pointcloud(const PointCloud *pointcloud, Mesh *me)
&pointcloud->pdata, &me->vdata, CD_MASK_PROP_ALL, CD_DUPLICATE, pointcloud->totpoint);
/* Convert the Position attribute to a mesh vertex. */
- me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, nullptr, me->totvert);
+ me->mvert = (MVert *)CustomData_add_layer(
+ &me->vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, me->totvert);
CustomData_update_typemap(&me->vdata);
const int layer_idx = CustomData_get_named_layer_index(
diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
index cc96a5e8c60..45cbf3aa28b 100644
--- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
@@ -137,19 +137,19 @@ static void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *ldata, int to
for (int i = 0; i < fdata->totlayer; i++) {
if (fdata->layers[i].type == CD_MTFACE) {
CustomData_add_layer_named(
- ldata, CD_MLOOPUV, CD_CALLOC, nullptr, totloop, fdata->layers[i].name);
+ ldata, CD_MLOOPUV, CD_SET_DEFAULT, nullptr, totloop, fdata->layers[i].name);
}
else if (fdata->layers[i].type == CD_MCOL) {
CustomData_add_layer_named(
- ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, nullptr, totloop, fdata->layers[i].name);
+ ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, nullptr, totloop, fdata->layers[i].name);
}
else if (fdata->layers[i].type == CD_MDISPS) {
CustomData_add_layer_named(
- ldata, CD_MDISPS, CD_CALLOC, nullptr, totloop, fdata->layers[i].name);
+ ldata, CD_MDISPS, CD_SET_DEFAULT, nullptr, totloop, fdata->layers[i].name);
}
else if (fdata->layers[i].type == CD_TESSLOOPNORMAL) {
CustomData_add_layer_named(
- ldata, CD_NORMAL, CD_CALLOC, nullptr, totloop, fdata->layers[i].name);
+ ldata, CD_NORMAL, CD_SET_DEFAULT, nullptr, totloop, fdata->layers[i].name);
}
}
}
@@ -849,26 +849,27 @@ void BKE_mesh_add_mface_layers(CustomData *fdata, CustomData *ldata, int total)
for (int i = 0; i < ldata->totlayer; i++) {
if (ldata->layers[i].type == CD_MLOOPUV) {
CustomData_add_layer_named(
- fdata, CD_MTFACE, CD_CALLOC, nullptr, total, ldata->layers[i].name);
+ fdata, CD_MTFACE, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name);
}
if (ldata->layers[i].type == CD_PROP_BYTE_COLOR) {
- CustomData_add_layer_named(fdata, CD_MCOL, CD_CALLOC, nullptr, total, ldata->layers[i].name);
+ CustomData_add_layer_named(
+ fdata, CD_MCOL, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name);
}
else if (ldata->layers[i].type == CD_PREVIEW_MLOOPCOL) {
CustomData_add_layer_named(
- fdata, CD_PREVIEW_MCOL, CD_CALLOC, nullptr, total, ldata->layers[i].name);
+ fdata, CD_PREVIEW_MCOL, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name);
}
else if (ldata->layers[i].type == CD_ORIGSPACE_MLOOP) {
CustomData_add_layer_named(
- fdata, CD_ORIGSPACE, CD_CALLOC, nullptr, total, ldata->layers[i].name);
+ fdata, CD_ORIGSPACE, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name);
}
else if (ldata->layers[i].type == CD_NORMAL) {
CustomData_add_layer_named(
- fdata, CD_TESSLOOPNORMAL, CD_CALLOC, nullptr, total, ldata->layers[i].name);
+ fdata, CD_TESSLOOPNORMAL, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name);
}
else if (ldata->layers[i].type == CD_TANGENT) {
CustomData_add_layer_named(
- fdata, CD_TANGENT, CD_CALLOC, nullptr, total, ldata->layers[i].name);
+ fdata, CD_TANGENT, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name);
}
}
diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc
index 2366b7526a1..f90a2e1b887 100644
--- a/source/blender/blenkernel/intern/mesh_normals.cc
+++ b/source/blender/blenkernel/intern/mesh_normals.cc
@@ -2054,7 +2054,7 @@ static void mesh_set_custom_normals(Mesh *mesh, float (*r_custom_nors)[3], const
}
else {
clnors = (short(*)[2])CustomData_add_layer(
- &mesh->ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, nullptr, numloops);
+ &mesh->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, numloops);
}
mesh_normals_loop_custom_set(mesh->mvert,
diff --git a/source/blender/blenkernel/intern/mesh_remap.c b/source/blender/blenkernel/intern/mesh_remap.c
index 5313cc39646..4c6ee0ae3ee 100644
--- a/source/blender/blenkernel/intern/mesh_remap.c
+++ b/source/blender/blenkernel/intern/mesh_remap.c
@@ -1352,7 +1352,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
const bool do_loop_nors_dst = (loop_nors_dst == NULL);
if (!loop_nors_dst) {
loop_nors_dst = CustomData_add_layer(
- ldata_dst, CD_NORMAL, CD_CALLOC, NULL, numloops_dst);
+ ldata_dst, CD_NORMAL, CD_SET_DEFAULT, NULL, numloops_dst);
CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
}
if (dirty_nors_dst || do_loop_nors_dst) {
diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
index 423f76407a0..c840c917eb3 100644
--- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
+++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc
@@ -291,7 +291,7 @@ void BKE_mesh_remesh_reproject_paint_mask(Mesh *target, const Mesh *source)
}
else {
target_mask = (float *)CustomData_add_layer(
- &target->vdata, CD_PAINT_MASK, CD_CALLOC, nullptr, target->totvert);
+ &target->vdata, CD_PAINT_MASK, CD_SET_DEFAULT, nullptr, target->totvert);
}
for (int i = 0; i < target->totvert; i++) {
@@ -325,7 +325,7 @@ void BKE_remesh_reproject_sculpt_face_sets(Mesh *target, const Mesh *source)
}
else {
target_face_sets = (int *)CustomData_add_layer(
- &target->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, nullptr, target->totpoly);
+ &target->pdata, CD_SCULPT_FACE_SETS, CD_SET_DEFAULT, nullptr, target->totpoly);
}
const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(source);
@@ -376,7 +376,7 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source)
int elem_num = domain == ATTR_DOMAIN_POINT ? target->totvert : target->totloop;
CustomData_add_layer_named(
- target_cdata, layer->type, CD_CALLOC, nullptr, elem_num, layer->name);
+ target_cdata, layer->type, CD_SET_DEFAULT, nullptr, elem_num, layer->name);
layer_i = CustomData_get_named_layer_index(target_cdata, layer->type, layer->name);
}
diff --git a/source/blender/blenkernel/intern/mesh_tangent.c b/source/blender/blenkernel/intern/mesh_tangent.c
index 1772419e1f3..497f9ff3cbd 100644
--- a/source/blender/blenkernel/intern/mesh_tangent.c
+++ b/source/blender/blenkernel/intern/mesh_tangent.c
@@ -452,7 +452,8 @@ void BKE_mesh_add_loop_tangent_named_layer_for_uv(CustomData *uv_data,
{
if (CustomData_get_named_layer_index(tan_data, CD_TANGENT, layer_name) == -1 &&
CustomData_get_named_layer_index(uv_data, CD_MLOOPUV, layer_name) != -1) {
- CustomData_add_layer_named(tan_data, CD_TANGENT, CD_CALLOC, NULL, numLoopData, layer_name);
+ CustomData_add_layer_named(
+ tan_data, CD_TANGENT, CD_SET_DEFAULT, NULL, numLoopData, layer_name);
}
}
@@ -581,7 +582,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
if ((tangent_mask & DM_TANGENT_MASK_ORCO) &&
CustomData_get_named_layer_index(loopdata, CD_TANGENT, "") == -1) {
CustomData_add_layer_named(
- loopdata_out, CD_TANGENT, CD_CALLOC, NULL, (int)loopdata_out_len, "");
+ loopdata_out, CD_TANGENT, CD_SET_DEFAULT, NULL, (int)loopdata_out_len, "");
}
if (calc_act && act_uv_name[0]) {
BKE_mesh_add_loop_tangent_named_layer_for_uv(
diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc
index 5bcbdb399e4..95a2eaec1aa 100644
--- a/source/blender/blenkernel/intern/mesh_validate.cc
+++ b/source/blender/blenkernel/intern/mesh_validate.cc
@@ -1548,8 +1548,8 @@ void BKE_mesh_calc_edges_tessface(Mesh *mesh)
/* write new edges into a temporary CustomData */
CustomData edgeData;
CustomData_reset(&edgeData);
- CustomData_add_layer(&edgeData, CD_MEDGE, CD_CALLOC, nullptr, numEdges);
- CustomData_add_layer(&edgeData, CD_ORIGINDEX, CD_CALLOC, nullptr, numEdges);
+ CustomData_add_layer(&edgeData, CD_MEDGE, CD_SET_DEFAULT, nullptr, numEdges);
+ CustomData_add_layer(&edgeData, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, numEdges);
MEdge *med = (MEdge *)CustomData_get_layer(&edgeData, CD_MEDGE);
int *index = (int *)CustomData_get_layer(&edgeData, CD_ORIGINDEX);
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 63945f9ed42..5c382a4e864 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -960,7 +960,7 @@ static void multiresModifier_disp_run(
if (!mdisps) {
if (op == CALC_DISPLACEMENTS) {
- mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS, CD_DEFAULT, NULL, me->totloop);
+ mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS, CD_SET_DEFAULT, NULL, me->totloop);
}
else {
return;
@@ -1487,7 +1487,7 @@ void multires_ensure_external_read(struct Mesh *mesh, int top_level)
MDisps *mdisps = CustomData_get_layer(&mesh->ldata, CD_MDISPS);
if (mdisps == NULL) {
- mdisps = CustomData_add_layer(&mesh->ldata, CD_MDISPS, CD_DEFAULT, NULL, mesh->totloop);
+ mdisps = CustomData_add_layer(&mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, NULL, mesh->totloop);
}
const int totloop = mesh->totloop;
diff --git a/source/blender/blenkernel/intern/multires_reshape.c b/source/blender/blenkernel/intern/multires_reshape.c
index b50a0787fe3..17e4860ab1b 100644
--- a/source/blender/blenkernel/intern/multires_reshape.c
+++ b/source/blender/blenkernel/intern/multires_reshape.c
@@ -181,7 +181,8 @@ void multiresModifier_subdivide_to_level(struct Object *object,
* are allocated at a proper level and return. */
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->ldata, CD_MDISPS);
if (!has_mdisps) {
- CustomData_add_layer(&coarse_mesh->ldata, CD_MDISPS, CD_CALLOC, NULL, coarse_mesh->totloop);
+ CustomData_add_layer(
+ &coarse_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, NULL, coarse_mesh->totloop);
}
/* NOTE: Subdivision happens from the top level of the existing multires modifier. If it is set
diff --git a/source/blender/blenkernel/intern/multires_reshape_subdivide.c b/source/blender/blenkernel/intern/multires_reshape_subdivide.c
index 9fa3e93a1e6..cecb57f4de4 100644
--- a/source/blender/blenkernel/intern/multires_reshape_subdivide.c
+++ b/source/blender/blenkernel/intern/multires_reshape_subdivide.c
@@ -68,7 +68,8 @@ void multires_subdivide_create_tangent_displacement_linear_grids(Object *object,
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->ldata, CD_MDISPS);
if (!has_mdisps) {
- CustomData_add_layer(&coarse_mesh->ldata, CD_MDISPS, CD_CALLOC, NULL, coarse_mesh->totloop);
+ CustomData_add_layer(
+ &coarse_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, NULL, coarse_mesh->totloop);
}
if (new_top_level == 1) {
diff --git a/source/blender/blenkernel/intern/multires_unsubdivide.c b/source/blender/blenkernel/intern/multires_unsubdivide.c
index cad680ecedd..27a1f84579e 100644
--- a/source/blender/blenkernel/intern/multires_unsubdivide.c
+++ b/source/blender/blenkernel/intern/multires_unsubdivide.c
@@ -901,10 +901,10 @@ static void multires_unsubdivide_add_original_index_datalayers(Mesh *mesh)
multires_unsubdivide_free_original_datalayers(mesh);
int *l_index = CustomData_add_layer_named(
- &mesh->ldata, CD_PROP_INT32, CD_CALLOC, NULL, mesh->totloop, lname);
+ &mesh->ldata, CD_PROP_INT32, CD_SET_DEFAULT, NULL, mesh->totloop, lname);
int *v_index = CustomData_add_layer_named(
- &mesh->vdata, CD_PROP_INT32, CD_CALLOC, NULL, mesh->totvert, vname);
+ &mesh->vdata, CD_PROP_INT32, CD_SET_DEFAULT, NULL, mesh->totvert, vname);
/* Initialize these data-layer with the indices in the current mesh. */
for (int i = 0; i < mesh->totloop; i++) {
@@ -1174,7 +1174,7 @@ static void multires_create_grids_in_unsubdivided_base_mesh(MultiresUnsubdivideC
CustomData_free_layers(&base_mesh->ldata, CD_MDISPS, base_mesh->totloop);
}
MDisps *mdisps = CustomData_add_layer(
- &base_mesh->ldata, CD_MDISPS, CD_CALLOC, NULL, base_mesh->totloop);
+ &base_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, NULL, base_mesh->totloop);
const int totdisp = pow_i(BKE_ccg_gridsize(context->num_total_levels), 2);
const int totloop = base_mesh->totloop;
diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc
index 2a85811e2e8..c90c83074bd 100644
--- a/source/blender/blenkernel/intern/object.cc
+++ b/source/blender/blenkernel/intern/object.cc
@@ -1665,7 +1665,7 @@ static void copy_ccg_data(Mesh *mesh_destination, Mesh *mesh_source, int layer_t
const int layer_index = CustomData_get_layer_index(data_destination, layer_type);
CustomData_free_layer(data_destination, layer_type, num_elements, layer_index);
BLI_assert(!CustomData_has_layer(data_destination, layer_type));
- CustomData_add_layer(data_destination, layer_type, CD_CALLOC, nullptr, num_elements);
+ CustomData_add_layer(data_destination, layer_type, CD_SET_DEFAULT, nullptr, num_elements);
BLI_assert(CustomData_has_layer(data_destination, layer_type));
CustomData_copy_layer_type_data(data_source, data_destination, layer_type, 0, 0, num_elements);
}
diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c
index 310ec7678bd..08d98775e34 100644
--- a/source/blender/blenkernel/intern/object_deform.c
+++ b/source/blender/blenkernel/intern/object_deform.c
@@ -115,7 +115,8 @@ MDeformVert *BKE_object_defgroup_data_create(ID *id)
{
if (GS(id->name) == ID_ME) {
Mesh *me = (Mesh *)id;
- me->dvert = CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, me->totvert);
+ me->dvert = CustomData_add_layer(
+ &me->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, me->totvert);
return me->dvert;
}
if (GS(id->name) == ID_LT) {
diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc
index a6b0a4d96ee..1dfc47efcd5 100644
--- a/source/blender/blenkernel/intern/paint.cc
+++ b/source/blender/blenkernel/intern/paint.cc
@@ -1835,8 +1835,8 @@ static void sculpt_face_sets_ensure(Mesh *mesh)
return;
}
- int *new_face_sets = static_cast<int *>(
- CustomData_add_layer(&mesh->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, nullptr, mesh->totpoly));
+ int *new_face_sets = static_cast<int *>(CustomData_add_layer(
+ &mesh->pdata, CD_SCULPT_FACE_SETS, CD_SET_DEFAULT, nullptr, mesh->totpoly));
/* Initialize the new Face Set data-layer with a default valid visible ID and set the default
* color to render it white. */
@@ -1917,7 +1917,7 @@ void BKE_sculpt_color_layer_create_if_needed(Object *object)
return;
}
- CustomData_add_layer(&orig_me->vdata, CD_PROP_COLOR, CD_DEFAULT, nullptr, orig_me->totvert);
+ CustomData_add_layer(&orig_me->vdata, CD_PROP_COLOR, CD_CONSTRUCT, nullptr, orig_me->totvert);
CustomDataLayer *layer = orig_me->vdata.layers +
CustomData_get_layer_index(&orig_me->vdata, CD_PROP_COLOR);
@@ -1958,8 +1958,8 @@ int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
int gridarea = gridsize * gridsize;
int i, j;
- gmask = static_cast<GridPaintMask *>(
- CustomData_add_layer(&me->ldata, CD_GRID_PAINT_MASK, CD_CALLOC, nullptr, me->totloop));
+ gmask = static_cast<GridPaintMask *>(CustomData_add_layer(
+ &me->ldata, CD_GRID_PAINT_MASK, CD_SET_DEFAULT, nullptr, me->totloop));
for (i = 0; i < me->totloop; i++) {
GridPaintMask *gpm = &gmask[i];
@@ -2002,7 +2002,7 @@ int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
/* create vertex paint mask layer if there isn't one already */
if (!paint_mask) {
- CustomData_add_layer(&me->vdata, CD_PAINT_MASK, CD_CALLOC, nullptr, me->totvert);
+ CustomData_add_layer(&me->vdata, CD_PAINT_MASK, CD_SET_DEFAULT, nullptr, me->totvert);
ret |= SCULPT_MASK_LAYER_CALC_VERT;
}
@@ -2078,7 +2078,7 @@ void BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(Mesh *mesh)
else {
initialize_new_face_sets = true;
int *new_face_sets = static_cast<int *>(CustomData_add_layer(
- &mesh->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, nullptr, mesh->totpoly));
+ &mesh->pdata, CD_SCULPT_FACE_SETS, CD_SET_DEFAULT, nullptr, mesh->totpoly));
/* Initialize the new Face Set data-layer with a default valid visible ID and set the default
* color to render it white. */
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index abecb9f8d9d..254cea0bd8b 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -3322,7 +3322,7 @@ static void hair_create_input_mesh(ParticleSimulationData *sim,
mesh = *r_mesh;
if (!mesh) {
*r_mesh = mesh = BKE_mesh_new_nomain(totpoint, totedge, 0, 0, 0);
- CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, mesh->totvert);
+ CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, mesh->totvert);
BKE_mesh_update_customdata_pointers(mesh, false);
}
mvert = mesh->mvert;
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 726c022ba2c..24f3097f9e3 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -3233,7 +3233,7 @@ bool *BKE_pbvh_get_vert_hide_for_write(PBVH *pbvh)
return pbvh->hide_vert;
}
pbvh->hide_vert = (bool *)CustomData_add_layer_named(
- &pbvh->mesh->vdata, CD_PROP_BOOL, CD_CALLOC, NULL, pbvh->mesh->totvert, ".hide_vert");
+ &pbvh->mesh->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, pbvh->mesh->totvert, ".hide_vert");
return pbvh->hide_vert;
}
diff --git a/source/blender/blenkernel/intern/pointcloud.cc b/source/blender/blenkernel/intern/pointcloud.cc
index 426ad797cef..306141cffb7 100644
--- a/source/blender/blenkernel/intern/pointcloud.cc
+++ b/source/blender/blenkernel/intern/pointcloud.cc
@@ -64,7 +64,7 @@ static void pointcloud_init_data(ID *id)
CustomData_reset(&pointcloud->pdata);
CustomData_add_layer_named(&pointcloud->pdata,
CD_PROP_FLOAT3,
- CD_CALLOC,
+ CD_SET_DEFAULT,
nullptr,
pointcloud->totpoint,
POINTCLOUD_ATTR_POSITION);
@@ -231,7 +231,7 @@ void *BKE_pointcloud_add_default(Main *bmain, const char *name)
CustomData_add_layer_named(&pointcloud->pdata,
CD_PROP_FLOAT,
- CD_CALLOC,
+ CD_SET_DEFAULT,
nullptr,
pointcloud->totpoint,
POINTCLOUD_ATTR_RADIUS);
@@ -251,7 +251,7 @@ PointCloud *BKE_pointcloud_new_nomain(const int totpoint)
CustomData_add_layer_named(&pointcloud->pdata,
CD_PROP_FLOAT,
- CD_CALLOC,
+ CD_SET_DEFAULT,
nullptr,
pointcloud->totpoint,
POINTCLOUD_ATTR_RADIUS);
@@ -336,7 +336,7 @@ PointCloud *BKE_pointcloud_new_for_eval(const PointCloud *pointcloud_src, int to
pointcloud_dst->totpoint = totpoint;
CustomData_copy(
- &pointcloud_src->pdata, &pointcloud_dst->pdata, CD_MASK_ALL, CD_CALLOC, totpoint);
+ &pointcloud_src->pdata, &pointcloud_dst->pdata, CD_MASK_ALL, CD_SET_DEFAULT, totpoint);
return pointcloud_dst;
}
diff --git a/source/blender/blenkernel/intern/subdiv_mesh.cc b/source/blender/blenkernel/intern/subdiv_mesh.cc
index e026a013498..da22ee6fd47 100644
--- a/source/blender/blenkernel/intern/subdiv_mesh.cc
+++ b/source/blender/blenkernel/intern/subdiv_mesh.cc
@@ -186,7 +186,7 @@ static void vertex_interpolation_init(const SubdivMeshContext *ctx,
CustomData_copy(&ctx->coarse_mesh->vdata,
&vertex_interpolation->vertex_data_storage,
CD_MASK_EVERYTHING.vmask,
- CD_CALLOC,
+ CD_SET_DEFAULT,
4);
/* Initialize indices. */
vertex_interpolation->vertex_indices[0] = 0;
@@ -321,7 +321,7 @@ static void loop_interpolation_init(const SubdivMeshContext *ctx,
CustomData_copy(&ctx->coarse_mesh->ldata,
&loop_interpolation->loop_data_storage,
CD_MASK_EVERYTHING.lmask,
- CD_CALLOC,
+ CD_SET_DEFAULT,
4);
/* Initialize indices. */
loop_interpolation->loop_indices[0] = 0;
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index f19aac68d35..9737801291e 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -1248,7 +1248,7 @@ static void *ccgDM_get_vert_data_layer(DerivedMesh *dm, int type)
BLI_rw_mutex_lock(&ccgdm->origindex_cache_rwlock, THREAD_LOCK_WRITE);
origindex = CustomData_add_layer(
- &dm->vertData, CD_ORIGINDEX, CD_CALLOC, NULL, dm->numVertData);
+ &dm->vertData, CD_ORIGINDEX, CD_SET_DEFAULT, NULL, dm->numVertData);
totorig = ccgSubSurf_getNumVerts(ss);
totnone = dm->numVertData - totorig;
@@ -1287,7 +1287,7 @@ static void *ccgDM_get_edge_data_layer(DerivedMesh *dm, int type)
}
origindex = CustomData_add_layer(
- &dm->edgeData, CD_ORIGINDEX, CD_CALLOC, NULL, dm->numEdgeData);
+ &dm->edgeData, CD_ORIGINDEX, CD_SET_DEFAULT, NULL, dm->numEdgeData);
totedge = ccgSubSurf_getNumEdges(ss);
totorig = totedge * (edgeSize - 1);
@@ -1330,7 +1330,7 @@ static void *ccgDM_get_poly_data_layer(DerivedMesh *dm, int type)
}
origindex = CustomData_add_layer(
- &dm->polyData, CD_ORIGINDEX, CD_CALLOC, NULL, dm->numPolyData);
+ &dm->polyData, CD_ORIGINDEX, CD_SET_DEFAULT, NULL, dm->numPolyData);
totface = ccgSubSurf_getNumFaces(ss);
diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c
index 3b73a81012d..ada2d27f9b2 100644
--- a/source/blender/blenlib/intern/BLI_memarena.c
+++ b/source/blender/blenlib/intern/BLI_memarena.c
@@ -158,6 +158,7 @@ void *BLI_memarena_calloc(MemArena *ma, size_t size)
BLI_assert(ma->use_calloc == false);
ptr = BLI_memarena_alloc(ma, size);
+ BLI_assert(ptr != NULL);
memset(ptr, 0, size);
return ptr;
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index 75cc333e4b5..20659daabd6 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -291,8 +291,8 @@ static void customdata_version_242(Mesh *me)
MEM_freeN(me->mcol);
}
- me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface);
- me->mtface = CustomData_add_layer(&me->fdata, CD_MTFACE, CD_CALLOC, NULL, me->totface);
+ me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_SET_DEFAULT, NULL, me->totface);
+ me->mtface = CustomData_add_layer(&me->fdata, CD_MTFACE, CD_SET_DEFAULT, NULL, me->totface);
mtf = me->mtface;
mcol = me->mcol;
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index 0ee5545527b..757d006b04d 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -513,23 +513,23 @@ void BM_mesh_copy_init_customdata_from_mesh_array(BMesh *bm_dst,
const Mesh *me_src = me_src_array[i];
if (i == 0) {
CustomData_copy_mesh_to_bmesh(
- &me_src->vdata, &bm_dst->vdata, CD_MASK_BMESH.vmask, CD_CALLOC, 0);
+ &me_src->vdata, &bm_dst->vdata, CD_MASK_BMESH.vmask, CD_SET_DEFAULT, 0);
CustomData_copy_mesh_to_bmesh(
- &me_src->edata, &bm_dst->edata, CD_MASK_BMESH.emask, CD_CALLOC, 0);
+ &me_src->edata, &bm_dst->edata, CD_MASK_BMESH.emask, CD_SET_DEFAULT, 0);
CustomData_copy_mesh_to_bmesh(
- &me_src->ldata, &bm_dst->ldata, CD_MASK_BMESH.lmask, CD_CALLOC, 0);
+ &me_src->ldata, &bm_dst->ldata, CD_MASK_BMESH.lmask, CD_SET_DEFAULT, 0);
CustomData_copy_mesh_to_bmesh(
- &me_src->pdata, &bm_dst->pdata, CD_MASK_BMESH.pmask, CD_CALLOC, 0);
+ &me_src->pdata, &bm_dst->pdata, CD_MASK_BMESH.pmask, CD_SET_DEFAULT, 0);
}
else {
CustomData_merge_mesh_to_bmesh(
- &me_src->vdata, &bm_dst->vdata, CD_MASK_BMESH.vmask, CD_CALLOC, 0);
+ &me_src->vdata, &bm_dst->vdata, CD_MASK_BMESH.vmask, CD_SET_DEFAULT, 0);
CustomData_merge_mesh_to_bmesh(
- &me_src->edata, &bm_dst->edata, CD_MASK_BMESH.emask, CD_CALLOC, 0);
+ &me_src->edata, &bm_dst->edata, CD_MASK_BMESH.emask, CD_SET_DEFAULT, 0);
CustomData_merge_mesh_to_bmesh(
- &me_src->ldata, &bm_dst->ldata, CD_MASK_BMESH.lmask, CD_CALLOC, 0);
+ &me_src->ldata, &bm_dst->ldata, CD_MASK_BMESH.lmask, CD_SET_DEFAULT, 0);
CustomData_merge_mesh_to_bmesh(
- &me_src->pdata, &bm_dst->pdata, CD_MASK_BMESH.pmask, CD_CALLOC, 0);
+ &me_src->pdata, &bm_dst->pdata, CD_MASK_BMESH.pmask, CD_SET_DEFAULT, 0);
}
cd_flag |= me_src->cd_flag;
@@ -558,10 +558,10 @@ void BM_mesh_copy_init_customdata(BMesh *bm_dst, BMesh *bm_src, const BMAllocTem
allocsize = &bm_mesh_allocsize_default;
}
- CustomData_copy(&bm_src->vdata, &bm_dst->vdata, CD_MASK_BMESH.vmask, CD_CALLOC, 0);
- CustomData_copy(&bm_src->edata, &bm_dst->edata, CD_MASK_BMESH.emask, CD_CALLOC, 0);
- CustomData_copy(&bm_src->ldata, &bm_dst->ldata, CD_MASK_BMESH.lmask, CD_CALLOC, 0);
- CustomData_copy(&bm_src->pdata, &bm_dst->pdata, CD_MASK_BMESH.pmask, CD_CALLOC, 0);
+ CustomData_copy(&bm_src->vdata, &bm_dst->vdata, CD_MASK_BMESH.vmask, CD_SET_DEFAULT, 0);
+ CustomData_copy(&bm_src->edata, &bm_dst->edata, CD_MASK_BMESH.emask, CD_SET_DEFAULT, 0);
+ CustomData_copy(&bm_src->ldata, &bm_dst->ldata, CD_MASK_BMESH.lmask, CD_SET_DEFAULT, 0);
+ CustomData_copy(&bm_src->pdata, &bm_dst->pdata, CD_MASK_BMESH.pmask, CD_SET_DEFAULT, 0);
CustomData_bmesh_init_pool(&bm_dst->vdata, allocsize->totvert, BM_VERT);
CustomData_bmesh_init_pool(&bm_dst->edata, allocsize->totedge, BM_EDGE);
@@ -596,7 +596,7 @@ void BM_mesh_copy_init_customdata_all_layers(BMesh *bm_dst,
for (int l = 0; l < src->totlayer; l++) {
CustomData_add_layer_named(
- dst, src->layers[l].type, CD_CALLOC, NULL, 0, src->layers[l].name);
+ dst, src->layers[l].type, CD_SET_DEFAULT, NULL, 0, src->layers[l].name);
}
CustomData_bmesh_init_pool(dst, size, htypes[i]);
}
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c
index 0c3db31dd1f..b7028dee5e1 100644
--- a/source/blender/bmesh/intern/bmesh_interp.c
+++ b/source/blender/bmesh/intern/bmesh_interp.c
@@ -846,7 +846,7 @@ void BM_data_layer_add(BMesh *bm, CustomData *data, int type)
/* the pool is now owned by olddata and must not be shared */
data->pool = NULL;
- CustomData_add_layer(data, type, CD_DEFAULT, NULL, 0);
+ CustomData_add_layer(data, type, CD_SET_DEFAULT, NULL, 0);
update_data_blocks(bm, &olddata, data);
if (olddata.layers) {
@@ -864,7 +864,7 @@ void BM_data_layer_add_named(BMesh *bm, CustomData *data, int type, const char *
/* the pool is now owned by olddata and must not be shared */
data->pool = NULL;
- CustomData_add_layer_named(data, type, CD_DEFAULT, NULL, 0, name);
+ CustomData_add_layer_named(data, type, CD_SET_DEFAULT, NULL, 0, name);
update_data_blocks(bm, &olddata, data);
if (olddata.layers) {
diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert.cc b/source/blender/bmesh/intern/bmesh_mesh_convert.cc
index b9c004b5392..4e0e27cd051 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_convert.cc
+++ b/source/blender/bmesh/intern/bmesh_mesh_convert.cc
@@ -217,10 +217,10 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshPar
if (!me || !me->totvert) {
if (me && is_new) { /* No verts? still copy custom-data layout. */
- CustomData_copy_mesh_to_bmesh(&me->vdata, &bm->vdata, mask.vmask, CD_DEFAULT, 0);
- CustomData_copy_mesh_to_bmesh(&me->edata, &bm->edata, mask.emask, CD_DEFAULT, 0);
- CustomData_copy_mesh_to_bmesh(&me->ldata, &bm->ldata, mask.lmask, CD_DEFAULT, 0);
- CustomData_copy_mesh_to_bmesh(&me->pdata, &bm->pdata, mask.pmask, CD_DEFAULT, 0);
+ CustomData_copy_mesh_to_bmesh(&me->vdata, &bm->vdata, mask.vmask, CD_CONSTRUCT, 0);
+ CustomData_copy_mesh_to_bmesh(&me->edata, &bm->edata, mask.emask, CD_CONSTRUCT, 0);
+ CustomData_copy_mesh_to_bmesh(&me->ldata, &bm->ldata, mask.lmask, CD_CONSTRUCT, 0);
+ CustomData_copy_mesh_to_bmesh(&me->pdata, &bm->pdata, mask.pmask, CD_CONSTRUCT, 0);
CustomData_bmesh_init_pool(&bm->vdata, me->totvert, BM_VERT);
CustomData_bmesh_init_pool(&bm->edata, me->totedge, BM_EDGE);
@@ -236,16 +236,16 @@ void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshPar
}
if (is_new) {
- CustomData_copy_mesh_to_bmesh(&me->vdata, &bm->vdata, mask.vmask, CD_CALLOC, 0);
- CustomData_copy_mesh_to_bmesh(&me->edata, &bm->edata, mask.emask, CD_CALLOC, 0);
- CustomData_copy_mesh_to_bmesh(&me->ldata, &bm->ldata, mask.lmask, CD_CALLOC, 0);
- CustomData_copy_mesh_to_bmesh(&me->pdata, &bm->pdata, mask.pmask, CD_CALLOC, 0);
+ CustomData_copy_mesh_to_bmesh(&me->vdata, &bm->vdata, mask.vmask, CD_SET_DEFAULT, 0);
+ CustomData_copy_mesh_to_bmesh(&me->edata, &bm->edata, mask.emask, CD_SET_DEFAULT, 0);
+ CustomData_copy_mesh_to_bmesh(&me->ldata, &bm->ldata, mask.lmask, CD_SET_DEFAULT, 0);
+ CustomData_copy_mesh_to_bmesh(&me->pdata, &bm->pdata, mask.pmask, CD_SET_DEFAULT, 0);
}
else {
- CustomData_bmesh_merge(&me->vdata, &bm->vdata, mask.vmask, CD_CALLOC, bm, BM_VERT);
- CustomData_bmesh_merge(&me->edata, &bm->edata, mask.emask, CD_CALLOC, bm, BM_EDGE);
- CustomData_bmesh_merge(&me->ldata, &bm->ldata, mask.lmask, CD_CALLOC, bm, BM_LOOP);
- CustomData_bmesh_merge(&me->pdata, &bm->pdata, mask.pmask, CD_CALLOC, bm, BM_FACE);
+ CustomData_bmesh_merge(&me->vdata, &bm->vdata, mask.vmask, CD_SET_DEFAULT, bm, BM_VERT);
+ CustomData_bmesh_merge(&me->edata, &bm->edata, mask.emask, CD_SET_DEFAULT, bm, BM_EDGE);
+ CustomData_bmesh_merge(&me->ldata, &bm->ldata, mask.lmask, CD_SET_DEFAULT, bm, BM_LOOP);
+ CustomData_bmesh_merge(&me->pdata, &bm->pdata, mask.pmask, CD_SET_DEFAULT, bm, BM_FACE);
}
/* -------------------------------------------------------------------- */
@@ -1016,10 +1016,10 @@ void BM_mesh_bm_to_me(Main *bmain, BMesh *bm, Mesh *me, const struct BMeshToMesh
{
CustomData_MeshMasks mask = CD_MASK_MESH;
CustomData_MeshMasks_update(&mask, &params->cd_mask_extra);
- CustomData_copy_mesh_to_bmesh(&bm->vdata, &me->vdata, mask.vmask, CD_CALLOC, me->totvert);
- CustomData_copy_mesh_to_bmesh(&bm->edata, &me->edata, mask.emask, CD_CALLOC, me->totedge);
- CustomData_copy_mesh_to_bmesh(&bm->ldata, &me->ldata, mask.lmask, CD_CALLOC, me->totloop);
- CustomData_copy_mesh_to_bmesh(&bm->pdata, &me->pdata, mask.pmask, CD_CALLOC, me->totpoly);
+ CustomData_copy_mesh_to_bmesh(&bm->vdata, &me->vdata, mask.vmask, CD_SET_DEFAULT, me->totvert);
+ CustomData_copy_mesh_to_bmesh(&bm->edata, &me->edata, mask.emask, CD_SET_DEFAULT, me->totedge);
+ CustomData_copy_mesh_to_bmesh(&bm->ldata, &me->ldata, mask.lmask, CD_SET_DEFAULT, me->totloop);
+ CustomData_copy_mesh_to_bmesh(&bm->pdata, &me->pdata, mask.pmask, CD_SET_DEFAULT, me->totpoly);
}
MVert *mvert = bm->totvert ? (MVert *)MEM_callocN(sizeof(MVert) * bm->totvert, "bm_to_me.vert") :
@@ -1271,10 +1271,10 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
me->totloop = bm->totloop;
me->totpoly = bm->totface;
- CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, nullptr, bm->totvert);
- CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, nullptr, bm->totedge);
- CustomData_add_layer(&me->ldata, CD_MLOOP, CD_CALLOC, nullptr, bm->totloop);
- CustomData_add_layer(&me->pdata, CD_MPOLY, CD_CALLOC, nullptr, bm->totface);
+ CustomData_add_layer(&me->vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, bm->totvert);
+ CustomData_add_layer(&me->edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, bm->totedge);
+ CustomData_add_layer(&me->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, bm->totloop);
+ CustomData_add_layer(&me->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, bm->totface);
/* Don't process shape-keys, we only feed them through the modifier stack as needed,
* e.g. for applying modifiers or the like. */
@@ -1283,10 +1283,10 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
CustomData_MeshMasks_update(&mask, cd_mask_extra);
}
mask.vmask &= ~CD_MASK_SHAPEKEY;
- CustomData_merge(&bm->vdata, &me->vdata, mask.vmask, CD_CALLOC, me->totvert);
- CustomData_merge(&bm->edata, &me->edata, mask.emask, CD_CALLOC, me->totedge);
- CustomData_merge(&bm->ldata, &me->ldata, mask.lmask, CD_CALLOC, me->totloop);
- CustomData_merge(&bm->pdata, &me->pdata, mask.pmask, CD_CALLOC, me->totpoly);
+ CustomData_merge(&bm->vdata, &me->vdata, mask.vmask, CD_SET_DEFAULT, me->totvert);
+ CustomData_merge(&bm->edata, &me->edata, mask.emask, CD_SET_DEFAULT, me->totedge);
+ CustomData_merge(&bm->ldata, &me->ldata, mask.lmask, CD_SET_DEFAULT, me->totloop);
+ CustomData_merge(&bm->pdata, &me->pdata, mask.pmask, CD_SET_DEFAULT, me->totpoly);
BKE_mesh_update_customdata_pointers(me, false);
diff --git a/source/blender/editors/curves/intern/curves_add.cc b/source/blender/editors/curves/intern/curves_add.cc
index 79916253207..6556f62443a 100644
--- a/source/blender/editors/curves/intern/curves_add.cc
+++ b/source/blender/editors/curves/intern/curves_add.cc
@@ -104,7 +104,7 @@ bke::CurvesGeometry primitive_random_sphere(const int curves_size, const int poi
MutableSpan<float3> positions = curves.positions_for_write();
float *radius_data = (float *)CustomData_add_layer_named(
- &curves.point_data, CD_PROP_FLOAT, CD_DEFAULT, nullptr, curves.point_num, "radius");
+ &curves.point_data, CD_PROP_FLOAT, CD_SET_DEFAULT, nullptr, curves.point_num, "radius");
MutableSpan<float> radii{radius_data, curves.points_num()};
for (const int i : offsets.index_range()) {
diff --git a/source/blender/editors/geometry/geometry_attributes.cc b/source/blender/editors/geometry/geometry_attributes.cc
index aec22f0f3ae..2dcb7aa438f 100644
--- a/source/blender/editors/geometry/geometry_attributes.cc
+++ b/source/blender/editors/geometry/geometry_attributes.cc
@@ -305,7 +305,7 @@ static int geometry_attribute_convert_exec(bContext *C, wmOperator *op)
void *new_data = MEM_malloc_arrayN(src_varray.size(), cpp_type.size(), __func__);
src_varray.materialize_to_uninitialized(new_data);
attributes.remove(name);
- attributes.add(name, dst_domain, dst_type, blender::bke::AttributeInitMove(new_data));
+ attributes.add(name, dst_domain, dst_type, blender::bke::AttributeInitMoveArray(new_data));
break;
}
case ConvertAttributeMode::UVMap: {
@@ -660,7 +660,7 @@ bool ED_geometry_attribute_convert(Mesh *mesh,
void *new_data = MEM_malloc_arrayN(src_varray.size(), cpp_type.size(), __func__);
src_varray.materialize_to_uninitialized(new_data);
attributes.remove(name);
- attributes.add(name, new_domain, new_type, blender::bke::AttributeInitMove(new_data));
+ attributes.add(name, new_domain, new_type, blender::bke::AttributeInitMoveArray(new_data));
int *active_index = BKE_id_attributes_active_index_p(&mesh->id);
if (*active_index > 0) {
diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc
index ea29d07feaf..e394f8a7251 100644
--- a/source/blender/editors/mesh/mesh_data.cc
+++ b/source/blender/editors/mesh/mesh_data.cc
@@ -286,7 +286,8 @@ int ED_mesh_uv_add(
is_init = true;
}
else {
- CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, nullptr, me->totloop, name);
+ CustomData_add_layer_named(
+ &me->ldata, CD_MLOOPUV, CD_SET_DEFAULT, nullptr, me->totloop, name);
}
if (active_set || layernum_dst == 0) {
@@ -409,7 +410,7 @@ int ED_mesh_color_add(
}
else {
CustomData_add_layer_named(
- &me->ldata, CD_PROP_BYTE_COLOR, CD_DEFAULT, nullptr, me->totloop, name);
+ &me->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, nullptr, me->totloop, name);
}
if (active_set || layernum == 0) {
@@ -432,7 +433,7 @@ bool ED_mesh_color_ensure(Mesh *me, const char *name)
if (!layer) {
CustomData_add_layer_named(
- &me->ldata, CD_PROP_BYTE_COLOR, CD_DEFAULT, nullptr, me->totloop, name);
+ &me->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, nullptr, me->totloop, name);
layer = me->ldata.layers + CustomData_get_layer_index(&me->ldata, CD_PROP_BYTE_COLOR);
BKE_id_attributes_active_color_set(&me->id, layer);
@@ -500,7 +501,7 @@ int ED_mesh_sculpt_color_add(Mesh *me, const char *name, const bool do_init, Rep
}
else {
CustomData_add_layer_named(
- &me->vdata, CD_PROP_COLOR, CD_DEFAULT, nullptr, me->totvert, name);
+ &me->vdata, CD_PROP_COLOR, CD_SET_DEFAULT, nullptr, me->totvert, name);
}
if (layernum == 0) {
@@ -790,7 +791,7 @@ static int mesh_customdata_custom_splitnormals_add_exec(bContext *C, wmOperator
me->smoothresh);
}
- CustomData_add_layer(data, CD_CUSTOMLOOPNORMAL, CD_DEFAULT, nullptr, me->totloop);
+ CustomData_add_layer(data, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, me->totloop);
}
DEG_id_tag_update(&me->id, 0);
@@ -875,11 +876,11 @@ static void mesh_add_verts(Mesh *mesh, int len)
int totvert = mesh->totvert + len;
CustomData vdata;
- CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH.vmask, CD_DEFAULT, totvert);
+ CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH.vmask, CD_SET_DEFAULT, totvert);
CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);
if (!CustomData_has_layer(&vdata, CD_MVERT)) {
- CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, nullptr, totvert);
+ CustomData_add_layer(&vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, totvert);
}
CustomData_free(&mesh->vdata, mesh->totvert);
@@ -913,11 +914,11 @@ static void mesh_add_edges(Mesh *mesh, int len)
totedge = mesh->totedge + len;
/* Update custom-data. */
- CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
+ CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_SET_DEFAULT, totedge);
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
if (!CustomData_has_layer(&edata, CD_MEDGE)) {
- CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, nullptr, totedge);
+ CustomData_add_layer(&edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, totedge);
}
CustomData_free(&mesh->edata, mesh->totedge);
@@ -947,11 +948,11 @@ static void mesh_add_loops(Mesh *mesh, int len)
totloop = mesh->totloop + len; /* new face count */
/* update customdata */
- CustomData_copy(&mesh->ldata, &ldata, CD_MASK_MESH.lmask, CD_DEFAULT, totloop);
+ CustomData_copy(&mesh->ldata, &ldata, CD_MASK_MESH.lmask, CD_SET_DEFAULT, totloop);
CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop);
if (!CustomData_has_layer(&ldata, CD_MLOOP)) {
- CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, nullptr, totloop);
+ CustomData_add_layer(&ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, totloop);
}
BKE_mesh_runtime_clear_cache(mesh);
@@ -976,11 +977,11 @@ static void mesh_add_polys(Mesh *mesh, int len)
totpoly = mesh->totpoly + len; /* new face count */
/* update customdata */
- CustomData_copy(&mesh->pdata, &pdata, CD_MASK_MESH.pmask, CD_DEFAULT, totpoly);
+ CustomData_copy(&mesh->pdata, &pdata, CD_MASK_MESH.pmask, CD_SET_DEFAULT, totpoly);
CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly);
if (!CustomData_has_layer(&pdata, CD_MPOLY)) {
- CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, nullptr, totpoly);
+ CustomData_add_layer(&pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, totpoly);
}
CustomData_free(&mesh->pdata, mesh->totpoly);
diff --git a/source/blender/editors/mesh/meshtools.cc b/source/blender/editors/mesh/meshtools.cc
index b1004b23a21..e9a34cf95cb 100644
--- a/source/blender/editors/mesh/meshtools.cc
+++ b/source/blender/editors/mesh/meshtools.cc
@@ -100,7 +100,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
((Mesh *)ob_dst->data)->cd_flag |= me->cd_flag;
/* standard data */
- CustomData_merge(&me->vdata, vdata, CD_MASK_MESH.vmask, CD_DEFAULT, totvert);
+ CustomData_merge(&me->vdata, vdata, CD_MASK_MESH.vmask, CD_SET_DEFAULT, totvert);
CustomData_copy_data_named(&me->vdata, vdata, 0, *vertofs, me->totvert);
/* vertex groups */
@@ -199,7 +199,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
}
if (me->totedge) {
- CustomData_merge(&me->edata, edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
+ CustomData_merge(&me->edata, edata, CD_MASK_MESH.emask, CD_SET_DEFAULT, totedge);
CustomData_copy_data_named(&me->edata, edata, 0, *edgeofs, me->totedge);
for (a = 0; a < me->totedge; a++, medge++) {
@@ -220,7 +220,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
}
}
- CustomData_merge(&me->ldata, ldata, CD_MASK_MESH.lmask, CD_DEFAULT, totloop);
+ CustomData_merge(&me->ldata, ldata, CD_MASK_MESH.lmask, CD_SET_DEFAULT, totloop);
CustomData_copy_data_named(&me->ldata, ldata, 0, *loopofs, me->totloop);
for (a = 0; a < me->totloop; a++, mloop++) {
@@ -244,7 +244,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
}
}
- CustomData_merge(&me->pdata, pdata, CD_MASK_MESH.pmask, CD_DEFAULT, totpoly);
+ CustomData_merge(&me->pdata, pdata, CD_MASK_MESH.pmask, CD_SET_DEFAULT, totpoly);
CustomData_copy_data_named(&me->pdata, pdata, 0, *polyofs, me->totpoly);
for (a = 0; a < me->totpoly; a++, mpoly++) {
@@ -571,10 +571,10 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op)
CustomData_reset(&ldata);
CustomData_reset(&pdata);
- mvert = (MVert *)CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, nullptr, totvert);
- medge = (MEdge *)CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, nullptr, totedge);
- mloop = (MLoop *)CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, nullptr, totloop);
- mpoly = (MPoly *)CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, nullptr, totpoly);
+ mvert = (MVert *)CustomData_add_layer(&vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, totvert);
+ medge = (MEdge *)CustomData_add_layer(&edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, totedge);
+ mloop = (MLoop *)CustomData_add_layer(&ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, totloop);
+ mpoly = (MPoly *)CustomData_add_layer(&pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, totpoly);
vertofs = 0;
edgeofs = 0;
diff --git a/source/blender/editors/object/object_facemap_ops.c b/source/blender/editors/object/object_facemap_ops.c
index dddf5e40e87..4364375a4e3 100644
--- a/source/blender/editors/object/object_facemap_ops.c
+++ b/source/blender/editors/object/object_facemap_ops.c
@@ -53,7 +53,7 @@ void ED_object_facemap_face_add(Object *ob, bFaceMap *fmap, int facenum)
/* if there's is no facemap layer then create one */
if ((facemap = CustomData_get_layer(&me->pdata, CD_FACEMAP)) == NULL) {
- facemap = CustomData_add_layer(&me->pdata, CD_FACEMAP, CD_DEFAULT, NULL, me->totpoly);
+ facemap = CustomData_add_layer(&me->pdata, CD_FACEMAP, CD_SET_DEFAULT, NULL, me->totpoly);
}
facemap[facenum] = fmap_nr;
diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc
index f6e97f81cb6..085ef59ac21 100644
--- a/source/blender/editors/object/object_modifier.cc
+++ b/source/blender/editors/object/object_modifier.cc
@@ -586,9 +586,11 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList *UNUSED(reports),
me->totvert = verts_num;
me->totedge = edges_num;
- me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, nullptr, verts_num);
- me->medge = (MEdge *)CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, nullptr, edges_num);
- me->mface = (MFace *)CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, nullptr, 0);
+ me->mvert = (MVert *)CustomData_add_layer(
+ &me->vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, verts_num);
+ me->medge = (MEdge *)CustomData_add_layer(
+ &me->edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, edges_num);
+ me->mface = (MFace *)CustomData_add_layer(&me->fdata, CD_MFACE, CD_SET_DEFAULT, nullptr, 0);
MVert *mvert = me->mvert;
MEdge *medge = me->medge;
@@ -2642,7 +2644,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
MVert *mvert = me_eval_deform->mvert;
/* add vertex weights to original mesh */
- CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_CALLOC, nullptr, me->totvert);
+ CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, nullptr, me->totvert);
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
Object *arm_ob = BKE_object_add(bmain, view_layer, OB_ARMATURE, nullptr);
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index a7aa29853e6..c1289364fb2 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -81,7 +81,7 @@ static void partialvis_update_mesh(Object *ob,
bool *hide_vert = CustomData_get_layer_named(&me->vdata, CD_PROP_BOOL, ".hide_vert");
if (hide_vert == NULL) {
hide_vert = CustomData_add_layer_named(
- &me->vdata, CD_PROP_BOOL, CD_CALLOC, NULL, me->totvert, ".hide_vert");
+ &me->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, me->totvert, ".hide_vert");
}
SCULPT_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN);
diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
index 433823c8373..000b69cc2ba 100644
--- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
@@ -218,7 +218,7 @@ static void SCULPT_dynamic_topology_disable_ex(
/* Reset Face Sets as they are no longer valid. */
if (!CustomData_has_layer(&me->pdata, CD_SCULPT_FACE_SETS)) {
- CustomData_add_layer(&me->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, me->totpoly);
+ CustomData_add_layer(&me->pdata, CD_SCULPT_FACE_SETS, CD_SET_DEFAULT, NULL, me->totpoly);
}
ss->face_sets = CustomData_get_layer(&me->pdata, CD_SCULPT_FACE_SETS);
for (int i = 0; i < me->totpoly; i++) {
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 58d62fb2165..b0dcef61c31 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -1683,7 +1683,7 @@ static void sculpt_undo_set_active_layer(struct bContext *C, SculptAttrRef *attr
CustomData *cdata = attr->domain == ATTR_DOMAIN_POINT ? &me->vdata : &me->ldata;
int totelem = attr->domain == ATTR_DOMAIN_POINT ? me->totvert : me->totloop;
- CustomData_add_layer_named(cdata, attr->type, CD_DEFAULT, NULL, totelem, attr->name);
+ CustomData_add_layer_named(cdata, attr->type, CD_SET_DEFAULT, NULL, totelem, attr->name);
layer = BKE_id_attribute_find(&me->id, attr->name, attr->type, attr->domain);
}
diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
index 68d6be485a3..87a2d1620aa 100644
--- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
+++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
@@ -577,13 +577,13 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
mesh->totcol = group->materials.size();
mesh->mvert = (MVert *)CustomData_add_layer(
- &mesh->vdata, CD_MVERT, CD_CALLOC, nullptr, mesh->totvert);
+ &mesh->vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, mesh->totvert);
mesh->medge = (MEdge *)CustomData_add_layer(
- &mesh->edata, CD_MEDGE, CD_CALLOC, nullptr, mesh->totedge);
+ &mesh->edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, mesh->totedge);
mesh->mpoly = (MPoly *)CustomData_add_layer(
- &mesh->pdata, CD_MPOLY, CD_CALLOC, nullptr, mesh->totpoly);
+ &mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, mesh->totpoly);
mesh->mloop = (MLoop *)CustomData_add_layer(
- &mesh->ldata, CD_MLOOP, CD_CALLOC, nullptr, mesh->totloop);
+ &mesh->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, mesh->totloop);
MVert *vertices = mesh->mvert;
MEdge *edges = mesh->medge;
@@ -594,14 +594,14 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
if (hasTex) {
// First UV layer
CustomData_add_layer_named(
- &mesh->ldata, CD_MLOOPUV, CD_CALLOC, nullptr, mesh->totloop, uvNames[0]);
+ &mesh->ldata, CD_MLOOPUV, CD_SET_DEFAULT, nullptr, mesh->totloop, uvNames[0]);
CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 0);
BKE_mesh_update_customdata_pointers(mesh, true);
loopsuv[0] = mesh->mloopuv;
// Second UV layer
CustomData_add_layer_named(
- &mesh->ldata, CD_MLOOPUV, CD_CALLOC, nullptr, mesh->totloop, uvNames[1]);
+ &mesh->ldata, CD_MLOOPUV, CD_SET_DEFAULT, nullptr, mesh->totloop, uvNames[1]);
CustomData_set_layer_active(&mesh->ldata, CD_MLOOPUV, 1);
BKE_mesh_update_customdata_pointers(mesh, true);
loopsuv[1] = mesh->mloopuv;
@@ -609,9 +609,9 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
// colors and transparency (the latter represented by grayscale colors)
MLoopCol *colors = (MLoopCol *)CustomData_add_layer_named(
- &mesh->ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, nullptr, mesh->totloop, "Color");
+ &mesh->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, nullptr, mesh->totloop, "Color");
MLoopCol *transp = (MLoopCol *)CustomData_add_layer_named(
- &mesh->ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, nullptr, mesh->totloop, "Alpha");
+ &mesh->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, nullptr, mesh->totloop, "Alpha");
mesh->mloopcol = colors;
mesh->mat = (Material **)MEM_mallocN(sizeof(Material *) * mesh->totcol, "MaterialList");
diff --git a/source/blender/io/alembic/intern/abc_customdata.cc b/source/blender/io/alembic/intern/abc_customdata.cc
index 2820a128072..644990afb35 100644
--- a/source/blender/io/alembic/intern/abc_customdata.cc
+++ b/source/blender/io/alembic/intern/abc_customdata.cc
@@ -540,7 +540,7 @@ void read_generated_coordinates(const ICompoundProperty &prop,
cd_data = CustomData_get_layer(&mesh->vdata, CD_ORCO);
}
else {
- cd_data = CustomData_add_layer(&mesh->vdata, CD_ORCO, CD_CALLOC, nullptr, totvert);
+ cd_data = CustomData_add_layer(&mesh->vdata, CD_ORCO, CD_SET_DEFAULT, nullptr, totvert);
}
float(*orcodata)[3] = static_cast<float(*)[3]>(cd_data);
diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc
index bacc1f06599..e18770f2bef 100644
--- a/source/blender/io/alembic/intern/abc_reader_mesh.cc
+++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc
@@ -391,7 +391,7 @@ static void *add_customdata_cb(Mesh *mesh, const char *name, int data_type)
/* Create a new layer. */
int numloops = mesh->totloop;
cd_ptr = CustomData_add_layer_named(
- &mesh->ldata, cd_data_type, CD_DEFAULT, nullptr, numloops, name);
+ &mesh->ldata, cd_data_type, CD_SET_DEFAULT, nullptr, numloops, name);
return cd_ptr;
}
@@ -890,7 +890,7 @@ static void read_vertex_creases(Mesh *mesh,
}
float *vertex_crease_data = (float *)CustomData_add_layer(
- &mesh->vdata, CD_CREASE, CD_DEFAULT, nullptr, mesh->totvert);
+ &mesh->vdata, CD_CREASE, CD_SET_DEFAULT, nullptr, mesh->totvert);
const int totvert = mesh->totvert;
for (int i = 0, v = indices->size(); i < v; ++i) {
diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp
index 9fbba1b97fb..34792fd6bb4 100644
--- a/source/blender/io/collada/MeshImporter.cpp
+++ b/source/blender/io/collada/MeshImporter.cpp
@@ -341,7 +341,8 @@ void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me)
}
me->totvert = pos.getFloatValues()->getCount() / stride;
- me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, nullptr, me->totvert);
+ me->mvert = (MVert *)CustomData_add_layer(
+ &me->vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, me->totvert);
MVert *mvert;
int i;
@@ -449,9 +450,9 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
me->totpoly = total_poly_count;
me->totloop = total_loop_count;
me->mpoly = (MPoly *)CustomData_add_layer(
- &me->pdata, CD_MPOLY, CD_CALLOC, nullptr, me->totpoly);
+ &me->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, me->totpoly);
me->mloop = (MLoop *)CustomData_add_layer(
- &me->ldata, CD_MLOOP, CD_CALLOC, nullptr, me->totloop);
+ &me->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, me->totloop);
unsigned int totuvset = collada_mesh->getUVCoords().getInputInfosArray().getCount();
for (int i = 0; i < totuvset; i++) {
@@ -468,7 +469,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
COLLADAFW::String &uvname = info->mName;
/* Allocate space for UV_data */
CustomData_add_layer_named(
- &me->ldata, CD_MLOOPUV, CD_DEFAULT, nullptr, me->totloop, uvname.c_str());
+ &me->ldata, CD_MLOOPUV, CD_SET_DEFAULT, nullptr, me->totloop, uvname.c_str());
}
/* activate the first uv map */
me->mloopuv = (MLoopUV *)CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, 0);
@@ -481,7 +482,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
collada_mesh->getColors().getInputInfosArray()[i];
COLLADAFW::String colname = extract_vcolname(info->mName);
CustomData_add_layer_named(
- &me->ldata, CD_PROP_BYTE_COLOR, CD_DEFAULT, nullptr, me->totloop, colname.c_str());
+ &me->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, nullptr, me->totloop, colname.c_str());
}
me->mloopcol = (MLoopCol *)CustomData_get_layer_n(&me->ldata, CD_PROP_BYTE_COLOR, 0);
}
@@ -546,11 +547,11 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
totedge = mesh->totedge + len;
/* Update custom-data. */
- CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
+ CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_SET_DEFAULT, totedge);
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
if (!CustomData_has_layer(&edata, CD_MEDGE)) {
- CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, nullptr, totedge);
+ CustomData_add_layer(&edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, totedge);
}
CustomData_free(&mesh->edata, mesh->totedge);
diff --git a/source/blender/io/stl/importer/stl_import_mesh.cc b/source/blender/io/stl/importer/stl_import_mesh.cc
index b9ed441f0d9..7686bfa1247 100644
--- a/source/blender/io/stl/importer/stl_import_mesh.cc
+++ b/source/blender/io/stl/importer/stl_import_mesh.cc
@@ -77,7 +77,7 @@ Mesh *STLMeshHelper::to_mesh(Main *bmain, char *mesh_name)
mesh->totvert = verts_.size();
mesh->mvert = static_cast<MVert *>(
- CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_CALLOC, nullptr, mesh->totvert));
+ CustomData_add_layer(&mesh->vdata, CD_MVERT, CD_SET_DEFAULT, nullptr, mesh->totvert));
for (int i = 0; i < mesh->totvert; i++) {
copy_v3_v3(mesh->mvert[i].co, verts_[i]);
}
@@ -85,9 +85,9 @@ Mesh *STLMeshHelper::to_mesh(Main *bmain, char *mesh_name)
mesh->totpoly = tris_.size();
mesh->totloop = tris_.size() * 3;
mesh->mpoly = static_cast<MPoly *>(
- CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_CALLOC, nullptr, mesh->totpoly));
+ CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, mesh->totpoly));
mesh->mloop = static_cast<MLoop *>(
- CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_CALLOC, nullptr, mesh->totloop));
+ CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_SET_DEFAULT, nullptr, mesh->totloop));
threading::parallel_for(tris_.index_range(), 2048, [&](IndexRange tris_range) {
for (const int i : tris_range) {
diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc
index 103bb0d0cef..94ff24421e2 100644
--- a/source/blender/io/usd/intern/usd_reader_mesh.cc
+++ b/source/blender/io/usd/intern/usd_reader_mesh.cc
@@ -207,7 +207,8 @@ static void *add_customdata_cb(Mesh *mesh, const char *name, const int data_type
/* Create a new layer. */
numloops = mesh->totloop;
- cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_DEFAULT, nullptr, numloops, name);
+ cd_ptr = CustomData_add_layer_named(
+ loopdata, cd_data_type, CD_SET_DEFAULT, nullptr, numloops, name);
return cd_ptr;
}
@@ -576,7 +577,7 @@ void USDMeshReader::read_vertex_creases(Mesh *mesh, const double motionSampleTim
}
float *creases = static_cast<float *>(
- CustomData_add_layer(&mesh->vdata, CD_CREASE, CD_DEFAULT, nullptr, mesh->totvert));
+ CustomData_add_layer(&mesh->vdata, CD_CREASE, CD_SET_DEFAULT, nullptr, mesh->totvert));
for (size_t i = 0; i < corner_indices.size(); i++) {
creases[corner_indices[i]] = corner_sharpnesses[i];
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
index a570b374231..2a0676b72ff 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
@@ -181,7 +181,7 @@ void MeshFromGeometry::create_polys_loops(Mesh *mesh, bool use_vertex_groups)
const int64_t total_verts = mesh_geometry_.get_vertex_count();
if (use_vertex_groups && total_verts && mesh_geometry_.has_vertex_groups_) {
mesh->dvert = static_cast<MDeformVert *>(
- CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_CALLOC, nullptr, total_verts));
+ CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, nullptr, total_verts));
}
const int64_t tot_face_elems{mesh->totpoly};
@@ -262,7 +262,7 @@ void MeshFromGeometry::create_uv_verts(Mesh *mesh)
return;
}
MLoopUV *mluv_dst = static_cast<MLoopUV *>(CustomData_add_layer(
- &mesh->ldata, CD_MLOOPUV, CD_DEFAULT, nullptr, mesh_geometry_.total_loops_));
+ &mesh->ldata, CD_MLOOPUV, CD_SET_DEFAULT, nullptr, mesh_geometry_.total_loops_));
int tot_loop_idx = 0;
for (const PolyElem &curr_face : mesh_geometry_.face_elements_) {
diff --git a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
index bd9360548af..35f977f41df 100644
--- a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
+++ b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
@@ -12,7 +12,7 @@
#include "BKE_scene.h"
#include "BLI_listbase.h"
-#include "BLI_math_base.h"
+#include "BLI_math_base.hh"
#include "BLI_math_vec_types.hh"
#include "BLO_readfile.h"
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 2e31cab4734..994d063dbaf 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -422,7 +422,7 @@ static void rna_MeshVertex_hide_set(PointerRNA *ptr, bool value)
return;
}
hide_vert = (bool *)CustomData_add_layer_named(
- &mesh->vdata, CD_PROP_BOOL, CD_CALLOC, NULL, mesh->totvert, ".hide_vert");
+ &mesh->vdata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totvert, ".hide_vert");
}
const int index = rna_MeshVertex_index_get(ptr);
hide_vert[index] = value;
@@ -556,7 +556,7 @@ static void rna_MeshPolygon_hide_set(PointerRNA *ptr, bool value)
return;
}
hide_poly = (bool *)CustomData_add_layer_named(
- &mesh->pdata, CD_PROP_BOOL, CD_CALLOC, NULL, mesh->totpoly, ".hide_poly");
+ &mesh->pdata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totpoly, ".hide_poly");
}
const int index = rna_MeshPolygon_index_get(ptr);
hide_poly[index] = value;
@@ -782,7 +782,7 @@ static void rna_MEdge_freestyle_edge_mark_set(PointerRNA *ptr, bool value)
FreestyleEdge *fed = CustomData_get(&me->edata, index, CD_FREESTYLE_EDGE);
if (!fed) {
- fed = CustomData_add_layer(&me->edata, CD_FREESTYLE_EDGE, CD_CALLOC, NULL, me->totedge);
+ fed = CustomData_add_layer(&me->edata, CD_FREESTYLE_EDGE, CD_SET_DEFAULT, NULL, me->totedge);
}
if (value) {
fed->flag |= FREESTYLE_EDGE_MARK;
@@ -808,7 +808,7 @@ static void rna_MPoly_freestyle_face_mark_set(PointerRNA *ptr, bool value)
FreestyleFace *ffa = CustomData_get(&me->pdata, index, CD_FREESTYLE_FACE);
if (!ffa) {
- ffa = CustomData_add_layer(&me->pdata, CD_FREESTYLE_FACE, CD_CALLOC, NULL, me->totpoly);
+ ffa = CustomData_add_layer(&me->pdata, CD_FREESTYLE_FACE, CD_SET_DEFAULT, NULL, me->totpoly);
}
if (value) {
ffa->flag |= FREESTYLE_FACE_MARK;
@@ -1291,7 +1291,7 @@ static void rna_MeshEdge_hide_set(PointerRNA *ptr, bool value)
return;
}
hide_edge = (bool *)CustomData_add_layer_named(
- &mesh->edata, CD_PROP_BOOL, CD_CALLOC, NULL, mesh->totedge, ".hide_edge");
+ &mesh->edata, CD_PROP_BOOL, CD_SET_DEFAULT, NULL, mesh->totedge, ".hide_edge");
}
const int index = rna_MeshEdge_index_get(ptr);
hide_edge[index] = value;
@@ -1734,7 +1734,8 @@ static void rna_Mesh_sculpt_vertex_color_remove(struct Mesh *me,
CustomDataLayer *cdl = NULL; \
int index; \
\
- CustomData_add_layer_named(&me->cdata, cd_prop_type, CD_DEFAULT, NULL, me->countvar, name); \
+ CustomData_add_layer_named( \
+ &me->cdata, cd_prop_type, CD_SET_DEFAULT, NULL, me->countvar, name); \
index = CustomData_get_named_layer_index(&me->cdata, cd_prop_type, name); \
\
cdl = (index == -1) ? NULL : &(me->cdata.layers[index]); \
diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c
index 8447074a3ef..41b0d0b0bfd 100644
--- a/source/blender/makesrna/intern/rna_mesh_api.c
+++ b/source/blender/makesrna/intern/rna_mesh_api.c
@@ -44,7 +44,7 @@ static const char *rna_Mesh_unit_test_compare(struct Mesh *mesh,
static void rna_Mesh_create_normals_split(Mesh *mesh)
{
if (!CustomData_has_layer(&mesh->ldata, CD_NORMAL)) {
- CustomData_add_layer(&mesh->ldata, CD_NORMAL, CD_CALLOC, NULL, mesh->totloop);
+ CustomData_add_layer(&mesh->ldata, CD_NORMAL, CD_SET_DEFAULT, NULL, mesh->totloop);
CustomData_set_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
}
}
@@ -64,7 +64,7 @@ static void rna_Mesh_calc_tangents(Mesh *mesh, ReportList *reports, const char *
}
else {
r_looptangents = CustomData_add_layer(
- &mesh->ldata, CD_MLOOPTANGENT, CD_CALLOC, NULL, mesh->totloop);
+ &mesh->ldata, CD_MLOOPTANGENT, CD_SET_DEFAULT, NULL, mesh->totloop);
CustomData_set_layer_flag(&mesh->ldata, CD_MLOOPTANGENT, CD_FLAG_TEMPORARY);
}
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 6c5baabe756..8f4a675b797 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -115,7 +115,7 @@ static void deformVerts(ModifierData *md,
float(*layerorco)[3];
if (!(layerorco = CustomData_get_layer(&mesh_src->vdata, CD_CLOTH_ORCO))) {
layerorco = CustomData_add_layer(
- &mesh_src->vdata, CD_CLOTH_ORCO, CD_CALLOC, NULL, mesh_src->totvert);
+ &mesh_src->vdata, CD_CLOTH_ORCO, CD_SET_DEFAULT, NULL, mesh_src->totvert);
}
memcpy(layerorco, kb->data, sizeof(float[3]) * verts_num);
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index d3b43176700..c571a4821b4 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -1044,7 +1044,7 @@ static void store_computed_output_attributes(
if (attributes.add(store.name,
store.domain,
blender::bke::cpp_type_to_custom_data_type(store.data.type()),
- blender::bke::AttributeInitMove(store.data.data()))) {
+ blender::bke::AttributeInitMoveArray(store.data.data()))) {
continue;
}
@@ -1277,13 +1277,13 @@ static void modifyGeometry(ModifierData *md,
* assumed that the output mesh does not have a mapping to the original mesh. */
Mesh &mesh = *geometry_set.get_mesh_for_write();
if (use_orig_index_verts) {
- CustomData_add_layer(&mesh.vdata, CD_ORIGINDEX, CD_DEFAULT, nullptr, mesh.totvert);
+ CustomData_add_layer(&mesh.vdata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, mesh.totvert);
}
if (use_orig_index_edges) {
- CustomData_add_layer(&mesh.edata, CD_ORIGINDEX, CD_DEFAULT, nullptr, mesh.totedge);
+ CustomData_add_layer(&mesh.edata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, mesh.totedge);
}
if (use_orig_index_polys) {
- CustomData_add_layer(&mesh.pdata, CD_ORIGINDEX, CD_DEFAULT, nullptr, mesh.totpoly);
+ CustomData_add_layer(&mesh.pdata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, mesh.totpoly);
}
}
}
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index 5a92aac6cda..9e3e06fb4dc 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -562,7 +562,7 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd,
}
if (clnors == NULL) {
- clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, loops_num);
+ clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, NULL, loops_num);
}
MOD_get_vgroup(ob, result, enmd->defgrp_name, &dvert, &defgrp_index);
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index ea9049200cc..c84d1b56cec 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -292,7 +292,7 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig, co
/* add uvs */
if (CustomData_number_of_layers(&result->ldata, CD_MLOOPUV) < MAX_MTFACE) {
gogd.mloopuvs = CustomData_add_layer(
- &result->ldata, CD_MLOOPUV, CD_CALLOC, NULL, polys_num * 4);
+ &result->ldata, CD_MLOOPUV, CD_SET_DEFAULT, NULL, polys_num * 4);
if (gogd.mloopuvs) { /* unlikely to fail */
gogd.ix = 1.0 / gogd.rx;
@@ -378,12 +378,16 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
const int loops_num = result->totloop;
MLoop *mloops = result->mloop;
MLoopCol *mloopcols = CustomData_add_layer_named(
- &result->ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, NULL, loops_num, omd->foamlayername);
+ &result->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, NULL, loops_num, omd->foamlayername);
MLoopCol *mloopcols_spray = NULL;
if (omd->flag & MOD_OCEAN_GENERATE_SPRAY) {
- mloopcols_spray = CustomData_add_layer_named(
- &result->ldata, CD_PROP_BYTE_COLOR, CD_CALLOC, NULL, loops_num, omd->spraylayername);
+ mloopcols_spray = CustomData_add_layer_named(&result->ldata,
+ CD_PROP_BYTE_COLOR,
+ CD_SET_DEFAULT,
+ NULL,
+ loops_num,
+ omd->spraylayername);
}
if (mloopcols) { /* unlikely to fail */
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index 6095be48f8f..b2ebf2ffeec 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -398,7 +398,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
medge_new = result->medge;
if (!CustomData_has_layer(&result->pdata, CD_ORIGINDEX)) {
- CustomData_add_layer(&result->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, (int)maxPolys);
+ CustomData_add_layer(&result->pdata, CD_ORIGINDEX, CD_SET_DEFAULT, NULL, (int)maxPolys);
}
int *origindex = CustomData_get_layer(&result->pdata, CD_ORIGINDEX);
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 84795cdb2d9..b41c730024c 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -1888,7 +1888,7 @@ static void skin_set_orig_indices(Mesh *mesh)
int *orig, totpoly;
totpoly = mesh->totpoly;
- orig = CustomData_add_layer(&mesh->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, totpoly);
+ orig = CustomData_add_layer(&mesh->pdata, CD_ORIGINDEX, CD_SET_DEFAULT, NULL, totpoly);
copy_vn_i(orig, totpoly, ORIGINDEX_NONE);
}
diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c b/source/blender/modifiers/intern/MOD_solidify_extrude.c
index 47277577d3e..15e8bd25997 100644
--- a/source/blender/modifiers/intern/MOD_solidify_extrude.c
+++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c
@@ -994,7 +994,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
if (dvert == NULL) {
/* Add a valid data layer! */
dvert = CustomData_add_layer(
- &result->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, result->totvert);
+ &result->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, result->totvert);
}
/* Ultimate security check. */
if (dvert != NULL) {
diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
index 8a5b600974c..9205083e836 100644
--- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
+++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c
@@ -1981,7 +1981,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
if (dvert == NULL) {
/* Add a valid data layer! */
dvert = CustomData_add_layer(
- &result->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, result->totvert);
+ &result->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, result->totvert);
}
result->dvert = dvert;
}
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 4646ba41a74..ccef867b752 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -124,7 +124,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
* (e.g. if a preceding modifier could not preserve it). */
if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPUV)) {
CustomData_add_layer_named(
- &mesh->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, mesh->totloop, umd->uvlayer_name);
+ &mesh->ldata, CD_MLOOPUV, CD_SET_DEFAULT, NULL, mesh->totloop, umd->uvlayer_name);
}
/* make sure we're using an existing layer */
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
index 039497b725b..5b5d464a710 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.c
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -609,7 +609,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
* it helps when generating clnor spaces and default normals. */
const bool has_clnors = clnors != NULL;
if (!clnors) {
- clnors = CustomData_add_layer(&result->ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, loops_num);
+ clnors = CustomData_add_layer(
+ &result->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, NULL, loops_num);
}
MDeformVert *dvert;
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 2a509ddf220..d71813c7dd5 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -203,7 +203,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
}
else {
/* Add a valid data layer! */
- dvert = CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, verts_num);
+ dvert = CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, verts_num);
}
/* Ultimate security check. */
if (!dvert) {
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index aa648eaec97..1d38333f15b 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -268,7 +268,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
}
else {
/* Add a valid data layer! */
- dvert = CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, verts_num);
+ dvert = CustomData_add_layer(&mesh->vdata, CD_MDEFORMVERT, CD_SET_DEFAULT, NULL, verts_num);
}
/* Ultimate security check. */
if (!dvert) {
diff --git a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc
index 9719833097e..c2d6f57ce8a 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc
@@ -123,7 +123,7 @@ static void try_capture_field_on_geometry(GeometryComponent &component,
}
}
attributes.remove(name);
- if (attributes.add(name, domain, data_type, bke::AttributeInitMove{buffer})) {
+ if (attributes.add(name, domain, data_type, bke::AttributeInitMoveArray{buffer})) {
return;
}
diff --git a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc
index f1fb9ce5563..896364bc591 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc
@@ -73,7 +73,7 @@ static void write_vertex_creases(Mesh &mesh, const VArray<float> &crease_varray)
}
else {
crease = static_cast<float *>(
- CustomData_add_layer(&mesh.vdata, CD_CREASE, CD_DEFAULT, nullptr, mesh.totvert));
+ CustomData_add_layer(&mesh.vdata, CD_CREASE, CD_SET_DEFAULT, nullptr, mesh.totvert));
}
materialize_and_clamp_creases(crease_varray, {crease, mesh.totvert});
}