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
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey@blender.org>2022-04-12 11:56:51 +0300
committerSergey Sharybin <sergey@blender.org>2022-04-13 12:48:12 +0300
commit25c357124de8905360c44a5a842284089ddec341 (patch)
treed7f7de7c459d622366ba5b0a7caec720c97f35c7 /source
parentda66c0519fce9bff981370868a359e64198552bc (diff)
Cover some DNA files with C++ utility macros
Solves compilation warning with Clang, and moves manipulation with DNA structures to the designed way for C++. The tests and few other places are update to the new code by Jacques. Ref T96847 Maniphest Tasks: T96847 Differential Revision: https://developer.blender.org/D14625
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/curve.cc4
-rw-r--r--source/blender/blenkernel/intern/lattice_deform_test.cc12
-rw-r--r--source/blender/blenkernel/intern/mesh.cc4
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.cc3
-rw-r--r--source/blender/blenkernel/intern/node.cc2
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc2
-rw-r--r--source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc4
-rw-r--r--source/blender/editors/render/render_shading.cc4
-rw-r--r--source/blender/makesdna/DNA_curve_types.h6
-rw-r--r--source/blender/makesdna/DNA_lattice_types.h4
-rw-r--r--source/blender/makesdna/DNA_light_types.h2
-rw-r--r--source/blender/makesdna/DNA_linestyle_types.h82
-rw-r--r--source/blender/makesdna/DNA_material_types.h6
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h8
-rw-r--r--source/blender/makesdna/DNA_simulation_types.h2
-rw-r--r--source/blender/makesdna/DNA_texture_types.h5
-rw-r--r--source/blender/makesdna/DNA_world_types.h2
-rw-r--r--source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc4
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc4
19 files changed, 138 insertions, 22 deletions
diff --git a/source/blender/blenkernel/intern/curve.cc b/source/blender/blenkernel/intern/curve.cc
index 2d72ad28d18..6815b4d7486 100644
--- a/source/blender/blenkernel/intern/curve.cc
+++ b/source/blender/blenkernel/intern/curve.cc
@@ -665,7 +665,7 @@ Nurb *BKE_nurb_duplicate(const Nurb *nu)
if (newnu == nullptr) {
return nullptr;
}
- memcpy(newnu, nu, sizeof(Nurb));
+ *newnu = blender::dna::shallow_copy(*nu);
if (nu->bezt) {
newnu->bezt = (BezTriple *)MEM_malloc_arrayN(nu->pntsu, sizeof(BezTriple), "duplicateNurb2");
@@ -699,7 +699,7 @@ Nurb *BKE_nurb_duplicate(const Nurb *nu)
Nurb *BKE_nurb_copy(Nurb *src, int pntsu, int pntsv)
{
Nurb *newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "copyNurb");
- memcpy(newnu, src, sizeof(Nurb));
+ *newnu = blender::dna::shallow_copy(*src);
if (pntsu == 1) {
SWAP(int, pntsu, pntsv);
diff --git a/source/blender/blenkernel/intern/lattice_deform_test.cc b/source/blender/blenkernel/intern/lattice_deform_test.cc
index 1b1bca5fc53..58aadf652b7 100644
--- a/source/blender/blenkernel/intern/lattice_deform_test.cc
+++ b/source/blender/blenkernel/intern/lattice_deform_test.cc
@@ -69,7 +69,7 @@ static void test_lattice_deform_free(LatticeDeformTestContext *ctx)
TEST(lattice_deform_performance, performance_no_dvert_1)
{
const int32_t num_items = 1;
- LatticeDeformTestContext ctx = {{{nullptr}}};
+ LatticeDeformTestContext ctx = {dna::shallow_zero_initialize()};
RandomNumberGenerator rng;
test_lattice_deform_init(&ctx, &rng, num_items);
test_lattice_deform(&ctx, num_items);
@@ -78,7 +78,7 @@ TEST(lattice_deform_performance, performance_no_dvert_1)
TEST(lattice_deform_performance, performance_no_dvert_1000)
{
const int32_t num_items = 1000;
- LatticeDeformTestContext ctx = {{{nullptr}}};
+ LatticeDeformTestContext ctx = {dna::shallow_zero_initialize()};
RandomNumberGenerator rng;
test_lattice_deform_init(&ctx, &rng, num_items);
test_lattice_deform(&ctx, num_items);
@@ -87,7 +87,7 @@ TEST(lattice_deform_performance, performance_no_dvert_1000)
TEST(lattice_deform_performance, performance_no_dvert_10000)
{
const int32_t num_items = 10000;
- LatticeDeformTestContext ctx = {{{nullptr}}};
+ LatticeDeformTestContext ctx = {dna::shallow_zero_initialize()};
RandomNumberGenerator rng;
test_lattice_deform_init(&ctx, &rng, num_items);
test_lattice_deform(&ctx, num_items);
@@ -96,7 +96,7 @@ TEST(lattice_deform_performance, performance_no_dvert_10000)
TEST(lattice_deform_performance, performance_no_dvert_100000)
{
const int32_t num_items = 100000;
- LatticeDeformTestContext ctx = {{{nullptr}}};
+ LatticeDeformTestContext ctx = {dna::shallow_zero_initialize()};
RandomNumberGenerator rng;
test_lattice_deform_init(&ctx, &rng, num_items);
test_lattice_deform(&ctx, num_items);
@@ -105,7 +105,7 @@ TEST(lattice_deform_performance, performance_no_dvert_100000)
TEST(lattice_deform_performance, performance_no_dvert_1000000)
{
const int32_t num_items = 1000000;
- LatticeDeformTestContext ctx = {{{nullptr}}};
+ LatticeDeformTestContext ctx = {dna::shallow_zero_initialize()};
RandomNumberGenerator rng;
test_lattice_deform_init(&ctx, &rng, num_items);
test_lattice_deform(&ctx, num_items);
@@ -114,7 +114,7 @@ TEST(lattice_deform_performance, performance_no_dvert_1000000)
TEST(lattice_deform_performance, performance_no_dvert_10000000)
{
const int32_t num_items = 10000000;
- LatticeDeformTestContext ctx = {{{nullptr}}};
+ LatticeDeformTestContext ctx = {dna::shallow_zero_initialize()};
RandomNumberGenerator rng;
test_lattice_deform_init(&ctx, &rng, num_items);
test_lattice_deform(&ctx, num_items);
diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc
index 5afc3c0be3b..25d97d0bd3c 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -218,7 +218,7 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
mesh->mface = nullptr;
mesh->totface = 0;
memset(&mesh->fdata, 0, sizeof(mesh->fdata));
- memset(&mesh->runtime, 0, sizeof(mesh->runtime));
+ mesh->runtime = blender::dna::shallow_zero_initialize();
flayers = flayers_buff;
/* Do not store actual geometry data in case this is a library override ID. */
@@ -329,7 +329,7 @@ static void mesh_blend_read_data(BlendDataReader *reader, ID *id)
mesh->texflag &= ~ME_AUTOSPACE_EVALUATED;
mesh->edit_mesh = nullptr;
- memset(&mesh->runtime, 0, sizeof(mesh->runtime));
+ mesh->runtime = blender::dna::shallow_zero_initialize();
BKE_mesh_runtime_init_data(mesh);
/* happens with old files */
diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc
index 6abaa471877..bce7021bbb9 100644
--- a/source/blender/blenkernel/intern/mesh_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_convert.cc
@@ -1446,8 +1446,7 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src,
/* mesh_src might depend on mesh_dst, so we need to do everything with a local copy */
/* TODO(Sybren): the above claim came from 2.7x derived-mesh code (DM_to_mesh);
* check whether it is still true with Mesh */
- Mesh tmp;
- memcpy(&tmp, mesh_dst, sizeof(tmp));
+ Mesh tmp = blender::dna::shallow_copy(*mesh_dst);
int totvert, totedge /*, totface */ /* UNUSED */, totloop, totpoly;
bool did_shapekeys = false;
eCDAllocType alloctype = CD_DUPLICATE;
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 7efdd855a04..4acccca322a 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -719,7 +719,7 @@ void ntreeBlendReadData(BlendDataReader *reader, bNodeTree *ntree)
}
case SH_NODE_TEX_POINTDENSITY: {
NodeShaderTexPointDensity *npd = (NodeShaderTexPointDensity *)node->storage;
- memset(&npd->pd, 0, sizeof(npd->pd));
+ npd->pd = blender::dna::shallow_zero_initialize();
break;
}
case SH_NODE_TEX_IMAGE: {
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 5597d496890..058f57e5a61 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -163,7 +163,7 @@ const ID *nested_id_hack_get_discarded_pointers(NestedIDHackTempStorage *storage
switch (GS(id->name)) {
# define SPECIAL_CASE(id_type, dna_type, field, variable) \
case id_type: { \
- storage->variable = *(dna_type *)id; \
+ storage->variable = dna::shallow_copy(*(dna_type *)id); \
storage->variable.field = nullptr; \
return &storage->variable.id; \
}
diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc
index 97e5386b14d..d52226a4c90 100644
--- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc
+++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc
@@ -143,7 +143,7 @@ static void extract_vcol_init(const MeshRenderData *mr,
CustomData *cd_vdata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->vdata : &mr->me->vdata;
CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;
- Mesh me_query = {0};
+ Mesh me_query = blender::dna::shallow_zero_initialize();
BKE_id_attribute_copy_domains_temp(
ID_ME, cd_vdata, nullptr, cd_ldata, nullptr, nullptr, &me_query.id);
@@ -256,7 +256,7 @@ static void extract_vcol_init_subdiv(const DRWSubdivCache *subdiv_cache,
const CustomData *cd_ldata = extract_bmesh ? &coarse_mesh->edit_mesh->bm->ldata :
&coarse_mesh->ldata;
- Mesh me_query = *coarse_mesh;
+ Mesh me_query = blender::dna::shallow_copy(*coarse_mesh);
BKE_id_attribute_copy_domains_temp(
ID_ME, cd_vdata, nullptr, cd_ldata, nullptr, nullptr, &me_query.id);
diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc
index f5bd60df2b4..46f62354fce 100644
--- a/source/blender/editors/render/render_shading.cc
+++ b/source/blender/editors/render/render_shading.cc
@@ -2613,7 +2613,7 @@ static void copy_mtex_copybuf(ID *id)
}
if (mtex && *mtex) {
- memcpy(&mtexcopybuf, *mtex, sizeof(MTex));
+ mtexcopybuf = blender::dna::shallow_copy(**mtex);
mtexcopied = 1;
}
else {
@@ -2649,7 +2649,7 @@ static void paste_mtex_copybuf(ID *id)
id_us_min(&(*mtex)->tex->id);
}
- memcpy(*mtex, &mtexcopybuf, sizeof(MTex));
+ **mtex = blender::dna::shallow_copy(mtexcopybuf);
id_us_plus((ID *)mtexcopybuf.tex);
}
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index 556e467c4b6..305b913b19e 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -127,6 +127,8 @@ typedef struct BPoint {
* also, it should be NURBS (Nurb isn't the singular of Nurbs).
*/
typedef struct Nurb {
+ DNA_DEFINE_CXX_METHODS(Nurb)
+
/** Multiple nurbs per curve object are allowed. */
struct Nurb *next, *prev;
short type;
@@ -169,6 +171,8 @@ typedef struct TextBox {
#
#
typedef struct EditNurb {
+ DNA_DEFINE_CXX_METHODS(EditNurb)
+
/* base of nurbs' list (old Curve->editnurb) */
ListBase nurbs;
@@ -187,6 +191,8 @@ typedef struct EditNurb {
} EditNurb;
typedef struct Curve {
+ DNA_DEFINE_CXX_METHODS(Curve)
+
ID id;
/** Animation data (must be immediately after id for utilities to use it). */
struct AnimData *adt;
diff --git a/source/blender/makesdna/DNA_lattice_types.h b/source/blender/makesdna/DNA_lattice_types.h
index b2775aa771a..907f1150ce5 100644
--- a/source/blender/makesdna/DNA_lattice_types.h
+++ b/source/blender/makesdna/DNA_lattice_types.h
@@ -23,6 +23,8 @@ struct MDeformVert;
#
#
typedef struct EditLatt {
+ DNA_DEFINE_CXX_METHODS(EditLatt)
+
struct Lattice *latt;
int shapenr;
@@ -35,6 +37,8 @@ typedef struct EditLatt {
} EditLatt;
typedef struct Lattice {
+ DNA_DEFINE_CXX_METHODS(Lattice)
+
ID id;
struct AnimData *adt;
diff --git a/source/blender/makesdna/DNA_light_types.h b/source/blender/makesdna/DNA_light_types.h
index e78a381603b..9202d7c2d51 100644
--- a/source/blender/makesdna/DNA_light_types.h
+++ b/source/blender/makesdna/DNA_light_types.h
@@ -24,6 +24,8 @@ struct Ipo;
struct bNodeTree;
typedef struct Light {
+ DNA_DEFINE_CXX_METHODS(Light)
+
ID id;
/** Animation data (must be immediately after id for utilities to use it). */
struct AnimData *adt;
diff --git a/source/blender/makesdna/DNA_linestyle_types.h b/source/blender/makesdna/DNA_linestyle_types.h
index b8279e7f2ca..0755803ea8f 100644
--- a/source/blender/makesdna/DNA_linestyle_types.h
+++ b/source/blender/makesdna/DNA_linestyle_types.h
@@ -29,6 +29,8 @@ struct Object;
struct bNodeTree;
typedef struct LineStyleModifier {
+ DNA_DEFINE_CXX_METHODS(LineStyleModifier)
+
struct LineStyleModifier *next, *prev;
/** MAX_NAME. */
@@ -92,12 +94,16 @@ typedef struct LineStyleModifier {
/* Along Stroke modifiers */
typedef struct LineStyleColorModifier_AlongStroke {
+ DNA_DEFINE_CXX_METHODS(LineStyleColorModifier_AlongStroke)
+
struct LineStyleModifier modifier;
struct ColorBand *color_ramp;
} LineStyleColorModifier_AlongStroke;
typedef struct LineStyleAlphaModifier_AlongStroke {
+ DNA_DEFINE_CXX_METHODS(LineStyleAlphaModifier_AlongStroke)
+
struct LineStyleModifier modifier;
struct CurveMapping *curve;
@@ -106,6 +112,8 @@ typedef struct LineStyleAlphaModifier_AlongStroke {
} LineStyleAlphaModifier_AlongStroke;
typedef struct LineStyleThicknessModifier_AlongStroke {
+ DNA_DEFINE_CXX_METHODS(LineStyleThicknessModifier_AlongStroke)
+
struct LineStyleModifier modifier;
struct CurveMapping *curve;
@@ -117,6 +125,8 @@ typedef struct LineStyleThicknessModifier_AlongStroke {
/* Distance from Camera modifiers */
typedef struct LineStyleColorModifier_DistanceFromCamera {
+ DNA_DEFINE_CXX_METHODS(LineStyleColorModifier_DistanceFromCamera)
+
struct LineStyleModifier modifier;
struct ColorBand *color_ramp;
@@ -124,6 +134,8 @@ typedef struct LineStyleColorModifier_DistanceFromCamera {
} LineStyleColorModifier_DistanceFromCamera;
typedef struct LineStyleAlphaModifier_DistanceFromCamera {
+ DNA_DEFINE_CXX_METHODS(LineStyleAlphaModifier_DistanceFromCamera)
+
struct LineStyleModifier modifier;
struct CurveMapping *curve;
@@ -133,6 +145,8 @@ typedef struct LineStyleAlphaModifier_DistanceFromCamera {
} LineStyleAlphaModifier_DistanceFromCamera;
typedef struct LineStyleThicknessModifier_DistanceFromCamera {
+ DNA_DEFINE_CXX_METHODS(LineStyleThicknessModifier_DistanceFromCamera)
+
struct LineStyleModifier modifier;
struct CurveMapping *curve;
@@ -145,6 +159,8 @@ typedef struct LineStyleThicknessModifier_DistanceFromCamera {
/* Distance from Object modifiers */
typedef struct LineStyleColorModifier_DistanceFromObject {
+ DNA_DEFINE_CXX_METHODS(LineStyleColorModifier_DistanceFromObject)
+
struct LineStyleModifier modifier;
struct Object *target;
@@ -153,6 +169,8 @@ typedef struct LineStyleColorModifier_DistanceFromObject {
} LineStyleColorModifier_DistanceFromObject;
typedef struct LineStyleAlphaModifier_DistanceFromObject {
+ DNA_DEFINE_CXX_METHODS(LineStyleAlphaModifier_DistanceFromObject)
+
struct LineStyleModifier modifier;
struct Object *target;
@@ -163,6 +181,8 @@ typedef struct LineStyleAlphaModifier_DistanceFromObject {
} LineStyleAlphaModifier_DistanceFromObject;
typedef struct LineStyleThicknessModifier_DistanceFromObject {
+ DNA_DEFINE_CXX_METHODS(LineStyleThicknessModifier_DistanceFromObject)
+
struct LineStyleModifier modifier;
struct Object *target;
@@ -176,6 +196,8 @@ typedef struct LineStyleThicknessModifier_DistanceFromObject {
/* 3D curvature modifiers */
typedef struct LineStyleColorModifier_Curvature_3D {
+ DNA_DEFINE_CXX_METHODS(LineStyleColorModifier_Curvature_3D)
+
struct LineStyleModifier modifier;
float min_curvature, max_curvature;
@@ -184,6 +206,8 @@ typedef struct LineStyleColorModifier_Curvature_3D {
} LineStyleColorModifier_Curvature_3D;
typedef struct LineStyleAlphaModifier_Curvature_3D {
+ DNA_DEFINE_CXX_METHODS(LineStyleAlphaModifier_Curvature_3D)
+
struct LineStyleModifier modifier;
struct CurveMapping *curve;
@@ -193,6 +217,8 @@ typedef struct LineStyleAlphaModifier_Curvature_3D {
} LineStyleAlphaModifier_Curvature_3D;
typedef struct LineStyleThicknessModifier_Curvature_3D {
+ DNA_DEFINE_CXX_METHODS(LineStyleThicknessModifier_Curvature_3D)
+
struct LineStyleModifier modifier;
struct CurveMapping *curve;
@@ -205,6 +231,8 @@ typedef struct LineStyleThicknessModifier_Curvature_3D {
/* Noise modifiers (for color, alpha and thickness) */
typedef struct LineStyleColorModifier_Noise {
+ DNA_DEFINE_CXX_METHODS(LineStyleColorModifier_Noise)
+
struct LineStyleModifier modifier;
struct ColorBand *color_ramp;
@@ -214,6 +242,8 @@ typedef struct LineStyleColorModifier_Noise {
} LineStyleColorModifier_Noise;
typedef struct LineStyleAlphaModifier_Noise {
+ DNA_DEFINE_CXX_METHODS(LineStyleAlphaModifier_Noise)
+
struct LineStyleModifier modifier;
struct CurveMapping *curve;
@@ -223,6 +253,8 @@ typedef struct LineStyleAlphaModifier_Noise {
} LineStyleAlphaModifier_Noise;
typedef struct LineStyleThicknessModifier_Noise {
+ DNA_DEFINE_CXX_METHODS(LineStyleThicknessModifier_Noise)
+
struct LineStyleModifier modifier;
float period, amplitude;
@@ -233,6 +265,8 @@ typedef struct LineStyleThicknessModifier_Noise {
/* Crease Angle modifiers */
typedef struct LineStyleColorModifier_CreaseAngle {
+ DNA_DEFINE_CXX_METHODS(LineStyleColorModifier_CreaseAngle)
+
struct LineStyleModifier modifier;
struct ColorBand *color_ramp;
@@ -240,6 +274,8 @@ typedef struct LineStyleColorModifier_CreaseAngle {
} LineStyleColorModifier_CreaseAngle;
typedef struct LineStyleAlphaModifier_CreaseAngle {
+ DNA_DEFINE_CXX_METHODS(LineStyleAlphaModifier_CreaseAngle)
+
struct LineStyleModifier modifier;
struct CurveMapping *curve;
@@ -249,6 +285,8 @@ typedef struct LineStyleAlphaModifier_CreaseAngle {
} LineStyleAlphaModifier_CreaseAngle;
typedef struct LineStyleThicknessModifier_CreaseAngle {
+ DNA_DEFINE_CXX_METHODS(LineStyleThicknessModifier_CreaseAngle)
+
struct LineStyleModifier modifier;
struct CurveMapping *curve;
@@ -261,12 +299,16 @@ typedef struct LineStyleThicknessModifier_CreaseAngle {
/* Tangent modifiers */
typedef struct LineStyleColorModifier_Tangent {
+ DNA_DEFINE_CXX_METHODS(LineStyleColorModifier_Tangent)
+
struct LineStyleModifier modifier;
struct ColorBand *color_ramp;
} LineStyleColorModifier_Tangent;
typedef struct LineStyleAlphaModifier_Tangent {
+ DNA_DEFINE_CXX_METHODS(LineStyleAlphaModifier_Tangent)
+
struct LineStyleModifier modifier;
struct CurveMapping *curve;
@@ -275,6 +317,8 @@ typedef struct LineStyleAlphaModifier_Tangent {
} LineStyleAlphaModifier_Tangent;
typedef struct LineStyleThicknessModifier_Tangent {
+ DNA_DEFINE_CXX_METHODS(LineStyleThicknessModifier_Tangent)
+
struct LineStyleModifier modifier;
struct CurveMapping *curve;
@@ -303,6 +347,8 @@ typedef struct LineStyleThicknessModifier_Tangent {
#define LS_MODIFIER_MATERIAL_LINE_A 15
typedef struct LineStyleColorModifier_Material {
+ DNA_DEFINE_CXX_METHODS(LineStyleColorModifier_Material)
+
struct LineStyleModifier modifier;
struct ColorBand *color_ramp;
@@ -311,6 +357,8 @@ typedef struct LineStyleColorModifier_Material {
} LineStyleColorModifier_Material;
typedef struct LineStyleAlphaModifier_Material {
+ DNA_DEFINE_CXX_METHODS(LineStyleAlphaModifier_Material)
+
struct LineStyleModifier modifier;
struct CurveMapping *curve;
@@ -319,6 +367,8 @@ typedef struct LineStyleAlphaModifier_Material {
} LineStyleAlphaModifier_Material;
typedef struct LineStyleThicknessModifier_Material {
+ DNA_DEFINE_CXX_METHODS(LineStyleThicknessModifier_Material)
+
struct LineStyleModifier modifier;
struct CurveMapping *curve;
@@ -330,6 +380,8 @@ typedef struct LineStyleThicknessModifier_Material {
/* Geometry modifiers */
typedef struct LineStyleGeometryModifier_Sampling {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_Sampling)
+
struct LineStyleModifier modifier;
float sampling;
@@ -337,6 +389,8 @@ typedef struct LineStyleGeometryModifier_Sampling {
} LineStyleGeometryModifier_Sampling;
typedef struct LineStyleGeometryModifier_BezierCurve {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_BezierCurve)
+
struct LineStyleModifier modifier;
float error;
@@ -344,6 +398,8 @@ typedef struct LineStyleGeometryModifier_BezierCurve {
} LineStyleGeometryModifier_BezierCurve;
typedef struct LineStyleGeometryModifier_SinusDisplacement {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_SinusDisplacement)
+
struct LineStyleModifier modifier;
float wavelength, amplitude, phase;
@@ -355,6 +411,8 @@ typedef struct LineStyleGeometryModifier_SinusDisplacement {
#define LS_MODIFIER_SPATIAL_NOISE_PURERANDOM 2
typedef struct LineStyleGeometryModifier_SpatialNoise {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_SpatialNoise)
+
struct LineStyleModifier modifier;
float amplitude, scale;
@@ -363,6 +421,8 @@ typedef struct LineStyleGeometryModifier_SpatialNoise {
} LineStyleGeometryModifier_SpatialNoise;
typedef struct LineStyleGeometryModifier_PerlinNoise1D {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_PerlinNoise1D)
+
struct LineStyleModifier modifier;
float frequency, amplitude;
@@ -374,6 +434,8 @@ typedef struct LineStyleGeometryModifier_PerlinNoise1D {
} LineStyleGeometryModifier_PerlinNoise1D;
typedef struct LineStyleGeometryModifier_PerlinNoise2D {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_PerlinNoise2D)
+
struct LineStyleModifier modifier;
float frequency, amplitude;
@@ -385,6 +447,8 @@ typedef struct LineStyleGeometryModifier_PerlinNoise2D {
} LineStyleGeometryModifier_PerlinNoise2D;
typedef struct LineStyleGeometryModifier_BackboneStretcher {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_BackboneStretcher)
+
struct LineStyleModifier modifier;
float backbone_length;
@@ -392,6 +456,8 @@ typedef struct LineStyleGeometryModifier_BackboneStretcher {
} LineStyleGeometryModifier_BackboneStretcher;
typedef struct LineStyleGeometryModifier_TipRemover {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_TipRemover)
+
struct LineStyleModifier modifier;
float tip_length;
@@ -399,6 +465,8 @@ typedef struct LineStyleGeometryModifier_TipRemover {
} LineStyleGeometryModifier_TipRemover;
typedef struct LineStyleGeometryModifier_Polygonalization {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_Polygonalization)
+
struct LineStyleModifier modifier;
float error;
@@ -406,6 +474,8 @@ typedef struct LineStyleGeometryModifier_Polygonalization {
} LineStyleGeometryModifier_Polygonalization;
typedef struct LineStyleGeometryModifier_GuidingLines {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_GuidingLines)
+
struct LineStyleModifier modifier;
float offset;
@@ -418,6 +488,8 @@ typedef struct LineStyleGeometryModifier_GuidingLines {
#define LS_MODIFIER_BLUEPRINT_SQUARES 4
typedef struct LineStyleGeometryModifier_Blueprint {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_Blueprint)
+
struct LineStyleModifier modifier;
int flags;
@@ -429,6 +501,8 @@ typedef struct LineStyleGeometryModifier_Blueprint {
} LineStyleGeometryModifier_Blueprint;
typedef struct LineStyleGeometryModifier_2DOffset {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_2DOffset)
+
struct LineStyleModifier modifier;
float start, end;
@@ -443,6 +517,8 @@ typedef struct LineStyleGeometryModifier_2DOffset {
#define LS_MODIFIER_2D_TRANSFORM_PIVOT_ABSOLUTE 5
typedef struct LineStyleGeometryModifier_2DTransform {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_2DTransform)
+
struct LineStyleModifier modifier;
int pivot;
@@ -455,6 +531,8 @@ typedef struct LineStyleGeometryModifier_2DTransform {
} LineStyleGeometryModifier_2DTransform;
typedef struct LineStyleGeometryModifier_Simplification {
+ DNA_DEFINE_CXX_METHODS(LineStyleGeometryModifier_Simplification)
+
struct LineStyleModifier modifier;
float tolerance;
@@ -464,6 +542,8 @@ typedef struct LineStyleGeometryModifier_Simplification {
/* Calligraphic thickness modifier */
typedef struct LineStyleThicknessModifier_Calligraphy {
+ DNA_DEFINE_CXX_METHODS(LineStyleThicknessModifier_Calligraphy)
+
struct LineStyleModifier modifier;
float min_thickness, max_thickness;
@@ -527,6 +607,8 @@ typedef struct LineStyleThicknessModifier_Calligraphy {
#define LS_INTEGRATION_LAST 5
typedef struct FreestyleLineStyle {
+ DNA_DEFINE_CXX_METHODS(FreestyleLineStyle)
+
ID id;
struct AnimData *adt;
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index b535d3cdb8a..38e99896ab1 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -27,6 +27,8 @@ struct bNodeTree;
/* WATCH IT: change type? also make changes in ipo.h */
typedef struct TexPaintSlot {
+ DNA_DEFINE_CXX_METHODS(TexPaintSlot)
+
/** Image to be painted on. Mutual exclusive with attribute_name. */
struct Image *ima;
/** Custom-data index for uv layer, #MAX_NAME. */
@@ -43,6 +45,8 @@ typedef struct TexPaintSlot {
} TexPaintSlot;
typedef struct MaterialGPencilStyle {
+ DNA_DEFINE_CXX_METHODS(MaterialGPencilStyle)
+
/** Texture image for strokes. */
struct Image *sima;
/** Texture image for filling. */
@@ -155,6 +159,8 @@ typedef enum eMaterialLineArtFlags {
} eMaterialLineArtFlags;
typedef struct Material {
+ DNA_DEFINE_CXX_METHODS(Material)
+
ID id;
/** Animation data (must be immediately after id for utilities to use it). */
struct AnimData *adt;
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index d8a853681fd..0ff9ebb2337 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -50,6 +50,8 @@ typedef struct EditMeshData {
* #BKE_mesh_runtime_looptri_ensure, #BKE_mesh_runtime_looptri_len.
*/
struct MLoopTri_Store {
+ DNA_DEFINE_CXX_METHODS(MLoopTri_Store)
+
/* WARNING! swapping between array (ready-to-be-used data) and array_wip
* (where data is actually computed)
* shall always be protected by same lock as one used for looptris computing. */
@@ -60,6 +62,8 @@ struct MLoopTri_Store {
/** Runtime data, not saved in files. */
typedef struct Mesh_Runtime {
+ DNA_DEFINE_CXX_METHODS(Mesh_Runtime)
+
/* Evaluated mesh for objects which do not have effective modifiers.
* This mesh is used as a result of modifier stack evaluation.
* Since modifier stack evaluation is threaded on object level we need some synchronization. */
@@ -138,6 +142,8 @@ typedef struct Mesh_Runtime {
} Mesh_Runtime;
typedef struct Mesh {
+ DNA_DEFINE_CXX_METHODS(Mesh)
+
ID id;
/** Animation data (must be immediately after id for utilities to use it). */
struct AnimData *adt;
@@ -336,6 +342,8 @@ typedef struct Mesh {
/* deprecated by MTFace, only here for file reading */
#ifdef DNA_DEPRECATED_ALLOW
typedef struct TFace {
+ DNA_DEFINE_CXX_METHODS(TFace)
+
/** The faces image for the active UVLayer. */
void *tpage;
float uv[4][2];
diff --git a/source/blender/makesdna/DNA_simulation_types.h b/source/blender/makesdna/DNA_simulation_types.h
index 4b2df1ddbfb..4bbbe9cd4e8 100644
--- a/source/blender/makesdna/DNA_simulation_types.h
+++ b/source/blender/makesdna/DNA_simulation_types.h
@@ -14,6 +14,8 @@ extern "C" {
#endif
typedef struct Simulation {
+ DNA_DEFINE_CXX_METHODS(Simulation)
+
ID id;
struct AnimData *adt; /* animation data (must be immediately after id) */
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index dab3a1b331e..b725939dbab 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -25,6 +25,7 @@ struct PreviewImage;
struct Tex;
typedef struct MTex {
+ DNA_DEFINE_CXX_METHODS(MTex)
short texco, mapto, maptoneg, blendtype;
struct Object *object;
@@ -96,6 +97,8 @@ typedef struct ColorBand {
} ColorBand;
typedef struct PointDensity {
+ DNA_DEFINE_CXX_METHODS(PointDensity)
+
short flag;
short falloff_type;
@@ -143,6 +146,8 @@ typedef struct PointDensity {
} PointDensity;
typedef struct Tex {
+ DNA_DEFINE_CXX_METHODS(Tex)
+
ID id;
/** Animation data (must be immediately after id for utilities to use it). */
struct AnimData *adt;
diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h
index 88f2e0c9407..bd2ba1e3bf7 100644
--- a/source/blender/makesdna/DNA_world_types.h
+++ b/source/blender/makesdna/DNA_world_types.h
@@ -27,6 +27,8 @@ struct bNodeTree;
* World defines general modeling data such as a background fill,
* gravity, color model etc. It mixes rendering data and modeling data. */
typedef struct World {
+ DNA_DEFINE_CXX_METHODS(World)
+
ID id;
/** Animation data (must be immediately after id for utilities to use it). */
struct AnimData *adt;
diff --git a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc
index bc34a1a6f2c..658de02fdab 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc
@@ -186,7 +186,7 @@ static TextLayout get_text_layout(GeoNodeExecParams &params)
params.extract_input<float>("Text Box Height");
VFont *vfont = (VFont *)params.node().id;
- Curve cu = {{nullptr}};
+ Curve cu = dna::shallow_zero_initialize();
cu.type = OB_FONT;
/* Set defaults */
cu.resolu = 12;
@@ -278,7 +278,7 @@ static Map<int, int> create_curve_instances(GeoNodeExecParams &params,
if (handles.contains(layout.char_codes[i])) {
continue;
}
- Curve cu = {{nullptr}};
+ Curve cu = dna::shallow_zero_initialize();
cu.type = OB_FONT;
cu.resolu = 12;
cu.vfont = vfont;
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc
index f628d1ec77b..17fff4a7e1e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc
@@ -79,7 +79,7 @@ static void node_shader_free_tex_pointdensity(bNode *node)
PointDensity *pd = &point_density->pd;
RE_point_density_free(pd);
BKE_texture_pointdensity_free_data(pd);
- memset(pd, 0, sizeof(*pd));
+ *pd = dna::shallow_zero_initialize();
MEM_freeN(point_density);
}
@@ -90,7 +90,7 @@ static void node_shader_copy_tex_pointdensity(bNodeTree *UNUSED(dest_ntree),
dest_node->storage = MEM_dupallocN(src_node->storage);
NodeShaderTexPointDensity *point_density = (NodeShaderTexPointDensity *)dest_node->storage;
PointDensity *pd = &point_density->pd;
- memset(pd, 0, sizeof(*pd));
+ *pd = dna::shallow_zero_initialize();
}
} // namespace blender::nodes::node_shader_tex_pointdensity_cc