diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-06-24 12:13:52 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-06-24 13:23:00 +0300 |
commit | 27da305a404f72a75a37892e1ac080c6531d059b (patch) | |
tree | 3fb809530c31b63882e95fa6c4ed1d9d6577e13f /source/blender/makesrna/intern | |
parent | 67b352f9c5317c81c8e862a49be656c56e8f0743 (diff) |
Depsgraph: support flushing parameters without a full COW update
Avoid computationally expensive copying operations
when only some settings have been modified.
This is done by adding support for updating parameters
without tagging for copy-on-write.
Currently only mesh data blocks are supported,
other data-blocks can be added individually.
This prepares for changing values such as edit-mesh auto-smooth angle
in edit-mode without duplicating all mesh-data.
The benefit will only be seen when the user interface no longer tags
all ID's for copy on write updates.
ID_RECALC_GEOMETRY_ALL_MODES has been added to support situations
where non edit-mode geometry is modified in edit-mode.
While this isn't something user are likely to do,
Python scripts may change the underlying mesh.
Reviewed By: sergey
Ref D11377
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 19 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh_api.c | 2 |
2 files changed, 17 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 77eed95d5be..2229fca1b45 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -239,6 +239,19 @@ static void rna_Mesh_update_data_legacy_deg_tag_all(Main *UNUSED(bmain), WM_main_add_notifier(NC_GEOM | ND_DATA, id); } +static void rna_Mesh_update_geom_and_params(Main *UNUSED(bmain), + Scene *UNUSED(scene), + PointerRNA *ptr) +{ + ID *id = ptr->owner_id; + if (id->us <= 0) { /* See note in section heading. */ + return; + } + + DEG_id_tag_update(id, ID_RECALC_GEOMETRY | ID_RECALC_PARAMETERS); + WM_main_add_notifier(NC_GEOM | ND_DATA, id); +} + static void rna_Mesh_update_data_edit_weight(Main *bmain, Scene *scene, PointerRNA *ptr) { BKE_mesh_batch_cache_dirty_tag(rna_mesh(ptr), BKE_MESH_BATCH_DIRTY_ALL); @@ -3333,7 +3346,7 @@ static void rna_def_mesh(BlenderRNA *brna) "Auto Smooth", "Auto smooth (based on smooth/sharp faces/edges and angle between faces), " "or use custom split normals data if available"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_geom_and_params"); prop = RNA_def_property(srna, "auto_smooth_angle", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "smoothresh"); @@ -3342,7 +3355,7 @@ static void rna_def_mesh(BlenderRNA *brna) "Auto Smooth Angle", "Maximum angle between face normals that will be considered as smooth " "(unused if custom split normals data are available)"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_geom_and_params"); RNA_define_verify_sdna(false); prop = RNA_def_property(srna, "has_custom_normals", PROP_BOOLEAN, PROP_NONE); @@ -3373,7 +3386,7 @@ static void rna_def_mesh(BlenderRNA *brna) prop, "Auto Texture Space", "Adjust active object's texture space automatically when transforming object"); - RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all"); + RNA_def_property_update(prop, 0, "rna_Mesh_update_geom_and_params"); # if 0 prop = RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION); diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index 2b0582cae9a..8128bdb83a0 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -208,7 +208,7 @@ static void rna_Mesh_clear_geometry(Mesh *mesh) { BKE_mesh_clear_geometry(mesh); - DEG_id_tag_update(&mesh->id, ID_RECALC_GEOMETRY); + DEG_id_tag_update(&mesh->id, ID_RECALC_GEOMETRY_ALL_MODES); WM_main_add_notifier(NC_GEOM | ND_DATA, mesh); } |