Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-02-12 21:03:38 +0300
committerHans Goudey <h.goudey@me.com>2021-02-12 21:03:38 +0300
commit5393054a5d68e4340fd9e4fc41fb1d8f130cc6cc (patch)
treef741663466aab7ccc256fe9a9baf1738e8c3e846
parenta4baedea91196176cb07d15a4d8acfab52cf9f83 (diff)
Geometry Nodes: Add dependency relation for collection objects
Currently moving or changing an object references in a node modifier's node group does not trigger re-evaluation. Because there is no collection relation in the dependency graph, we must add the relation to all objects in the collection individually.
-rw-r--r--source/blender/modifiers/intern/MOD_nodes.cc39
1 files changed, 31 insertions, 8 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 23bfe76a5c3..0fec7cfe937 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -150,6 +150,31 @@ static void find_used_ids_from_settings(const NodesModifierSettings &settings, S
&ids);
}
+static void add_object_relation(const ModifierUpdateDepsgraphContext *ctx, Object &object)
+{
+ DEG_add_object_relation(ctx->node, &object, DEG_OB_COMP_TRANSFORM, "Nodes Modifier");
+ if (&(ID &)object != &ctx->object->id) {
+ if (object.type != OB_EMPTY) {
+ DEG_add_object_relation(ctx->node, &object, DEG_OB_COMP_GEOMETRY, "Nodes Modifier");
+ }
+ }
+}
+
+static void add_collection_object_relations_recursive(const ModifierUpdateDepsgraphContext *ctx,
+ Collection &collection)
+{
+ LISTBASE_FOREACH (CollectionObject *, collection_object, &collection.gobject) {
+ BLI_assert(collection_object->ob != nullptr);
+ Object &object = *collection_object->ob;
+ add_object_relation(ctx, object);
+ }
+ LISTBASE_FOREACH (CollectionChild *, collection_child, &collection.children) {
+ BLI_assert(collection_child->collection != nullptr);
+ Collection &collection = *collection_child->collection;
+ add_collection_object_relations_recursive(ctx, collection);
+ }
+}
+
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
{
NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md);
@@ -163,18 +188,16 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
for (ID *id : used_ids) {
if (GS(id->name) == ID_OB) {
Object *object = reinterpret_cast<Object *>(id);
- DEG_add_object_relation(ctx->node, object, DEG_OB_COMP_TRANSFORM, "Nodes Modifier");
- if (id != &ctx->object->id) {
- if (object->type != OB_EMPTY) {
- DEG_add_object_relation(
- ctx->node, (Object *)id, DEG_OB_COMP_GEOMETRY, "Nodes Modifier");
- }
- }
+ add_object_relation(ctx, *object);
+ }
+ if (GS(id->name) == ID_GR) {
+ Collection *collection = reinterpret_cast<Collection *>(id);
+ add_collection_object_relations_recursive(ctx, *collection);
}
}
}
- /* TODO: Add dependency for collection changes. */
+ /* TODO: Add dependency for adding and removing objects in collections. */
}
static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)