diff options
Diffstat (limited to 'source/blender/blenkernel/intern/cdderivedmesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 5eeccb7b450..afde9d806c6 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -2069,24 +2069,21 @@ void CDDM_apply_vert_normals(DerivedMesh *dm, short (*vertNormals)[3]) copy_v3_v3_short(vert->no, vertNormals[i]); } -void CDDM_calc_normals_mapping(DerivedMesh *dm) +void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals) { CDDerivedMesh *cddm = (CDDerivedMesh*)dm; float (*face_nors)[3] = NULL; - /* use this to skip calculating normals on original vert's, this may need to be changed */ - const short only_face_normals = CustomData_is_referenced_layer(&dm->vertData, CD_MVERT); - if(dm->numVertData == 0) return; /* now we skip calculating vertex normals for referenced layer, * no need to duplicate verts. * WATCH THIS, bmesh only change!, * need to take care of the side effects here - campbell */ -#if 0 + #if 0 /* we don't want to overwrite any referenced layers */ cddm->mvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MVERT, dm->numVertData); -#endif + #endif if (dm->numTessFaceData == 0) { @@ -2105,17 +2102,24 @@ void CDDM_calc_normals_mapping(DerivedMesh *dm) face_nors = MEM_mallocN(sizeof(float)*3*dm->numTessFaceData, "face_nors"); - + /* calculate face normals */ mesh_calc_normals_mapping_ex(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm), - dm->numLoopData, dm->numPolyData, NULL, cddm->mface, dm->numTessFaceData, - CustomData_get_layer(&dm->faceData, CD_POLYINDEX), face_nors, - only_face_normals); - - CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN, - face_nors, dm->numTessFaceData); + dm->numLoopData, dm->numPolyData, NULL, cddm->mface, dm->numTessFaceData, + CustomData_get_layer(&dm->faceData, CD_POLYINDEX), face_nors, + only_face_normals); + + CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN, + face_nors, dm->numTessFaceData); +} + +void CDDM_calc_normals_mapping(DerivedMesh *dm) +{ + /* use this to skip calculating normals on original vert's, this may need to be changed */ + const short only_face_normals = CustomData_is_referenced_layer(&dm->vertData, CD_MVERT); + CDDM_calc_normals_mapping_ex(dm, only_face_normals); } /* bmesh note: this matches what we have in trunk */ |