[Bf-blender-cvs] [8ff6322152f] master: Cleanup: improved comment for skipping updated with zero user meshes

Campbell Barton noreply at git.blender.org
Thu Jun 17 08:47:20 CEST 2021


Commit: 8ff6322152f3c1547c7e1f5c35535269c8db85a7
Author: Campbell Barton
Date:   Thu Jun 17 16:19:23 2021 +1000
Branches: master
https://developer.blender.org/rB8ff6322152f3c1547c7e1f5c35535269c8db85a7

Cleanup: improved comment for skipping updated with zero user meshes

Noticed by @sybren D11377 review.

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

M	source/blender/makesrna/intern/rna_mesh.c

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

diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index d5a1047d287..0f07fd2aa97 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -206,17 +206,22 @@ static bool rna_Mesh_has_custom_normals_get(PointerRNA *ptr)
 }
 
 /* -------------------------------------------------------------------- */
-/* Update Callbacks */
+/** \name Update Callbacks
+ *
+ * \note Skipping meshes without users is a simple way to avoid updates on newly created meshes.
+ * This speeds up importers that manipulate mesh data before linking it to an object & collection.
+ *
+ * \{ */
 
 static void rna_Mesh_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
 {
   ID *id = ptr->owner_id;
-
-  /* cheating way for importers to avoid slow updates */
-  if (id->us > 0) {
-    DEG_id_tag_update(id, 0);
-    WM_main_add_notifier(NC_GEOM | ND_DATA, id);
+  if (id->us <= 0) { /* See note in section heading. */
+    return;
   }
+
+  DEG_id_tag_update(id, 0);
+  WM_main_add_notifier(NC_GEOM | ND_DATA, id);
 }
 
 static void rna_Mesh_update_data_edit_weight(Main *bmain, Scene *scene, PointerRNA *ptr)
@@ -235,19 +240,21 @@ static void rna_Mesh_update_data_edit_active_color(Main *bmain, Scene *scene, Po
 static void rna_Mesh_update_select(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
 {
   ID *id = ptr->owner_id;
-  /* cheating way for importers to avoid slow updates */
-  if (id->us > 0) {
-    WM_main_add_notifier(NC_GEOM | ND_SELECT, id);
+  if (id->us <= 0) { /* See note in section heading. */
+    return;
   }
+
+  WM_main_add_notifier(NC_GEOM | ND_SELECT, id);
 }
 
 void rna_Mesh_update_draw(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
 {
   ID *id = ptr->owner_id;
-  /* cheating way for importers to avoid slow updates */
-  if (id->us > 0) {
-    WM_main_add_notifier(NC_GEOM | ND_DATA, id);
+  if (id->us <= 0) { /* See note in section heading. */
+    return;
   }
+
+  WM_main_add_notifier(NC_GEOM | ND_DATA, id);
 }
 
 static void rna_Mesh_update_vertmask(Main *bmain, Scene *scene, PointerRNA *ptr)
@@ -274,6 +281,8 @@ static void rna_Mesh_update_facemask(Main *bmain, Scene *scene, PointerRNA *ptr)
   rna_Mesh_update_draw(bmain, scene, ptr);
 }
 
+/** \} */
+
 /* -------------------------------------------------------------------- */
 /* Property get/set Callbacks  */



More information about the Bf-blender-cvs mailing list