Added BKE_mesh_ensure_normals()

This calls BKE_mesh_calc_normals() only if the mesh vertex normals are
marked as dirty.
This commit is contained in:
2018-05-08 10:06:37 +02:00
parent 42dfbf79c3
commit 66b1cd45fb
2 changed files with 10 additions and 0 deletions

View File

@@ -202,6 +202,7 @@ void BKE_mesh_calc_normals_poly(
int numLoops, int numPolys, float (*r_polyNors)[3],
const bool only_face_normals);
void BKE_mesh_calc_normals(struct Mesh *me);
void BKE_mesh_ensure_normals(struct Mesh *me);
void BKE_mesh_calc_normals_tessface(
struct MVert *mverts, int numVerts,
const struct MFace *mfaces, int numFaces,

View File

@@ -332,6 +332,15 @@ void BKE_mesh_calc_normals_poly(
MEM_freeN(lnors_weighted);
}
void BKE_mesh_ensure_normals(Mesh *mesh)
{
if (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) {
BKE_mesh_calc_normals(mesh);
}
BLI_assert((mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) == 0);
}
/* Note that this does not update the CD_NORMAL layer, but does update the normals in the CD_MVERT layer. */
void BKE_mesh_calc_normals(Mesh *mesh)
{
#ifdef DEBUG_TIME