Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_nodes.cc
| Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | switch (socket->type) { | ||||
| ids.add(&image->id); | ids.add(&image->id); | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| 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 updated, otherwise there may be a missing relation when the node tree is changed. 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_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_transform_relation) | |||||
| { | { | ||||
| Set<const bNodeTree *> handled_groups; | Set<const bNodeTree *> handled_groups; | ||||
| LISTBASE_FOREACH (const bNode *, node, &tree.nodes) { | LISTBASE_FOREACH (const bNode *, node, &tree.nodes) { | ||||
| add_used_ids_from_sockets(node->inputs, ids); | add_used_ids_from_sockets(node->inputs, ids); | ||||
| add_used_ids_from_sockets(node->outputs, ids); | add_used_ids_from_sockets(node->outputs, ids); | ||||
| if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) { | if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) { | ||||
| const bNodeTree *group = (bNodeTree *)node->id; | const bNodeTree *group = (bNodeTree *)node->id; | ||||
| if (group != nullptr && handled_groups.add(group)) { | if (group != nullptr && handled_groups.add(group)) { | ||||
| find_used_ids_from_nodes(*group, ids); | process_nodes_for_depsgraph(*group, ids, needs_transform_relation); | ||||
| } | } | ||||
| } | } | ||||
| needs_transform_relation |= node_needs_transform_relation(*node); | |||||
| } | } | ||||
| } | } | ||||
| static void find_used_ids_from_settings(const NodesModifierSettings &settings, Set<ID *> &ids) | static void find_used_ids_from_settings(const NodesModifierSettings &settings, Set<ID *> &ids) | ||||
| { | { | ||||
| IDP_foreach_property( | IDP_foreach_property( | ||||
| settings.properties, | settings.properties, | ||||
| IDP_TYPE_FILTER_ID, | IDP_TYPE_FILTER_ID, | ||||
| Show All 37 Lines | |||||
| static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) | static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) | ||||
| { | { | ||||
| NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md); | NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(md); | ||||
| if (nmd->node_group == nullptr) { | if (nmd->node_group == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| DEG_add_modifier_to_transform_relation(ctx->node, "Nodes Modifier"); | |||||
| DEG_add_node_tree_output_relation(ctx->node, nmd->node_group, "Nodes Modifier"); | DEG_add_node_tree_output_relation(ctx->node, nmd->node_group, "Nodes Modifier"); | ||||
| bool needs_transform_relation = false; | |||||
JacquesLucke: `needs_own_transform_relation`
The current name could also refer to the transforms of other… | |||||
| Set<ID *> used_ids; | Set<ID *> used_ids; | ||||
| find_used_ids_from_settings(nmd->settings, 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_transform_relation); | ||||
| for (ID *id : used_ids) { | for (ID *id : used_ids) { | ||||
| switch ((ID_Type)GS(id->name)) { | switch ((ID_Type)GS(id->name)) { | ||||
| case ID_OB: { | case ID_OB: { | ||||
| Object *object = reinterpret_cast<Object *>(id); | Object *object = reinterpret_cast<Object *>(id); | ||||
| add_object_relation(ctx, *object); | add_object_relation(ctx, *object); | ||||
| break; | break; | ||||
| } | } | ||||
| case ID_GR: { | case ID_GR: { | ||||
| Collection *collection = reinterpret_cast<Collection *>(id); | Collection *collection = reinterpret_cast<Collection *>(id); | ||||
| add_collection_relation(ctx, *collection); | add_collection_relation(ctx, *collection); | ||||
| break; | break; | ||||
| } | } | ||||
| case ID_IM: | case ID_IM: | ||||
| case ID_TE: { | case ID_TE: { | ||||
| DEG_add_generic_id_relation(ctx->node, id, "Nodes Modifier"); | DEG_add_generic_id_relation(ctx->node, id, "Nodes Modifier"); | ||||
| } | } | ||||
| default: { | default: { | ||||
| /* Purposefully don't add relations for materials. While there are material sockets, | /* Purposefully don't add relations for materials. While there are material sockets, | ||||
| * the pointers are only passed around as handles rather than dereferenced. */ | * the pointers are only passed around as handles rather than dereferenced. */ | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (needs_transform_relation) { | |||||
| DEG_add_modifier_to_transform_relation(ctx->node, "Nodes Modifier"); | |||||
| } | |||||
| } | } | ||||
| static bool check_tree_for_time_node(const bNodeTree &tree, | static bool check_tree_for_time_node(const bNodeTree &tree, | ||||
| Set<const bNodeTree *> &r_checked_trees) | Set<const bNodeTree *> &r_checked_trees) | ||||
| { | { | ||||
| if (!r_checked_trees.add(&tree)) { | if (!r_checked_trees.add(&tree)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 992 Lines • Show Last 20 Lines | |||||
needs_own_transform_relation
The current name could also refer to the transforms of other objects.