diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-06-24 12:18:53 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-06-24 13:23:00 +0300 |
commit | 51568030e9c833da867c8d80c72b2eca2f591477 (patch) | |
tree | d6360324fb4e98e916a7795c9669ab9925a5f643 | |
parent | 27da305a404f72a75a37892e1ac080c6531d059b (diff) |
Depsgraph: remove redundant mesh data duplication in edit-mode
This resolves a bottleneck where every update while transforming
copied the entire mesh data-block, which isn't needed as the edit-mesh
is the source of the data being edited.
Testing shows a significant overall speedup when transforming:
- ~1.5x with a subdivided cube 1.5 million vertices.
- ~3.0x with the spring mesh (edit-mode with modifiers disabled,
duplicated 10x to drop performance).
Reviewed By: sergey
Ref D11337
-rw-r--r-- | source/blender/depsgraph/intern/node/deg_node_component.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/depsgraph/intern/node/deg_node_component.h b/source/blender/depsgraph/intern/node/deg_node_component.h index a7c69b27654..965022823d3 100644 --- a/source/blender/depsgraph/intern/node/deg_node_component.h +++ b/source/blender/depsgraph/intern/node/deg_node_component.h @@ -31,6 +31,10 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BKE_object.h" + +#include "DNA_object_types.h" + struct ID; struct bPoseChannel; @@ -158,6 +162,23 @@ struct ComponentNode : public Node { DEG_COMPONENT_NODE_DECLARE; \ } +/* When updating object data in edit-mode, don't request COW update since this will duplicate + * all object data which is unnecessary when the edit-mode data is used for calculating modifiers. + * + * TODO: Investigate modes besides edit-mode. */ +#define DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_OBDATA_IN_EDIT_MODE(name) \ + struct name##ComponentNode : public ComponentNode { \ + DEG_COMPONENT_NODE_DECLARE; \ + virtual bool need_tag_cow_before_update() override \ + { \ + if (OB_DATA_SUPPORT_EDITMODE(owner->id_type) && \ + BKE_object_data_is_in_editmode(owner->id_orig)) { \ + return false; \ + } \ + return true; \ + } \ + } + #define DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(name) \ struct name##ComponentNode : public ComponentNode { \ DEG_COMPONENT_NODE_DECLARE; \ @@ -171,7 +192,7 @@ DEG_COMPONENT_NODE_DECLARE_GENERIC(Animation); DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(BatchCache); DEG_COMPONENT_NODE_DECLARE_GENERIC(Cache); DEG_COMPONENT_NODE_DECLARE_GENERIC(CopyOnWrite); -DEG_COMPONENT_NODE_DECLARE_GENERIC(Geometry); +DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_OBDATA_IN_EDIT_MODE(Geometry); DEG_COMPONENT_NODE_DECLARE_GENERIC(ImageAnimation); DEG_COMPONENT_NODE_DECLARE_GENERIC(LayerCollections); DEG_COMPONENT_NODE_DECLARE_GENERIC(Particles); |