[Bf-blender-cvs] [6cf4999e500] master: Cleanup: Slightly improve mesh normals and runtime comments

Hans Goudey noreply at git.blender.org
Wed Nov 16 19:58:12 CET 2022


Commit: 6cf4999e5008bd94dbd23f1e1b752cd0273e14c6
Author: Hans Goudey
Date:   Wed Nov 16 12:45:59 2022 -0600
Branches: master
https://developer.blender.org/rB6cf4999e5008bd94dbd23f1e1b752cd0273e14c6

Cleanup: Slightly improve mesh normals and runtime comments

Also resolved an unused variable warning caused by an earlier cleanup.

===================================================================

M	source/blender/blenkernel/BKE_mesh.h
M	source/blender/blenkernel/intern/mesh_runtime.cc
M	source/blender/io/alembic/intern/abc_reader_mesh.cc

===================================================================

diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index f1bb1c076c1..ec3f12f2475 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -381,15 +381,16 @@ const float (*BKE_mesh_poly_normals_ensure(const struct Mesh *mesh))[3];
 void BKE_mesh_normals_tag_dirty(struct Mesh *mesh);
 
 /**
- * Check that a mesh with non-dirty normals has vertex and face custom data layers.
+ * Check that a mesh with non-dirty normals has the caches allocatred with a proper size.
  * If these asserts fail, it means some area cleared the dirty flag but didn't copy or add the
- * normal layers, or removed normals but didn't set the dirty flag.
+ * normals, or removed normals but didn't set the dirty flag.
  */
 void BKE_mesh_assert_normals_dirty_or_calculated(const struct Mesh *mesh);
 
 /**
- * Retrieve write access to the vertex normal layer, ensuring that it exists and that it is not
- * shared. The provided vertex normals should be the same as if they were calculated automatically.
+ * Retrieve write access to the cached vertex normals, ensuring that they are allocated but *not*
+ * that they are calculated. The provided vertex normals should be the same as if they were
+ * calculated automatically.
  *
  * \note In order to clear the dirty flag, this function should be followed by a call to
  * #BKE_mesh_vertex_normals_clear_dirty. This is separate so that normals are still tagged dirty
@@ -401,8 +402,9 @@ void BKE_mesh_assert_normals_dirty_or_calculated(const struct Mesh *mesh);
 float (*BKE_mesh_vertex_normals_for_write(struct Mesh *mesh))[3];
 
 /**
- * Retrieve write access to the poly normal layer, ensuring that it exists and that it is not
- * shared. The provided poly normals should be the same as if they were calculated automatically.
+ * Retrieve write access to the cached polygon normals, ensuring that they are allocated but *not*
+ * that they are calculated. The provided polygon normals should be the same as if they were
+ * calculated automatically.
  *
  * \note In order to clear the dirty flag, this function should be followed by a call to
  * #BKE_mesh_poly_normals_clear_dirty. This is separate so that normals are still tagged dirty
diff --git a/source/blender/blenkernel/intern/mesh_runtime.cc b/source/blender/blenkernel/intern/mesh_runtime.cc
index f7e4dc5b88b..9c2a0f94cb2 100644
--- a/source/blender/blenkernel/intern/mesh_runtime.cc
+++ b/source/blender/blenkernel/intern/mesh_runtime.cc
@@ -226,7 +226,6 @@ bool BKE_mesh_runtime_ensure_edit_data(struct Mesh *mesh)
   if (mesh->runtime->edit_data != nullptr) {
     return false;
   }
-
   mesh->runtime->edit_data = MEM_cnew<EditMeshData>(__func__);
   return true;
 }
@@ -250,6 +249,7 @@ void BKE_mesh_runtime_clear_cache(Mesh *mesh)
 
 void BKE_mesh_runtime_clear_geometry(Mesh *mesh)
 {
+  /* Tagging shared caches dirty will free the allocated data if there is only one user. */
   free_bvh_cache(*mesh->runtime);
   free_normals(*mesh->runtime);
   free_subdiv_ccg(*mesh->runtime);
diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc
index 458fd72501d..f2183624888 100644
--- a/source/blender/io/alembic/intern/abc_reader_mesh.cc
+++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc
@@ -246,7 +246,7 @@ static void read_mpolys(CDStreamConfig &config, const AbcMeshData &mesh_data)
   }
 }
 
-static void process_no_normals(CDStreamConfig &config)
+static void process_no_normals(CDStreamConfig & /*config*/)
 {
   /* Absence of normals in the Alembic mesh is interpreted as 'smooth'. */
 }



More information about the Bf-blender-cvs mailing list