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
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user