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:
authorCampbell Barton <ideasman42@gmail.com>2018-10-11 08:32:49 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-10-11 08:34:12 +0300
commitb7363941f7ddfd5154a0a61f17c6186d049793be (patch)
treebe23f7256974558ab872ebbd4547ac99d8451b60 /source/blender/blenkernel/intern
parentbf455c2ca98ff3062a733ad357f2c2c43ffda5df (diff)
Cleanup: make BKE_mesh_ensure_normals_for_display public
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c35
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.c29
2 files changed, 31 insertions, 33 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index e04a5bcf0a3..d1f58b675b2 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -1363,37 +1363,6 @@ static void add_shapekey_layers(Mesh *me_dst, Mesh *me_src, Object *UNUSED(ob))
}
}
-/**
- * Called after calculating all modifiers.
- *
- * \note tessfaces should already be calculated.
- */
-static void mesh_ensure_display_normals(Mesh *mesh)
-{
- /* Note: mesh *may* have a poly CD_NORMAL layer (generated by a modifier needing poly normals e.g.).
- * We do not use it here, though. And it should be tagged as temp!
- */
- /* BLI_assert((CustomData_has_layer(&mesh->pdata, CD_NORMAL) == false)); */
-
- if (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL || !CustomData_has_layer(&mesh->pdata, CD_NORMAL)) {
- float (*face_nors)[3] = NULL;
- face_nors = MEM_malloc_arrayN(mesh->totpoly, sizeof(*face_nors), "face_nors");
-
- /* if normals are dirty we want to calculate vertex normals too */
- bool only_face_normals = !(mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL);
-
- /* calculate face normals */
- BKE_mesh_calc_normals_poly(
- mesh->mvert, NULL, mesh->totvert, mesh->mloop, mesh->mpoly,
- mesh->totloop, mesh->totpoly, face_nors,
- only_face_normals);
-
- CustomData_add_layer(&mesh->pdata, CD_NORMAL, CD_ASSIGN, face_nors, mesh->totpoly);
-
- mesh->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL;
- }
-}
-
static void mesh_calc_modifiers(
struct Depsgraph *depsgraph, Scene *scene, Object *ob, float (*inputVertexCos)[3],
int useDeform,
@@ -1828,7 +1797,7 @@ static void mesh_calc_modifiers(
* If using loop normals, poly nors have already been computed.
*/
if (!do_loop_normals) {
- mesh_ensure_display_normals(*r_final);
+ BKE_mesh_ensure_normals_for_display(*r_final);
}
}
@@ -2167,7 +2136,7 @@ static void editbmesh_calc_modifiers(
/* same as mesh_calc_modifiers (if using loop normals, poly nors have already been computed). */
if (!do_loop_normals) {
- mesh_ensure_display_normals(*r_final);
+ BKE_mesh_ensure_normals_for_display(*r_final);
/* Some modifiers, like datatransfer, may generate those data, we do not want to keep them,
* as they are used by display code when available (i.e. even if autosmooth is disabled). */
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index f20d17c7917..f9ced904536 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -354,6 +354,35 @@ void BKE_mesh_ensure_normals(Mesh *mesh)
BLI_assert((mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL) == 0);
}
+/**
+ * Called after calculating all modifiers.
+ */
+void BKE_mesh_ensure_normals_for_display(Mesh *mesh)
+{
+ /* Note: mesh *may* have a poly CD_NORMAL layer (generated by a modifier needing poly normals e.g.).
+ * We do not use it here, though. And it should be tagged as temp!
+ */
+ /* BLI_assert((CustomData_has_layer(&mesh->pdata, CD_NORMAL) == false)); */
+
+ if (mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL || !CustomData_has_layer(&mesh->pdata, CD_NORMAL)) {
+ float (*poly_nors)[3] = NULL;
+ poly_nors = MEM_malloc_arrayN((size_t)mesh->totpoly, sizeof(*poly_nors), __func__);
+
+ /* if normals are dirty we want to calculate vertex normals too */
+ bool only_face_normals = !(mesh->runtime.cd_dirty_vert & CD_MASK_NORMAL);
+
+ /* calculate face normals */
+ BKE_mesh_calc_normals_poly(
+ mesh->mvert, NULL, mesh->totvert, mesh->mloop, mesh->mpoly,
+ mesh->totloop, mesh->totpoly, poly_nors,
+ only_face_normals);
+
+ CustomData_add_layer(&mesh->pdata, CD_NORMAL, CD_ASSIGN, poly_nors, mesh->totpoly);
+
+ mesh->runtime.cd_dirty_vert &= ~CD_MASK_NORMAL;
+ }
+}
+
/* 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)
{