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 /source/blender/blenkernel/intern/mesh_convert.c
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
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_convert.c')
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c39
1 files changed, 20 insertions, 19 deletions
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);
}