diff options
author | Jacques Lucke <jacques@blender.org> | 2021-04-26 17:35:22 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-04-26 17:35:22 +0300 |
commit | b67fe05d4bea2d3c9efbd127e9d9dc3a897e89e6 (patch) | |
tree | 088364c494e90748663f0e29fec61dc8da9149a5 /source/blender/depsgraph/intern/depsgraph_build.cc | |
parent | a65d5dadeb610a8262acb0d9a57b3a15eec14e96 (diff) |
Depsgraph: support depending on collection geometry
This fixes T87666 and T83252.
The boolean modifier and geometry nodes can depend on the geometry
of an entire collection. Before, the modifiers had to manually create relations
to all the objects in the collection. This worked for the most part, but was
cumbersome and did not solve all issues. For example, the modifiers were not
properly updated when objects were added/removed from the referenced collection.
This commit introduces the concept of "collection geometry" in the depsgraph.
The geometry of a collection depends on the transforms and geometry of all
the objects in it. The boolean modifier and geometry nodes can now just depend
on the collection geometry instead of creating all the dependencies themselves.
Differential Revision: https://developer.blender.org/D11053
Diffstat (limited to 'source/blender/depsgraph/intern/depsgraph_build.cc')
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_build.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index 6717ba521f6..6c1e91d068b 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -32,11 +32,13 @@ #include "PIL_time_utildefines.h" #include "DNA_cachefile_types.h" +#include "DNA_collection_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_simulation_types.h" +#include "BKE_collection.h" #include "BKE_main.h" #include "BKE_scene.h" @@ -107,6 +109,29 @@ void DEG_add_object_relation(DepsNodeHandle *node_handle, deg_node_handle->builder->add_node_handle_relation(comp_key, deg_node_handle, description); } +void DEG_add_collection_geometry_relation(DepsNodeHandle *node_handle, + Collection *collection, + const char *description) +{ + deg::OperationKey operation_key{ + &collection->id, deg::NodeType::GEOMETRY, deg::OperationCode::GEOMETRY_EVAL_DONE}; + deg::DepsNodeHandle *deg_node_handle = get_node_handle(node_handle); + deg_node_handle->builder->add_node_handle_relation(operation_key, deg_node_handle, description); +} + +void DEG_add_collection_geometry_customdata_mask(DepsNodeHandle *node_handle, + Collection *collection, + const CustomData_MeshMasks *masks) +{ + FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (collection, ob) { + DEG_add_customdata_mask(node_handle, ob, masks); + if (ob->type == OB_EMPTY && ob->instance_collection != nullptr) { + DEG_add_collection_geometry_customdata_mask(node_handle, ob->instance_collection, masks); + } + } + FOREACH_COLLECTION_OBJECT_RECURSIVE_END; +} + void DEG_add_simulation_relation(DepsNodeHandle *node_handle, Simulation *simulation, const char *description) |