diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-06-17 09:19:23 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-06-17 09:32:08 +0300 |
commit | 8ff6322152f3c1547c7e1f5c35535269c8db85a7 (patch) | |
tree | 492b935d9a2e70f87d1d872ad487978b128dd5e3 /source | |
parent | 6db290641e0ece4d8353638036211b45c2880604 (diff) |
Cleanup: improved comment for skipping updated with zero user meshes
Noticed by @sybren D11377 review.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 33 |
1 files changed, 21 insertions, 12 deletions
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 */ |