[Bf-blender-cvs] [0540e4372cf] pygpu_extensions: Geometry Nodes: Add dependency relation for collection objects
Hans Goudey
noreply at git.blender.org
Fri Feb 12 22:56:28 CET 2021
Commit: 0540e4372cf231530310ff2d655517a252dc83f5
Author: Hans Goudey
Date: Fri Feb 12 12:03:38 2021 -0600
Branches: pygpu_extensions
https://developer.blender.org/rB0540e4372cf231530310ff2d655517a252dc83f5
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.
===================================================================
M source/blender/modifiers/intern/MOD_nodes.cc
===================================================================
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)
More information about the Bf-blender-cvs
mailing list