Geometry Nodes: Remove object transform dependency in some cases
The geometry nodes modifier currently always adds a dependency relation from the evaluated geometry to the object transform. However, that can be avoided unless there is a collection or object info node in "Relative" mode. In order to avoid requiring dependency graph relations updates often when editing a node tree, this patch doesn't check if the node is muted or if the data-block sockets are empty before adding the dependency. Fixes T95265 Differential Revision: https://developer.blender.org/D13973
This commit is contained in:
parent
b91ae8b14c
commit
c9b578eac8
Notes:
blender-bot
2023-12-08 16:39:08 +01:00
Referenced by issue #95265, Geometry nodes. Recalculation during object transform Referenced by issue #88332, Geometry nodes impacting performance even when GN modifier fully disabled
|
@ -10524,7 +10524,7 @@ static void def_geo_object_info(StructRNA *srna)
|
|||
RNA_def_property_enum_items(prop, rna_node_geometry_object_info_transform_space_items);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Transform Space", "The transformation of the vector and geometry outputs");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update_relations");
|
||||
}
|
||||
|
||||
static void def_geo_legacy_points_to_volume(StructRNA *srna)
|
||||
|
@ -10608,7 +10608,7 @@ static void def_geo_collection_info(StructRNA *srna)
|
|||
prop = RNA_def_property(srna, "transform_space", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, rna_node_geometry_collection_info_transform_space_items);
|
||||
RNA_def_property_ui_text(prop, "Transform Space", "The transformation of the geometry output");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update_relations");
|
||||
}
|
||||
|
||||
static void def_geo_legacy_attribute_proximity(StructRNA *srna)
|
||||
|
|
|
@ -176,7 +176,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;
|
||||
|
||||
|
@ -187,9 +212,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,12 +269,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: {
|
||||
|
@ -272,6 +298,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,
|
||||
|
|
Loading…
Reference in New Issue