From 8ff6322152f3c1547c7e1f5c35535269c8db85a7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 17 Jun 2021 16:19:23 +1000 Subject: Cleanup: improved comment for skipping updated with zero user meshes Noticed by @sybren D11377 review. --- source/blender/makesrna/intern/rna_mesh.c | 33 ++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'source/blender/makesrna/intern') 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 */ -- cgit v1.2.3