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:
Diffstat (limited to 'source/blender/modifiers/intern/MOD_nodes.cc')
-rw-r--r--source/blender/modifiers/intern/MOD_nodes.cc38
1 files changed, 34 insertions, 4 deletions
diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index 24a8a9621c5..0d5a9a9e609 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -177,7 +177,32 @@ static void add_used_ids_from_sockets(const ListBase &sockets, Set<ID *> &ids)
}
}
-static void find_used_ids_from_nodes(const bNodeTree &tree, Set<ID *> &ids)
+/**
+ * \note We can only check properties here that cause the dependency graph to update relations when
+ * they are changed, otherwise there may be a missing relation after editing. So this could check
+ * more properties like whether the node is muted, but we would have to accept the cost of updating
+ * relations when those properties are changed.
+ */
+static bool node_needs_own_transform_relation(const bNode &node)
+{
+ if (node.type == GEO_NODE_COLLECTION_INFO) {
+ const NodeGeometryCollectionInfo &storage = *static_cast<const NodeGeometryCollectionInfo *>(
+ node.storage);
+ return storage.transform_space == GEO_NODE_TRANSFORM_SPACE_RELATIVE;
+ }
+
+ if (node.type == GEO_NODE_OBJECT_INFO) {
+ const NodeGeometryObjectInfo &storage = *static_cast<const NodeGeometryObjectInfo *>(
+ node.storage);
+ return storage.transform_space == GEO_NODE_TRANSFORM_SPACE_RELATIVE;
+ }
+
+ return false;
+}
+
+static void process_nodes_for_depsgraph(const bNodeTree &tree,
+ Set<ID *> &ids,
+ bool &needs_own_transform_relation)
{
Set<const bNodeTree *> handled_groups;
@@ -188,9 +213,10 @@ static void find_used_ids_from_nodes(const bNodeTree &tree, Set<ID *> &ids)
if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) {
const bNodeTree *group = (bNodeTree *)node->id;
if (group != nullptr && handled_groups.add(group)) {
- find_used_ids_from_nodes(*group, ids);
+ process_nodes_for_depsgraph(*group, ids, needs_own_transform_relation);
}
}
+ needs_own_transform_relation |= node_needs_own_transform_relation(*node);
}
}
@@ -244,12 +270,12 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
return;
}
- DEG_add_modifier_to_transform_relation(ctx->node, "Nodes Modifier");
DEG_add_node_tree_output_relation(ctx->node, nmd->node_group, "Nodes Modifier");
+ bool needs_own_transform_relation = false;
Set<ID *> used_ids;
find_used_ids_from_settings(nmd->settings, used_ids);
- find_used_ids_from_nodes(*nmd->node_group, used_ids);
+ process_nodes_for_depsgraph(*nmd->node_group, used_ids, needs_own_transform_relation);
for (ID *id : used_ids) {
switch ((ID_Type)GS(id->name)) {
case ID_OB: {
@@ -273,6 +299,10 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
}
}
}
+
+ if (needs_own_transform_relation) {
+ DEG_add_modifier_to_transform_relation(ctx->node, "Nodes Modifier");
+ }
}
static bool check_tree_for_time_node(const bNodeTree &tree,