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:
authorBastien Montagne <montagne29@wanadoo.fr>2019-03-07 13:13:40 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-03-07 13:29:50 +0300
commitab0bc65c24bdf68c356adb2566f3669153c931ea (patch)
tree23909478874a13d84e504a905809eb211e62a9e2
parentcee53160d2bd9067a3d43cc862ce61e36ff70454 (diff)
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc., 'simply' do the same for the mask flags we use all around Blender code to request some data, or limit some operation to some layers, etc. Reason we need this is that some cddata types (like Normals) are actually shared between verts/polys/loops, and we don’t want to generate clnors everytime we request vnors! As a side note, this also does final fix to T59338, which was the trigger for this patch (need to request computed loop normals for another mesh than evaluated one). Reviewers: brecht, campbellbarton, sergey Differential Revision: https://developer.blender.org/D4407
-rw-r--r--source/blender/alembic/intern/abc_hair.cc2
-rw-r--r--source/blender/alembic/intern/abc_mesh.cc8
-rw-r--r--source/blender/alembic/intern/abc_points.cc2
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h18
-rw-r--r--source/blender/blenkernel/BKE_cdderivedmesh.h8
-rw-r--r--source/blender/blenkernel/BKE_customdata.h21
-rw-r--r--source/blender/blenkernel/BKE_data_transfer.h2
-rw-r--r--source/blender/blenkernel/BKE_editmesh.h2
-rw-r--r--source/blender/blenkernel/BKE_mesh.h9
-rw-r--r--source/blender/blenkernel/BKE_mesh_runtime.h25
-rw-r--r--source/blender/blenkernel/BKE_modifier.h21
-rw-r--r--source/blender/blenkernel/BKE_particle.h3
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c308
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c41
-rw-r--r--source/blender/blenkernel/intern/crazyspace.c10
-rw-r--r--source/blender/blenkernel/intern/customdata.c180
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c43
-rw-r--r--source/blender/blenkernel/intern/editderivedmesh.c2
-rw-r--r--source/blender/blenkernel/intern/fluidsim.c2
-rw-r--r--source/blender/blenkernel/intern/mesh.c30
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c39
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c14
-rw-r--r--source/blender/blenkernel/intern/modifier.c23
-rw-r--r--source/blender/blenkernel/intern/multires.c12
-rw-r--r--source/blender/blenkernel/intern/multires_reshape.c4
-rw-r--r--source/blender/blenkernel/intern/object_update.c10
-rw-r--r--source/blender/blenkernel/intern/paint.c4
-rw-r--r--source/blender/blenkernel/intern/particle.c21
-rw-r--r--source/blender/blenkernel/intern/pbvh.c7
-rw-r--r--source/blender/blenkernel/intern/subdiv_foreach.c1
-rw-r--r--source/blender/blenkernel/intern/subdiv_mesh.c5
-rw-r--r--source/blender/blenloader/intern/readfile.c4
-rw-r--r--source/blender/blenloader/intern/writefile.c15
-rw-r--r--source/blender/bmesh/intern/bmesh_construct.c8
-rw-r--r--source/blender/bmesh/intern/bmesh_core.c1
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.c49
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.h7
-rw-r--r--source/blender/collada/MeshImporter.cpp2
-rw-r--r--source/blender/collada/collada_utils.cpp8
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_build.h3
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_query.h8
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder.cc2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.cc8
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes.h2
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc20
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.h3
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc4
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc6
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query.cc13
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type.cc12
-rw-r--r--source/blender/depsgraph/intern/depsgraph_type.h92
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_id.cc4
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_id.h4
-rw-r--r--source/blender/editors/armature/armature_skinning.c2
-rw-r--r--source/blender/editors/include/ED_view3d.h9
-rw-r--r--source/blender/editors/mesh/editmesh_add.c5
-rw-r--r--source/blender/editors/mesh/editmesh_knife_project.c2
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c8
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c2
-rw-r--r--source/blender/editors/mesh/mesh_data.c10
-rw-r--r--source/blender/editors/mesh/meshtools.c14
-rw-r--r--source/blender/editors/object/object_add.c8
-rw-r--r--source/blender/editors/object/object_bake.c8
-rw-r--r--source/blender/editors/object/object_data_transfer.c8
-rw-r--r--source/blender/editors/object/object_modifier.c8
-rw-r--r--source/blender/editors/object/object_relations.c2
-rw-r--r--source/blender/editors/object/object_vgroup.c6
-rw-r--r--source/blender/editors/physics/particle_edit.c4
-rw-r--r--source/blender/editors/physics/particle_object.c12
-rw-r--r--source/blender/editors/render/render_opengl.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c14
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_proj.c9
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c6
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c8
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c8
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c21
-rw-r--r--source/blender/editors/space_view3d/view3d_iterators.c8
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c2
-rw-r--r--source/blender/makesdna/DNA_customdata_types.h13
-rw-r--r--source/blender/makesdna/DNA_object_types.h5
-rw-r--r--source/blender/makesdna/DNA_scene_types.h7
-rw-r--r--source/blender/makesrna/intern/rna_modifier.c8
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c8
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c14
-rw-r--r--source/blender/modifiers/intern/MOD_boolean.c12
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c9
-rw-r--r--source/blender/modifiers/intern/MOD_cloth.c15
-rw-r--r--source/blender/modifiers/intern/MOD_correctivesmooth.c9
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c9
-rw-r--r--source/blender/modifiers/intern/MOD_datatransfer.c16
-rw-r--r--source/blender/modifiers/intern/MOD_decimate.c13
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c15
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c10
-rw-r--r--source/blender/modifiers/intern/MOD_edgesplit.c4
-rw-r--r--source/blender/modifiers/intern/MOD_explode.c10
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c16
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciandeform.c9
-rw-r--r--source/blender/modifiers/intern/MOD_laplaciansmooth.c11
-rw-r--r--source/blender/modifiers/intern/MOD_lattice.c9
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c4
-rw-r--r--source/blender/modifiers/intern/MOD_meshdeform.c11
-rw-r--r--source/blender/modifiers/intern/MOD_mirror.c4
-rw-r--r--source/blender/modifiers/intern/MOD_normal_edit.c11
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c15
-rw-r--r--source/blender/modifiers/intern/MOD_particleinstance.c8
-rw-r--r--source/blender/modifiers/intern/MOD_particlesystem.c7
-rw-r--r--source/blender/modifiers/intern/MOD_shrinkwrap.c21
-rw-r--r--source/blender/modifiers/intern/MOD_simpledeform.c10
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c7
-rw-r--r--source/blender/modifiers/intern/MOD_smoke.c8
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c9
-rw-r--r--source/blender/modifiers/intern/MOD_solidify.c9
-rw-r--r--source/blender/modifiers/intern/MOD_surfacedeform.c2
-rw-r--r--source/blender/modifiers/intern/MOD_triangulate.c6
-rw-r--r--source/blender/modifiers/intern/MOD_util.c2
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c8
-rw-r--r--source/blender/modifiers/intern/MOD_uvwarp.c10
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c14
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c16
-rw-r--r--source/blender/modifiers/intern/MOD_weighted_normal.c13
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c12
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c12
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c12
-rw-r--r--source/blender/modifiers/intern/MOD_wireframe.c14
-rw-r--r--source/blender/python/bmesh/bmesh_py_types.c12
-rw-r--r--source/blender/python/mathutils/mathutils_bvhtree.c12
-rw-r--r--source/blender/render/intern/source/pointdensity.c9
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c7
128 files changed, 1061 insertions, 790 deletions
diff --git a/source/blender/alembic/intern/abc_hair.cc b/source/blender/alembic/intern/abc_hair.cc
index 6e149956fbf..a587e2a2cd1 100644
--- a/source/blender/alembic/intern/abc_hair.cc
+++ b/source/blender/alembic/intern/abc_hair.cc
@@ -69,7 +69,7 @@ void AbcHairWriter::do_write()
if (!m_psys) {
return;
}
- Mesh *mesh = mesh_get_eval_final(m_settings.depsgraph, m_settings.scene, m_object, CD_MASK_MESH);
+ Mesh *mesh = mesh_get_eval_final(m_settings.depsgraph, m_settings.scene, m_object, &CD_MASK_MESH);
BKE_mesh_tessface_ensure(mesh);
std::vector<Imath::V3f> verts;
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index d7d826cce12..50d9567fba7 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -554,7 +554,7 @@ Mesh *AbcGenericMeshWriter::getFinalMesh(bool &r_needsfree)
BM_mesh_triangulate(bm, quad_method, ngon_method, tag_only, NULL, NULL, NULL);
- Mesh *result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ Mesh *result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BM_mesh_free(bm);
if (r_needsfree) {
@@ -671,7 +671,7 @@ AbcMeshWriter::~AbcMeshWriter()
Mesh *AbcMeshWriter::getEvaluatedMesh(Scene *scene_eval, Object *ob_eval, bool &UNUSED(r_needsfree))
{
- return mesh_get_eval_final(m_settings.depsgraph, scene_eval, ob_eval, CD_MASK_MESH);
+ return mesh_get_eval_final(m_settings.depsgraph, scene_eval, ob_eval, &CD_MASK_MESH);
}
@@ -1059,7 +1059,7 @@ void AbcMeshReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
m_object->data = mesh;
Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
- BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true);
+ BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, &CD_MASK_MESH, true);
if (m_settings->validate_meshes) {
BKE_mesh_validate(mesh, false, false);
@@ -1342,7 +1342,7 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
m_object->data = mesh;
Mesh *read_mesh = this->read_mesh(mesh, sample_sel, MOD_MESHSEQ_READ_ALL, NULL);
- BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true);
+ BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, &CD_MASK_MESH, true);
ISubDSchema::Sample sample;
try {
diff --git a/source/blender/alembic/intern/abc_points.cc b/source/blender/alembic/intern/abc_points.cc
index a36c7c5bfb9..d9b78f83ff5 100644
--- a/source/blender/alembic/intern/abc_points.cc
+++ b/source/blender/alembic/intern/abc_points.cc
@@ -174,7 +174,7 @@ void AbcPointsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSel
Mesh *mesh = BKE_mesh_add(bmain, m_data_name.c_str());
Mesh *read_mesh = this->read_mesh(mesh, sample_sel, 0, NULL);
- BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, CD_MASK_MESH, true);
+ BKE_mesh_nomain_to_mesh(read_mesh, mesh, m_object, &CD_MASK_MESH, true);
if (m_settings->validate_meshes) {
BKE_mesh_validate(mesh, false, false);
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index fb78e03639b..cd7422415dc 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -75,6 +75,7 @@
struct BMEditMesh;
struct CCGElem;
struct CCGKey;
+struct CustomData_MeshMasks;
struct Depsgraph;
struct MEdge;
struct MFace;
@@ -348,7 +349,7 @@ void DM_from_template_ex(
DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type,
int numVerts, int numEdges, int numTessFaces,
int numLoops, int numPolys,
- CustomDataMask mask);
+ const struct CustomData_MeshMasks *mask);
void DM_from_template(
DerivedMesh *dm, DerivedMesh *source,
DerivedMeshType type,
@@ -362,10 +363,11 @@ int DM_release(DerivedMesh *dm);
/** utility function to convert a DerivedMesh to a Mesh
*/
-void DM_to_mesh(DerivedMesh *dm, struct Mesh *me, struct Object *ob, CustomDataMask mask, bool take_ownership);
+void DM_to_mesh(DerivedMesh *dm, struct Mesh *me, struct Object *ob,
+ const struct CustomData_MeshMasks *mask, bool take_ownership);
-void DM_set_only_copy(DerivedMesh *dm, CustomDataMask mask);
+void DM_set_only_copy(DerivedMesh *dm, const struct CustomData_MeshMasks *mask);
/* adds a vertex/edge/face custom data layer to a DerivedMesh, optionally
* backed by an external data array
@@ -488,27 +490,27 @@ void mesh_get_mapped_verts_coords(struct Mesh *me_eval, float (*r_cos)[3], const
DerivedMesh *mesh_create_derived_render(
struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask);
+ struct Object *ob, const struct CustomData_MeshMasks *dataMask);
/* same as above but wont use render settings */
DerivedMesh *mesh_create_derived(struct Mesh *me, float (*vertCos)[3]);
struct Mesh *editbmesh_get_eval_cage(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *,
- struct BMEditMesh *em, CustomDataMask dataMask);
+ struct BMEditMesh *em, const struct CustomData_MeshMasks *dataMask);
struct Mesh *editbmesh_get_eval_cage_from_orig(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *,
- struct BMEditMesh *em, CustomDataMask dataMask);
+ struct BMEditMesh *em, const struct CustomData_MeshMasks *dataMask);
struct Mesh *editbmesh_get_eval_cage_and_final(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *,
- struct BMEditMesh *em, CustomDataMask dataMask,
+ struct BMEditMesh *em, const struct CustomData_MeshMasks *dataMask,
struct Mesh **r_final);
float (*editbmesh_get_vertex_cos(struct BMEditMesh *em, int *r_numVerts))[3];
bool editbmesh_modifier_is_enabled(struct Scene *scene, struct ModifierData *md, bool has_prev_mesh);
void makeDerivedMesh(
struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct BMEditMesh *em,
- CustomDataMask dataMask, const bool build_shapekey_layers);
+ const struct CustomData_MeshMasks *dataMask, const bool build_shapekey_layers);
void DM_add_named_tangent_layer_for_uv(
CustomData *uv_data, CustomData *tan_data, int numLoopData,
diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h
index 1e7bad3cd6c..e218355447d 100644
--- a/source/blender/blenkernel/BKE_cdderivedmesh.h
+++ b/source/blender/blenkernel/BKE_cdderivedmesh.h
@@ -31,6 +31,7 @@
#include "BKE_customdata.h"
struct BMEditMesh;
+struct CustomData_MeshMasks;
struct DerivedMesh;
struct MLoopNorSpaceArray;
struct Mesh;
@@ -47,7 +48,7 @@ struct DerivedMesh *CDDM_new(int numVerts, int numEdges, int numFaces,
struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh);
/* creates a CDDerivedMesh from the given Mesh with custom allocation type. */
-struct DerivedMesh *CDDM_from_mesh_ex(struct Mesh *mesh, eCDAllocType alloctype, CustomDataMask mask);
+struct DerivedMesh *CDDM_from_mesh_ex(struct Mesh *mesh, eCDAllocType alloctype, const struct CustomData_MeshMasks *mask);
struct DerivedMesh *CDDM_from_bmesh(struct BMesh *bm, const bool use_mdisps);
@@ -71,11 +72,10 @@ struct DerivedMesh *CDDM_copy(struct DerivedMesh *dm);
* given DerivedMesh and containing the requested numbers of elements.
* elements are initialized to all zeros
*/
-struct DerivedMesh *CDDM_from_template_ex(
- struct DerivedMesh *source,
+struct DerivedMesh *CDDM_from_template_ex(struct DerivedMesh *source,
int numVerts, int numEdges, int numFaces,
int numLoops, int numPolys,
- CustomDataMask mask);
+ const struct CustomData_MeshMasks *mask);
struct DerivedMesh *CDDM_from_template(
struct DerivedMesh *source,
int numVerts, int numEdges, int numFaces,
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index ba3d1dbf187..4a7e6b22b0c 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -36,19 +36,21 @@ extern "C" {
struct BMesh;
struct CustomData;
+struct CustomData_MeshMasks;
struct ID;
typedef uint64_t CustomDataMask;
/*a data type large enough to hold 1 element from any customdata layer type*/
typedef struct {unsigned char data[64]; } CDBlockBytes;
-extern const CustomDataMask CD_MASK_BAREMESH;
-extern const CustomDataMask CD_MASK_MESH;
-extern const CustomDataMask CD_MASK_EDITMESH;
-extern const CustomDataMask CD_MASK_DERIVEDMESH;
-extern const CustomDataMask CD_MASK_BMESH;
-extern const CustomDataMask CD_MASK_FACECORNERS;
-extern const CustomDataMask CD_MASK_EVERYTHING;
+extern const CustomData_MeshMasks CD_MASK_BAREMESH;
+extern const CustomData_MeshMasks CD_MASK_BAREMESH_ORIGINDEX;
+extern const CustomData_MeshMasks CD_MASK_MESH;
+extern const CustomData_MeshMasks CD_MASK_EDITMESH;
+extern const CustomData_MeshMasks CD_MASK_DERIVEDMESH;
+extern const CustomData_MeshMasks CD_MASK_BMESH;
+extern const CustomData_MeshMasks CD_MASK_FACECORNERS;
+extern const CustomData_MeshMasks CD_MASK_EVERYTHING;
/* for ORIGINDEX layer type, indicates no original index for this element */
#define ORIGINDEX_NONE -1
@@ -69,12 +71,15 @@ typedef enum eCDAllocType {
#define CD_TYPE_AS_MASK(_type) (CustomDataMask)((CustomDataMask)1 << (CustomDataMask)(_type))
-void customData_mask_layers__print(CustomDataMask mask);
+void customData_mask_layers__print(const struct CustomData_MeshMasks *mask);
typedef void (*cd_interp)(const void **sources, const float *weights, const float *sub_weights, int count, void *dest);
typedef void (*cd_copy)(const void *source, void *dest, int count);
typedef bool (*cd_validate)(void *item, const uint totitems, const bool do_fixes);
+void CustomData_MeshMasks_update(CustomData_MeshMasks *mask_dst, const CustomData_MeshMasks *mask_src);
+bool CustomData_MeshMasks_are_matching(const CustomData_MeshMasks *mask_ref, const CustomData_MeshMasks *mask_required);
+
/**
* Checks if the layer at physical offset \a layer_n (in data->layers) support math
* the below operations.
diff --git a/source/blender/blenkernel/BKE_data_transfer.h b/source/blender/blenkernel/BKE_data_transfer.h
index dea36a6fce3..8f949e5d985 100644
--- a/source/blender/blenkernel/BKE_data_transfer.h
+++ b/source/blender/blenkernel/BKE_data_transfer.h
@@ -66,7 +66,7 @@ enum {
};
-CustomDataMask BKE_object_data_transfer_dttypes_to_cdmask(const int dtdata_types);
+void BKE_object_data_transfer_dttypes_to_cdmask(const int dtdata_types, struct CustomData_MeshMasks *r_data_masks);
bool BKE_object_data_transfer_get_dttypes_capacity(
const int dtdata_types, bool *r_advanced_mixing, bool *r_threshold);
int BKE_object_data_transfer_get_dttypes_item_types(const int dtdata_types);
diff --git a/source/blender/blenkernel/BKE_editmesh.h b/source/blender/blenkernel/BKE_editmesh.h
index 4850c864d4a..34cd3ddf6f6 100644
--- a/source/blender/blenkernel/BKE_editmesh.h
+++ b/source/blender/blenkernel/BKE_editmesh.h
@@ -61,7 +61,7 @@ typedef struct BMEditMesh {
struct Mesh *mesh_eval_final, *mesh_eval_cage;
/*derivedmesh stuff*/
- CustomDataMask lastDataMask;
+ CustomData_MeshMasks lastDataMask;
unsigned char (*derivedVertColor)[4];
int derivedVertColorLen;
unsigned char (*derivedFaceColor)[4];
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 07d04a55496..a2613c2c2e3 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -27,7 +27,7 @@
#include "BLI_compiler_compat.h"
/* defines CustomDataMask */
-#include "BKE_customdata.h"
+//#include "BKE_customdata.h"
struct BLI_Stack;
struct BMEditMesh;
@@ -37,6 +37,7 @@ struct BMeshFromMeshParams;
struct BMeshToMeshParams;
struct BoundBox;
struct CustomData;
+struct CustomData_MeshMasks;
struct Depsgraph;
struct EdgeHash;
struct ID;
@@ -83,10 +84,10 @@ struct BMesh *BKE_mesh_to_bmesh(
const bool add_key_index, const struct BMeshCreateParams *params);
struct Mesh *BKE_mesh_from_bmesh_nomain(struct BMesh *bm, const struct BMeshToMeshParams *params);
-struct Mesh *BKE_mesh_from_bmesh_for_eval_nomain(struct BMesh *bm, const int64_t cd_mask_extra);
+struct Mesh *BKE_mesh_from_bmesh_for_eval_nomain(struct BMesh *bm, const struct CustomData_MeshMasks *cd_mask_extra);
struct Mesh *BKE_mesh_from_editmesh_with_coords_thin_wrap(
- struct BMEditMesh *em, CustomDataMask data_mask, float (*vertexCos)[3]);
+ struct BMEditMesh *em, const struct CustomData_MeshMasks *data_mask, float (*vertexCos)[3]);
int poly_find_loop_from_vert(
const struct MPoly *poly,
@@ -179,7 +180,7 @@ struct Mesh *BKE_mesh_create_derived_for_modifier(
/* Copies a nomain-Mesh into an existing Mesh. */
void BKE_mesh_nomain_to_mesh(struct Mesh *mesh_src, struct Mesh *mesh_dst, struct Object *ob,
- CustomDataMask mask, bool take_ownership);
+ const struct CustomData_MeshMasks *mask, bool take_ownership);
void BKE_mesh_nomain_to_meshkey(struct Mesh *mesh_src, struct Mesh *mesh_dst, struct KeyBlock *kb);
diff --git a/source/blender/blenkernel/BKE_mesh_runtime.h b/source/blender/blenkernel/BKE_mesh_runtime.h
index 4ee8995dd99..d3eb573bc2d 100644
--- a/source/blender/blenkernel/BKE_mesh_runtime.h
+++ b/source/blender/blenkernel/BKE_mesh_runtime.h
@@ -25,10 +25,11 @@
* This file contains access functions for the Mesh.runtime struct.
*/
-#include "BKE_customdata.h" /* for CustomDataMask */
+//#include "BKE_customdata.h" /* for CustomDataMask */
struct ColorBand;
struct CustomData;
+struct CustomData_MeshMasks;
struct Depsgraph;
struct KeyBlock;
struct MLoop;
@@ -66,50 +67,50 @@ void BKE_mesh_runtime_verttri_from_looptri(
#ifdef USE_DERIVEDMESH
struct DerivedMesh *mesh_get_derived_final(
struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask);
+ struct Object *ob, const struct CustomData_MeshMasks *dataMask);
#endif
struct Mesh *mesh_get_eval_final(
- struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, CustomDataMask dataMask);
+ struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask);
#ifdef USE_DERIVEDMESH
struct DerivedMesh *mesh_get_derived_deform(
struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask);
+ struct Object *ob, const struct CustomData_MeshMasks *dataMask);
#endif
struct Mesh *mesh_get_eval_deform(
struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask);
+ struct Object *ob, const struct CustomData_MeshMasks *dataMask);
struct Mesh *mesh_create_eval_final_render(
struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask);
+ struct Object *ob, const struct CustomData_MeshMasks *dataMask);
#ifdef USE_DERIVEDMESH
struct DerivedMesh *mesh_create_derived_index_render(
struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask, int index);
+ struct Object *ob, const struct CustomData_MeshMasks *dataMask, int index);
#endif
struct Mesh *mesh_create_eval_final_index_render(
struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask, int index);
+ struct Object *ob, const struct CustomData_MeshMasks *dataMask, int index);
#ifdef USE_DERIVEDMESH
struct DerivedMesh *mesh_create_derived_view(
struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask);
+ struct Object *ob, const struct CustomData_MeshMasks *dataMask);
#endif
struct Mesh *mesh_create_eval_final_view(
struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask);
+ struct Object *ob, const struct CustomData_MeshMasks *dataMask);
struct Mesh *mesh_create_eval_no_deform(
struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask);
+ const struct CustomData_MeshMasks *dataMask);
struct Mesh *mesh_create_eval_no_deform_render(
struct Depsgraph *depsgraph, struct Scene *scene,
struct Object *ob, float (*vertCos)[3],
- CustomDataMask dataMask);
+ const struct CustomData_MeshMasks *dataMask);
void BKE_mesh_runtime_eval_to_meshkey(struct Mesh *me_deformed, struct Mesh *me, struct KeyBlock *kb);
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 51fb6d8a591..1a1e510b9e1 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -25,6 +25,7 @@
#include "BKE_customdata.h"
struct BMEditMesh;
+struct CustomData_MeshMasks;
struct DepsNodeHandle;
struct Depsgraph;
struct DerivedMesh;
@@ -214,23 +215,20 @@ typedef struct ModifierTypeInfo {
*/
void (*initData)(struct ModifierData *md);
- /* Should return a CustomDataMask indicating what data this
+ /* Should add to passed \a r_cddata_masks the data types that this
* modifier needs. If (mask & (1 << (layer type))) != 0, this modifier
- * needs that custom data layer. This function's return value can change
+ * needs that custom data layer. It can change required layers
* depending on the modifier's settings.
*
* Note that this means extra data (e.g. vertex groups) - it is assumed
* that all modifiers need mesh data and deform modifiers need vertex
* coordinates.
*
- * Note that this limits the number of custom data layer types to 32.
- *
- * If this function is not present or it returns 0, it is assumed that
- * no extra data is needed.
+ * If this function is not present, it is assumed that no extra data is needed.
*
* This function is optional.
*/
- CustomDataMask (*requiredDataMask)(struct Object *ob, struct ModifierData *md);
+ void (*requiredDataMask)(struct Object *ob, struct ModifierData *md, struct CustomData_MeshMasks *r_cddata_masks);
/* Free internal modifier data variables, this function should
* not free the md variable itself.
@@ -365,10 +363,10 @@ bool modifiers_isPreview(struct Object *ob);
typedef struct CDMaskLink {
struct CDMaskLink *next;
- CustomDataMask mask;
+ struct CustomData_MeshMasks mask;
} CDMaskLink;
-/* Calculates and returns a linked list of CustomDataMasks indicating the
+/* Calculates and returns a linked list of CustomData_MeshMasks indicating the
* data required by each modifier in the stack pointed to by md for correct
* evaluation, assuming the data indicated by dataMask is required at the
* end of the stack.
@@ -376,9 +374,10 @@ typedef struct CDMaskLink {
struct CDMaskLink *modifiers_calcDataMasks(struct Scene *scene,
struct Object *ob,
struct ModifierData *md,
- CustomDataMask dataMask,
+ const struct CustomData_MeshMasks *dataMask,
int required_mode,
- ModifierData *previewmd, CustomDataMask previewmask);
+ ModifierData *previewmd,
+ const struct CustomData_MeshMasks *previewmask);
struct ModifierData *modifiers_getLastPreview(struct Scene *scene,
struct ModifierData *md,
int required_mode);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 715d8670071..19036e63a8c 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -41,6 +41,7 @@ struct ParticleSystemModifierData;
struct BVHTreeRay;
struct BVHTreeRayHit;
+struct CustomData_MeshMasks;
struct Depsgraph;
struct Depsgraph;
struct EdgeHash;
@@ -333,7 +334,7 @@ void psys_interpolate_mcol(const struct MCol *mcol, int quad, const float w[4],
void copy_particle_key(struct ParticleKey *to, struct ParticleKey *from, int time);
-CustomDataMask psys_emitter_customdata_mask(struct ParticleSystem *psys);
+void psys_emitter_customdata_mask(struct ParticleSystem *psys, struct CustomData_MeshMasks *r_cddata_masks);
void psys_particle_on_emitter(struct ParticleSystemModifierData *psmd, int distr, int index, int index_dmcache,
float fuv[4], float foffset, float vec[3], float nor[3],
float utan[3], float vtan[3], float orco[3]);
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 27da5b8c635..a3f89d65c5a 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -28,6 +28,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_cloth_types.h"
+#include "DNA_customdata_types.h"
#include "DNA_key_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
@@ -361,13 +362,13 @@ void DM_from_template_ex(
DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type,
int numVerts, int numEdges, int numTessFaces,
int numLoops, int numPolys,
- CustomDataMask mask)
+ const CustomData_MeshMasks *mask)
{
- CustomData_copy(&source->vertData, &dm->vertData, mask, CD_CALLOC, numVerts);
- CustomData_copy(&source->edgeData, &dm->edgeData, mask, CD_CALLOC, numEdges);
- CustomData_copy(&source->faceData, &dm->faceData, mask, CD_CALLOC, numTessFaces);
- CustomData_copy(&source->loopData, &dm->loopData, mask, CD_CALLOC, numLoops);
- CustomData_copy(&source->polyData, &dm->polyData, mask, CD_CALLOC, numPolys);
+ 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);
dm->cd_flag = source->cd_flag;
@@ -392,7 +393,7 @@ void DM_from_template(
dm, source, type,
numVerts, numEdges, numTessFaces,
numLoops, numPolys,
- CD_MASK_DERIVEDMESH);
+ &CD_MASK_DERIVEDMESH);
}
int DM_release(DerivedMesh *dm)
@@ -433,8 +434,8 @@ void DM_DupPolys(DerivedMesh *source, DerivedMesh *target)
CustomData_free(&target->loopData, source->numLoopData);
CustomData_free(&target->polyData, source->numPolyData);
- CustomData_copy(&source->loopData, &target->loopData, CD_MASK_DERIVEDMESH, CD_DUPLICATE, source->numLoopData);
- CustomData_copy(&source->polyData, &target->polyData, CD_MASK_DERIVEDMESH, CD_DUPLICATE, source->numPolyData);
+ CustomData_copy(&source->loopData, &target->loopData, CD_MASK_DERIVEDMESH.lmask, CD_DUPLICATE, source->numLoopData);
+ CustomData_copy(&source->polyData, &target->polyData, CD_MASK_DERIVEDMESH.pmask, CD_DUPLICATE, source->numPolyData);
target->numLoopData = source->numLoopData;
target->numPolyData = source->numPolyData;
@@ -492,7 +493,7 @@ void DM_ensure_looptri_data(DerivedMesh *dm)
}
}
-void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask, bool take_ownership)
+void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, const CustomData_MeshMasks *mask, bool take_ownership)
{
/* dm might depend on me, so we need to do everything with a local copy */
Mesh tmp = *me;
@@ -526,10 +527,10 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask, bool
totpoly = tmp.totpoly = dm->getNumPolys(dm);
tmp.totface = 0;
- CustomData_copy(&dm->vertData, &tmp.vdata, mask, alloctype, totvert);
- CustomData_copy(&dm->edgeData, &tmp.edata, mask, alloctype, totedge);
- CustomData_copy(&dm->loopData, &tmp.ldata, mask, alloctype, totloop);
- CustomData_copy(&dm->polyData, &tmp.pdata, mask, alloctype, totpoly);
+ CustomData_copy(&dm->vertData, &tmp.vdata, mask->vmask, alloctype, totvert);
+ CustomData_copy(&dm->edgeData, &tmp.edata, mask->emask, alloctype, totedge);
+ CustomData_copy(&dm->loopData, &tmp.ldata, mask->lmask, alloctype, totloop);
+ CustomData_copy(&dm->polyData, &tmp.pdata, mask->pmask, alloctype, totpoly);
tmp.cd_flag = dm->cd_flag;
tmp.runtime.deformed_only = dm->deformedOnly;
@@ -627,10 +628,10 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me, Object *ob, CustomDataMask mask, bool
if (take_ownership) {
if (alloctype == CD_ASSIGN) {
- CustomData_free_typemask(&dm->vertData, dm->numVertData, ~mask);
- CustomData_free_typemask(&dm->edgeData, dm->numEdgeData, ~mask);
- CustomData_free_typemask(&dm->loopData, dm->numLoopData, ~mask);
- CustomData_free_typemask(&dm->polyData, dm->numPolyData, ~mask);
+ CustomData_free_typemask(&dm->vertData, dm->numVertData, ~mask->vmask);
+ CustomData_free_typemask(&dm->edgeData, dm->numEdgeData, ~mask->emask);
+ CustomData_free_typemask(&dm->loopData, dm->numLoopData, ~mask->lmask);
+ CustomData_free_typemask(&dm->polyData, dm->numPolyData, ~mask->pmask);
}
dm->release(dm);
}
@@ -655,31 +656,31 @@ void BKE_mesh_runtime_eval_to_meshkey(Mesh *me_deformed, Mesh *me, KeyBlock *kb)
* zero for the layer type, so only layer types specified by the mask
* will be copied
*/
-void DM_set_only_copy(DerivedMesh *dm, CustomDataMask mask)
+void DM_set_only_copy(DerivedMesh *dm, const CustomData_MeshMasks *mask)
{
- CustomData_set_only_copy(&dm->vertData, mask);
- CustomData_set_only_copy(&dm->edgeData, mask);
- CustomData_set_only_copy(&dm->faceData, mask);
+ CustomData_set_only_copy(&dm->vertData, mask->vmask);
+ CustomData_set_only_copy(&dm->edgeData, mask->emask);
+ CustomData_set_only_copy(&dm->faceData, mask->fmask);
/* this wasn't in 2.63 and is disabled for 2.64 because it gives problems with
* weight paint mode when there are modifiers applied, needs further investigation,
* see replies to r50969, Campbell */
#if 0
- CustomData_set_only_copy(&dm->loopData, mask);
- CustomData_set_only_copy(&dm->polyData, mask);
+ CustomData_set_only_copy(&dm->loopData, mask->lmask);
+ CustomData_set_only_copy(&dm->polyData, mask->pmask);
#endif
}
-static void mesh_set_only_copy(Mesh *mesh, CustomDataMask mask)
+static void mesh_set_only_copy(Mesh *mesh, const CustomData_MeshMasks *mask)
{
- CustomData_set_only_copy(&mesh->vdata, mask);
- CustomData_set_only_copy(&mesh->edata, mask);
- CustomData_set_only_copy(&mesh->fdata, mask);
+ CustomData_set_only_copy(&mesh->vdata, mask->vmask);
+ CustomData_set_only_copy(&mesh->edata, mask->emask);
+ CustomData_set_only_copy(&mesh->fdata, mask->fmask);
/* this wasn't in 2.63 and is disabled for 2.64 because it gives problems with
* weight paint mode when there are modifiers applied, needs further investigation,
* see replies to r50969, Campbell */
#if 0
- CustomData_set_only_copy(&mesh->ldata, mask);
- CustomData_set_only_copy(&mesh->pdata, mask);
+ CustomData_set_only_copy(&mesh->ldata, mask->lmask);
+ CustomData_set_only_copy(&mesh->pdata, mask->pmask);
#endif
}
@@ -982,7 +983,7 @@ static Mesh *create_orco_mesh(Object *ob, Mesh *me, BMEditMesh *em, int layer)
int free;
if (em) {
- mesh = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, 0);
+ mesh = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL);
}
else {
mesh = BKE_mesh_copy_for_eval(me, true);
@@ -1152,7 +1153,7 @@ static void mesh_copy_autosmooth(Mesh *me, Mesh *me_orig)
static void mesh_calc_modifiers(
struct Depsgraph *depsgraph, Scene *scene, Object *ob, float (*inputVertexCos)[3],
int useDeform,
- const bool need_mapping, CustomDataMask dataMask,
+ const bool need_mapping, const CustomData_MeshMasks *dataMask,
const int index, const bool useCache, const bool build_shapekey_layers,
/* return args */
Mesh **r_deform, Mesh **r_final)
@@ -1160,7 +1161,8 @@ static void mesh_calc_modifiers(
ModifierData *firstmd, *md, *previewmd = NULL;
CDMaskLink *datamasks, *curr;
/* XXX Always copying POLYINDEX, else tessellated data are no more valid! */
- CustomDataMask mask, nextmask, previewmask = 0, append_mask = CD_MASK_ORIGINDEX | CD_MASK_BAREMESH;
+ CustomData_MeshMasks mask, nextmask, previewmask = {0}, append_mask = CD_MASK_BAREMESH_ORIGINDEX;
+
float (*deformedVerts)[3] = NULL;
int numVerts = ((Mesh *)ob->data)->totvert;
const bool useRenderParams = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
@@ -1206,7 +1208,7 @@ static void mesh_calc_modifiers(
previewmd = modifiers_getLastPreview(scene, md, required_mode);
}
- datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode, previewmd, previewmask);
+ datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode, previewmd, &previewmask);
curr = datamasks;
if (r_deform) {
@@ -1336,12 +1338,12 @@ static void mesh_calc_modifiers(
}
/* add an orco layer if needed by this modifier */
- if (mti->requiredDataMask)
- mask = mti->requiredDataMask(ob, md);
- else
- mask = 0;
+ memset(&mask, 0, sizeof(mask));
+ if (mti->requiredDataMask) {
+ mti->requiredDataMask(ob, md, &mask);
+ }
- if (me && (mask & CD_MASK_ORCO)) {
+ if (me && (mask.vmask & CD_MASK_ORCO)) {
add_orco_mesh(ob, NULL, me, me_orco, CD_ORCO);
}
@@ -1381,7 +1383,7 @@ static void mesh_calc_modifiers(
if (curr->next)
nextmask = curr->next->mask;
else
- nextmask = dataMask;
+ nextmask = *dataMask;
/* apply vertex coordinates or build a Mesh as necessary */
if (me) {
@@ -1408,7 +1410,7 @@ static void mesh_calc_modifiers(
* requests it, this way Mirror, Solidify etc will keep ORIGINDEX
* data by using generic DM_copy_vert_data() functions.
*/
- if (need_mapping || (nextmask & CD_MASK_ORIGINDEX)) {
+ if (need_mapping || ((nextmask.vmask | nextmask.emask | nextmask.pmask) & CD_MASK_ORIGINDEX)) {
/* calc */
CustomData_add_layer(&me->vdata, CD_ORIGINDEX, CD_CALLOC, NULL, me->totvert);
CustomData_add_layer(&me->edata, CD_ORIGINDEX, CD_CALLOC, NULL, me->totedge);
@@ -1426,15 +1428,21 @@ static void mesh_calc_modifiers(
mask = curr->mask;
/* needMapping check here fixes bug [#28112], otherwise it's
* possible that it won't be copied */
- mask |= append_mask;
- mesh_set_only_copy(me, mask | (need_mapping ? CD_MASK_ORIGINDEX : 0));
+ CustomData_MeshMasks_update(&mask, &append_mask);
+ if (need_mapping) {
+ mask.vmask |= CD_MASK_ORIGINDEX;
+ mask.emask |= CD_MASK_ORIGINDEX;
+ mask.pmask |= CD_MASK_ORIGINDEX;
+ }
+ mesh_set_only_copy(me, &mask);
/* add cloth rest shape key if needed */
- if (mask & CD_MASK_CLOTH_ORCO)
+ if (mask.vmask & CD_MASK_CLOTH_ORCO) {
add_orco_mesh(ob, NULL, me, me_orco, CD_CLOTH_ORCO);
+ }
/* add an origspace layer if needed */
- if ((curr->mask) & CD_MASK_ORIGSPACE_MLOOP) {
+ if ((curr->mask.lmask) & CD_MASK_ORIGSPACE_MLOOP) {
if (!CustomData_has_layer(&me->ldata, CD_ORIGSPACE_MLOOP)) {
CustomData_add_layer(&me->ldata, CD_ORIGSPACE_MLOOP, CD_CALLOC, NULL, me->totloop);
mesh_init_origspace(me);
@@ -1463,15 +1471,18 @@ static void mesh_calc_modifiers(
}
/* create an orco mesh in parallel */
- if (nextmask & CD_MASK_ORCO) {
+ if (nextmask.vmask & CD_MASK_ORCO) {
if (!me_orco) {
me_orco = create_orco_mesh(ob, ob->data, NULL, CD_ORCO);
}
- nextmask &= ~CD_MASK_ORCO;
- mesh_set_only_copy(me_orco, nextmask | CD_MASK_ORIGINDEX |
- (mti->requiredDataMask ?
- mti->requiredDataMask(ob, md) : 0));
+ nextmask.vmask &= ~CD_MASK_ORCO;
+ CustomData_MeshMasks temp_cddata_masks = {.vmask=CD_MASK_ORIGINDEX, .emask=CD_MASK_ORIGINDEX, .fmask=CD_MASK_ORIGINDEX, .pmask=CD_MASK_ORIGINDEX};
+ if (mti->requiredDataMask != NULL) {
+ mti->requiredDataMask(ob, md, &temp_cddata_masks);
+ }
+ CustomData_MeshMasks_update(&temp_cddata_masks, &nextmask);
+ mesh_set_only_copy(me_orco, &temp_cddata_masks);
me_next = modwrap_applyModifier(md, &mectx_orco, me_orco);
ASSERT_IS_VALID_MESH(me_next);
@@ -1488,13 +1499,16 @@ static void mesh_calc_modifiers(
}
/* create cloth orco mesh in parallel */
- if (nextmask & CD_MASK_CLOTH_ORCO) {
+ if (nextmask.vmask & CD_MASK_CLOTH_ORCO) {
if (!me_orco_cloth) {
me_orco_cloth = create_orco_mesh(ob, ob->data, NULL, CD_CLOTH_ORCO);
}
- nextmask &= ~CD_MASK_CLOTH_ORCO;
- mesh_set_only_copy(me_orco_cloth, nextmask | CD_MASK_ORIGINDEX);
+ nextmask.vmask &= ~CD_MASK_CLOTH_ORCO;
+ nextmask.vmask |= CD_MASK_ORIGINDEX;
+ nextmask.emask |= CD_MASK_ORIGINDEX;
+ nextmask.pmask |= CD_MASK_ORIGINDEX;
+ mesh_set_only_copy(me_orco_cloth, &nextmask);
me_next = modwrap_applyModifier(md, &mectx_orco, me_orco_cloth);
ASSERT_IS_VALID_MESH(me_next);
@@ -1512,8 +1526,9 @@ static void mesh_calc_modifiers(
/* in case of dynamic paint, make sure preview mask remains for following modifiers */
/* XXX Temp and hackish solution! */
- if (md->type == eModifierType_DynamicPaint)
- append_mask |= CD_MASK_PREVIEW_MLOOPCOL;
+ if (md->type == eModifierType_DynamicPaint) {
+ append_mask.lmask |= CD_MASK_PREVIEW_MLOOPCOL;
+ }
me->runtime.deformed_only = false;
}
@@ -1556,7 +1571,7 @@ static void mesh_calc_modifiers(
}
/* add an orco layer if needed */
- if (dataMask & CD_MASK_ORCO) {
+ if (dataMask->vmask & CD_MASK_ORCO) {
add_orco_mesh(ob, NULL, *r_final, me_orco, CD_ORCO);
if (r_deform && *r_deform)
@@ -1571,7 +1586,7 @@ static void mesh_calc_modifiers(
if (sculpt_dyntopo == false) {
/* watch this! after 2.75a we move to from tessface to looptri (by default) */
- if (dataMask & CD_MASK_MFACE) {
+ if (dataMask->fmask & CD_MASK_MFACE) {
BKE_mesh_tessface_ensure(*r_final);
}
@@ -1613,7 +1628,7 @@ static void mesh_calc_modifiers(
static void mesh_calc_modifiers_dm(
struct Depsgraph *depsgraph, Scene *scene, Object *ob, float (*inputVertexCos)[3],
int useDeform,
- const bool need_mapping, CustomDataMask dataMask,
+ const bool need_mapping, const CustomData_MeshMasks *dataMask,
const int index, const bool useCache, const bool build_shapekey_layers,
/* return args */
DerivedMesh **r_deformdm, DerivedMesh **r_finaldm)
@@ -1626,11 +1641,11 @@ static void mesh_calc_modifiers_dm(
(r_deformdm ? &deform_mesh : NULL), &final_mesh);
if (deform_mesh) {
- *r_deformdm = CDDM_from_mesh_ex(deform_mesh, CD_DUPLICATE, CD_MASK_MESH);
+ *r_deformdm = CDDM_from_mesh_ex(deform_mesh, CD_DUPLICATE, &CD_MASK_MESH);
BKE_id_free(NULL, deform_mesh);
}
- *r_finaldm = CDDM_from_mesh_ex(final_mesh, CD_DUPLICATE, CD_MASK_MESH);
+ *r_finaldm = CDDM_from_mesh_ex(final_mesh, CD_DUPLICATE, &CD_MASK_MESH);
BKE_id_free(NULL, final_mesh);
}
#endif
@@ -1672,13 +1687,13 @@ bool editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, bool has_prev
static void editbmesh_calc_modifiers(
struct Depsgraph *depsgraph, Scene *scene, Object *ob,
- BMEditMesh *em, CustomDataMask dataMask,
+ BMEditMesh *em, const CustomData_MeshMasks *dataMask,
/* return args */
Mesh **r_cage, Mesh **r_final)
{
ModifierData *md;
float (*deformedVerts)[3] = NULL;
- CustomDataMask mask = 0, append_mask = CD_MASK_BAREMESH;
+ CustomData_MeshMasks mask = {0}, append_mask = CD_MASK_BAREMESH;
int i, numVerts = 0, cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1);
CDMaskLink *datamasks, *curr;
const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
@@ -1702,7 +1717,7 @@ static void editbmesh_calc_modifiers(
md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
/* copied from mesh_calc_modifiers */
- datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode, NULL, 0);
+ datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode, NULL, NULL);
curr = datamasks;
@@ -1711,6 +1726,7 @@ static void editbmesh_calc_modifiers(
for (i = 0; md; i++, md = md->next, curr = curr->next) {
const ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+ memset(&mask, 0, sizeof(mask));
if (!editbmesh_modifier_is_enabled(scene, md, me != NULL)) {
continue;
@@ -1718,8 +1734,8 @@ static void editbmesh_calc_modifiers(
/* add an orco layer if needed by this modifier */
if (me && mti->requiredDataMask) {
- mask = mti->requiredDataMask(ob, md);
- if (mask & CD_MASK_ORCO) {
+ mti->requiredDataMask(ob, md, &mask);
+ if (mask.vmask & CD_MASK_ORCO) {
add_orco_mesh(ob, em, me, me_orco, CD_ORCO);
}
}
@@ -1770,7 +1786,7 @@ static void editbmesh_calc_modifiers(
}
else {
- me = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, 0);
+ me = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL);
ASSERT_IS_VALID_MESH(me);
mesh_copy_autosmooth(me, ob->data);
@@ -1782,13 +1798,16 @@ static void editbmesh_calc_modifiers(
/* create an orco derivedmesh in parallel */
mask = curr->mask;
- if (mask & CD_MASK_ORCO) {
+ if (mask.vmask & CD_MASK_ORCO) {
if (!me_orco) {
me_orco = create_orco_mesh(ob, ob->data, em, CD_ORCO);
}
- mask &= ~CD_MASK_ORCO;
- mesh_set_only_copy(me_orco, mask | CD_MASK_ORIGINDEX);
+ mask.vmask &= ~CD_MASK_ORCO;
+ mask.vmask |= CD_MASK_ORIGINDEX;
+ mask.emask |= CD_MASK_ORIGINDEX;
+ mask.pmask |= CD_MASK_ORIGINDEX;
+ mesh_set_only_copy(me_orco, &mask);
me_next = modwrap_applyModifier(md, &mectx_orco, me_orco);
ASSERT_IS_VALID_MESH(me_next);
@@ -1803,12 +1822,15 @@ static void editbmesh_calc_modifiers(
}
/* set the DerivedMesh to only copy needed data */
- mask |= append_mask;
- mask = curr->mask; /* CD_MASK_ORCO may have been cleared above */
+ CustomData_MeshMasks_update(&mask, &append_mask);
+ mask = curr->mask; /* CD_MASK_ORCO may have been cleared above */ /* XXX WHAT? ovewrites mask ??? */
+ mask.vmask |= CD_MASK_ORIGINDEX;
+ mask.emask |= CD_MASK_ORIGINDEX;
+ mask.pmask |= CD_MASK_ORIGINDEX;
- mesh_set_only_copy(me, mask | CD_MASK_ORIGINDEX);
+ mesh_set_only_copy(me, &mask);
- if (mask & CD_MASK_ORIGSPACE_MLOOP) {
+ if (mask.lmask & CD_MASK_ORIGSPACE_MLOOP) {
if (!CustomData_has_layer(&me->ldata, CD_ORIGSPACE_MLOOP)) {
CustomData_add_layer(&me->ldata, CD_ORIGSPACE_MLOOP, CD_CALLOC, NULL, me->totloop);
mesh_init_origspace(me);
@@ -1849,7 +1871,7 @@ static void editbmesh_calc_modifiers(
me_orig->runtime.edit_data->vertexCos = MEM_dupallocN(deformedVerts);
}
*r_cage = BKE_mesh_from_editmesh_with_coords_thin_wrap(
- em, mask,
+ em, &mask,
deformedVerts ? MEM_dupallocN(deformedVerts) : NULL);
mesh_copy_autosmooth(*r_cage, ob->data);
}
@@ -1909,7 +1931,7 @@ static void editbmesh_calc_modifiers(
* but don't recalculate if the last modifier in the stack gives us tessfaces
* check if the derived meshes are DM_TYPE_EDITBMESH before calling, this isn't essential
* but quiets annoying error messages since tessfaces wont be created. */
- if (dataMask & CD_MASK_MFACE) {
+ if (dataMask->fmask & CD_MASK_MFACE) {
if ((*r_final)->edit_mesh == NULL) {
BKE_mesh_tessface_ensure(*r_final);
}
@@ -1942,7 +1964,7 @@ static void editbmesh_calc_modifiers(
}
/* add an orco layer if needed */
- if (dataMask & CD_MASK_ORCO)
+ if (dataMask->vmask & CD_MASK_ORCO)
add_orco_mesh(ob, em, *r_final, me_orco, CD_ORCO);
if (me_orco) {
@@ -2014,7 +2036,7 @@ static void mesh_runtime_check_normals_valid(const Mesh *mesh)
}
static void mesh_build_data(
- struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask,
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask,
const bool build_shapekey_layers, const bool need_mapping)
{
BLI_assert(ob->type == OB_MESH);
@@ -2026,10 +2048,14 @@ static void mesh_build_data(
BKE_object_free_derived_caches(ob);
BKE_object_sculpt_modifiers_changed(ob);
+#if 0 /* XXX This is already taken care of in mesh_calc_modifiers()... */
if (need_mapping) {
/* Also add the flag so that it is recorded in lastDataMask. */
- dataMask |= CD_MASK_ORIGINDEX;
+ dataMask->vmask |= CD_MASK_ORIGINDEX;
+ dataMask->emask |= CD_MASK_ORIGINDEX;
+ dataMask->pmask |= CD_MASK_ORIGINDEX;
}
+#endif
mesh_calc_modifiers(
depsgraph, scene, ob, NULL, 1, need_mapping, dataMask, -1, true, build_shapekey_layers,
@@ -2037,8 +2063,8 @@ static void mesh_build_data(
#ifdef USE_DERIVEDMESH
/* TODO(campbell): remove these copies, they are expected in various places over the code. */
- ob->derivedDeform = CDDM_from_mesh_ex(ob->runtime.mesh_deform_eval, CD_REFERENCE, CD_MASK_MESH);
- ob->derivedFinal = CDDM_from_mesh_ex(ob->runtime.mesh_eval, CD_REFERENCE, CD_MASK_MESH);
+ ob->derivedDeform = CDDM_from_mesh_ex(ob->runtime.mesh_deform_eval, CD_REFERENCE, &CD_MASK_MESH);
+ ob->derivedFinal = CDDM_from_mesh_ex(ob->runtime.mesh_eval, CD_REFERENCE, &CD_MASK_MESH);
#endif
BKE_object_boundbox_calc_from_mesh(ob, ob->runtime.mesh_eval);
@@ -2054,7 +2080,7 @@ static void mesh_build_data(
ob->derivedFinal->needsFree = 0;
ob->derivedDeform->needsFree = 0;
#endif
- ob->runtime.last_data_mask = dataMask;
+ ob->runtime.last_data_mask = *dataMask;
ob->runtime.last_need_mapping = need_mapping;
if ((ob->mode & OB_MODE_ALL_SCULPT) && ob->sculpt) {
@@ -2071,7 +2097,7 @@ static void mesh_build_data(
static void editbmesh_build_data(
struct Depsgraph *depsgraph, Scene *scene,
- Object *obedit, BMEditMesh *em, CustomDataMask dataMask)
+ Object *obedit, BMEditMesh *em, CustomData_MeshMasks *dataMask)
{
BLI_assert(em->ob->id.tag & LIB_TAG_COPIED_ON_WRITE);
@@ -2092,16 +2118,17 @@ static void editbmesh_build_data(
BKE_object_boundbox_calc_from_mesh(obedit, em->mesh_eval_final);
- em->lastDataMask = dataMask;
+ em->lastDataMask = *dataMask;
mesh_runtime_check_normals_valid(em->mesh_eval_final);
}
-static CustomDataMask object_get_datamask(const Depsgraph *depsgraph, Object *ob, bool *r_need_mapping)
+static void object_get_datamask(const Depsgraph *depsgraph, Object *ob, CustomData_MeshMasks *r_mask, bool *r_need_mapping)
{
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
Object *actob = view_layer->basact ? DEG_get_original_object(view_layer->basact->object) : NULL;
- CustomDataMask mask = DEG_get_customdata_mask_for_object(depsgraph, ob);
+
+ DEG_get_customdata_mask_for_object(depsgraph, ob, r_mask);
if (r_need_mapping) {
*r_need_mapping = false;
@@ -2117,37 +2144,37 @@ static CustomDataMask object_get_datamask(const Depsgraph *depsgraph, Object *ob
/* check if we need tfaces & mcols due to face select or texture paint */
if ((ob->mode & OB_MODE_TEXTURE_PAINT) || editing) {
- mask |= CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTFACE;
+ r_mask->lmask |= CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL;
+ r_mask->fmask |= CD_MASK_MTFACE;
}
/* check if we need mcols due to vertex paint or weightpaint */
if (ob->mode & OB_MODE_VERTEX_PAINT) {
- mask |= CD_MASK_MLOOPCOL;
+ r_mask->lmask |= CD_MASK_MLOOPCOL;
}
if (ob->mode & OB_MODE_WEIGHT_PAINT) {
- mask |= CD_MASK_MDEFORMVERT;
+ r_mask->vmask |= CD_MASK_MDEFORMVERT;
}
if (ob->mode & OB_MODE_EDIT)
- mask |= CD_MASK_MVERT_SKIN;
+ r_mask->vmask |= CD_MASK_MVERT_SKIN;
}
-
- return mask;
}
void makeDerivedMesh(
struct Depsgraph *depsgraph, Scene *scene, Object *ob, BMEditMesh *em,
- CustomDataMask dataMask, const bool build_shapekey_layers)
+ const CustomData_MeshMasks *dataMask, const bool build_shapekey_layers)
{
bool need_mapping;
- dataMask |= object_get_datamask(depsgraph, ob, &need_mapping);
+ CustomData_MeshMasks cddata_masks = *dataMask;
+ object_get_datamask(depsgraph, ob, &cddata_masks, &need_mapping);
if (em) {
- editbmesh_build_data(depsgraph, scene, ob, em, dataMask);
+ editbmesh_build_data(depsgraph, scene, ob, em, &cddata_masks);
}
else {
- mesh_build_data(depsgraph, scene, ob, dataMask, build_shapekey_layers, need_mapping);
+ mesh_build_data(depsgraph, scene, ob, &cddata_masks, build_shapekey_layers, need_mapping);
}
}
@@ -2156,27 +2183,27 @@ void makeDerivedMesh(
#ifdef USE_DERIVEDMESH
/* Deprecated DM, use: 'mesh_get_eval_final'. */
DerivedMesh *mesh_get_derived_final(
- struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
{
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
bool need_mapping;
- dataMask |= object_get_datamask(depsgraph, ob, &need_mapping);
+ CustomData_MeshMasks cddata_masks = *dataMask;
+ object_get_datamask(depsgraph, ob, &cddata_masks, &need_mapping);
if (!ob->derivedFinal ||
- ((dataMask & ob->lastDataMask) != dataMask) ||
+ !CustomData_MeshMasks_are_matching(&(ob->lastDataMask), &cddata_masks) ||
(need_mapping != ob->lastNeedMapping))
{
- mesh_build_data(depsgraph, scene, ob, dataMask, false, need_mapping);
+ mesh_build_data(depsgraph, scene, ob, cddata_masks, false, need_mapping);
}
if (ob->derivedFinal) { BLI_assert(!(ob->derivedFinal->dirty & DM_DIRTY_NORMALS)); }
return ob->derivedFinal;
}
#endif
-Mesh *mesh_get_eval_final(
- struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
+Mesh *mesh_get_eval_final(struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
{
/* This function isn't thread-safe and can't be used during evaluation. */
BLI_assert(DEG_debug_is_evaluating(depsgraph) == false);
@@ -2189,13 +2216,15 @@ Mesh *mesh_get_eval_final(
* the data we need, rebuild the derived mesh
*/
bool need_mapping;
- dataMask |= object_get_datamask(depsgraph, ob, &need_mapping);
+ CustomData_MeshMasks cddata_masks = *dataMask;
+ object_get_datamask(depsgraph, ob, &cddata_masks, &need_mapping);
if (!ob->runtime.mesh_eval ||
- ((dataMask & ob->runtime.last_data_mask) != dataMask) ||
+ !CustomData_MeshMasks_are_matching(&(ob->runtime.last_data_mask), &cddata_masks) ||
(need_mapping && !ob->runtime.last_need_mapping))
{
- mesh_build_data(depsgraph, scene, ob, dataMask | ob->runtime.last_data_mask,
+ CustomData_MeshMasks_update(&cddata_masks, &ob->runtime.last_data_mask);
+ mesh_build_data(depsgraph, scene, ob, &cddata_masks,
false, need_mapping || ob->runtime.last_need_mapping);
}
@@ -2205,26 +2234,27 @@ Mesh *mesh_get_eval_final(
#ifdef USE_DERIVEDMESH
/* Deprecated DM, use: 'mesh_get_eval_deform' instead. */
-DerivedMesh *mesh_get_derived_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_get_derived_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
{
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
bool need_mapping;
- dataMask |= object_get_datamask(depsgraph, ob, &need_mapping);
+ CustomData_MeshMasks cddata_masks = *dataMask;
+ object_get_datamask(depsgraph, ob, &cddata_masks, &need_mapping);
if (!ob->derivedDeform ||
- ((dataMask & ob->lastDataMask) != dataMask) ||
+ !CustomData_MeshMasks_are_matching(&(ob->lastDataMask), &cddata_masks) ||
(need_mapping != ob->lastNeedMapping))
{
- mesh_build_data(depsgraph, scene, ob, dataMask, false, need_mapping);
+ mesh_build_data(depsgraph, scene, ob, cddata_masks, false, need_mapping);
}
return ob->derivedDeform;
}
#endif
-Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
+Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
{
/* This function isn't thread-safe and can't be used during evaluation. */
BLI_assert(DEG_debug_is_evaluating(depsgraph) == false);
@@ -2238,13 +2268,15 @@ Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob
*/
bool need_mapping;
- dataMask |= object_get_datamask(depsgraph, ob, &need_mapping);
+ CustomData_MeshMasks cddata_masks = *dataMask;
+ object_get_datamask(depsgraph, ob, &cddata_masks, &need_mapping);
if (!ob->runtime.mesh_deform_eval ||
- ((dataMask & ob->runtime.last_data_mask) != dataMask) ||
+ !CustomData_MeshMasks_are_matching(&(ob->runtime.last_data_mask), &cddata_masks) ||
(need_mapping && !ob->runtime.last_need_mapping))
{
- mesh_build_data(depsgraph, scene, ob, dataMask | ob->runtime.last_data_mask,
+ CustomData_MeshMasks_update(&cddata_masks, &ob->runtime.last_data_mask);
+ mesh_build_data(depsgraph, scene, ob, &cddata_masks,
false, need_mapping || ob->runtime.last_need_mapping);
}
@@ -2254,7 +2286,8 @@ Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph, Scene *scene, Object *ob
#ifdef USE_DERIVEDMESH
/* Deprecated, use `mesh_create_eval_final_render` instead. */
-DerivedMesh *mesh_create_derived_render(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
+DerivedMesh *mesh_create_derived_render(
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
{
DerivedMesh *final;
@@ -2265,7 +2298,7 @@ DerivedMesh *mesh_create_derived_render(struct Depsgraph *depsgraph, Scene *scen
return final;
}
#endif
-Mesh *mesh_create_eval_final_render(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask)
+Mesh *mesh_create_eval_final_render(Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask)
{
Mesh *final;
@@ -2278,7 +2311,8 @@ Mesh *mesh_create_eval_final_render(struct Depsgraph *depsgraph, Scene *scene, O
#ifdef USE_DERIVEDMESH
/* Deprecated, use `mesh_create_eval_final_index_render` instead. */
-DerivedMesh *mesh_create_derived_index_render(struct Depsgraph *depsgraph, Scene *scene, Object *ob, CustomDataMask dataMask, int index)
+DerivedMesh *mesh_create_derived_index_render(
+ struct Depsgraph *depsgraph, Scene *scene, Object *ob, const CustomData_MeshMasks *dataMask, int index)
{
DerivedMesh *final;
@@ -2290,8 +2324,8 @@ DerivedMesh *mesh_create_derived_index_render(struct Depsgraph *depsgraph, Scene
}
#endif
Mesh *mesh_create_eval_final_index_render(
- struct Depsgraph *depsgraph, struct Scene *scene,
- struct Object *ob, CustomDataMask dataMask, int index)
+ Depsgraph *depsgraph, Scene *scene,
+ Object *ob, const CustomData_MeshMasks *dataMask, int index)
{
Mesh *final;
@@ -2306,7 +2340,7 @@ Mesh *mesh_create_eval_final_index_render(
/* Deprecated, use `mesh_create_eval_final_view` instead. */
DerivedMesh *mesh_create_derived_view(
struct Depsgraph *depsgraph, Scene *scene,
- Object *ob, CustomDataMask dataMask)
+ Object *ob, const CustomData_MeshMasks *dataMask)
{
DerivedMesh *final;
@@ -2327,8 +2361,8 @@ DerivedMesh *mesh_create_derived_view(
#endif
Mesh *mesh_create_eval_final_view(
- struct Depsgraph *depsgraph, Scene *scene,
- Object *ob, CustomDataMask dataMask)
+ Depsgraph *depsgraph, Scene *scene,
+ Object *ob, const CustomData_MeshMasks *dataMask)
{
Mesh *final;
@@ -2348,8 +2382,8 @@ Mesh *mesh_create_eval_final_view(
}
Mesh *mesh_create_eval_no_deform(
- struct Depsgraph *depsgraph, Scene *scene, Object *ob,
- float (*vertCos)[3], CustomDataMask dataMask)
+ Depsgraph *depsgraph, Scene *scene, Object *ob,
+ float (*vertCos)[3], const CustomData_MeshMasks *dataMask)
{
Mesh *final;
@@ -2361,8 +2395,8 @@ Mesh *mesh_create_eval_no_deform(
}
Mesh *mesh_create_eval_no_deform_render(
- struct Depsgraph *depsgraph, Scene *scene, Object *ob,
- float (*vertCos)[3], CustomDataMask dataMask)
+ Depsgraph *depsgraph, Scene *scene, Object *ob,
+ float (*vertCos)[3], const CustomData_MeshMasks *dataMask)
{
Mesh *final;
@@ -2376,20 +2410,22 @@ Mesh *mesh_create_eval_no_deform_render(
/***/
Mesh *editbmesh_get_eval_cage_and_final(
- struct Depsgraph *depsgraph, Scene *scene, Object *obedit, BMEditMesh *em,
- CustomDataMask dataMask,
+ Depsgraph *depsgraph, Scene *scene, Object *obedit, BMEditMesh *em,
+ const CustomData_MeshMasks *dataMask,
/* return args */
Mesh **r_final)
{
+ CustomData_MeshMasks cddata_masks = *dataMask;
+
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- dataMask |= object_get_datamask(depsgraph, obedit, NULL);
+ object_get_datamask(depsgraph, obedit, &cddata_masks, NULL);
if (!em->mesh_eval_cage ||
- (em->lastDataMask & dataMask) != dataMask)
+ !CustomData_MeshMasks_are_matching(&(em->lastDataMask), &cddata_masks))
{
- editbmesh_build_data(depsgraph, scene, obedit, em, dataMask);
+ editbmesh_build_data(depsgraph, scene, obedit, em, &cddata_masks);
}
*r_final = em->mesh_eval_final;
@@ -2399,17 +2435,19 @@ Mesh *editbmesh_get_eval_cage_and_final(
Mesh *editbmesh_get_eval_cage(
struct Depsgraph *depsgraph, Scene *scene, Object *obedit, BMEditMesh *em,
- CustomDataMask dataMask)
+ const CustomData_MeshMasks *dataMask)
{
+ CustomData_MeshMasks cddata_masks = *dataMask;
+
/* if there's no derived mesh or the last data mask used doesn't include
* the data we need, rebuild the derived mesh
*/
- dataMask |= object_get_datamask(depsgraph, obedit, NULL);
+ object_get_datamask(depsgraph, obedit, &cddata_masks, NULL);
if (!em->mesh_eval_cage ||
- (em->lastDataMask & dataMask) != dataMask)
+ !CustomData_MeshMasks_are_matching(&(em->lastDataMask), &cddata_masks))
{
- editbmesh_build_data(depsgraph, scene, obedit, em, dataMask);
+ editbmesh_build_data(depsgraph, scene, obedit, em, &cddata_masks);
}
return em->mesh_eval_cage;
@@ -2417,7 +2455,7 @@ Mesh *editbmesh_get_eval_cage(
Mesh *editbmesh_get_eval_cage_from_orig(
struct Depsgraph *depsgraph, Scene *scene, Object *obedit, BMEditMesh *UNUSED(em),
- CustomDataMask dataMask)
+ const CustomData_MeshMasks *dataMask)
{
BLI_assert((obedit->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0);
Scene *scene_eval = (Scene *)DEG_get_evaluated_id(depsgraph, &scene->id);
@@ -2467,7 +2505,7 @@ DMCoNo *mesh_get_mapped_verts_nors(Scene *scene, Object *ob)
if (ob->type != OB_MESH || me->totvert == 0)
return NULL;
- dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+ dm = mesh_get_derived_final(scene, ob, &CD_MASK_BAREMESH_ORIGINDEX);
if (dm->foreachMappedVert) {
vertexcosnos = MEM_calloc_arrayN(me->totvert, sizeof(DMCoNo), "vertexcosnos map");
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index cb4118b6abb..859c5534183 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -582,15 +582,16 @@ DerivedMesh *CDDM_new(int numVerts, int numEdges, int numTessFaces, int numLoops
DerivedMesh *CDDM_from_mesh(Mesh *mesh)
{
- return CDDM_from_mesh_ex(mesh, CD_REFERENCE, CD_MASK_MESH);
+ return CDDM_from_mesh_ex(mesh, CD_REFERENCE, &CD_MASK_MESH);
}
-DerivedMesh *CDDM_from_mesh_ex(Mesh *mesh, eCDAllocType alloctype, CustomDataMask mask)
+DerivedMesh *CDDM_from_mesh_ex(Mesh *mesh, eCDAllocType alloctype, const CustomData_MeshMasks *mask)
{
CDDerivedMesh *cddm = cdDM_create(__func__);
DerivedMesh *dm = &cddm->dm;
+ CustomData_MeshMasks cddata_masks = *mask;
- mask &= ~CD_MASK_MDISPS;
+ cddata_masks.lmask &= ~CD_MASK_MDISPS;
/* this does a referenced copy, with an exception for fluidsim */
@@ -608,15 +609,15 @@ DerivedMesh *CDDM_from_mesh_ex(Mesh *mesh, eCDAllocType alloctype, CustomDataMas
}
/* TODO DM_DIRTY_TESS_CDLAYERS ? Maybe not though, since we probably want to switch to looptris ? */
- CustomData_merge(&mesh->vdata, &dm->vertData, mask, alloctype,
+ CustomData_merge(&mesh->vdata, &dm->vertData, cddata_masks.vmask, alloctype,
mesh->totvert);
- CustomData_merge(&mesh->edata, &dm->edgeData, mask, alloctype,
+ CustomData_merge(&mesh->edata, &dm->edgeData, cddata_masks.emask, alloctype,
mesh->totedge);
- CustomData_merge(&mesh->fdata, &dm->faceData, mask | CD_MASK_ORIGINDEX, alloctype,
+ CustomData_merge(&mesh->fdata, &dm->faceData, cddata_masks.fmask | CD_MASK_ORIGINDEX, alloctype,
0 /* mesh->totface */);
- CustomData_merge(&mesh->ldata, &dm->loopData, mask, alloctype,
+ CustomData_merge(&mesh->ldata, &dm->loopData, cddata_masks.lmask, alloctype,
mesh->totloop);
- CustomData_merge(&mesh->pdata, &dm->polyData, mask, alloctype,
+ CustomData_merge(&mesh->pdata, &dm->polyData, cddata_masks.pmask, alloctype,
mesh->totpoly);
cddm->mvert = CustomData_get_layer(&dm->vertData, CD_MVERT);
@@ -767,7 +768,7 @@ static DerivedMesh *cddm_from_bmesh_ex(
int numCol = CustomData_number_of_layers(&bm->ldata, CD_MLOOPCOL);
int numUV = CustomData_number_of_layers(&bm->ldata, CD_MLOOPUV);
int *index, add_orig;
- CustomDataMask mask;
+ CustomData_MeshMasks mask = {0};
unsigned int i, j;
const int cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
@@ -779,18 +780,21 @@ static DerivedMesh *cddm_from_bmesh_ex(
/* don't add origindex layer if one already exists */
add_orig = !CustomData_has_layer(&bm->pdata, CD_ORIGINDEX);
- mask = use_mdisps ? CD_MASK_DERIVEDMESH | CD_MASK_MDISPS : CD_MASK_DERIVEDMESH;
+ mask = CD_MASK_DERIVEDMESH;
+ if (use_mdisps) {
+ mask.lmask |= CD_MASK_MDISPS;
+ }
/* don't process shapekeys, we only feed them through the modifier stack as needed,
* e.g. for applying modifiers or the like*/
- mask &= ~CD_MASK_SHAPEKEY;
- CustomData_merge(&bm->vdata, &dm->vertData, mask,
+ mask.vmask &= ~CD_MASK_SHAPEKEY;
+ CustomData_merge(&bm->vdata, &dm->vertData, mask.vmask,
CD_CALLOC, dm->numVertData);
- CustomData_merge(&bm->edata, &dm->edgeData, mask,
+ CustomData_merge(&bm->edata, &dm->edgeData, mask.emask,
CD_CALLOC, dm->numEdgeData);
- CustomData_merge(&bm->ldata, &dm->loopData, mask,
+ CustomData_merge(&bm->ldata, &dm->loopData, mask.lmask,
CD_CALLOC, dm->numLoopData);
- CustomData_merge(&bm->pdata, &dm->polyData, mask,
+ CustomData_merge(&bm->pdata, &dm->polyData, mask.pmask,
CD_CALLOC, dm->numPolyData);
/* add tessellation mface layers */
@@ -974,11 +978,10 @@ DerivedMesh *CDDM_copy(DerivedMesh *source)
/* note, the CD_ORIGINDEX layers are all 0, so if there is a direct
* relationship between mesh data this needs to be set by the caller. */
-DerivedMesh *CDDM_from_template_ex(
- DerivedMesh *source,
+DerivedMesh *CDDM_from_template_ex(DerivedMesh *source,
int numVerts, int numEdges, int numTessFaces,
int numLoops, int numPolys,
- CustomDataMask mask)
+ const CustomData_MeshMasks *mask)
{
CDDerivedMesh *cddm = cdDM_create("CDDM_from_template dest");
DerivedMesh *dm = &cddm->dm;
@@ -1026,7 +1029,7 @@ DerivedMesh *CDDM_from_template(
return CDDM_from_template_ex(
source, numVerts, numEdges, numTessFaces,
numLoops, numPolys,
- CD_MASK_DERIVEDMESH);
+ &CD_MASK_DERIVEDMESH);
}
void CDDM_apply_vert_coords(DerivedMesh *dm, float (*vertCoords)[3])
diff --git a/source/blender/blenkernel/intern/crazyspace.c b/source/blender/blenkernel/intern/crazyspace.c
index 270849c8ff8..3b83d7308a4 100644
--- a/source/blender/blenkernel/intern/crazyspace.c
+++ b/source/blender/blenkernel/intern/crazyspace.c
@@ -105,13 +105,13 @@ float (*BKE_crazyspace_get_mapped_editverts(
/* disable subsurf temporal, get mapped cos, and enable it */
if (modifiers_disable_subsurf_temporary(obedit)) {
/* need to make new derivemesh */
- makeDerivedMesh(depsgraph, scene, obedit, me->edit_mesh, CD_MASK_BAREMESH, false);
+ makeDerivedMesh(depsgraph, scene, obedit, me->edit_mesh, &CD_MASK_BAREMESH, false);
}
/* now get the cage */
vertexcos = MEM_mallocN(sizeof(*vertexcos) * nverts, "vertexcos map");
- me_eval = editbmesh_get_eval_cage_from_orig(depsgraph, scene, obedit, me->edit_mesh, CD_MASK_BAREMESH);
+ me_eval = editbmesh_get_eval_cage_from_orig(depsgraph, scene, obedit, me->edit_mesh, &CD_MASK_BAREMESH);
mesh_get_mapped_verts_coords(me_eval, vertexcos, nverts);
@@ -273,12 +273,12 @@ int BKE_crazyspace_get_first_deform_matrices_editbmesh(
if (mti->type == eModifierTypeType_OnlyDeform && mti->deformMatricesEM) {
if (!defmats) {
const int required_mode = eModifierMode_Realtime | eModifierMode_Editmode;
- CustomDataMask data_mask = CD_MASK_BAREMESH;
- CDMaskLink *datamasks = modifiers_calcDataMasks(scene, ob, md, data_mask, required_mode, NULL, 0);
+ CustomData_MeshMasks data_mask = CD_MASK_BAREMESH;
+ CDMaskLink *datamasks = modifiers_calcDataMasks(scene, ob, md, &data_mask, required_mode, NULL, NULL);
data_mask = datamasks->mask;
BLI_linklist_free((LinkNode *)datamasks, NULL);
- me = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, data_mask, NULL);
+ me = BKE_mesh_from_editmesh_with_coords_thin_wrap(em, &data_mask, NULL);
deformedVerts = editbmesh_get_vertex_cos(em, &numVerts);
defmats = MEM_mallocN(sizeof(*defmats) * numVerts, "defmats");
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index f4b9040ce85..c3e45480a57 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -62,6 +62,28 @@ BLI_STATIC_ASSERT(ARRAY_SIZE(((CustomData *)NULL)->typemap) == CD_NUMTYPES, "siz
static CLG_LogRef LOG = {"bke.customdata"};
+
+/** Update mask_dst with layers defined in mask_src (equivalent to a bitwise OR). */
+void CustomData_MeshMasks_update(CustomData_MeshMasks *mask_dst, const CustomData_MeshMasks *mask_src)
+{
+ mask_dst->vmask |= mask_src->vmask;
+ mask_dst->emask |= mask_src->emask;
+ mask_dst->fmask |= mask_src->fmask;
+ mask_dst->pmask |= mask_src->pmask;
+ mask_dst->lmask |= mask_src->lmask;
+}
+
+/** Return True if all layers set in \a mask_required are also set in \a mask_ref */
+bool CustomData_MeshMasks_are_matching(const CustomData_MeshMasks *mask_ref, const CustomData_MeshMasks *mask_required)
+{
+ return (((mask_required->vmask & mask_ref->vmask) == mask_required->vmask) &&
+ ((mask_required->emask & mask_ref->emask) == mask_required->emask) &&
+ ((mask_required->fmask & mask_ref->fmask) == mask_required->fmask) &&
+ ((mask_required->pmask & mask_ref->pmask) == mask_required->pmask) &&
+ ((mask_required->lmask & mask_ref->lmask) == mask_required->lmask));
+}
+
+
/********************* Layer type information **********************/
typedef struct LayerTypeInfo {
int size; /* the memory size of one element of this layer's data */
@@ -1370,59 +1392,83 @@ static const char *LAYERTYPENAMES[CD_NUMTYPES] = {
};
-const CustomDataMask CD_MASK_BAREMESH =
- CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MLOOP | CD_MASK_MPOLY | CD_MASK_BWEIGHT | CD_MASK_FACEMAP;
-const CustomDataMask CD_MASK_MESH =
- CD_MASK_MVERT | CD_MASK_MEDGE |
- CD_MASK_MDEFORMVERT |
- CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_MDISPS |
- CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MPOLY | CD_MASK_MLOOP |
- CD_MASK_RECAST | CD_MASK_PAINT_MASK |
- CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE |
- CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_FACEMAP;
-const CustomDataMask CD_MASK_EDITMESH =
- CD_MASK_MDEFORMVERT | CD_MASK_MLOOPUV |
- CD_MASK_MLOOPCOL | CD_MASK_SHAPE_KEYINDEX |
- CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR |
- CD_MASK_MDISPS | CD_MASK_SHAPEKEY | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
- CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN | CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_FACEMAP;
-const CustomDataMask CD_MASK_DERIVEDMESH =
- CD_MASK_MDEFORMVERT |
- CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_CLOTH_ORCO |
- CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_PREVIEW_MLOOPCOL |
- CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORIGSPACE_MLOOP | CD_MASK_ORCO | CD_MASK_TANGENT |
- CD_MASK_PREVIEW_MCOL | CD_MASK_SHAPEKEY | CD_MASK_RECAST |
- CD_MASK_ORIGINDEX | CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE |
- CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_FACEMAP;
-const CustomDataMask CD_MASK_BMESH =
- CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL |
- CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT |
- CD_MASK_PROP_STR | CD_MASK_SHAPEKEY | CD_MASK_SHAPE_KEYINDEX | CD_MASK_MDISPS |
- CD_MASK_CREASE | CD_MASK_BWEIGHT | CD_MASK_RECAST | CD_MASK_PAINT_MASK |
- CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE |
- CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_FACEMAP;
+const CustomData_MeshMasks CD_MASK_BAREMESH = {
+ .vmask = CD_MASK_MVERT | CD_MASK_BWEIGHT,
+ .emask = CD_MASK_MEDGE | CD_MASK_BWEIGHT,
+ .fmask = 0,
+ .lmask = CD_MASK_MLOOP,
+ .pmask = CD_MASK_MPOLY | CD_MASK_FACEMAP,
+};
+const CustomData_MeshMasks CD_MASK_BAREMESH_ORIGINDEX = {
+ .vmask = CD_MASK_MVERT | CD_MASK_BWEIGHT | CD_MASK_ORIGINDEX,
+ .emask = CD_MASK_MEDGE | CD_MASK_BWEIGHT | CD_MASK_ORIGINDEX,
+ .fmask = 0,
+ .lmask = CD_MASK_MLOOP,
+ .pmask = CD_MASK_MPOLY | CD_MASK_FACEMAP | CD_MASK_ORIGINDEX,
+};
+const CustomData_MeshMasks CD_MASK_MESH = {
+ .vmask = (CD_MASK_MVERT | CD_MASK_MDEFORMVERT | CD_MASK_BWEIGHT | CD_MASK_MVERT_SKIN | CD_MASK_PAINT_MASK |
+ CD_MASK_GENERIC_DATA),
+ .emask = (CD_MASK_MEDGE | CD_MASK_BWEIGHT | CD_MASK_FREESTYLE_EDGE | CD_MASK_GENERIC_DATA),
+ .fmask = 0,
+ .lmask = (CD_MASK_MLOOP | CD_MASK_MDISPS | CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_CUSTOMLOOPNORMAL |
+ CD_MASK_GRID_PAINT_MASK | CD_MASK_GENERIC_DATA),
+ .pmask = (CD_MASK_MPOLY | CD_MASK_RECAST | CD_MASK_FACEMAP | CD_MASK_FREESTYLE_FACE | CD_MASK_GENERIC_DATA),
+};
+const CustomData_MeshMasks CD_MASK_EDITMESH = {
+ .vmask = (CD_MASK_MDEFORMVERT | CD_MASK_PAINT_MASK | CD_MASK_MVERT_SKIN | CD_MASK_SHAPEKEY |
+ CD_MASK_SHAPE_KEYINDEX | CD_MASK_GENERIC_DATA),
+ .emask = (CD_MASK_GENERIC_DATA),
+ .fmask = 0,
+ .lmask = (CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_GRID_PAINT_MASK |
+ CD_MASK_GENERIC_DATA),
+ .pmask = (CD_MASK_MDISPS | CD_MASK_RECAST | CD_MASK_FACEMAP | CD_MASK_GENERIC_DATA),
+};
+const CustomData_MeshMasks CD_MASK_DERIVEDMESH = {
+ .vmask = (CD_MASK_ORIGINDEX | CD_MASK_MDEFORMVERT | CD_MASK_SHAPEKEY | CD_MASK_MVERT_SKIN |
+ CD_MASK_ORCO | CD_MASK_CLOTH_ORCO | CD_MASK_GENERIC_DATA),
+ .emask = (CD_MASK_ORIGINDEX | CD_MASK_FREESTYLE_EDGE | CD_MASK_GENERIC_DATA),
+ .fmask = (CD_MASK_ORIGINDEX | CD_MASK_ORIGSPACE | CD_MASK_PREVIEW_MCOL | CD_MASK_TANGENT),
+ .lmask = (CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_PREVIEW_MLOOPCOL |
+ CD_MASK_ORIGSPACE_MLOOP | CD_MASK_TANGENT | CD_MASK_GENERIC_DATA),
+ .pmask = (CD_MASK_ORIGINDEX | CD_MASK_RECAST | CD_MASK_FREESTYLE_FACE | CD_MASK_FACEMAP | CD_MASK_GENERIC_DATA),
+};
+const CustomData_MeshMasks CD_MASK_BMESH = {
+ .vmask = (CD_MASK_MDEFORMVERT | CD_MASK_BWEIGHT | CD_MASK_MVERT_SKIN | CD_MASK_SHAPEKEY |
+ CD_MASK_SHAPE_KEYINDEX | CD_MASK_PAINT_MASK | CD_MASK_GENERIC_DATA),
+ .emask = (CD_MASK_BWEIGHT | CD_MASK_CREASE | CD_MASK_FREESTYLE_EDGE | CD_MASK_GENERIC_DATA),
+ .fmask = 0,
+ .lmask = (CD_MASK_MDISPS | CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_CUSTOMLOOPNORMAL |
+ CD_MASK_GRID_PAINT_MASK | CD_MASK_GENERIC_DATA),
+ .pmask = (CD_MASK_RECAST | CD_MASK_FREESTYLE_FACE | CD_MASK_FACEMAP | CD_MASK_GENERIC_DATA),
+};
/**
* cover values copied by #BKE_mesh_loops_to_tessdata
*/
-const CustomDataMask CD_MASK_FACECORNERS =
- CD_MASK_MTFACE | CD_MASK_MLOOPUV |
- CD_MASK_MCOL | CD_MASK_MLOOPCOL |
- CD_MASK_PREVIEW_MCOL | CD_MASK_PREVIEW_MLOOPCOL |
- CD_MASK_ORIGSPACE | CD_MASK_ORIGSPACE_MLOOP |
- CD_MASK_TESSLOOPNORMAL | CD_MASK_NORMAL |
- CD_MASK_TANGENT | CD_MASK_MLOOPTANGENT;
-const CustomDataMask CD_MASK_EVERYTHING =
- CD_MASK_MVERT | CD_MASK_MDEFORMVERT | CD_MASK_MEDGE | CD_MASK_MFACE |
- CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_ORIGINDEX | CD_MASK_NORMAL /* | CD_MASK_POLYINDEX */ | CD_MASK_PROP_FLT |
- CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_ORIGSPACE | CD_MASK_ORCO | CD_MASK_MLOOPUV |
- CD_MASK_MLOOPCOL | CD_MASK_TANGENT | CD_MASK_MDISPS | CD_MASK_PREVIEW_MCOL | CD_MASK_CLOTH_ORCO | CD_MASK_RECAST |
- /* BMESH ONLY START */
- CD_MASK_MPOLY | CD_MASK_MLOOP | CD_MASK_SHAPE_KEYINDEX | CD_MASK_SHAPEKEY | CD_MASK_BWEIGHT | CD_MASK_CREASE |
- CD_MASK_ORIGSPACE_MLOOP | CD_MASK_PREVIEW_MLOOPCOL | CD_MASK_BM_ELEM_PYPTR |
- /* BMESH ONLY END */
- CD_MASK_PAINT_MASK | CD_MASK_GRID_PAINT_MASK | CD_MASK_MVERT_SKIN |
- CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE |
- CD_MASK_MLOOPTANGENT | CD_MASK_TESSLOOPNORMAL | CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_FACEMAP;
+const CustomData_MeshMasks CD_MASK_FACECORNERS = {
+ .vmask = 0,
+ .emask = 0,
+ .fmask = (CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_PREVIEW_MCOL | CD_MASK_ORIGSPACE |
+ CD_MASK_TESSLOOPNORMAL | CD_MASK_TANGENT),
+ .lmask = (CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_PREVIEW_MLOOPCOL | CD_MASK_ORIGSPACE_MLOOP |
+ CD_MASK_NORMAL | CD_MASK_MLOOPTANGENT),
+ .pmask = 0,
+};
+const CustomData_MeshMasks CD_MASK_EVERYTHING = {
+ .vmask = (CD_MASK_MVERT | CD_MASK_BM_ELEM_PYPTR | CD_MASK_ORIGINDEX | CD_MASK_NORMAL | CD_MASK_MDEFORMVERT |
+ CD_MASK_BWEIGHT | CD_MASK_MVERT_SKIN | CD_MASK_ORCO | CD_MASK_CLOTH_ORCO | CD_MASK_SHAPEKEY |
+ CD_MASK_SHAPE_KEYINDEX | CD_MASK_PAINT_MASK | CD_MASK_GENERIC_DATA),
+ .emask = (CD_MASK_MEDGE | CD_MASK_BM_ELEM_PYPTR | CD_MASK_ORIGINDEX | CD_MASK_BWEIGHT | CD_MASK_CREASE |
+ CD_MASK_FREESTYLE_EDGE | CD_MASK_GENERIC_DATA),
+ .fmask = (CD_MASK_MFACE | CD_MASK_ORIGINDEX | CD_MASK_NORMAL | CD_MASK_MTFACE | CD_MASK_MCOL |
+ CD_MASK_ORIGSPACE | CD_MASK_TANGENT | CD_MASK_TESSLOOPNORMAL | CD_MASK_PREVIEW_MCOL |
+ CD_MASK_GENERIC_DATA),
+ .lmask = (CD_MASK_MLOOP | CD_MASK_BM_ELEM_PYPTR | CD_MASK_MDISPS | CD_MASK_NORMAL | CD_MASK_MLOOPUV |
+ CD_MASK_MLOOPCOL | CD_MASK_CUSTOMLOOPNORMAL | CD_MASK_MLOOPTANGENT | CD_MASK_PREVIEW_MLOOPCOL |
+ CD_MASK_ORIGSPACE_MLOOP | CD_MASK_GRID_PAINT_MASK | CD_MASK_GENERIC_DATA),
+ .pmask = (CD_MASK_MPOLY | CD_MASK_BM_ELEM_PYPTR | CD_MASK_ORIGINDEX | CD_MASK_NORMAL | CD_MASK_RECAST |
+ CD_MASK_FACEMAP | CD_MASK_FREESTYLE_FACE | CD_MASK_GENERIC_DATA),
+};
static const LayerTypeInfo *layerType_getInfo(int type)
{
@@ -1438,13 +1484,41 @@ static const char *layerType_getName(int type)
return LAYERTYPENAMES[type];
}
-void customData_mask_layers__print(CustomDataMask mask)
+void customData_mask_layers__print(const CustomData_MeshMasks *mask)
{
int i;
- printf("mask=0x%lx:\n", (long unsigned int)mask);
+ printf("verts mask=0x%lx:\n", (long unsigned int)mask->vmask);
+ for (i = 0; i < CD_NUMTYPES; i++) {
+ if (mask->vmask & CD_TYPE_AS_MASK(i)) {
+ printf(" %s\n", layerType_getName(i));
+ }
+ }
+
+ printf("edges mask=0x%lx:\n", (long unsigned int)mask->emask);
+ for (i = 0; i < CD_NUMTYPES; i++) {
+ if (mask->emask & CD_TYPE_AS_MASK(i)) {
+ printf(" %s\n", layerType_getName(i));
+ }
+ }
+
+ printf("faces mask=0x%lx:\n", (long unsigned int)mask->fmask);
+ for (i = 0; i < CD_NUMTYPES; i++) {
+ if (mask->fmask & CD_TYPE_AS_MASK(i)) {
+ printf(" %s\n", layerType_getName(i));
+ }
+ }
+
+ printf("loops mask=0x%lx:\n", (long unsigned int)mask->lmask);
+ for (i = 0; i < CD_NUMTYPES; i++) {
+ if (mask->lmask & CD_TYPE_AS_MASK(i)) {
+ printf(" %s\n", layerType_getName(i));
+ }
+ }
+
+ printf("polys mask=0x%lx:\n", (long unsigned int)mask->pmask);
for (i = 0; i < CD_NUMTYPES; i++) {
- if (mask & CD_TYPE_AS_MASK(i)) {
+ if (mask->pmask & CD_TYPE_AS_MASK(i)) {
printf(" %s\n", layerType_getName(i));
}
}
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index 2f011d6a919..4c4d57ddbac 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -51,12 +51,9 @@
static CLG_LogRef LOG = {"bke.data_transfer"};
-CustomDataMask BKE_object_data_transfer_dttypes_to_cdmask(const int dtdata_types)
+void BKE_object_data_transfer_dttypes_to_cdmask(const int dtdata_types, CustomData_MeshMasks *r_data_masks)
{
- CustomDataMask cddata_mask = 0;
- int i;
-
- for (i = 0; i < DT_TYPE_MAX; i++) {
+ for (int i = 0; i < DT_TYPE_MAX; i++) {
const int dtdata_type = 1 << i;
int cddata_type;
@@ -66,20 +63,30 @@ CustomDataMask BKE_object_data_transfer_dttypes_to_cdmask(const int dtdata_types
cddata_type = BKE_object_data_transfer_dttype_to_cdtype(dtdata_type);
if (!(cddata_type & CD_FAKE)) {
- cddata_mask |= 1LL << cddata_type;
+ if (DT_DATATYPE_IS_VERT(dtdata_type)) {
+ r_data_masks->vmask |= 1LL << cddata_type;
+ }
+ else if (DT_DATATYPE_IS_EDGE(dtdata_type)) {
+ r_data_masks->emask |= 1LL << cddata_type;
+ }
+ else if (DT_DATATYPE_IS_LOOP(dtdata_type)) {
+ r_data_masks->lmask |= 1LL << cddata_type;
+ }
+ else if (DT_DATATYPE_IS_POLY(dtdata_type)) {
+ r_data_masks->pmask |= 1LL << cddata_type;
+ }
}
else if (cddata_type == CD_FAKE_MDEFORMVERT) {
- cddata_mask |= CD_MASK_MDEFORMVERT; /* Exception for vgroups :/ */
+ r_data_masks->vmask |= CD_MASK_MDEFORMVERT; /* Exception for vgroups :/ */
}
else if (cddata_type == CD_FAKE_UV) {
- cddata_mask |= CD_MASK_MLOOPUV;
+ r_data_masks->lmask |= CD_MASK_MLOOPUV;
}
else if (cddata_type == CD_FAKE_LNOR) {
- cddata_mask |= CD_MASK_NORMAL | CD_MASK_CUSTOMLOOPNORMAL;
+ r_data_masks->vmask |= CD_MASK_NORMAL;
+ r_data_masks->lmask |= CD_MASK_NORMAL | CD_MASK_CUSTOMLOOPNORMAL;
}
}
-
- return cddata_mask;
}
/* Check what can do each layer type (if it is actually handled by transferdata, if it supports advanced mixing... */
@@ -992,15 +999,15 @@ void BKE_object_data_transfer_layout(
const bool use_create = true; /* We always create needed layers here. */
- CustomDataMask me_src_mask = CD_MASK_BAREMESH;
+ CustomData_MeshMasks me_src_mask = CD_MASK_BAREMESH;
BLI_assert((ob_src != ob_dst) && (ob_src->type == OB_MESH) && (ob_dst->type == OB_MESH));
me_dst = ob_dst->data;
/* Get source evaluated mesh.*/
- me_src_mask |= BKE_object_data_transfer_dttypes_to_cdmask(data_types);
- me_src = mesh_get_eval_final(depsgraph, scene, ob_src, me_src_mask);
+ BKE_object_data_transfer_dttypes_to_cdmask(data_types, &me_src_mask);
+ me_src = mesh_get_eval_final(depsgraph, scene, ob_src, &me_src_mask);
if (!me_src) {
return;
}
@@ -1090,7 +1097,7 @@ bool BKE_object_data_transfer_ex(
const bool use_delete = false; /* We never delete data layers from destination here. */
- CustomDataMask me_src_mask = CD_MASK_BAREMESH;
+ CustomData_MeshMasks me_src_mask = CD_MASK_BAREMESH;
BLI_assert((ob_src != ob_dst) && (ob_src->type == OB_MESH) && (ob_dst->type == OB_MESH));
@@ -1113,17 +1120,17 @@ bool BKE_object_data_transfer_ex(
}
/* Get source evaluated mesh.*/
- me_src_mask |= BKE_object_data_transfer_dttypes_to_cdmask(data_types);
+ BKE_object_data_transfer_dttypes_to_cdmask(data_types, &me_src_mask);
if (is_modifier) {
me_src = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_src, false);
- if (me_src == NULL || (me_src_mask & ~ob_src->runtime.last_data_mask) != 0) {
+ if (me_src == NULL || !CustomData_MeshMasks_are_matching(&ob_src->runtime.last_data_mask, &me_src_mask)) {
CLOG_WARN(&LOG, "Data Transfer: source mesh data is not ready - dependency cycle?");
return changed;
}
}
else {
- me_src = mesh_get_eval_final(depsgraph, scene, ob_src, me_src_mask);
+ me_src = mesh_get_eval_final(depsgraph, scene, ob_src, &me_src_mask);
}
if (!me_src) {
return changed;
diff --git a/source/blender/blenkernel/intern/editderivedmesh.c b/source/blender/blenkernel/intern/editderivedmesh.c
index ddb4b9eb211..c46691901f0 100644
--- a/source/blender/blenkernel/intern/editderivedmesh.c
+++ b/source/blender/blenkernel/intern/editderivedmesh.c
@@ -526,7 +526,7 @@ float (*BKE_editmesh_vertexCos_get(struct Depsgraph *depsgraph, BMEditMesh *em,
struct CageUserData data;
float (*cos_cage)[3];
- cage = editbmesh_get_eval_cage(depsgraph, scene, em->ob, em, CD_MASK_BAREMESH);
+ cage = editbmesh_get_eval_cage(depsgraph, scene, em->ob, em, &CD_MASK_BAREMESH);
cos_cage = MEM_callocN(sizeof(*cos_cage) * em->bm->totvert, "bmbvh cos_cage");
/* when initializing cage verts, we only want the first cage coordinate for each vertex,
diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c
index 70f021c57f4..2263c5f1a05 100644
--- a/source/blender/blenkernel/intern/fluidsim.c
+++ b/source/blender/blenkernel/intern/fluidsim.c
@@ -54,7 +54,7 @@ void initElbeemMesh(struct Depsgraph *depsgraph, struct Scene *scene, struct Obj
float *verts;
int *tris;
- mesh = mesh_create_eval_final_index_render(depsgraph, scene, ob, CD_MASK_BAREMESH, modifierIndex);
+ mesh = mesh_create_eval_final_index_render(depsgraph, scene, ob, &CD_MASK_BAREMESH, modifierIndex);
mvert = mesh->mvert;
mloop = mesh->mloop;
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index a05ba2bb35f..592f3a26a12 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -535,22 +535,22 @@ void BKE_mesh_copy_data(Main *bmain, Mesh *me_dst, const Mesh *me_src, const int
me_dst->runtime.is_original = false;
const bool do_tessface = ((me_src->totface != 0) && (me_src->totpoly == 0)); /* only do tessface if we have no polys */
- CustomDataMask mask = CD_MASK_MESH;
+ CustomData_MeshMasks mask = CD_MASK_MESH;
if (me_src->id.tag & LIB_TAG_NO_MAIN) {
/* For copies in depsgraph, keep data like origindex and orco. */
- mask |= CD_MASK_DERIVEDMESH;
+ CustomData_MeshMasks_update(&mask, &CD_MASK_DERIVEDMESH);
}
me_dst->mat = MEM_dupallocN(me_src->mat);
const eCDAllocType alloc_type = (flag & LIB_ID_COPY_CD_REFERENCE) ? CD_REFERENCE : CD_DUPLICATE;
- CustomData_copy(&me_src->vdata, &me_dst->vdata, mask, alloc_type, me_dst->totvert);
- CustomData_copy(&me_src->edata, &me_dst->edata, mask, alloc_type, me_dst->totedge);
- CustomData_copy(&me_src->ldata, &me_dst->ldata, mask, alloc_type, me_dst->totloop);
- CustomData_copy(&me_src->pdata, &me_dst->pdata, mask, alloc_type, me_dst->totpoly);
+ CustomData_copy(&me_src->vdata, &me_dst->vdata, mask.vmask, alloc_type, me_dst->totvert);
+ CustomData_copy(&me_src->edata, &me_dst->edata, mask.emask, alloc_type, me_dst->totedge);
+ CustomData_copy(&me_src->ldata, &me_dst->ldata, mask.lmask, alloc_type, me_dst->totloop);
+ CustomData_copy(&me_src->pdata, &me_dst->pdata, mask.pmask, alloc_type, me_dst->totpoly);
if (do_tessface) {
- CustomData_copy(&me_src->fdata, &me_dst->fdata, mask, alloc_type, me_dst->totface);
+ CustomData_copy(&me_src->fdata, &me_dst->fdata, mask.fmask, alloc_type, me_dst->totface);
}
else {
mesh_tessface_clear_intern(me_dst, false);
@@ -629,7 +629,7 @@ static Mesh *mesh_new_nomain_from_template_ex(
const Mesh *me_src,
int verts_len, int edges_len, int tessface_len,
int loops_len, int polys_len,
- CustomDataMask mask)
+ CustomData_MeshMasks mask)
{
/* Only do tessface if we are creating tessfaces or copying from mesh with only tessfaces. */
const bool do_tessface = (tessface_len ||
@@ -648,12 +648,12 @@ static Mesh *mesh_new_nomain_from_template_ex(
me_dst->cd_flag = me_src->cd_flag;
- CustomData_copy(&me_src->vdata, &me_dst->vdata, mask, CD_CALLOC, verts_len);
- CustomData_copy(&me_src->edata, &me_dst->edata, mask, CD_CALLOC, edges_len);
- CustomData_copy(&me_src->ldata, &me_dst->ldata, mask, CD_CALLOC, loops_len);
- CustomData_copy(&me_src->pdata, &me_dst->pdata, mask, CD_CALLOC, polys_len);
+ 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);
if (do_tessface) {
- CustomData_copy(&me_src->fdata, &me_dst->fdata, mask, CD_CALLOC, tessface_len);
+ CustomData_copy(&me_src->fdata, &me_dst->fdata, mask.fmask, CD_CALLOC, tessface_len);
}
else {
mesh_tessface_clear_intern(me_dst, false);
@@ -736,7 +736,7 @@ Mesh *BKE_mesh_from_bmesh_nomain(BMesh *bm, const struct BMeshToMeshParams *para
return mesh;
}
-Mesh *BKE_mesh_from_bmesh_for_eval_nomain(BMesh *bm, const int64_t cd_mask_extra)
+Mesh *BKE_mesh_from_bmesh_for_eval_nomain(BMesh *bm, const CustomData_MeshMasks *cd_mask_extra)
{
Mesh *mesh = BKE_id_new_nomain(ID_ME, NULL);
BM_mesh_bm_to_me_for_eval(bm, mesh, cd_mask_extra);
@@ -747,7 +747,7 @@ Mesh *BKE_mesh_from_bmesh_for_eval_nomain(BMesh *bm, const int64_t cd_mask_extra
* TODO(campbell): support mesh with only an edit-mesh which is lazy initialized.
*/
Mesh *BKE_mesh_from_editmesh_with_coords_thin_wrap(
- BMEditMesh *em, CustomDataMask data_mask, float (*vertexCos)[3])
+ BMEditMesh *em, const CustomData_MeshMasks *data_mask, float (*vertexCos)[3])
{
Mesh *me = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, data_mask);
/* Use editmesh directly where possible. */
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c
index 5831471eb05..ad60cb9c49d 100644
--- a/source/blender/blenkernel/intern/mesh_convert.c
+++ b/source/blender/blenkernel/intern/mesh_convert.c
@@ -592,7 +592,7 @@ void BKE_mesh_from_nurbs_displist(
else {
me = BKE_mesh_add(bmain, obdata_name);
ob->runtime.mesh_eval = NULL;
- BKE_mesh_nomain_to_mesh(me_eval, me, ob, CD_MASK_MESH, false);
+ BKE_mesh_nomain_to_mesh(me_eval, me, ob, &CD_MASK_MESH, false);
}
me->totcol = cu->totcol;
@@ -817,7 +817,7 @@ void BKE_mesh_to_curve(Main *bmain, Depsgraph *depsgraph, Scene *UNUSED(scene),
/* make new mesh data from the original copy */
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_MESH);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_MESH);
ListBase nurblist = {NULL, NULL};
BKE_mesh_to_curve_nurblist(me_eval, &nurblist, 0);
@@ -981,22 +981,22 @@ Mesh *BKE_mesh_new_from_object(
else {
/* Make a dummy mesh, saves copying */
Mesh *me_eval;
- /* CustomDataMask mask = CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL; */
- CustomDataMask mask = CD_MASK_MESH; /* this seems more suitable, exporter,
- * for example, needs CD_MASK_MDEFORMVERT */
+ CustomData_MeshMasks mask = CD_MASK_MESH; /* this seems more suitable, exporter,
+ * for example, needs CD_MASK_MDEFORMVERT */
- if (calc_undeformed)
- mask |= CD_MASK_ORCO;
+ if (calc_undeformed) {
+ mask.vmask |= CD_MASK_ORCO;
+ }
if (render) {
- me_eval = mesh_create_eval_final_render(depsgraph, sce, ob, mask);
+ me_eval = mesh_create_eval_final_render(depsgraph, sce, ob, &mask);
}
else {
- me_eval = mesh_create_eval_final_view(depsgraph, sce, ob, mask);
+ me_eval = mesh_create_eval_final_view(depsgraph, sce, ob, &mask);
}
tmpmesh = BKE_mesh_add(bmain, ((ID *)ob->data)->name + 2);
- BKE_mesh_nomain_to_mesh(me_eval, tmpmesh, ob, mask, true);
+ BKE_mesh_nomain_to_mesh(me_eval, tmpmesh, ob, &mask, true);
/* Copy autosmooth settings from original mesh. */
Mesh *me = (Mesh *)ob->data;
@@ -1228,7 +1228,8 @@ static void shapekey_layers_to_keyblocks(Mesh *mesh_src, Mesh *mesh_dst, int act
/* This is a Mesh-based copy of DM_to_mesh() */
-void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, CustomDataMask mask, bool take_ownership)
+void BKE_mesh_nomain_to_mesh(
+ Mesh *mesh_src, Mesh *mesh_dst, Object *ob, const CustomData_MeshMasks *mask, bool take_ownership)
{
/* mesh_src might depend on mesh_dst, so we need to do everything with a local copy */
/* TODO(Sybren): the above claim came from DM_to_mesh(); check whether it is still true with Mesh */
@@ -1262,10 +1263,10 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, CustomD
totpoly = tmp.totpoly = mesh_src->totpoly;
tmp.totface = 0;
- CustomData_copy(&mesh_src->vdata, &tmp.vdata, mask, alloctype, totvert);
- CustomData_copy(&mesh_src->edata, &tmp.edata, mask, alloctype, totedge);
- CustomData_copy(&mesh_src->ldata, &tmp.ldata, mask, alloctype, totloop);
- CustomData_copy(&mesh_src->pdata, &tmp.pdata, mask, alloctype, totpoly);
+ CustomData_copy(&mesh_src->vdata, &tmp.vdata, mask->vmask, alloctype, totvert);
+ CustomData_copy(&mesh_src->edata, &tmp.edata, mask->emask, alloctype, totedge);
+ CustomData_copy(&mesh_src->ldata, &tmp.ldata, mask->lmask, alloctype, totloop);
+ CustomData_copy(&mesh_src->pdata, &tmp.pdata, mask->pmask, alloctype, totpoly);
tmp.cd_flag = mesh_src->cd_flag;
tmp.runtime.deformed_only = mesh_src->runtime.deformed_only;
@@ -1370,10 +1371,10 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, CustomD
if (take_ownership) {
if (alloctype == CD_ASSIGN) {
- CustomData_free_typemask(&mesh_src->vdata, mesh_src->totvert, ~mask);
- CustomData_free_typemask(&mesh_src->edata, mesh_src->totedge, ~mask);
- CustomData_free_typemask(&mesh_src->ldata, mesh_src->totloop, ~mask);
- CustomData_free_typemask(&mesh_src->pdata, mesh_src->totpoly, ~mask);
+ CustomData_free_typemask(&mesh_src->vdata, mesh_src->totvert, ~mask->vmask);
+ CustomData_free_typemask(&mesh_src->edata, mesh_src->totedge, ~mask->emask);
+ CustomData_free_typemask(&mesh_src->ldata, mesh_src->totloop, ~mask->lmask);
+ CustomData_free_typemask(&mesh_src->pdata, mesh_src->totpoly, ~mask->pmask);
}
BKE_id_free(NULL, mesh_src);
}
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index 29879be3d45..a5aa198bc4e 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -40,6 +40,7 @@
#include "BLI_math_base.h"
#include "BLI_math_vector.h"
+#include "BKE_customdata.h"
#include "BKE_deform.h"
#include "BKE_mesh.h"
@@ -888,12 +889,15 @@ bool BKE_mesh_validate_all_customdata(
bool is_valid = true;
bool is_change_v, is_change_e, is_change_l, is_change_p;
int tot_uvloop, tot_vcolloop;
- CustomDataMask mask = check_meshmask ? CD_MASK_MESH : 0;
+ CustomData_MeshMasks mask = {0};
+ if (check_meshmask) {
+ mask = CD_MASK_MESH;
+ }
- is_valid &= mesh_validate_customdata(vdata, mask, totvert, do_verbose, do_fixes, &is_change_v);
- is_valid &= mesh_validate_customdata(edata, mask, totedge, do_verbose, do_fixes, &is_change_e);
- is_valid &= mesh_validate_customdata(ldata, mask, totloop, do_verbose, do_fixes, &is_change_l);
- is_valid &= mesh_validate_customdata(pdata, mask, totpoly, do_verbose, do_fixes, &is_change_p);
+ is_valid &= mesh_validate_customdata(vdata, mask.vmask, totvert, do_verbose, do_fixes, &is_change_v);
+ is_valid &= mesh_validate_customdata(edata, mask.emask, totedge, do_verbose, do_fixes, &is_change_e);
+ is_valid &= mesh_validate_customdata(ldata, mask.lmask, totloop, do_verbose, do_fixes, &is_change_l);
+ is_valid &= mesh_validate_customdata(pdata, mask.pmask, totpoly, do_verbose, do_fixes, &is_change_p);
tot_uvloop = CustomData_number_of_layers(ldata, CD_MLOOPUV);
tot_vcolloop = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index ab5e2eaf491..189bd8623c4 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -478,8 +478,8 @@ bool modifier_isEnabled(const struct Scene *scene, ModifierData *md, int require
}
CDMaskLink *modifiers_calcDataMasks(struct Scene *scene, Object *ob, ModifierData *md,
- CustomDataMask dataMask, int required_mode,
- ModifierData *previewmd, CustomDataMask previewmask)
+ const CustomData_MeshMasks *dataMask, int required_mode,
+ ModifierData *previewmd, const CustomData_MeshMasks *previewmask)
{
CDMaskLink *dataMasks = NULL;
CDMaskLink *curr, *prev;
@@ -492,10 +492,10 @@ CDMaskLink *modifiers_calcDataMasks(struct Scene *scene, Object *ob, ModifierDat
if (modifier_isEnabled(scene, md, required_mode)) {
if (mti->requiredDataMask)
- curr->mask = mti->requiredDataMask(ob, md);
+ mti->requiredDataMask(ob, md, &curr->mask);
- if (previewmd == md) {
- curr->mask |= previewmask;
+ if (previewmd == md && previewmask != NULL) {
+ CustomData_MeshMasks_update(&curr->mask, previewmask);
}
}
@@ -512,15 +512,10 @@ CDMaskLink *modifiers_calcDataMasks(struct Scene *scene, Object *ob, ModifierDat
*/
for (curr = dataMasks, prev = NULL; curr; prev = curr, curr = curr->next) {
if (prev) {
- CustomDataMask prev_mask = prev->mask;
- CustomDataMask curr_mask = curr->mask;
-
- curr->mask = curr_mask | prev_mask;
+ CustomData_MeshMasks_update(&curr->mask, &prev->mask);
}
else {
- CustomDataMask curr_mask = curr->mask;
-
- curr->mask = curr_mask | dataMask;
+ CustomData_MeshMasks_update(&curr->mask, dataMask);
}
}
@@ -877,13 +872,13 @@ struct DerivedMesh *modifier_applyModifier_DM_deprecated(
Mesh *mesh = NULL;
if (dm != NULL) {
mesh = BKE_id_new_nomain(ID_ME, NULL);
- DM_to_mesh(dm, mesh, ctx->object, CD_MASK_EVERYTHING, false);
+ DM_to_mesh(dm, mesh, ctx->object, &CD_MASK_EVERYTHING, false);
}
struct Mesh *new_mesh = mti->applyModifier(md, ctx, mesh);
/* Make a DM that doesn't reference new_mesh so we can free the latter. */
- DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE, CD_MASK_EVERYTHING);
+ DerivedMesh *ndm = CDDM_from_mesh_ex(new_mesh, CD_DUPLICATE, &CD_MASK_EVERYTHING);
if (new_mesh != mesh) {
BKE_id_free(NULL, new_mesh);
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 422ce5ae19b..774fde0af7d 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -280,7 +280,7 @@ Mesh *BKE_multires_create_mesh(
Object *ob)
{
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- Mesh *deformed_mesh = mesh_get_eval_deform(depsgraph, scene, ob_eval, CD_MASK_BAREMESH);
+ Mesh *deformed_mesh = mesh_get_eval_deform(depsgraph, scene, ob_eval, &CD_MASK_BAREMESH);
ModifierEvalContext modifier_ctx = {
.depsgraph = depsgraph,
.object = ob_eval,
@@ -759,7 +759,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Scene *scene, Object
/* generate highest level with displacements */
cddm = CDDM_from_mesh(me);
- DM_set_only_copy(cddm, CD_MASK_BAREMESH);
+ DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
dispdm = multires_dm_create_local(scene, ob, cddm, totlvl, totlvl, 0, 0, MULTIRES_IGNORE_SIMPLIFY);
cddm->release(cddm);
@@ -855,7 +855,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Scene *scene, Object
/* subdivide the mesh to highest level without displacements */
cddm = CDDM_from_mesh(me);
- DM_set_only_copy(cddm, CD_MASK_BAREMESH);
+ DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
origdm = subsurf_dm_create_local(
scene, ob, cddm, totlvl, 0, 0, mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE,
0, false, SUBSURF_IGNORE_SIMPLIFY);
@@ -898,7 +898,7 @@ static void multires_subdivide(
/* create subsurf DM from original mesh at high level */
cddm = CDDM_from_mesh(me);
- DM_set_only_copy(cddm, CD_MASK_BAREMESH);
+ DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
highdm = subsurf_dm_create_local(
NULL, ob, cddm, totlvl, simple, 0, mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE,
has_mask, false, SUBSURF_IGNORE_SIMPLIFY);
@@ -1220,7 +1220,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm, Scene *scene)
/* create subsurf DM from original mesh at high level */
if (ob->derivedDeform) cddm = CDDM_copy(ob->derivedDeform);
else cddm = CDDM_from_mesh(me);
- DM_set_only_copy(cddm, CD_MASK_BAREMESH);
+ DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
highdm = subsurf_dm_create_local(
scene, ob, cddm, totlvl, mmd->simple, 0, mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE,
@@ -1284,7 +1284,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm, Scene *scene)
if (ob->derivedDeform) cddm = CDDM_copy(ob->derivedDeform);
else cddm = CDDM_from_mesh(me);
- DM_set_only_copy(cddm, CD_MASK_BAREMESH);
+ DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
subdm = subsurf_dm_create_local(
scene, ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE,
diff --git a/source/blender/blenkernel/intern/multires_reshape.c b/source/blender/blenkernel/intern/multires_reshape.c
index a1253d65294..019757cc75a 100644
--- a/source/blender/blenkernel/intern/multires_reshape.c
+++ b/source/blender/blenkernel/intern/multires_reshape.c
@@ -861,7 +861,7 @@ static Subdiv *multires_create_subdiv_for_reshape(
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
Mesh *deformed_mesh = mesh_get_eval_deform(
- depsgraph, scene_eval, object_eval, CD_MASK_BAREMESH);
+ depsgraph, scene_eval, object_eval, &CD_MASK_BAREMESH);
SubdivSettings subdiv_settings;
BKE_multires_subdiv_settings_init(&subdiv_settings, mmd);
Subdiv *subdiv = BKE_subdiv_new_from_mesh(&subdiv_settings, deformed_mesh);
@@ -965,7 +965,7 @@ bool multiresModifier_reshapeFromObject(
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *src_eval = DEG_get_evaluated_object(depsgraph, src);
Mesh *src_mesh_eval = mesh_get_eval_final(
- depsgraph, scene_eval, src_eval, CD_MASK_BAREMESH);
+ depsgraph, scene_eval, src_eval, &CD_MASK_BAREMESH);
int num_deformed_verts;
float (*deformed_verts)[3] = BKE_mesh_vertexCos_get(
src_mesh_eval, &num_deformed_verts);
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 60cf4d1b1d4..304c9985f10 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -168,18 +168,20 @@ void BKE_object_handle_data_update(
}
#endif
- uint64_t data_mask = scene->customdata_mask | CD_MASK_BAREMESH;
+ CustomData_MeshMasks cddata_masks = scene->customdata_mask;
+ CustomData_MeshMasks_update(&cddata_masks, &CD_MASK_BAREMESH);
#ifdef WITH_FREESTYLE
/* make sure Freestyle edge/face marks appear in DM for render (see T40315) */
if (DEG_get_mode(depsgraph) != DAG_EVAL_VIEWPORT) {
- data_mask |= CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE;
+ cddata_masks.emask |= CD_MASK_FREESTYLE_EDGE;
+ cddata_masks.pmask |= CD_MASK_FREESTYLE_FACE;
}
#endif
if (em) {
- makeDerivedMesh(depsgraph, scene, ob, em, data_mask, false); /* was CD_MASK_BAREMESH */
+ makeDerivedMesh(depsgraph, scene, ob, em, &cddata_masks, false); /* was CD_MASK_BAREMESH */
}
else {
- makeDerivedMesh(depsgraph, scene, ob, NULL, data_mask, false);
+ makeDerivedMesh(depsgraph, scene, ob, NULL, &cddata_masks, false);
}
break;
}
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 2977a8bed16..b3999e61216 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1100,7 +1100,7 @@ void BKE_sculpt_update_mesh_elements(
ss->kb = (mmd == NULL) ? BKE_keyblock_from_object(ob) : NULL;
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob_eval, CD_MASK_BAREMESH);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob_eval, &CD_MASK_BAREMESH);
/* VWPaint require mesh info for loop lookup, so require sculpt mode here */
if (mmd && ob->mode & OB_MODE_SCULPT) {
@@ -1397,7 +1397,7 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob)
}
else if (ob->type == OB_MESH) {
Mesh *me_eval_deform = mesh_get_eval_deform(
- depsgraph, DEG_get_evaluated_scene(depsgraph), object_eval, CD_MASK_BAREMESH);
+ depsgraph, DEG_get_evaluated_scene(depsgraph), object_eval, &CD_MASK_BAREMESH);
pbvh = build_pbvh_from_regular_mesh(ob, me_eval_deform);
}
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 3146e3f9fd2..da2975d8efc 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -1625,39 +1625,40 @@ static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index),
/* Particles on emitter */
/************************************************/
-CustomDataMask psys_emitter_customdata_mask(ParticleSystem *psys)
+void psys_emitter_customdata_mask(ParticleSystem *psys, CustomData_MeshMasks *r_cddata_masks)
{
- CustomDataMask dataMask = 0;
MTex *mtex;
int i;
if (!psys->part)
- return 0;
+ return;
for (i = 0; i < MAX_MTEX; i++) {
mtex = psys->part->mtex[i];
if (mtex && mtex->mapto && (mtex->texco & TEXCO_UV))
- dataMask |= CD_MASK_MTFACE;
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
}
if (psys->part->tanfac != 0.0f)
- dataMask |= CD_MASK_MTFACE;
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
/* ask for vertexgroups if we need them */
for (i = 0; i < PSYS_TOT_VG; i++) {
if (psys->vgroup[i]) {
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
break;
}
}
/* particles only need this if they are after a non deform modifier, and
* the modifier stack will only create them in that case. */
- dataMask |= CD_MASK_ORIGSPACE_MLOOP | CD_MASK_ORIGINDEX;
-
- dataMask |= CD_MASK_ORCO;
+ r_cddata_masks->lmask |= CD_MASK_ORIGSPACE_MLOOP;
+ /* XXX Check we do need all those? */
+ r_cddata_masks->vmask |= CD_MASK_ORIGINDEX;
+ r_cddata_masks->emask |= CD_MASK_ORIGINDEX;
+ r_cddata_masks->pmask |= CD_MASK_ORIGINDEX;
- return dataMask;
+ r_cddata_masks->vmask |= CD_MASK_ORCO;
}
void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int index, int index_dmcache,
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 6947270d88e..7dc772576c5 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -18,16 +18,17 @@
* \ingroup bli
*/
-#include "DNA_meshdata_types.h"
-
#include "MEM_guardedalloc.h"
+#include "BLI_utildefines.h"
+
#include "BLI_bitmap.h"
#include "BLI_math.h"
-#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "BLI_task.h"
+#include "DNA_meshdata_types.h"
+
#include "BKE_pbvh.h"
#include "BKE_ccg.h"
#include "BKE_subsurf.h"
diff --git a/source/blender/blenkernel/intern/subdiv_foreach.c b/source/blender/blenkernel/intern/subdiv_foreach.c
index 26312be9d69..bb01bfd587a 100644
--- a/source/blender/blenkernel/intern/subdiv_foreach.c
+++ b/source/blender/blenkernel/intern/subdiv_foreach.c
@@ -32,6 +32,7 @@
#include "BLI_bitmap.h"
#include "BLI_task.h"
+#include "BKE_customdata.h"
#include "BKE_mesh.h"
#include "BKE_key.h"
#include "BKE_subdiv.h"
diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c
index 709f3fef4fc..8ac120ec79d 100644
--- a/source/blender/blenkernel/intern/subdiv_mesh.c
+++ b/source/blender/blenkernel/intern/subdiv_mesh.c
@@ -32,6 +32,7 @@
#include "BLI_alloca.h"
#include "BLI_math_vector.h"
+#include "BKE_customdata.h"
#include "BKE_mesh.h"
#include "BKE_key.h"
#include "BKE_subdiv.h"
@@ -224,7 +225,7 @@ static void vertex_interpolation_init(
/* Allocate storage for loops corresponding to ptex corners. */
CustomData_copy(&ctx->coarse_mesh->vdata,
&vertex_interpolation->vertex_data_storage,
- CD_MASK_EVERYTHING,
+ CD_MASK_EVERYTHING.vmask,
CD_CALLOC,
4);
/* Initialize indices. */
@@ -355,7 +356,7 @@ static void loop_interpolation_init(
/* Allocate storage for loops corresponding to ptex corners. */
CustomData_copy(&ctx->coarse_mesh->ldata,
&loop_interpolation->loop_data_storage,
- CD_MASK_EVERYTHING,
+ CD_MASK_EVERYTHING.lmask,
CD_CALLOC,
4);
/* Initialize indices. */
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 82ef725ef37..e34382dc752 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6640,7 +6640,9 @@ static void direct_link_scene(FileData *fd, Scene *sce)
sce->depsgraph_hash = NULL;
sce->fps_info = NULL;
- sce->customdata_mask_modal = 0;
+
+ memset(&sce->customdata_mask, 0, sizeof(sce->customdata_mask));
+ memset(&sce->customdata_mask_modal, 0, sizeof(sce->customdata_mask_modal));
BKE_sound_create_scene(sce);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 6694e050695..4226b111d16 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2101,14 +2101,15 @@ static void write_grid_paint_mask(WriteData *wd, int count, GridPaintMask *grid_
}
static void write_customdata(
- WriteData *wd, ID *id, int count, CustomData *data, CustomDataLayer *layers,
+ WriteData *wd, ID *id,
+ int count, CustomData *data, CustomDataLayer *layers, CustomDataMask cddata_mask,
int partial_type, int partial_count)
{
int i;
/* write external customdata (not for undo) */
if (data->external && (wd->use_memfile == false)) {
- CustomData_external_write(data, id, CD_MASK_MESH, count, 0);
+ CustomData_external_write(data, id, cddata_mask, count, 0);
}
writestruct_at_address(wd, DATA, CustomDataLayer, data->totlayer, data->layers, layers);
@@ -2209,12 +2210,12 @@ static void write_mesh(WriteData *wd, Mesh *mesh)
writedata(wd, DATA, sizeof(void *) * mesh->totcol, mesh->mat);
writedata(wd, DATA, sizeof(MSelect) * mesh->totselect, mesh->mselect);
- write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, -1, 0);
- write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, -1, 0);
+ write_customdata(wd, &mesh->id, mesh->totvert, &mesh->vdata, vlayers, CD_MASK_MESH.vmask, -1, 0);
+ write_customdata(wd, &mesh->id, mesh->totedge, &mesh->edata, elayers, CD_MASK_MESH.emask, -1, 0);
/* fdata is really a dummy - written so slots align */
- write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, -1, 0);
- write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, -1, 0);
- write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, -1, 0);
+ write_customdata(wd, &mesh->id, mesh->totface, &mesh->fdata, flayers, CD_MASK_MESH.fmask, -1, 0);
+ write_customdata(wd, &mesh->id, mesh->totloop, &mesh->ldata, llayers, CD_MASK_MESH.lmask, -1, 0);
+ write_customdata(wd, &mesh->id, mesh->totpoly, &mesh->pdata, players, CD_MASK_MESH.pmask, -1, 0);
/* restore pointer */
mesh = old_mesh;
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c
index a0eac488c77..fba71b20e7c 100644
--- a/source/blender/bmesh/intern/bmesh_construct.c
+++ b/source/blender/bmesh/intern/bmesh_construct.c
@@ -662,10 +662,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, CD_CALLOC, 0);
- CustomData_copy(&bm_src->edata, &bm_dst->edata, CD_MASK_BMESH, CD_CALLOC, 0);
- CustomData_copy(&bm_src->ldata, &bm_dst->ldata, CD_MASK_BMESH, CD_CALLOC, 0);
- CustomData_copy(&bm_src->pdata, &bm_dst->pdata, CD_MASK_BMESH, CD_CALLOC, 0);
+ 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_bmesh_init_pool(&bm_dst->vdata, allocsize->totvert, BM_VERT);
CustomData_bmesh_init_pool(&bm_dst->edata, allocsize->totedge, BM_EDGE);
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c
index 95bfab46619..eead30bcd24 100644
--- a/source/blender/bmesh/intern/bmesh_core.c
+++ b/source/blender/bmesh/intern/bmesh_core.c
@@ -32,6 +32,7 @@
#include "DNA_meshdata_types.h"
+#include "BKE_customdata.h"
#include "BKE_mesh.h"
#include "bmesh.h"
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c
index 46a0ed2bddd..c5557eb91c2 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@ -195,15 +195,15 @@ void BM_mesh_bm_from_me(
BMFace *f, **ftable = NULL;
float (*keyco)[3] = NULL;
int totloops, i;
- const int64_t mask = CD_MASK_BMESH | params->cd_mask_extra;
- const int64_t mask_loop_only = mask & ~CD_MASK_ORIGINDEX;
+ CustomData_MeshMasks mask = CD_MASK_BMESH;
+ CustomData_MeshMasks_update(&mask, &params->cd_mask_extra);
if (!me || !me->totvert) {
if (me && is_new) { /*no verts? still copy customdata layout*/
- CustomData_copy(&me->vdata, &bm->vdata, mask, CD_ASSIGN, 0);
- CustomData_copy(&me->edata, &bm->edata, mask, CD_ASSIGN, 0);
- CustomData_copy(&me->ldata, &bm->ldata, mask_loop_only, CD_ASSIGN, 0);
- CustomData_copy(&me->pdata, &bm->pdata, mask, CD_ASSIGN, 0);
+ CustomData_copy(&me->vdata, &bm->vdata, mask.vmask, CD_ASSIGN, 0);
+ CustomData_copy(&me->edata, &bm->edata, mask.emask, CD_ASSIGN, 0);
+ CustomData_copy(&me->ldata, &bm->ldata, mask.lmask, CD_ASSIGN, 0);
+ CustomData_copy(&me->pdata, &bm->pdata, mask.pmask, CD_ASSIGN, 0);
CustomData_bmesh_init_pool(&bm->vdata, me->totvert, BM_VERT);
CustomData_bmesh_init_pool(&bm->edata, me->totedge, BM_EDGE);
@@ -214,10 +214,10 @@ void BM_mesh_bm_from_me(
}
if (is_new) {
- CustomData_copy(&me->vdata, &bm->vdata, mask, CD_CALLOC, 0);
- CustomData_copy(&me->edata, &bm->edata, mask, CD_CALLOC, 0);
- CustomData_copy(&me->ldata, &bm->ldata, mask_loop_only, CD_CALLOC, 0);
- CustomData_copy(&me->pdata, &bm->pdata, mask, CD_CALLOC, 0);
+ CustomData_copy(&me->vdata, &bm->vdata, mask.vmask, CD_CALLOC, 0);
+ CustomData_copy(&me->edata, &bm->edata, mask.emask, CD_CALLOC, 0);
+ CustomData_copy(&me->ldata, &bm->ldata, mask.lmask, CD_CALLOC, 0);
+ CustomData_copy(&me->pdata, &bm->pdata, mask.pmask, CD_CALLOC, 0);
}
/* -------------------------------------------------------------------- */
@@ -604,11 +604,12 @@ void BM_mesh_bm_to_me(
me->act_face = -1;
{
- const CustomDataMask mask = CD_MASK_MESH | params->cd_mask_extra;
- CustomData_copy(&bm->vdata, &me->vdata, mask, CD_CALLOC, me->totvert);
- CustomData_copy(&bm->edata, &me->edata, mask, CD_CALLOC, me->totedge);
- CustomData_copy(&bm->ldata, &me->ldata, mask, CD_CALLOC, me->totloop);
- CustomData_copy(&bm->pdata, &me->pdata, mask, CD_CALLOC, me->totpoly);
+ CustomData_MeshMasks mask = CD_MASK_MESH;
+ CustomData_MeshMasks_update(&mask, &params->cd_mask_extra);
+ CustomData_copy(&bm->vdata, &me->vdata, mask.vmask, CD_CALLOC, me->totvert);
+ CustomData_copy(&bm->edata, &me->edata, mask.emask, CD_CALLOC, me->totedge);
+ CustomData_copy(&bm->ldata, &me->ldata, mask.lmask, CD_CALLOC, me->totloop);
+ CustomData_copy(&bm->pdata, &me->pdata, mask.pmask, CD_CALLOC, me->totpoly);
}
CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, mvert, me->totvert);
@@ -950,11 +951,11 @@ void BM_mesh_bm_to_me(
*
* \note Was `cddm_from_bmesh_ex` in 2.7x, removed `MFace` support.
*/
-void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const int64_t cd_mask_extra)
+void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *cd_mask_extra)
{
/* must be an empty mesh. */
BLI_assert(me->totvert == 0);
- BLI_assert((cd_mask_extra & CD_MASK_SHAPEKEY) == 0);
+ BLI_assert(cd_mask_extra == NULL || (cd_mask_extra->vmask & CD_MASK_SHAPEKEY) == 0);
me->totvert = bm->totvert;
me->totedge = bm->totedge;
@@ -973,11 +974,15 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const int64_t cd_mask_extra)
/* don't process shapekeys, we only feed them through the modifier stack as needed,
* e.g. for applying modifiers or the like*/
- const CustomDataMask mask = (CD_MASK_DERIVEDMESH | cd_mask_extra) & ~CD_MASK_SHAPEKEY;
- CustomData_merge(&bm->vdata, &me->vdata, mask, CD_CALLOC, me->totvert);
- CustomData_merge(&bm->edata, &me->edata, mask, CD_CALLOC, me->totedge);
- CustomData_merge(&bm->ldata, &me->ldata, mask, CD_CALLOC, me->totloop);
- CustomData_merge(&bm->pdata, &me->pdata, mask, CD_CALLOC, me->totpoly);
+ CustomData_MeshMasks mask = CD_MASK_DERIVEDMESH;
+ if (cd_mask_extra != NULL) {
+ 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);
BKE_mesh_update_customdata_pointers(me, false);
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.h b/source/blender/bmesh/intern/bmesh_mesh_conv.h
index 52d3b0b8808..30a1e8bffd5 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.h
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.h
@@ -24,6 +24,7 @@
* \ingroup bmesh
*/
+struct CustomData_MeshMasks;
struct Main;
struct Mesh;
@@ -39,7 +40,7 @@ struct BMeshFromMeshParams {
uint use_shapekey : 1;
/* define the active shape key (index + 1) */
int active_shapekey;
- int64_t cd_mask_extra;
+ struct CustomData_MeshMasks cd_mask_extra;
};
void BM_mesh_bm_from_me(
BMesh *bm, const struct Mesh *me,
@@ -49,7 +50,7 @@ ATTR_NONNULL(1, 3);
struct BMeshToMeshParams {
/** Update object hook indices & vertex parents. */
uint calc_object_remap : 1;
- int64_t cd_mask_extra;
+ struct CustomData_MeshMasks cd_mask_extra;
};
void BM_mesh_bm_to_me(
struct Main *bmain, BMesh *bm, struct Mesh *me,
@@ -57,7 +58,7 @@ void BM_mesh_bm_to_me(
ATTR_NONNULL(2, 3, 4);
void BM_mesh_bm_to_me_for_eval(
- BMesh *bm, struct Mesh *me, const int64_t cd_mask_extra)
+ BMesh *bm, struct Mesh *me, const struct CustomData_MeshMasks *cd_mask_extra)
ATTR_NONNULL(1, 2);
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp
index 65ce7ba5677..306120e464f 100644
--- a/source/blender/collada/MeshImporter.cpp
+++ b/source/blender/collada/MeshImporter.cpp
@@ -556,7 +556,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
totedge = mesh->totedge + len;
/* update customdata */
- CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge);
+ CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
if (!CustomData_has_layer(&edata, CD_MEDGE))
diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp
index 406d4dabc88..37a4608fe29 100644
--- a/source/blender/collada/collada_utils.cpp
+++ b/source/blender/collada/collada_utils.cpp
@@ -256,19 +256,19 @@ Mesh *bc_get_mesh_copy(
bool apply_modifiers,
bool triangulate)
{
- CustomDataMask mask = CD_MASK_MESH;
+ CustomData_MeshMasks mask = CD_MASK_MESH;
Mesh *tmpmesh = NULL;
if (apply_modifiers) {
#if 0 /* Not supported by new system currently... */
switch (export_mesh_type) {
case BC_MESH_TYPE_VIEW:
{
- dm = mesh_create_derived_view(depsgraph, scene, ob, mask);
+ dm = mesh_create_derived_view(depsgraph, scene, ob, &mask);
break;
}
case BC_MESH_TYPE_RENDER:
{
- dm = mesh_create_derived_render(depsgraph, scene, ob, mask);
+ dm = mesh_create_derived_render(depsgraph, scene, ob, &mask);
break;
}
}
@@ -276,7 +276,7 @@ Mesh *bc_get_mesh_copy(
Depsgraph *depsgraph = blender_context.get_depsgraph();
Scene *scene_eval = blender_context.get_evaluated_scene();
Object *ob_eval = blender_context.get_evaluated_object(ob);
- tmpmesh = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, mask);
+ tmpmesh = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &mask);
#endif
}
else {
diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 3a44c46dcc5..62315391e95 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -35,6 +35,7 @@ struct Depsgraph;
struct CacheFile;
struct Collection;
+struct CustomData_MeshMasks;
struct EffectorWeights;
struct ID;
struct Main;
@@ -161,7 +162,7 @@ void DEG_add_object_pointcache_relation(struct DepsNodeHandle *node_handle,
const char *description);
void DEG_add_special_eval_flag(struct DepsNodeHandle *handle, struct ID *id, uint32_t flag);
-void DEG_add_customdata_mask(struct DepsNodeHandle *handle, struct Object *object, uint64_t mask);
+void DEG_add_customdata_mask(struct DepsNodeHandle *handle, struct Object *object, const struct CustomData_MeshMasks *masks);
struct ID *DEG_get_id_from_handle(struct DepsNodeHandle *node_handle);
struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *node_handle);
diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index 1e544941e64..11732c55a99 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -33,6 +33,7 @@ struct ID;
struct BLI_Iterator;
struct Base;
+struct CustomData_MeshMasks;
struct Depsgraph;
struct DupliObject;
struct ListBase;
@@ -66,9 +67,10 @@ bool DEG_id_type_any_updated(const struct Depsgraph *depsgraph);
/* Get additional evaluation flags for the given ID. */
uint32_t DEG_get_eval_flags_for_id(const struct Depsgraph *graph, struct ID *id);
-/* Get additional mesh CustomDataMask flags for the given object. */
-uint64_t DEG_get_customdata_mask_for_object(const struct Depsgraph *graph,
- struct Object *object);
+/* Get additional mesh CustomData_MeshMasks flags for the given object. */
+void DEG_get_customdata_mask_for_object(const struct Depsgraph *graph,
+ struct Object *object,
+ struct CustomData_MeshMasks *r_mask);
/* Get scene the despgraph is created for. */
struct Scene *DEG_get_evaluated_scene(const struct Depsgraph *graph);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index ca454610f1e..b6e516ee9b4 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -203,7 +203,7 @@ void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY;
}
/* Tag rebuild if the custom data mask changed. */
- if (id_node->customdata_mask != id_node->previous_customdata_mask) {
+ if (id_node->customdata_masks != id_node->previous_customdata_masks) {
flag |= ID_RECALC_GEOMETRY;
}
if (!deg_copy_on_write_is_expanded(id_node->id_cow)) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 463f4fa0935..dbf6b1d1451 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -154,14 +154,14 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id)
ID *id_cow = NULL;
IDComponentsMask previously_visible_components_mask = 0;
uint32_t previous_eval_flags = 0;
- uint64_t previous_customdata_mask = 0;
+ DEGCustomDataMeshMasks previous_customdata_masks;
IDInfo *id_info = (IDInfo *)BLI_ghash_lookup(id_info_hash_, id);
if (id_info != NULL) {
id_cow = id_info->id_cow;
previously_visible_components_mask =
id_info->previously_visible_components_mask;
previous_eval_flags = id_info->previous_eval_flags;
- previous_customdata_mask = id_info->previous_customdata_mask;
+ previous_customdata_masks = id_info->previous_customdata_masks;
/* Tag ID info to not free the CoW ID pointer. */
id_info->id_cow = NULL;
}
@@ -169,7 +169,7 @@ IDNode *DepsgraphNodeBuilder::add_id_node(ID *id)
id_node->previously_visible_components_mask =
previously_visible_components_mask;
id_node->previous_eval_flags = previous_eval_flags;
- id_node->previous_customdata_mask = previous_customdata_mask;
+ id_node->previous_customdata_masks = previous_customdata_masks;
/* Currently all ID nodes are supposed to have copy-on-write logic.
*
* NOTE: Zero number of components indicates that ID node was just created. */
@@ -339,7 +339,7 @@ void DepsgraphNodeBuilder::begin_build()
id_info->previously_visible_components_mask =
id_node->visible_components_mask;
id_info->previous_eval_flags = id_node->eval_flags;
- id_info->previous_customdata_mask = id_node->customdata_mask;
+ id_info->previous_customdata_masks = id_node->customdata_masks;
BLI_ghash_insert(id_info_hash_, id_node->id_orig, id_info);
id_node->id_cow = NULL;
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index 0bf4c13d515..d5d1ac2d33a 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -230,7 +230,7 @@ public:
/* Special evaluation flag mask from the previous depsgraph. */
uint32_t previous_eval_flags;
/* Mesh CustomData mask from the previous depsgraph. */
- uint64_t previous_customdata_mask;
+ DEGCustomDataMeshMasks previous_customdata_masks;
};
protected:
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 9aab90f88cf..161d0a9cd9f 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -309,16 +309,18 @@ void DepsgraphRelationBuilder::add_modifier_to_transform_relation(
transform_operation_node, geometry_operation_node, description);
}
-void DepsgraphRelationBuilder::add_customdata_mask(Object *object, uint64_t mask)
+void DepsgraphRelationBuilder::add_customdata_mask(
+ Object *object,
+ const DEGCustomDataMeshMasks &customdata_masks)
{
- if (mask != 0 && object != NULL && object->type == OB_MESH) {
+ if (customdata_masks != DEGCustomDataMeshMasks() && object != NULL && object->type == OB_MESH) {
DEG::IDNode *id_node = graph_->find_id_node(&object->id);
if (id_node == NULL) {
BLI_assert(!"ID should always be valid");
}
else {
- id_node->customdata_mask |= mask;
+ id_node->customdata_masks |= customdata_masks;
}
}
}
@@ -864,7 +866,11 @@ void DepsgraphRelationBuilder::build_object_parent(Object *object)
* TODO(sergey): This optimization got lost at 2.8, so either verify
* we can get rid of this mask here, or bring the optimization
* back. */
- add_customdata_mask(object->parent, CD_MASK_ORIGINDEX);
+ add_customdata_mask(object->parent,
+ DEGCustomDataMeshMasks::MaskVert(CD_MASK_ORIGINDEX) |
+ DEGCustomDataMeshMasks::MaskEdge(CD_MASK_ORIGINDEX) |
+ DEGCustomDataMeshMasks::MaskFace(CD_MASK_ORIGINDEX) |
+ DEGCustomDataMeshMasks::MaskPoly(CD_MASK_ORIGINDEX));
ComponentKey transform_key(parent_id, NodeType::TRANSFORM);
add_relation(transform_key, ob_key, "Vertex Parent TFM");
break;
@@ -1118,7 +1124,7 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
target_transform_key, constraint_op_key, cti->name);
add_relation(
target_geometry_key, constraint_op_key, cti->name);
- add_customdata_mask(ct->tar, CD_MASK_MDEFORMVERT);
+ add_customdata_mask(ct->tar, DEGCustomDataMeshMasks::MaskVert(CD_MASK_MDEFORMVERT));
}
else if (con->type == CONSTRAINT_TYPE_SHRINKWRAP) {
bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data;
@@ -1131,7 +1137,9 @@ void DepsgraphRelationBuilder::build_constraints(ID *id,
if (ct->tar->type == OB_MESH && scon->shrinkType != MOD_SHRINKWRAP_NEAREST_VERTEX) {
bool track = (scon->flag & CON_SHRINKWRAP_TRACK_NORMAL) != 0;
if (track || BKE_shrinkwrap_needs_normals(scon->shrinkType, scon->shrinkMode)) {
- add_customdata_mask(ct->tar, CD_MASK_NORMAL | CD_MASK_CUSTOMLOOPNORMAL);
+ add_customdata_mask(ct->tar,
+ DEGCustomDataMeshMasks::MaskVert(CD_MASK_NORMAL) |
+ DEGCustomDataMeshMasks::MaskLoop(CD_MASK_CUSTOMLOOPNORMAL));
}
if (scon->shrinkType == MOD_SHRINKWRAP_TARGET_PROJECT) {
add_special_eval_flag(&ct->tar->id, DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
index fb76b469572..250593eeda0 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h
@@ -204,7 +204,8 @@ public:
void add_modifier_to_transform_relation(const DepsNodeHandle *handle,
const char *description);
- void add_customdata_mask(Object *object, uint64_t mask);
+ void add_customdata_mask(Object *object,
+ const DEGCustomDataMeshMasks &customdata_masks);
void add_special_eval_flag(ID *object, uint32_t flag);
void build_id(ID *id);
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
index 8742dc43651..fe88b532dca 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
@@ -130,7 +130,7 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object,
* separately. */
ComponentKey target_key(&data->tar->id, NodeType::GEOMETRY);
add_relation(target_key, solver_key, con->name);
- add_customdata_mask(data->tar, CD_MASK_MDEFORMVERT);
+ add_customdata_mask(data->tar, DEGCustomDataMeshMasks::MaskVert(CD_MASK_MDEFORMVERT));
}
else {
/* Standard Object Target. */
@@ -160,7 +160,7 @@ void DepsgraphRelationBuilder::build_ik_pose(Object *object,
* separately. */
ComponentKey target_key(&data->poletar->id, NodeType::GEOMETRY);
add_relation(target_key, solver_key, con->name);
- add_customdata_mask(data->poletar, CD_MASK_MDEFORMVERT);
+ add_customdata_mask(data->poletar, DEGCustomDataMeshMasks::MaskVert(CD_MASK_MDEFORMVERT));
}
else {
ComponentKey target_key(&data->poletar->id, NodeType::TRANSFORM);
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 8480f152709..ffd0f9da31a 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -211,10 +211,12 @@ void DEG_add_special_eval_flag(struct DepsNodeHandle *node_handle,
void DEG_add_customdata_mask(struct DepsNodeHandle *node_handle,
struct Object *object,
- uint64_t mask)
+ const CustomData_MeshMasks *masks)
{
DEG::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle);
- deg_node_handle->builder->add_customdata_mask(object, mask);
+ deg_node_handle->builder->add_customdata_mask(
+ object,
+ DEG::DEGCustomDataMeshMasks(masks));
}
struct ID *DEG_get_id_from_handle(struct DepsNodeHandle *node_handle)
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index a366b9b6568..3b7f19e9916 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -29,6 +29,7 @@ extern "C" {
#include <string.h> // XXX: memcpy
#include "BLI_utildefines.h"
+#include "BKE_customdata.h"
#include "BKE_idcode.h"
#include "BKE_main.h"
#include "BLI_listbase.h"
@@ -114,7 +115,7 @@ uint32_t DEG_get_eval_flags_for_id(const Depsgraph *graph, ID *id)
return id_node->eval_flags;
}
-uint64_t DEG_get_customdata_mask_for_object(const Depsgraph *graph, Object *ob)
+void DEG_get_customdata_mask_for_object(const Depsgraph *graph, Object *ob, CustomData_MeshMasks *r_mask)
{
if (graph == NULL) {
/* Happens when converting objects to mesh from a python script
@@ -122,17 +123,21 @@ uint64_t DEG_get_customdata_mask_for_object(const Depsgraph *graph, Object *ob)
*
* Currently harmless because it's only called for temporary
* objects which are out of the DAG anyway. */
- return 0;
+ return;
}
const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
const DEG::IDNode *id_node = deg_graph->find_id_node(DEG_get_original_id(&ob->id));
if (id_node == NULL) {
/* TODO(sergey): Does it mean we need to check set scene? */
- return 0;
+ return;
}
- return id_node->customdata_mask;
+ r_mask->vmask |= id_node->customdata_masks.vert_mask;
+ r_mask->emask |= id_node->customdata_masks.edge_mask;
+ r_mask->fmask |= id_node->customdata_masks.face_mask;
+ r_mask->lmask |= id_node->customdata_masks.loop_mask;
+ r_mask->pmask |= id_node->customdata_masks.poly_mask;
}
Scene *DEG_get_evaluated_scene(const Depsgraph *graph)
diff --git a/source/blender/depsgraph/intern/depsgraph_type.cc b/source/blender/depsgraph/intern/depsgraph_type.cc
index 28d93cb9194..5be2cae10d7 100644
--- a/source/blender/depsgraph/intern/depsgraph_type.cc
+++ b/source/blender/depsgraph/intern/depsgraph_type.cc
@@ -29,8 +29,11 @@
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
+#include "DNA_customdata_types.h"
+
#include "DEG_depsgraph.h"
+#include "intern/depsgraph_type.h"
#include "intern/node/deg_node.h"
#include "intern/node/deg_node_component.h"
#include "intern/node/deg_node_factory.h"
@@ -49,3 +52,12 @@ void DEG_register_node_types(void)
void DEG_free_node_types(void)
{
}
+
+DEG::DEGCustomDataMeshMasks::DEGCustomDataMeshMasks(const CustomData_MeshMasks *other) :
+ vert_mask(other->vmask),
+ edge_mask(other->emask),
+ face_mask(other->fmask),
+ loop_mask(other->lmask),
+ poly_mask(other->pmask)
+{
+}
diff --git a/source/blender/depsgraph/intern/depsgraph_type.h b/source/blender/depsgraph/intern/depsgraph_type.h
index 5233b6d018d..d34b6d724cb 100644
--- a/source/blender/depsgraph/intern/depsgraph_type.h
+++ b/source/blender/depsgraph/intern/depsgraph_type.h
@@ -39,6 +39,8 @@
struct Depsgraph;
+struct CustomData_MeshMasks;
+
namespace DEG {
/* Commonly used types. */
@@ -70,4 +72,94 @@ enum eUpdateSource {
DEG_UPDATE_SOURCE_VISIBILITY = (1 << 3),
};
+/* C++ wrapper around DNA's CustomData_MeshMasks struct. */
+struct DEGCustomDataMeshMasks {
+ uint64_t vert_mask;
+ uint64_t edge_mask;
+ uint64_t face_mask;
+ uint64_t loop_mask;
+ uint64_t poly_mask;
+
+ DEGCustomDataMeshMasks()
+ : vert_mask(0),
+ edge_mask(0),
+ face_mask(0),
+ loop_mask(0),
+ poly_mask(0)
+ {
+ }
+
+ explicit DEGCustomDataMeshMasks(const CustomData_MeshMasks *other);
+
+ DEGCustomDataMeshMasks& operator|=(const DEGCustomDataMeshMasks& other)
+ {
+ this->vert_mask |= other.vert_mask;
+ this->edge_mask |= other.edge_mask;
+ this->face_mask |= other.face_mask;
+ this->loop_mask |= other.loop_mask;
+ this->poly_mask |= other.poly_mask;
+ return *this;
+ }
+
+ DEGCustomDataMeshMasks operator|(const DEGCustomDataMeshMasks& other) const
+ {
+ DEGCustomDataMeshMasks result;
+ result.vert_mask = this->vert_mask | other.vert_mask;
+ result.edge_mask = this->edge_mask | other.edge_mask;
+ result.face_mask = this->face_mask | other.face_mask;
+ result.loop_mask = this->loop_mask | other.loop_mask;
+ result.poly_mask = this->poly_mask | other.poly_mask;
+ return result;
+ }
+
+ bool operator==(const DEGCustomDataMeshMasks& other) const
+ {
+ return (this->vert_mask == other.vert_mask &&
+ this->edge_mask == other.edge_mask &&
+ this->face_mask == other.face_mask &&
+ this->loop_mask == other.loop_mask &&
+ this->poly_mask == other.poly_mask);
+ }
+
+ bool operator!=(const DEGCustomDataMeshMasks& other) const
+ {
+ return !(*this == other);
+ }
+
+ static DEGCustomDataMeshMasks MaskVert(const uint64_t vert_mask)
+ {
+ DEGCustomDataMeshMasks result;
+ result.vert_mask = vert_mask;
+ return result;
+ }
+
+ static DEGCustomDataMeshMasks MaskEdge(const uint64_t edge_mask)
+ {
+ DEGCustomDataMeshMasks result;
+ result.edge_mask = edge_mask;
+ return result;
+ }
+
+ static DEGCustomDataMeshMasks MaskFace(const uint64_t face_mask)
+ {
+ DEGCustomDataMeshMasks result;
+ result.face_mask = face_mask;
+ return result;
+ }
+
+ static DEGCustomDataMeshMasks MaskLoop(const uint64_t loop_mask)
+ {
+ DEGCustomDataMeshMasks result;
+ result.loop_mask = loop_mask;
+ return result;
+ }
+
+ static DEGCustomDataMeshMasks MaskPoly(const uint64_t poly_mask)
+ {
+ DEGCustomDataMeshMasks result;
+ result.poly_mask = poly_mask;
+ return result;
+ }
+};
+
} // namespace DEG
diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc
index f992ce33279..d391f727d35 100644
--- a/source/blender/depsgraph/intern/node/deg_node_id.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_id.cc
@@ -109,8 +109,8 @@ void IDNode::init(const ID *id, const char *UNUSED(subdata))
id_orig = (ID *)id;
eval_flags = 0;
previous_eval_flags = 0;
- customdata_mask = 0;
- previous_customdata_mask = 0;
+ customdata_masks = DEGCustomDataMeshMasks();
+ previous_customdata_masks = DEGCustomDataMeshMasks();
linked_state = DEG_ID_LINKED_INDIRECTLY;
is_directly_visible = true;
is_collection_fully_expanded = false;
diff --git a/source/blender/depsgraph/intern/node/deg_node_id.h b/source/blender/depsgraph/intern/node/deg_node_id.h
index 9c3ce7580ad..bbf671790c7 100644
--- a/source/blender/depsgraph/intern/node/deg_node_id.h
+++ b/source/blender/depsgraph/intern/node/deg_node_id.h
@@ -84,8 +84,8 @@ struct IDNode : public Node {
uint32_t previous_eval_flags;
/* Extra customdata mask which needs to be evaluated for the mesh object. */
- uint64_t customdata_mask;
- uint64_t previous_customdata_mask;
+ DEGCustomDataMeshMasks customdata_masks;
+ DEGCustomDataMeshMasks previous_customdata_masks;
eDepsNode_LinkedState_Type linked_state;
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index ee0043f6ccf..5608479905a 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -370,7 +370,7 @@ static void add_verts_to_dgroups(
/* if in weight paint mode, use final verts from evaluated mesh */
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
BKE_mesh_foreach_mapped_vert_coords_get(me_eval, verts, mesh->totvert);
vertsfilled = 1;
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 2457d78f1d4..131069bfb5f 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -35,6 +35,7 @@ struct Base;
struct BezTriple;
struct BoundBox;
struct Camera;
+struct CustomData_MeshMasks;
struct Depsgraph;
struct EditBone;
struct GPUFX;
@@ -486,8 +487,12 @@ char ED_view3d_lock_view_from_index(int index);
char ED_view3d_axis_view_opposite(char view);
bool ED_view3d_lock(struct RegionView3D *rv3d);
-uint64_t ED_view3d_datamask(const struct bContext *C, const struct Scene *scene, const struct View3D *v3d);
-uint64_t ED_view3d_screen_datamask(const struct bContext *C, const struct Scene *scene, const struct bScreen *screen);
+void ED_view3d_datamask(
+ const struct bContext *C, const struct Scene *scene, const struct View3D *v3d,
+ struct CustomData_MeshMasks *r_cddata_masks);
+void ED_view3d_screen_datamask(
+ const struct bContext *C, const struct Scene *scene, const struct bScreen *screen,
+ struct CustomData_MeshMasks *r_cddata_masks);
bool ED_view3d_offset_lock_check(const struct View3D *v3d, const struct RegionView3D *rv3d);
void ED_view3d_persp_switch_from_camera(
diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c
index d42b4c97d33..aca8fac8bf7 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -21,12 +21,13 @@
* \ingroup edmesh
*/
+#include "BLI_math.h"
+#include "BLI_sys_types.h"
+
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BLI_math.h"
-
#include "BLT_translation.h"
#include "BKE_context.h"
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c
index 45ce8e8b76a..13fcb99f59b 100644
--- a/source/blender/editors/mesh/editmesh_knife_project.c
+++ b/source/blender/editors/mesh/editmesh_knife_project.c
@@ -65,7 +65,7 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C, Scene *scene,
me_eval = ob_eval->runtime.mesh_eval;
if (me_eval == NULL) {
Scene *scene_eval = (Scene *)DEG_get_evaluated_id(depsgraph, &scene->id);
- me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
+ me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
}
me_eval_needs_free = false;
}
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 83366987c7a..273003c3ccd 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -3708,10 +3708,10 @@ static Base *mesh_separate_tagged(Main *bmain, Scene *scene, ViewLayer *view_lay
&((struct BMeshCreateParams){.use_toolflags = true,}));
BM_mesh_elem_toolflags_ensure(bm_new); /* needed for 'duplicate' bmo */
- CustomData_copy(&bm_old->vdata, &bm_new->vdata, CD_MASK_BMESH, CD_CALLOC, 0);
- CustomData_copy(&bm_old->edata, &bm_new->edata, CD_MASK_BMESH, CD_CALLOC, 0);
- CustomData_copy(&bm_old->ldata, &bm_new->ldata, CD_MASK_BMESH, CD_CALLOC, 0);
- CustomData_copy(&bm_old->pdata, &bm_new->pdata, CD_MASK_BMESH, CD_CALLOC, 0);
+ CustomData_copy(&bm_old->vdata, &bm_new->vdata, CD_MASK_BMESH.vmask, CD_CALLOC, 0);
+ CustomData_copy(&bm_old->edata, &bm_new->edata, CD_MASK_BMESH.emask, CD_CALLOC, 0);
+ CustomData_copy(&bm_old->ldata, &bm_new->ldata, CD_MASK_BMESH.lmask, CD_CALLOC, 0);
+ CustomData_copy(&bm_old->pdata, &bm_new->pdata, CD_MASK_BMESH.pmask, CD_CALLOC, 0);
CustomData_bmesh_init_pool(&bm_new->vdata, bm_mesh_allocsize_default.totvert, BM_VERT);
CustomData_bmesh_init_pool(&bm_new->edata, bm_mesh_allocsize_default.totedge, BM_EDGE);
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c
index 16aeba78118..e22addd614e 100644
--- a/source/blender/editors/mesh/editmesh_undo.c
+++ b/source/blender/editors/mesh/editmesh_undo.c
@@ -509,7 +509,7 @@ static void *undomesh_from_editmesh(UndoMesh *um, BMEditMesh *em, Key *key)
NULL, em->bm, &um->me, (&(struct BMeshToMeshParams){
/* Undo code should not be manipulating 'G_MAIN->object' hooks/vertex-parent. */
.calc_object_remap = false,
- .cd_mask_extra = CD_MASK_SHAPE_KEYINDEX,
+ .cd_mask_extra = {.vmask=CD_MASK_SHAPE_KEYINDEX},
}));
um->selectmode = em->selectmode;
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index ea64adbffa3..3d880fc0bfe 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -911,7 +911,7 @@ static void mesh_add_verts(Mesh *mesh, int len)
return;
totvert = mesh->totvert + len;
- CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH, CD_DEFAULT, totvert);
+ CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH.vmask, CD_DEFAULT, totvert);
CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);
if (!CustomData_has_layer(&vdata, CD_MVERT))
@@ -944,7 +944,7 @@ static void mesh_add_edges(Mesh *mesh, int len)
totedge = mesh->totedge + len;
/* update customdata */
- CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge);
+ CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
if (!CustomData_has_layer(&edata, CD_MEDGE))
@@ -974,7 +974,7 @@ static void mesh_add_tessfaces(Mesh *mesh, int len)
totface = mesh->totface + len; /* new face count */
/* update customdata */
- CustomData_copy(&mesh->fdata, &fdata, CD_MASK_MESH, CD_DEFAULT, totface);
+ CustomData_copy(&mesh->fdata, &fdata, CD_MASK_MESH.fmask, CD_DEFAULT, totface);
CustomData_copy_data(&mesh->fdata, &fdata, 0, 0, mesh->totface);
if (!CustomData_has_layer(&fdata, CD_MFACE))
@@ -1003,7 +1003,7 @@ 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, CD_DEFAULT, totloop);
+ CustomData_copy(&mesh->ldata, &ldata, CD_MASK_MESH.lmask, CD_DEFAULT, totloop);
CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop);
if (!CustomData_has_layer(&ldata, CD_MLOOP))
@@ -1028,7 +1028,7 @@ 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, CD_DEFAULT, totpoly);
+ CustomData_copy(&mesh->pdata, &pdata, CD_MASK_MESH.pmask, CD_DEFAULT, totpoly);
CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly);
if (!CustomData_has_layer(&pdata, CD_MPOLY))
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index b316e054250..2b8535f868b 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -97,7 +97,7 @@ static void join_mesh_single(
((Mesh *)ob_dst->data)->cd_flag |= me->cd_flag;
/* standard data */
- CustomData_merge(&me->vdata, vdata, CD_MASK_MESH, CD_DEFAULT, totvert);
+ CustomData_merge(&me->vdata, vdata, CD_MASK_MESH.vmask, CD_DEFAULT, totvert);
CustomData_copy_data_named(&me->vdata, vdata, 0, *vertofs, me->totvert);
/* vertex groups */
@@ -191,7 +191,7 @@ static void join_mesh_single(
}
if (me->totedge) {
- CustomData_merge(&me->edata, edata, CD_MASK_MESH, CD_DEFAULT, totedge);
+ CustomData_merge(&me->edata, edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
CustomData_copy_data_named(&me->edata, edata, 0, *edgeofs, me->totedge);
for (a = 0; a < me->totedge; a++, medge++) {
@@ -213,7 +213,7 @@ static void join_mesh_single(
}
}
- CustomData_merge(&me->ldata, ldata, CD_MASK_MESH, CD_DEFAULT, totloop);
+ CustomData_merge(&me->ldata, ldata, CD_MASK_MESH.lmask, CD_DEFAULT, totloop);
CustomData_copy_data_named(&me->ldata, ldata, 0, *loopofs, me->totloop);
for (a = 0; a < me->totloop; a++, mloop++) {
@@ -237,7 +237,7 @@ static void join_mesh_single(
}
}
- CustomData_merge(&me->pdata, pdata, CD_MASK_MESH, CD_DEFAULT, totpoly);
+ CustomData_merge(&me->pdata, pdata, CD_MASK_MESH.pmask, CD_DEFAULT, totpoly);
CustomData_copy_data_named(&me->pdata, pdata, 0, *polyofs, me->totpoly);
for (a = 0; a < me->totpoly; a++, mpoly++) {
@@ -665,7 +665,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter);
- me_deformed = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
+ me_deformed = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
if (!me_deformed) {
continue;
@@ -1087,7 +1087,7 @@ bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned
struct ARegion *ar = CTX_wm_region(C);
/* derived mesh to find deformed locations */
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH_ORIGINDEX);
int v_idx_best = ORIGINDEX_NONE;
@@ -1216,7 +1216,7 @@ bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int
Object *ob_eval = DEG_get_evaluated_object(vc.depsgraph, ob);
/* derived mesh to find deformed locations */
- Mesh *me_eval = mesh_get_eval_final(vc.depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
+ Mesh *me_eval = mesh_get_eval_final(vc.depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
ARegion *ar = vc.ar;
RegionView3D *rv3d = ar->regiondata;
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 0e6505ab712..d131534b5ca 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1886,8 +1886,8 @@ static int convert_exec(bContext *C, wmOperator *op)
DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY);
}
- uint64_t customdata_mask_prev = scene->customdata_mask;
- scene->customdata_mask |= CD_MASK_MESH;
+ CustomData_MeshMasks customdata_mask_prev = scene->customdata_mask;
+ CustomData_MeshMasks_update(&scene->customdata_mask, &CD_MASK_MESH);
BKE_scene_graph_update_tagged(depsgraph, bmain);
scene->customdata_mask = customdata_mask_prev;
}
@@ -1966,9 +1966,9 @@ static int convert_exec(bContext *C, wmOperator *op)
*/
Scene *scene_eval = (Scene *)DEG_get_evaluated_id(depsgraph, &scene->id);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_MESH);
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_MESH);
me_eval = BKE_mesh_copy_for_eval(me_eval, false);
- BKE_mesh_nomain_to_mesh(me_eval, newob->data, newob, CD_MASK_MESH, true);
+ BKE_mesh_nomain_to_mesh(me_eval, newob->data, newob, &CD_MASK_MESH, true);
BKE_object_free_modifiers(newob, 0); /* after derivedmesh calls! */
}
else if (ob->type == OB_FONT) {
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index 9835d09ec3a..ac1f31d0b48 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -226,7 +226,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l
MultiresModifierData tmp_mmd = *mmd;
DerivedMesh *cddm = CDDM_from_mesh(me);
- DM_set_only_copy(cddm, CD_MASK_BAREMESH);
+ DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
if (mmd->lvl == 0) {
dm = CDDM_copy(cddm);
@@ -252,13 +252,13 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l
DerivedMesh *cddm = CDDM_from_mesh(me);
DerivedMesh *dm;
- DM_set_only_copy(cddm, CD_MASK_BAREMESH);
+ DM_set_only_copy(cddm, &CD_MASK_BAREMESH);
/* TODO: DM_set_only_copy wouldn't set mask for loop and poly data,
* but we really need BAREMESH only to save lots of memory
*/
- CustomData_set_only_copy(&cddm->loopData, CD_MASK_BAREMESH);
- CustomData_set_only_copy(&cddm->polyData, CD_MASK_BAREMESH);
+ CustomData_set_only_copy(&cddm->loopData, CD_MASK_BAREMESH.lmask);
+ CustomData_set_only_copy(&cddm->polyData, CD_MASK_BAREMESH.pmask);
*lvl = mmd->totlvl;
*simple = mmd->simple != 0;
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index 34f758900e9..8ca0b9c3c91 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -135,7 +135,9 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
- me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, CD_MASK_BAREMESH | CD_MASK_MLOOPUV);
+ CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH;
+ cddata_masks.lmask |= CD_MASK_MLOOPUV;
+ me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, &cddata_masks);
num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPUV);
RNA_enum_item_add_separator(&item, &totitem);
@@ -157,7 +159,9 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
- me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, CD_MASK_BAREMESH | CD_MASK_MLOOPCOL);
+ CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH;
+ cddata_masks.lmask |= CD_MASK_MLOOPCOL;
+ me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, &cddata_masks);
num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPCOL);
RNA_enum_item_add_separator(&item, &totitem);
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index c7291076234..6ea6617191f 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -96,7 +96,7 @@ static void modifier_skin_customdata_delete(struct Object *ob);
static void object_force_modifier_update_for_bind(Depsgraph *depsgraph, Scene *scene, Object *ob)
{
if (ob->type == OB_MESH) {
- Mesh *me_eval = mesh_create_eval_final_view(depsgraph, scene, ob, 0);
+ Mesh *me_eval = mesh_create_eval_final_view(depsgraph, scene, ob, &CD_MASK_BAREMESH);
BKE_id_free(NULL, me_eval);
}
else if (ob->type == OB_LATTICE) {
@@ -637,7 +637,7 @@ static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scen
return 0;
}
- BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, CD_MASK_MESH, true);
+ BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, &CD_MASK_MESH, true);
if (md->type == eModifierType_Multires)
multires_customdata_delete(me);
@@ -1353,7 +1353,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op)
BLI_path_rel(path, BKE_main_blendfile_path(bmain));
CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path);
- CustomData_external_write(&me->ldata, &me->id, CD_MASK_MESH, me->totloop, 0);
+ CustomData_external_write(&me->ldata, &me->id, CD_MASK_MESH.lmask, me->totloop, 0);
return OPERATOR_FINISHED;
}
@@ -1748,7 +1748,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain,
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, skin_ob);
- me_eval_deform = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
+ me_eval_deform = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
mvert = me_eval_deform->mvert;
/* add vertex weights to original mesh */
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index a5159118196..22b7e49093e 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -153,7 +153,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
/* derivedMesh might be needed for solving parenting,
* so re-create it here */
- makeDerivedMesh(depsgraph, scene, obedit, em, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX, false);
+ makeDerivedMesh(depsgraph, scene, obedit, em, &CD_MASK_BAREMESH_ORIGINDEX, false);
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index f3181f227b2..c0e022df629 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -1289,7 +1289,7 @@ static void moveCloserToDistanceFromPlane(
float originalDistToBe = distToBe;
do {
wasChange = false;
- me_deform = mesh_get_eval_deform(depsgraph, scene, ob, CD_MASK_BAREMESH);
+ me_deform = mesh_get_eval_deform(depsgraph, scene, ob, &CD_MASK_BAREMESH);
m = me_deform->mvert[index];
copy_v3_v3(oldPos, m.co);
distToStart = dot_v3v3(norm, oldPos) + d;
@@ -1329,7 +1329,7 @@ static void moveCloserToDistanceFromPlane(
if (dw->weight > 1) {
dw->weight = 1;
}
- me_deform = mesh_get_eval_deform(depsgraph, scene, ob, CD_MASK_BAREMESH);
+ me_deform = mesh_get_eval_deform(depsgraph, scene, ob, &CD_MASK_BAREMESH);
m = me_deform->mvert[index];
getVerticalAndHorizontalChange(norm, d, coord, oldPos, distToStart, m.co, changes, dists, i);
dw->weight = oldw;
@@ -1459,7 +1459,7 @@ static void vgroup_fix(const bContext *C, Scene *scene, Object *ob, float distTo
MVert *p = MEM_callocN(sizeof(MVert) * (count), "deformedPoints");
int k;
- Mesh *me_deform = mesh_get_eval_deform(depsgraph, scene, ob, CD_MASK_BAREMESH);
+ Mesh *me_deform = mesh_get_eval_deform(depsgraph, scene, ob, &CD_MASK_BAREMESH);
k = count;
while (k--) {
p[k] = me_deform->mvert[verts[k]];
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 0c08fc6fb29..b2f314a66ec 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -3593,9 +3593,9 @@ static int particle_intersect_mesh(Depsgraph *depsgraph, Scene *UNUSED(scene), O
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- mesh = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
+ mesh = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
if (mesh == NULL) {
- mesh = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
+ mesh = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
}
psys_enable_all(ob);
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index e0903a9d7c5..ac304f1aeec 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -51,7 +51,6 @@
#include "BKE_report.h"
#include "DEG_depsgraph.h"
-#include "DEG_depsgraph_query.h"
#include "DEG_depsgraph_build.h"
#include "RNA_access.h"
@@ -1030,7 +1029,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
ParticleSystem *psys_start = NULL, *psys, *psys_from;
ParticleSystem **tmp_psys;
Mesh *final_mesh;
- CustomDataMask cdmask;
+ CustomData_MeshMasks cdmask = {0};
int i, totpsys;
if (ob_to->type != OB_MESH)
@@ -1052,7 +1051,6 @@ static bool copy_particle_systems_to_object(const bContext *C,
tmp_psys = MEM_mallocN(sizeof(ParticleSystem *) * totpsys, "temporary particle system array");
- cdmask = 0;
for (psys_from = PSYS_FROM_FIRST, i = 0;
psys_from;
psys_from = PSYS_FROM_NEXT(psys_from), ++i)
@@ -1063,7 +1061,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
if (psys_start == NULL)
psys_start = psys;
- cdmask |= psys_emitter_customdata_mask(psys);
+ psys_emitter_customdata_mask(psys, &cdmask);
}
/* to iterate source and target psys in sync,
* we need to know where the newly added psys start
@@ -1071,8 +1069,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
psys_start = totpsys > 0 ? tmp_psys[0] : NULL;
/* Get the evaluated mesh (psys and their modifiers have not been appended yet) */
- Object *ob_to_eval = DEG_get_evaluated_object(depsgraph, ob_to);
- final_mesh = mesh_get_eval_final(depsgraph, scene, ob_to_eval, cdmask);
+ final_mesh = mesh_get_eval_final(depsgraph, scene, ob_to, &cdmask);
/* now append psys to the object and make modifiers */
for (i = 0, psys_from = PSYS_FROM_FIRST;
@@ -1085,7 +1082,6 @@ static bool copy_particle_systems_to_object(const bContext *C,
/* append to the object */
BLI_addtail(&ob_to->particlesystem, psys);
- psys_unique_name(ob_to, psys, "");
/* add a particle system modifier for each system */
md = modifier_new(eModifierType_ParticleSystem);
@@ -1093,7 +1089,7 @@ static bool copy_particle_systems_to_object(const bContext *C,
/* push on top of the stack, no use trying to reproduce old stack order */
BLI_addtail(&ob_to->modifiers, md);
- BLI_strncpy(md->name, psys->name, sizeof(md->name));
+ BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", i);
modifier_unique_name(&ob_to->modifiers, (ModifierData *)psmd);
psmd->psys = psys;
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index d4312b3d18a..feadc88e1d7 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -42,6 +42,7 @@
#include "BKE_camera.h"
#include "BKE_context.h"
+#include "BKE_customdata.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_main.h"
@@ -603,11 +604,12 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
oglrender->rv3d = oglrender->ar->regiondata;
/* MUST be cleared on exit */
- oglrender->scene->customdata_mask_modal = ED_view3d_datamask(C, oglrender->scene, oglrender->v3d);
+ memset(&oglrender->scene->customdata_mask_modal, 0, sizeof(oglrender->scene->customdata_mask_modal));
+ ED_view3d_datamask(C, oglrender->scene, oglrender->v3d, &oglrender->scene->customdata_mask_modal);
/* apply immediately in case we're rendering from a script,
* running notifiers again will overwrite */
- oglrender->scene->customdata_mask |= oglrender->scene->customdata_mask_modal;
+ CustomData_MeshMasks_update(&oglrender->scene->customdata_mask, &oglrender->scene->customdata_mask_modal);
}
/* create render */
@@ -738,7 +740,7 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender)
MEM_freeN(oglrender->seq_data.ibufs_arr);
}
- oglrender->scene->customdata_mask_modal = 0;
+ memset(&oglrender->scene->customdata_mask_modal, 0, sizeof(oglrender->scene->customdata_mask_modal));
CTX_wm_area_set(C, oglrender->prevsa);
CTX_wm_region_set(C, oglrender->prevar);
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 6da33ad8b72..e39abd591cf 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -61,6 +61,7 @@
#include "BKE_colorband.h"
#include "BKE_context.h"
#include "BKE_colortools.h"
+#include "BKE_customdata.h"
#include "BKE_idprop.h"
#include "BKE_image.h"
#include "BKE_library.h"
@@ -3780,17 +3781,26 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p
return false;
}
+ CustomData_MeshMasks cddata_masks = scene_eval->customdata_mask;
+ cddata_masks.fmask |= CD_MASK_MTFACE;
+ cddata_masks.lmask |= CD_MASK_MLOOPUV;
+
/* Workaround for subsurf selection, try the display mesh first */
if (ps->source == PROJ_SRC_IMAGE_CAM) {
/* using render mesh, assume only camera was rendered from */
ps->me_eval = mesh_create_eval_final_render(
- depsgraph, scene_eval, ob_eval, scene_eval->customdata_mask | CD_MASK_MLOOPUV | CD_MASK_MTFACE);
+ depsgraph, scene_eval, ob_eval, &cddata_masks);
ps->me_eval_free = true;
}
else {
+ if (ps->do_face_sel) {
+ cddata_masks.vmask |= CD_MASK_ORIGINDEX;
+ cddata_masks.emask |= CD_MASK_ORIGINDEX;
+ cddata_masks.pmask |= CD_MASK_ORIGINDEX;
+ }
ps->me_eval = mesh_get_eval_final(
depsgraph, scene_eval, ob_eval,
- scene_eval->customdata_mask | CD_MASK_MLOOPUV | CD_MASK_MTFACE | (ps->do_face_sel ? CD_MASK_ORIGINDEX : 0));
+ &cddata_masks);
ps->me_eval_free = false;
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.c b/source/blender/editors/sculpt_paint/paint_vertex_proj.c
index ca26d2050e4..9246c852b3a 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_proj.c
@@ -33,6 +33,7 @@
#include "DNA_object_types.h"
#include "BKE_context.h"
+#include "BKE_customdata.h"
#include "BKE_mesh_iterators.h"
#include "BKE_mesh_runtime.h"
@@ -103,7 +104,9 @@ static void vpaint_proj_dm_map_cosnos_init(
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
Mesh *me = ob->data;
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+
+ CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH_ORIGINDEX;
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &cddata_masks);
memset(vp_handle->vcosnos, 0, sizeof(*vp_handle->vcosnos) * me->totvert);
BKE_mesh_foreach_mapped_vert(me_eval, vpaint_proj_dm_map_cosnos_init__map_cb, vp_handle, MESH_FOREACH_USE_NORMAL);
@@ -168,7 +171,9 @@ static void vpaint_proj_dm_map_cosnos_update(
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
Mesh *me = ob->data;
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
+
+ CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH_ORIGINDEX;
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &cddata_masks);
/* quick sanity check - we shouldn't have to run this if there are no modifiers */
BLI_assert(BLI_listbase_is_empty(&ob->modifiers) == false);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index 5db01610886..aa3f424f816 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -788,7 +788,11 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, scene->customdata_mask | CD_MASK_ORIGINDEX);
+ CustomData_MeshMasks cddata_masks = scene->customdata_mask;
+ cddata_masks.vmask |= CD_MASK_ORIGINDEX;
+ cddata_masks.emask |= CD_MASK_ORIGINDEX;
+ cddata_masks.pmask |= CD_MASK_ORIGINDEX;
+ Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &cddata_masks);
if (data.is_init) {
data.vert_visit = BLI_BITMAP_NEW(me->totvert, __func__);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 800d9e6d562..7bce2464ef7 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5532,13 +5532,13 @@ void sculpt_dynamic_topology_disable_ex(
me->totpoly = unode->bm_enter_totpoly;
me->totedge = unode->bm_enter_totedge;
me->totface = 0;
- CustomData_copy(&unode->bm_enter_vdata, &me->vdata, CD_MASK_MESH,
+ CustomData_copy(&unode->bm_enter_vdata, &me->vdata, CD_MASK_MESH.vmask,
CD_DUPLICATE, unode->bm_enter_totvert);
- CustomData_copy(&unode->bm_enter_edata, &me->edata, CD_MASK_MESH,
+ CustomData_copy(&unode->bm_enter_edata, &me->edata, CD_MASK_MESH.emask,
CD_DUPLICATE, unode->bm_enter_totedge);
- CustomData_copy(&unode->bm_enter_ldata, &me->ldata, CD_MASK_MESH,
+ CustomData_copy(&unode->bm_enter_ldata, &me->ldata, CD_MASK_MESH.lmask,
CD_DUPLICATE, unode->bm_enter_totloop);
- CustomData_copy(&unode->bm_enter_pdata, &me->pdata, CD_MASK_MESH,
+ CustomData_copy(&unode->bm_enter_pdata, &me->pdata, CD_MASK_MESH.pmask,
CD_DUPLICATE, unode->bm_enter_totpoly);
BKE_mesh_update_customdata_pointers(me, false);
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 53329c4cf78..8c934b6a16a 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -845,13 +845,13 @@ static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob,
* dynamic-topology immediately does topological edits
* (converting polys to triangles) that the BMLog can't
* fully restore from */
- CustomData_copy(&me->vdata, &unode->bm_enter_vdata, CD_MASK_MESH,
+ CustomData_copy(&me->vdata, &unode->bm_enter_vdata, CD_MASK_MESH.vmask,
CD_DUPLICATE, me->totvert);
- CustomData_copy(&me->edata, &unode->bm_enter_edata, CD_MASK_MESH,
+ CustomData_copy(&me->edata, &unode->bm_enter_edata, CD_MASK_MESH.emask,
CD_DUPLICATE, me->totedge);
- CustomData_copy(&me->ldata, &unode->bm_enter_ldata, CD_MASK_MESH,
+ CustomData_copy(&me->ldata, &unode->bm_enter_ldata, CD_MASK_MESH.lmask,
CD_DUPLICATE, me->totloop);
- CustomData_copy(&me->pdata, &unode->bm_enter_pdata, CD_MASK_MESH,
+ CustomData_copy(&me->pdata, &unode->bm_enter_pdata, CD_MASK_MESH.pmask,
CD_DUPLICATE, me->totpoly);
unode->bm_enter_totvert = me->totvert;
unode->bm_enter_totedge = me->totedge;
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 0afdd36dbb6..a52fd89d284 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -879,40 +879,37 @@ void ED_view3d_draw_depth_gpencil(
/* *********************** customdata **************** */
-CustomDataMask ED_view3d_datamask(const bContext *C, const Scene *UNUSED(scene), const View3D *v3d)
+void ED_view3d_datamask(
+ const bContext *C, const Scene *UNUSED(scene), const View3D *v3d, CustomData_MeshMasks *r_cddata_masks)
{
- CustomDataMask mask = 0;
const int drawtype = view3d_effective_drawtype(v3d);
if (ELEM(drawtype, OB_TEXTURE, OB_MATERIAL)) {
- mask |= CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL;
+ r_cddata_masks->lmask |= CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL;
if (drawtype == OB_MATERIAL)
- mask |= CD_MASK_ORCO;
+ r_cddata_masks->vmask |= CD_MASK_ORCO;
}
if ((CTX_data_mode_enum(C) == CTX_MODE_EDIT_MESH) &&
(v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_WEIGHT))
{
- mask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
-
- return mask;
}
/* goes over all modes and view3d settings */
-CustomDataMask ED_view3d_screen_datamask(const bContext *C, const Scene *scene, const bScreen *screen)
+void ED_view3d_screen_datamask(
+ const bContext *C, const Scene *scene, const bScreen *screen, CustomData_MeshMasks *r_cddata_masks)
{
- CustomDataMask mask = CD_MASK_BAREMESH;
+ CustomData_MeshMasks_update(r_cddata_masks, &CD_MASK_BAREMESH);
/* check if we need tfaces & mcols due to view mode */
for (const ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
if (sa->spacetype == SPACE_VIEW3D) {
- mask |= ED_view3d_datamask(C, scene, sa->spacedata.first);
+ ED_view3d_datamask(C, scene, sa->spacedata.first, r_cddata_masks);
}
}
-
- return mask;
}
/**
diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c
index 93cdecec557..0054680281b 100644
--- a/source/blender/editors/space_view3d/view3d_iterators.c
+++ b/source/blender/editors/space_view3d/view3d_iterators.c
@@ -115,7 +115,7 @@ void meshobject_foreachScreenVert(
Scene *scene_eval = DEG_get_evaluated_scene(vc->depsgraph);
Object *ob_eval = DEG_get_evaluated_object(vc->depsgraph, vc->obact);
- me = mesh_get_eval_deform(vc->depsgraph, scene_eval, ob_eval, CD_MASK_BAREMESH);
+ me = mesh_get_eval_deform(vc->depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
@@ -155,7 +155,7 @@ void mesh_foreachScreenVert(
{
foreachScreenVert_userData data;
- Mesh *me = editbmesh_get_eval_cage_from_orig(vc->depsgraph, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+ Mesh *me = editbmesh_get_eval_cage_from_orig(vc->depsgraph, vc->scene, vc->obedit, vc->em, &CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
@@ -208,7 +208,7 @@ void mesh_foreachScreenEdge(
{
foreachScreenEdge_userData data;
- Mesh *me = editbmesh_get_eval_cage_from_orig(vc->depsgraph, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+ Mesh *me = editbmesh_get_eval_cage_from_orig(vc->depsgraph, vc->scene, vc->obedit, vc->em, &CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
@@ -253,7 +253,7 @@ void mesh_foreachScreenFace(
{
foreachScreenFace_userData data;
- Mesh *me = editbmesh_get_eval_cage_from_orig(vc->depsgraph, vc->scene, vc->obedit, vc->em, CD_MASK_BAREMESH);
+ Mesh *me = editbmesh_get_eval_cage_from_orig(vc->depsgraph, vc->scene, vc->obedit, vc->em, &CD_MASK_BAREMESH);
ED_view3d_check_mats_rv3d(vc->rv3d);
data.vc = *vc;
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
index d64d0a3cbfd..104b27965a5 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
@@ -23,6 +23,8 @@
#include <stdio.h>
+#include "BLI_utildefines.h"
+
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_gpencil_types.h"
diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h
index 4bacfd15751..91412044e0e 100644
--- a/source/blender/makesdna/DNA_customdata_types.h
+++ b/source/blender/makesdna/DNA_customdata_types.h
@@ -190,6 +190,19 @@ typedef enum CustomDataType {
#define CD_MASK_TESSLOOPNORMAL (1LL << CD_TESSLOOPNORMAL)
#define CD_MASK_CUSTOMLOOPNORMAL (1LL << CD_CUSTOMLOOPNORMAL)
+/** Data types that may be defined for all mesh elements types. */
+#define CD_MASK_GENERIC_DATA (CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR)
+
+
+typedef struct CustomData_MeshMasks {
+ uint64_t vmask;
+ uint64_t emask;
+ uint64_t fmask;
+ uint64_t pmask;
+ uint64_t lmask;
+} CustomData_MeshMasks;
+
+
/* CustomData.flag */
enum {
/* Indicates layer should not be copied by CustomData_from_template or CustomData_copy_data */
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index eac8b82d6ea..3b09801b4b7 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -28,6 +28,7 @@
#include "DNA_object_enums.h"
#include "DNA_defs.h"
+#include "DNA_customdata_types.h"
#include "DNA_listBase.h"
#include "DNA_ID.h"
#include "DNA_action_types.h" /* bAnimVizSettings */
@@ -122,13 +123,15 @@ typedef struct LodLevel {
* TODO(sergey): Consider moving it to more appropriate place. */
struct ObjectBBoneDeform;
+struct CustomData_MeshMasks;
+
/* Not saved in file! */
typedef struct Object_Runtime {
/**
* The custom data layer mask that was last used
* to calculate mesh_eval and mesh_deform_eval.
*/
- uint64_t last_data_mask;
+ CustomData_MeshMasks last_data_mask;
/** Did last modifier stack generation need mapping support? */
char last_need_mapping;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 5e1f4304389..2607ca5f333 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -34,6 +34,7 @@ extern "C" {
#endif
#include "DNA_color_types.h" /* color management */
+#include "DNA_customdata_types.h" /* Scene's runtime cddata masks. */
#include "DNA_vec_types.h"
#include "DNA_listBase.h"
#include "DNA_ID.h"
@@ -50,6 +51,7 @@ struct Brush;
struct Collection;
struct ColorSpace;
struct CurveMapping;
+struct CustomData_MeshMasks;
struct Editing;
struct Image;
struct MovieClip;
@@ -1752,10 +1754,9 @@ typedef struct Scene {
void *_pad8;
/* XXX. runtime flag for drawing, actually belongs in the window,
* only used by BKE_object_handle_update() */
- uint64_t customdata_mask;
+ struct CustomData_MeshMasks customdata_mask;
/* XXX. same as above but for temp operator use (gl renders) */
- uint64_t customdata_mask_modal;
-
+ struct CustomData_MeshMasks customdata_mask_modal;
/* Color Management */
ColorManagedViewSettings view_settings;
diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c
index 31c78533151..f9f94560452 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -937,7 +937,9 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf(
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
- me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, CD_MASK_BAREMESH | CD_MASK_MLOOPUV);
+ CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH;
+ cddata_masks.lmask |= CD_MASK_MLOOPUV;
+ me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, &cddata_masks);
num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPUV);
RNA_enum_item_add_separator(&item, &totitem);
@@ -959,7 +961,9 @@ static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf(
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
- me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, CD_MASK_BAREMESH | CD_MASK_MLOOPCOL);
+ CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH;
+ cddata_masks.lmask |= CD_MASK_MLOOPCOL;
+ me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, &cddata_masks);
num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPCOL);
RNA_enum_item_add_separator(&item, &totitem);
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index e58beaaa42d..4a474dde585 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -65,14 +65,10 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
tamd->prevCos = NULL;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *r_cddata_masks)
{
- CustomDataMask dataMask = 0;
-
/* ask for vertexgroups */
- dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 0b28f51a338..3450e745341 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -69,15 +69,14 @@ static void copyData(const ModifierData *md_src, ModifierData *md_dst, const int
modifier_copyData_generic(md_src, md_dst, flag);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
BevelModifierData *bmd = (BevelModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (bmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (bmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
/*
@@ -117,7 +116,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
.add_key_index = false,
.use_shapekey = false,
.active_shapekey = 0,
- .cd_mask_extra = CD_MASK_ORIGINDEX,
+ /* XXX We probably can use CD_MASK_BAREMESH_ORIGDINDEX here instead (also for other modifiers cases)? */
+ .cd_mask_extra = {.vmask=CD_MASK_ORIGINDEX, .emask=CD_MASK_ORIGINDEX, .pmask=CD_MASK_ORIGINDEX},
});
if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0])
@@ -188,7 +188,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
harden_normals, face_strength_mode,
miter_outer, miter_inner, spread, mesh->smoothresh);
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BLI_assert(bm->vtoolflagpool == NULL &&
bm->etoolflagpool == NULL &&
diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c
index b81536ff947..a90ddde7946 100644
--- a/source/blender/modifiers/intern/MOD_boolean.c
+++ b/source/blender/modifiers/intern/MOD_boolean.c
@@ -301,7 +301,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
MEM_freeN(looptris);
}
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BM_mesh_free(bm);
@@ -321,13 +321,11 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
return result;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *r_cddata_masks)
{
- CustomDataMask dataMask = CD_MASK_MTFACE | CD_MASK_MEDGE;
-
- dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->emask |= CD_MASK_MEDGE;
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
}
ModifierTypeInfo modifierType_Boolean = {
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index 4aac71dd58d..f408a22aadf 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -66,15 +66,14 @@ static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool
return false;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
CastModifierData *cmd = (CastModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (cmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (cmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void foreachObjectLink(
diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 54dcf796036..41f35faac1b 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -127,18 +127,17 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DEG_add_modifier_to_transform_relation(ctx->node, "Cloth Modifier");
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
- CustomDataMask dataMask = 0;
ClothModifierData *clmd = (ClothModifierData *)md;
- if (cloth_uses_vgroup(clmd))
- dataMask |= CD_MASK_MDEFORMVERT;
-
- if (clmd->sim_parms->shapekey_rest != 0)
- dataMask |= CD_MASK_CLOTH_ORCO;
+ if (cloth_uses_vgroup(clmd)) {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
- return dataMask;
+ if (clmd->sim_parms->shapekey_rest != 0) {
+ r_cddata_masks->vmask |= CD_MASK_CLOTH_ORCO;
+ }
}
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c
index fa5e68fa630..cc6177b9bc8 100644
--- a/source/blender/modifiers/intern/MOD_correctivesmooth.c
+++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c
@@ -105,15 +105,14 @@ static void freeData(ModifierData *md)
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
- CustomDataMask dataMask = 0;
+
/* ask for vertex groups if we need them */
- if (csmd->defgrp_name[0]) {
- dataMask |= CD_MASK_MDEFORMVERT;
+ if (csmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
- return dataMask;
}
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index 4a8b6de9981..f3a5e280947 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -50,15 +50,14 @@ static void initData(ModifierData *md)
cmd->defaxis = MOD_CURVE_POSX;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
CurveModifierData *cmd = (CurveModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (cmd->name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (cmd->name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams))
diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c
index d7b18074b09..3e461476eac 100644
--- a/source/blender/modifiers/intern/MOD_datatransfer.c
+++ b/source/blender/modifiers/intern/MOD_datatransfer.c
@@ -75,19 +75,16 @@ static void initData(ModifierData *md)
dtmd->flags = MOD_DATATRANSFER_OBSRC_TRANSFORM;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
DataTransferModifierData *dtmd = (DataTransferModifierData *) md;
- CustomDataMask dataMask = 0;
- if (dtmd->defgrp_name[0]) {
+ if (dtmd->defgrp_name[0] != '\0') {
/* We need vertex groups! */
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
- dataMask |= BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types);
-
- return dataMask;
+ BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types, r_cddata_masks);
}
static bool dependsOnNormals(ModifierData *md)
@@ -123,10 +120,11 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
{
DataTransferModifierData *dtmd = (DataTransferModifierData *) md;
if (dtmd->ob_source != NULL) {
- CustomDataMask mask = BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types);
+ CustomData_MeshMasks cddata_masks = {0};
+ BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types, &cddata_masks);
DEG_add_object_relation(ctx->node, dtmd->ob_source, DEG_OB_COMP_GEOMETRY, "DataTransfer Modifier");
- DEG_add_customdata_mask(ctx->node, dtmd->ob_source, mask);
+ DEG_add_customdata_mask(ctx->node, dtmd->ob_source, &cddata_masks);
if (dtmd->flags & MOD_DATATRANSFER_OBSRC_TRANSFORM) {
DEG_add_object_relation(ctx->node, dtmd->ob_source, DEG_OB_COMP_TRANSFORM, "DataTransfer Modifier");
diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c
index fbc3529c221..52289ef107e 100644
--- a/source/blender/modifiers/intern/MOD_decimate.c
+++ b/source/blender/modifiers/intern/MOD_decimate.c
@@ -57,17 +57,14 @@ static void initData(ModifierData *md)
dmd->defgrp_factor = 1.0;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
DecimateModifierData *dmd = (DecimateModifierData *) md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (dmd->defgrp_name[0] && (dmd->defgrp_factor > 0.0f)) {
- dataMask |= CD_MASK_MDEFORMVERT;
+ if (dmd->defgrp_name[0] != '\0' && (dmd->defgrp_factor > 0.0f)) {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
-
- return dataMask;
}
static DecimateModifierData *getOriginalModifierData(
@@ -166,7 +163,7 @@ static Mesh *applyModifier(
&(struct BMeshCreateParams){0},
&(struct BMeshFromMeshParams){
.calc_face_normal = calc_face_normal,
- .cd_mask_extra = CD_MASK_ORIGINDEX,
+ .cd_mask_extra = {.vmask=CD_MASK_ORIGINDEX, .emask=CD_MASK_ORIGINDEX, .pmask=CD_MASK_ORIGINDEX},
});
switch (dmd->mode) {
@@ -199,7 +196,7 @@ static Mesh *applyModifier(
updateFaceCount(ctx, dmd, bm->totface);
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BLI_assert(bm->vtoolflagpool == NULL &&
bm->etoolflagpool == NULL &&
bm->ftoolflagpool == NULL); /* make sure we never alloc'd these */
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index fc619837cb7..87b25982d81 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -65,22 +65,23 @@ static void initData(ModifierData *md)
dmd->space = MOD_DISP_SPACE_LOCAL;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
DisplaceModifierData *dmd = (DisplaceModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (dmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
+ if (dmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
/* ask for UV coordinates if we need them */
- if (dmd->texmapping == MOD_DISP_MAP_UV) dataMask |= CD_MASK_MTFACE;
+ if (dmd->texmapping == MOD_DISP_MAP_UV) {
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
if (dmd->direction == MOD_DISP_DIR_CLNOR) {
- dataMask |= CD_MASK_CUSTOMLOOPNORMAL;
+ r_cddata_masks->lmask |= CD_MASK_CUSTOMLOOPNORMAL;
}
-
- return dataMask;
}
static bool dependsOnTime(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index 3fea556c3e4..b84e46e145c 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -64,10 +64,9 @@ static void freeData(ModifierData *md)
dynamicPaint_Modifier_free(pmd);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
- CustomDataMask dataMask = 0;
if (pmd->canvas) {
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
@@ -76,21 +75,20 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ ||
surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE)
{
- dataMask |= CD_MASK_MLOOPUV;
+ r_cddata_masks->lmask |= CD_MASK_MLOOPUV;
}
/* mcol */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT ||
surface->init_color_type == MOD_DPAINT_INITIAL_VERTEXCOLOR)
{
- dataMask |= CD_MASK_MLOOPCOL;
+ r_cddata_masks->lmask |= CD_MASK_MLOOPCOL;
}
/* CD_MDEFORMVERT */
if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) {
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
}
}
- return dataMask;
}
static Mesh *applyModifier(
diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c
index 548790ef78f..70c1ec5a59b 100644
--- a/source/blender/modifiers/intern/MOD_edgesplit.c
+++ b/source/blender/modifiers/intern/MOD_edgesplit.c
@@ -60,7 +60,7 @@ static Mesh *doEdgeSplit(Mesh *mesh, EdgeSplitModifierData *emd)
.add_key_index = false,
.use_shapekey = false,
.active_shapekey = 0,
- .cd_mask_extra = CD_MASK_ORIGINDEX,
+ .cd_mask_extra = {.vmask=CD_MASK_ORIGINDEX, .emask=CD_MASK_ORIGINDEX, .pmask=CD_MASK_ORIGINDEX},
});
if (do_split_angle) {
@@ -100,7 +100,7 @@ static Mesh *doEdgeSplit(Mesh *mesh, EdgeSplitModifierData *emd)
/* BM_mesh_validate(bm); */ /* for troubleshooting */
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BM_mesh_free(bm);
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c
index 5c5612f29a4..3a0449a4e52 100644
--- a/source/blender/modifiers/intern/MOD_explode.c
+++ b/source/blender/modifiers/intern/MOD_explode.c
@@ -76,15 +76,13 @@ static bool dependsOnTime(ModifierData *UNUSED(md))
{
return true;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
ExplodeModifierData *emd = (ExplodeModifierData *) md;
- CustomDataMask dataMask = 0;
- if (emd->vgroup)
- dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (emd->vgroup) {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void createFacepa(
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index 0646f634e0d..e911dbc4b5a 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -67,16 +67,20 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
thmd->indexar = MEM_dupallocN(hmd->indexar);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
HookModifierData *hmd = (HookModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (hmd->name[0]) dataMask |= CD_MASK_MDEFORMVERT;
- if (hmd->indexar) dataMask |= CD_MASK_ORIGINDEX;
-
- return dataMask;
+ if (hmd->name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
+ if (hmd->indexar != NULL) {
+ /* TODO check which origindex are actually needed? */
+ r_cddata_masks->vmask |= CD_MASK_ORIGINDEX;
+ r_cddata_masks->emask |= CD_MASK_ORIGINDEX;
+ r_cddata_masks->pmask |= CD_MASK_ORIGINDEX;
+ }
}
static void freeData(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c
index 827d555e900..db76b0fd0c2 100644
--- a/source/blender/modifiers/intern/MOD_laplaciandeform.c
+++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c
@@ -716,12 +716,13 @@ static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool
return 1;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)md;
- CustomDataMask dataMask = 0;
- if (lmd->anchor_grp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
- return dataMask;
+
+ if (lmd->anchor_grp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void deformVerts(
diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
index ee9f4ad8af7..a6670f313ce 100644
--- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c
+++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c
@@ -69,7 +69,7 @@ struct BLaplacianSystem {
};
typedef struct BLaplacianSystem LaplacianSystem;
-static CustomDataMask required_data_mask(Object *ob, ModifierData *md);
+static void required_data_mask(Object *ob, ModifierData *md, CustomData_MeshMasks *r_cddata_masks);
static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, bool useRenderParams);
static float compute_volume(const float center[3], float (*vertexCos)[3], const MPoly *mpoly, int numPolys, const MLoop *mloop);
static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numPolys, int a_numLoops, int a_numVerts);
@@ -476,15 +476,14 @@ static bool is_disabled(const struct Scene *UNUSED(scene), ModifierData *md, boo
return 0;
}
-static CustomDataMask required_data_mask(Object *UNUSED(ob), ModifierData *md)
+static void required_data_mask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (smd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (smd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void deformVerts(
diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index ba3624be71e..46a9c4f0a47 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -47,15 +47,14 @@ static void initData(ModifierData *md)
lmd->strength = 1.0f;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
LatticeModifierData *lmd = (LatticeModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (lmd->name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (lmd->name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams))
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index 3440f37516d..6d8317ffe77 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -49,9 +49,9 @@
#include "BLI_strict_flags.h"
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *r_cddata_masks)
{
- return CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
static void foreachObjectLink(
diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c
index 1717e554798..e59a6ae9add 100644
--- a/source/blender/modifiers/intern/MOD_meshdeform.c
+++ b/source/blender/modifiers/intern/MOD_meshdeform.c
@@ -89,15 +89,14 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
if (mmd->bindcos) tmmd->bindcos = MEM_dupallocN(mmd->bindcos); /* deprecated */
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
MeshDeformModifierData *mmd = (MeshDeformModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (mmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (mmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
@@ -303,7 +302,7 @@ static void meshdeformModifier_do(
if (cagemesh == NULL && mmd->bindcagecos == NULL && ob == DEG_get_original_object(ob)) {
/* Special case, binding happens outside of depsgraph evaluation, so we can build our own
* target mesh if needed. */
- cagemesh = mesh_create_eval_final_view(ctx->depsgraph, DEG_get_input_scene(ctx->depsgraph), mmd->object, 0);
+ cagemesh = mesh_create_eval_final_view(ctx->depsgraph, DEG_get_input_scene(ctx->depsgraph), mmd->object, &CD_MASK_BAREMESH);
free_cagemesh = cagemesh != NULL;
}
#endif
diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c
index 3f02268c04c..cb4243a6150 100644
--- a/source/blender/modifiers/intern/MOD_mirror.c
+++ b/source/blender/modifiers/intern/MOD_mirror.c
@@ -95,7 +95,7 @@ static Mesh *doBiscetOnMirrorPlane(
&(struct BMeshCreateParams){0},
&(struct BMeshFromMeshParams){
.calc_face_normal = true,
- .cd_mask_extra = CD_MASK_ORIGINDEX,
+ .cd_mask_extra = {.vmask=CD_MASK_ORIGINDEX, .emask=CD_MASK_ORIGINDEX, .pmask=CD_MASK_ORIGINDEX},
});
/* Define bisecting plane (aka mirror plane). */
@@ -122,7 +122,7 @@ static Mesh *doBiscetOnMirrorPlane(
}
}
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BM_mesh_free(bm);
return result;
diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c
index 8da49fb6632..d838d203ed5 100644
--- a/source/blender/modifiers/intern/MOD_normal_edit.c
+++ b/source/blender/modifiers/intern/MOD_normal_edit.c
@@ -499,17 +499,16 @@ static void initData(ModifierData *md)
enmd->mix_limit = M_PI;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
NormalEditModifierData *enmd = (NormalEditModifierData *)md;
- CustomDataMask dataMask = CD_MASK_CUSTOMLOOPNORMAL;
+
+ r_cddata_masks->lmask |= CD_MASK_CUSTOMLOOPNORMAL;
/* Ask for vertexgroups if we need them. */
- if (enmd->defgrp_name[0]) {
- dataMask |= (CD_MASK_MDEFORMVERT);
+ if (enmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
-
- return dataMask;
}
static bool dependsOnNormals(ModifierData *UNUSED(md))
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index cf8e51d4694..50ec32bd605 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -150,22 +150,17 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
}
#ifdef WITH_OCEANSIM
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
OceanModifierData *omd = (OceanModifierData *)md;
- CustomDataMask dataMask = 0;
- if (omd->flag & MOD_OCEAN_GENERATE_FOAM)
- dataMask |= CD_MASK_MCOL;
-
- return dataMask;
+ if (omd->flag & MOD_OCEAN_GENERATE_FOAM) {
+ r_cddata_masks->fmask |= CD_MASK_MCOL; /* XXX Should be loop cddata I guess? */
+ }
}
#else /* WITH_OCEANSIM */
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *UNUSED(r_cddata_masks))
{
- /* unused */
- (void)md;
- return 0;
}
#endif /* WITH_OCEANSIM */
diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c
index d219375b187..a9d8db493b8 100644
--- a/source/blender/modifiers/intern/MOD_particleinstance.c
+++ b/source/blender/modifiers/intern/MOD_particleinstance.c
@@ -63,19 +63,15 @@ static void initData(ModifierData *md)
STRNCPY(pimd->value_layer_name, "");
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
- CustomDataMask dataMask = 0;
if (pimd->index_layer_name[0] != '\0' ||
pimd->value_layer_name[0] != '\0')
{
- dataMask |= CD_MASK_MLOOPCOL;
+ r_cddata_masks->lmask |= CD_MASK_MLOOPCOL;
}
-
- return dataMask;
-
}
static bool isDisabled(const struct Scene *scene, ModifierData *md, bool useRenderParams)
diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c
index 2360d3e3713..08a19506694 100644
--- a/source/blender/modifiers/intern/MOD_particlesystem.c
+++ b/source/blender/modifiers/intern/MOD_particlesystem.c
@@ -81,10 +81,11 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
tpsmd->totdmvert = tpsmd->totdmedge = tpsmd->totdmface = 0;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md;
- return psys_emitter_customdata_mask(psmd->psys);
+
+ psys_emitter_customdata_mask(psmd->psys, r_cddata_masks);
}
/* saves the current emitter state for a particle system and calculates particles */
@@ -154,7 +155,7 @@ static void deformVerts(
if (em) {
/* In edit mode get directly from the edit mesh. */
- psmd->mesh_original = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, 0);
+ psmd->mesh_original = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL);
}
else {
/* Otherwise get regular mesh. */
diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c
index 4af838df02a..7b33df5bf86 100644
--- a/source/blender/modifiers/intern/MOD_shrinkwrap.c
+++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c
@@ -54,22 +54,20 @@ static void initData(ModifierData *md)
smd->auxTarget = NULL;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (smd->vgroup_name[0])
- dataMask |= CD_MASK_MDEFORMVERT;
+ if (smd->vgroup_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
if ((smd->shrinkType == MOD_SHRINKWRAP_PROJECT) &&
(smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL))
{
- dataMask |= CD_MASK_MVERT;
+ r_cddata_masks->vmask |= CD_MASK_MVERT; /* XXX Really? These should always be present, always... */
}
-
- return dataMask;
}
static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
@@ -136,16 +134,17 @@ static void deformVertsEM(
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
{
ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md;
- CustomDataMask mask = 0;
+ CustomData_MeshMasks mask = {0};
if (BKE_shrinkwrap_needs_normals(smd->shrinkType, smd->shrinkMode)) {
- mask |= CD_MASK_NORMAL | CD_MASK_CUSTOMLOOPNORMAL;
+ mask.vmask |= CD_MASK_NORMAL;
+ mask.lmask |= CD_MASK_NORMAL | CD_MASK_CUSTOMLOOPNORMAL;
}
if (smd->target != NULL) {
DEG_add_object_relation(ctx->node, smd->target, DEG_OB_COMP_TRANSFORM, "Shrinkwrap Modifier");
DEG_add_object_relation(ctx->node, smd->target, DEG_OB_COMP_GEOMETRY, "Shrinkwrap Modifier");
- DEG_add_customdata_mask(ctx->node, smd->target, mask);
+ DEG_add_customdata_mask(ctx->node, smd->target, &mask);
if (smd->shrinkType == MOD_SHRINKWRAP_TARGET_PROJECT) {
DEG_add_special_eval_flag(ctx->node, &smd->target->id, DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY);
}
@@ -153,7 +152,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
if (smd->auxTarget != NULL) {
DEG_add_object_relation(ctx->node, smd->auxTarget, DEG_OB_COMP_TRANSFORM, "Shrinkwrap Modifier");
DEG_add_object_relation(ctx->node, smd->auxTarget, DEG_OB_COMP_GEOMETRY, "Shrinkwrap Modifier");
- DEG_add_customdata_mask(ctx->node, smd->auxTarget, mask);
+ DEG_add_customdata_mask(ctx->node, smd->auxTarget, &mask);
if (smd->shrinkType == MOD_SHRINKWRAP_TARGET_PROJECT) {
DEG_add_special_eval_flag(ctx->node, &smd->auxTarget->id, DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY);
}
diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c
index f53f320d93f..cc36cfbf9eb 100644
--- a/source/blender/modifiers/intern/MOD_simpledeform.c
+++ b/source/blender/modifiers/intern/MOD_simpledeform.c
@@ -344,16 +344,14 @@ static void initData(ModifierData *md)
smd->limit[1] = 1.0f;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (smd->vgroup_name[0])
- dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (smd->vgroup_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void foreachObjectLink(
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index 75c485b879f..7ba7882d0d0 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -1875,7 +1875,7 @@ static Mesh *base_skin(Mesh *origmesh,
if (!bm)
return NULL;
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BM_mesh_free(bm);
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
@@ -1926,10 +1926,9 @@ static Mesh *applyModifier(ModifierData *md,
return result;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob),
- ModifierData *UNUSED(md))
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *r_cddata_masks)
{
- return CD_MASK_MVERT_SKIN | CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MVERT_SKIN | CD_MASK_MDEFORMVERT;
}
ModifierTypeInfo modifierType_Skin = {
diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c
index 5269d651c6d..905e8a18e1b 100644
--- a/source/blender/modifiers/intern/MOD_smoke.c
+++ b/source/blender/modifiers/intern/MOD_smoke.c
@@ -75,22 +75,20 @@ static void freeData(ModifierData *md)
smokeModifier_free(smd);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
SmokeModifierData *smd = (SmokeModifierData *)md;
- CustomDataMask dataMask = 0;
if (smd && (smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) {
if (smd->flow->source == MOD_SMOKE_FLOW_SOURCE_MESH) {
/* vertex groups */
if (smd->flow->vgroup_density)
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
/* uv layer */
if (smd->flow->texture_type == MOD_SMOKE_FLOW_TEXTURE_MAP_UV)
- dataMask |= CD_MASK_MTFACE;
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
}
}
- return dataMask;
}
static Mesh *applyModifier(
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index 65d93f0c608..2b9339842fa 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -64,15 +64,14 @@ static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool
return 0;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
SmoothModifierData *smd = (SmoothModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (smd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (smd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void smoothModifier_do(
diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c
index 1425269b642..e449403eb70 100644
--- a/source/blender/modifiers/intern/MOD_solidify.c
+++ b/source/blender/modifiers/intern/MOD_solidify.c
@@ -167,15 +167,14 @@ static void initData(ModifierData *md)
smd->flag = MOD_SOLIDIFY_RIM;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
SolidifyModifierData *smd = (SolidifyModifierData *) md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (smd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (smd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
/* specific function for solidify - define locally */
diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c
index d1e5a3e31f0..554545077fa 100644
--- a/source/blender/modifiers/intern/MOD_surfacedeform.c
+++ b/source/blender/modifiers/intern/MOD_surfacedeform.c
@@ -1153,7 +1153,7 @@ static void surfacedeformModifier_do(
if (target == NULL && smd->verts == NULL && ob == DEG_get_original_object(ob)) {
/* Special case, binding happens outside of depsgraph evaluation, so we can build our own
* target mesh if needed. */
- target = mesh_create_eval_final_view(ctx->depsgraph, DEG_get_input_scene(ctx->depsgraph), smd->target, 0);
+ target = mesh_create_eval_final_view(ctx->depsgraph, DEG_get_input_scene(ctx->depsgraph), smd->target, CD_MASK_BAREMESH);
free_target = target != NULL;
}
#endif
diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c
index 94910fbe80e..1d28d28286b 100644
--- a/source/blender/modifiers/intern/MOD_triangulate.c
+++ b/source/blender/modifiers/intern/MOD_triangulate.c
@@ -40,7 +40,7 @@ static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, const int ngon_
BMesh *bm;
int total_edges, i;
MEdge *me;
- CustomDataMask cddata_masks = CD_MASK_ORIGINDEX;
+ CustomData_MeshMasks cddata_masks = {.vmask=CD_MASK_ORIGINDEX, .emask=CD_MASK_ORIGINDEX, .pmask=CD_MASK_ORIGINDEX};
bool keep_clnors = (flag & MOD_TRIANGULATE_KEEP_CUSTOMLOOP_NORMALS) != 0;
@@ -48,7 +48,7 @@ static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, const int ngon_
BKE_mesh_calc_normals_split(mesh);
/* We need that one to 'survive' to/from BMesh conversions. */
CustomData_clear_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
- cddata_masks |= CD_MASK_NORMAL; /* TODO: once D4421 is in, only request CD_NORMAL on loop data... */
+ cddata_masks.lmask |= CD_MASK_NORMAL;
}
bm = BKE_mesh_to_bmesh_ex(
@@ -61,7 +61,7 @@ static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, const int ngon_
BM_mesh_triangulate(bm, quad_method, ngon_method, false, NULL, NULL, NULL);
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, cddata_masks);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, &cddata_masks);
BM_mesh_free(bm);
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 2d6e995403e..245186bbc02 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -179,7 +179,7 @@ Mesh *MOD_deform_mesh_eval_get(
}
else if (ob->type == OB_MESH) {
if (em) {
- mesh = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, 0);
+ mesh = BKE_mesh_from_bmesh_for_eval_nomain(em->bm, NULL);
}
else {
/* TODO(sybren): after modifier conversion of DM to Mesh is done, check whether
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 670cceb1ed5..26c7ec7ed13 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -57,14 +57,10 @@ static void initData(ModifierData *md)
umd->scalex = umd->scaley = 1.0f;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *r_cddata_masks)
{
- CustomDataMask dataMask = 0;
-
/* ask for UV coordinates */
- dataMask |= CD_MLOOPUV;
-
- return dataMask;
+ r_cddata_masks->lmask |= CD_MLOOPUV;
}
static void foreachObjectLink(
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c
index 8bf950ff175..d4f17b742f1 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.c
+++ b/source/blender/modifiers/intern/MOD_uvwarp.c
@@ -62,16 +62,14 @@ static void initData(ModifierData *md)
copy_v2_fl(umd->center, 0.5f);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
UVWarpModifierData *umd = (UVWarpModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (umd->vgroup_name[0])
- dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (umd->vgroup_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static void matrix_from_obj_pchan(float mat[4][4], Object *ob, const char *bonename)
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 9276b7df9b3..adda5df61ea 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -69,19 +69,19 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
twmd->curfalloff = curvemapping_copy(wmd->curfalloff);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WarpModifierData *wmd = (WarpModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (wmd->defgrp_name[0]) dataMask |= (CD_MASK_MDEFORMVERT);
- dataMask |= (CD_MASK_MDEFORMVERT);
+ if (wmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
/* ask for UV coordinates if we need them */
- if (wmd->texmapping == MOD_DISP_MAP_UV) dataMask |= (1 << CD_MTFACE);
-
- return dataMask;
+ if (wmd->texmapping == MOD_DISP_MAP_UV) {
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
}
static bool dependsOnTime(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index dce78819925..80ac323c82f 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -119,21 +119,19 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WaveModifierData *wmd = (WaveModifierData *)md;
- CustomDataMask dataMask = 0;
-
/* ask for UV coordinates if we need them */
- if (wmd->texture && wmd->texmapping == MOD_DISP_MAP_UV)
- dataMask |= CD_MASK_MTFACE;
+ if (wmd->texture && wmd->texmapping == MOD_DISP_MAP_UV) {
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
/* ask for vertexgroups if we need them */
- if (wmd->defgrp_name[0])
- dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
+ if (wmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static bool dependsOnNormals(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c
index 6321d1ac3cb..9eda072b7d3 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.c
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.c
@@ -602,20 +602,19 @@ static void initData(ModifierData *md)
wnmd->flag = 0;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WeightedNormalModifierData *wnmd = (WeightedNormalModifierData *)md;
- CustomDataMask dataMask = CD_MASK_CUSTOMLOOPNORMAL;
- if (wnmd->defgrp_name[0]) {
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->lmask = CD_MASK_CUSTOMLOOPNORMAL;
+
+ if (wnmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
}
if (wnmd->flag & MOD_WEIGHTEDNORMAL_FACE_INFLUENCE) {
- dataMask |= CD_MASK_PROP_INT;
+ r_cddata_masks->pmask |= CD_MASK_PROP_INT;
}
-
- return dataMask;
}
static bool dependsOnNormals(ModifierData *UNUSED(md))
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 8723136078e..32d058e5659 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -84,21 +84,19 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
twmd->cmap_curve = curvemapping_copy(wmd->cmap_curve);
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md;
- CustomDataMask dataMask = 0;
/* We need vertex groups! */
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
/* Ask for UV coordinates if we need them. */
- if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
- dataMask |= CD_MASK_MTFACE;
+ if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV) {
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
-
- return dataMask;
}
static bool dependsOnTime(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index f54efc0e4dd..495d235b406 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -119,21 +119,19 @@ static void initData(ModifierData *md)
wmd->mask_tex_mapping = MOD_DISP_MAP_LOCAL;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md;
- CustomDataMask dataMask = 0;
/* We need vertex groups! */
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
/* Ask for UV coordinates if we need them. */
- if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
- dataMask |= CD_MASK_MTFACE;
+ if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV) {
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
-
- return dataMask;
}
static bool dependsOnTime(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 8df4b1df780..2e2e4fe963d 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -288,21 +288,19 @@ static void initData(ModifierData *md)
wmd->max_dist = 1.0f; /* vert arbitrary distance, but don't use 0 */
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md;
- CustomDataMask dataMask = 0;
/* We need vertex groups! */
- dataMask |= CD_MASK_MDEFORMVERT;
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
/* Ask for UV coordinates if we need them. */
- if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV)
- dataMask |= CD_MASK_MTFACE;
+ if (wmd->mask_tex_mapping == MOD_DISP_MAP_UV) {
+ r_cddata_masks->fmask |= CD_MASK_MTFACE;
+ }
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
-
- return dataMask;
}
static bool dependsOnTime(ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.c
index 39c932e8afa..b9136233456 100644
--- a/source/blender/modifiers/intern/MOD_wireframe.c
+++ b/source/blender/modifiers/intern/MOD_wireframe.c
@@ -39,16 +39,14 @@ static void initData(ModifierData *md)
wmd->crease_weight = 1.0f;
}
-static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
+static void requiredDataMask(Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
{
WireframeModifierData *wmd = (WireframeModifierData *)md;
- CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if (wmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT;
-
- return dataMask;
-
+ if (wmd->defgrp_name[0] != '\0') {
+ r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
+ }
}
static bool dependsOnNormals(ModifierData *UNUSED(md))
@@ -71,7 +69,7 @@ static Mesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob, Mesh *
.add_key_index = false,
.use_shapekey = false,
.active_shapekey = 0,
- .cd_mask_extra = CD_MASK_ORIGINDEX,
+ .cd_mask_extra = {.vmask=CD_MASK_ORIGINDEX, .emask=CD_MASK_ORIGINDEX, .pmask=CD_MASK_ORIGINDEX},
});
BM_mesh_wireframe(
@@ -89,7 +87,7 @@ static Mesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob, Mesh *
MAX2(ob->totcol - 1, 0),
false);
- result = BKE_mesh_from_bmesh_for_eval_nomain(bm, 0);
+ result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL);
BM_mesh_free(bm);
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c
index 540c3aa0516..b371b482ece 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -941,7 +941,7 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
bool use_deform = true;
bool use_cage = false;
bool use_fnorm = true;
- const int mask = CD_MASK_BMESH;
+ CustomData_MeshMasks data_masks = CD_MASK_BMESH;
BPY_BM_CHECK_OBJ(self);
@@ -976,15 +976,15 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
return NULL;
}
else {
- me_eval = mesh_create_eval_final_render(depsgraph, scene_eval, ob_eval, mask);
+ me_eval = mesh_create_eval_final_render(depsgraph, scene_eval, ob_eval, &data_masks);
}
}
else {
if (use_cage) {
- me_eval = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, mask);
+ me_eval = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &data_masks);
}
else {
- me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, mask);
+ me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &data_masks);
}
}
}
@@ -996,10 +996,10 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
return NULL;
}
else if (use_render) {
- me_eval = mesh_create_eval_no_deform_render(depsgraph, scene_eval, ob, NULL, mask);
+ me_eval = mesh_create_eval_no_deform_render(depsgraph, scene_eval, ob, NULL, &data_masks);
}
else {
- me_eval = mesh_create_eval_no_deform(depsgraph, scene_eval, ob, NULL, mask);
+ me_eval = mesh_create_eval_no_deform(depsgraph, scene_eval, ob, NULL, &data_masks);
}
}
diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c
index d695e1b689d..9b972f5fc91 100644
--- a/source/blender/python/mathutils/mathutils_bvhtree.c
+++ b/source/blender/python/mathutils/mathutils_bvhtree.c
@@ -1045,7 +1045,7 @@ static Mesh *bvh_get_mesh(
{
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
/* we only need minimum mesh data for topology and vertex locations */
- CustomDataMask mask = CD_MASK_BAREMESH;
+ CustomData_MeshMasks data_masks = CD_MASK_BAREMESH;
const bool use_render = DEG_get_mode(depsgraph) == DAG_EVAL_RENDER;
*r_free_mesh = false;
@@ -1059,15 +1059,15 @@ static Mesh *bvh_get_mesh(
}
else {
*r_free_mesh = true;
- return mesh_create_eval_final_render(depsgraph, scene, ob, mask);
+ return mesh_create_eval_final_render(depsgraph, scene, ob, &data_masks);
}
}
else if (ob_eval != NULL) {
if (use_cage) {
- return mesh_get_eval_deform(depsgraph, scene, ob_eval, mask); /* ob->derivedDeform */
+ return mesh_get_eval_deform(depsgraph, scene, ob_eval, &data_masks); /* ob->derivedDeform */
}
else {
- return mesh_get_eval_final(depsgraph, scene, ob_eval, mask); /* ob->derivedFinal */
+ return mesh_get_eval_final(depsgraph, scene, ob_eval, &data_masks); /* ob->derivedFinal */
}
}
else {
@@ -1086,7 +1086,7 @@ static Mesh *bvh_get_mesh(
}
else {
*r_free_mesh = true;
- return mesh_create_eval_no_deform_render(depsgraph, scene, ob, NULL, mask);
+ return mesh_create_eval_no_deform_render(depsgraph, scene, ob, NULL, &data_masks);
}
}
else {
@@ -1097,7 +1097,7 @@ static Mesh *bvh_get_mesh(
}
else {
*r_free_mesh = true;
- return mesh_create_eval_no_deform(depsgraph, scene, ob, NULL, mask);
+ return mesh_create_eval_no_deform(depsgraph, scene, ob, NULL, &data_masks);
}
}
}
diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c
index 48bb0db24db..06d51fb161d 100644
--- a/source/blender/render/intern/source/pointdensity.c
+++ b/source/blender/render/intern/source/pointdensity.c
@@ -363,18 +363,21 @@ static void pointdensity_cache_object(PointDensity *pd,
{
float *data_color;
int i;
- CustomDataMask mask = CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL;
MVert *mvert = NULL, *mv;
Mesh *mesh = ob->data;
+#if 0 /* UNUSED */
+ CustomData_MeshMasks mask = CD_MASK_BAREMESH;
+ mask.fmask |= CD_MASK_MTFACE | CD_MASK_MCOL;
switch (pd->ob_color_source) {
case TEX_PD_COLOR_VERTCOL:
- mask |= CD_MASK_MLOOPCOL;
+ mask.lmask |= CD_MASK_MLOOPCOL;
break;
case TEX_PD_COLOR_VERTWEIGHT:
- mask |= CD_MASK_MDEFORMVERT;
+ mask.vmask |= CD_MASK_MDEFORMVERT;
break;
}
+#endif
mvert = mesh->mvert; /* local object space */
pd->totpoints = mesh->totvert;
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index ca0c931915f..08d7ec19eb3 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -47,6 +47,7 @@
#include "BLI_timer.h"
#include "BKE_context.h"
+#include "BKE_customdata.h"
#include "BKE_idprop.h"
#include "BKE_global.h"
#include "BKE_layer.h"
@@ -314,12 +315,12 @@ void wm_event_do_depsgraph(bContext *C)
return;
}
/* Combine datamasks so 1 win doesn't disable UV's in another [#26448]. */
- uint64_t win_combine_v3d_datamask = 0;
+ CustomData_MeshMasks win_combine_v3d_datamask = {0};
for (wmWindow *win = wm->windows.first; win; win = win->next) {
const Scene *scene = WM_window_get_active_scene(win);
const bScreen *screen = WM_window_get_active_screen(win);
- win_combine_v3d_datamask |= ED_view3d_screen_datamask(C, scene, screen);
+ ED_view3d_screen_datamask(C, scene, screen, &win_combine_v3d_datamask);
}
/* Update all the dependency graphs of visible view layers. */
for (wmWindow *win = wm->windows.first; win; win = win->next) {
@@ -329,7 +330,7 @@ void wm_event_do_depsgraph(bContext *C)
/* Copied to set's in scene_update_tagged_recursive() */
scene->customdata_mask = win_combine_v3d_datamask;
/* XXX, hack so operators can enforce datamasks [#26482], gl render */
- scene->customdata_mask |= scene->customdata_mask_modal;
+ CustomData_MeshMasks_update(&scene->customdata_mask, &scene->customdata_mask_modal);
/* TODO(sergey): For now all dependency graphs which are evaluated from
* workspace are considered active. This will work all fine with "locked"
* view layer and time across windows. This is to be granted separately,