Changeset View
Standalone View
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
| Show First 20 Lines • Show All 615 Lines • ▼ Show 20 Lines | FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (collection, ob, graph_->mode) { | ||||
| ComponentKey dupli_geometry_component_key(&ob->id, dupli_geometry_component_type); | ComponentKey dupli_geometry_component_key(&ob->id, dupli_geometry_component_type); | ||||
| add_relation(dupli_geometry_component_key, duplicator_key, "Dupligroup"); | add_relation(dupli_geometry_component_key, duplicator_key, "Dupligroup"); | ||||
| } | } | ||||
| } | } | ||||
| FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; | FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; | ||||
| } | } | ||||
| } | } | ||||
| void DepsgraphRelationBuilder::build_object(Base *base, Object *object) | void DepsgraphRelationBuilder::build_object(Base * /*base*/, Object *object) | ||||
| { | { | ||||
| if (built_map_.checkIsBuiltAndTag(object)) { | if (built_map_.checkIsBuiltAndTag(object)) { | ||||
| if (base != nullptr) { | |||||
| build_object_flags(base, object); | |||||
| } | |||||
| return; | return; | ||||
| } | } | ||||
| /* Object Transforms */ | /* Object Transforms */ | ||||
| OperationCode base_op = (object->parent) ? OperationCode::TRANSFORM_PARENT : | OperationCode base_op = (object->parent) ? OperationCode::TRANSFORM_PARENT : | ||||
| OperationCode::TRANSFORM_LOCAL; | OperationCode::TRANSFORM_LOCAL; | ||||
| OperationKey base_op_key(&object->id, NodeType::TRANSFORM, base_op); | OperationKey base_op_key(&object->id, NodeType::TRANSFORM, base_op); | ||||
| OperationKey init_transform_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_INIT); | OperationKey init_transform_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_INIT); | ||||
| OperationKey local_transform_key( | OperationKey local_transform_key( | ||||
| &object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_LOCAL); | &object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_LOCAL); | ||||
| OperationKey parent_transform_key( | OperationKey parent_transform_key( | ||||
| &object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_PARENT); | &object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_PARENT); | ||||
| OperationKey transform_eval_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL); | OperationKey transform_eval_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL); | ||||
| OperationKey final_transform_key( | OperationKey final_transform_key( | ||||
| &object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_FINAL); | &object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_FINAL); | ||||
| OperationKey ob_eval_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL); | OperationKey ob_eval_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL); | ||||
| add_relation(init_transform_key, local_transform_key, "Transform Init"); | add_relation(init_transform_key, local_transform_key, "Transform Init"); | ||||
| /* Various flags, flushing from bases/collections. */ | /* Various flags, flushing from bases/collections. */ | ||||
| build_object_flags(base, object); | build_object_from_layer_relations(object); | ||||
sergey: This is a bit confusing terminology. In the nodes builder the `build_object_from_layer()`is… | |||||
Done Inline ActionsEven though it makes sense given the FROM_LAYER component, my brain keeps reading it as build_X_from_Y, and we're not building an object from a layer. I agree that naming the function build_object_from_layer_relations is an improvement, so I'll do that and leave the overall naming for a future improvement. sybren: Even though it makes sense given the `FROM_LAYER` component, my brain keeps reading it as… | |||||
| /* Parenting. */ | /* Parenting. */ | ||||
| if (object->parent != nullptr) { | if (object->parent != nullptr) { | ||||
| /* Make sure parent object's relations are built. */ | /* Make sure parent object's relations are built. */ | ||||
| build_object(nullptr, object->parent); | build_object(nullptr, object->parent); | ||||
| /* Parent relationship. */ | /* Parent relationship. */ | ||||
| build_object_parent(object); | build_object_parent(object); | ||||
| /* Local -> parent. */ | /* Local -> parent. */ | ||||
| add_relation(local_transform_key, parent_transform_key, "ObLocal -> ObParent"); | add_relation(local_transform_key, parent_transform_key, "ObLocal -> ObParent"); | ||||
| ▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | void DepsgraphRelationBuilder::build_object_proxy_group(Object *object) | ||||
| /* Object is local here (local in .blend file, users interacts with it). */ | /* Object is local here (local in .blend file, users interacts with it). */ | ||||
| build_object(nullptr, object->proxy_group); | build_object(nullptr, object->proxy_group); | ||||
| OperationKey proxy_group_eval_key( | OperationKey proxy_group_eval_key( | ||||
| &object->proxy_group->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL); | &object->proxy_group->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL); | ||||
| OperationKey transform_eval_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL); | OperationKey transform_eval_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL); | ||||
| add_relation(proxy_group_eval_key, transform_eval_key, "Proxy Group Transform"); | add_relation(proxy_group_eval_key, transform_eval_key, "Proxy Group Transform"); | ||||
| } | } | ||||
| void DepsgraphRelationBuilder::build_object_flags(Base *base, Object *object) | void DepsgraphRelationBuilder::build_object_from_layer_relations(Object *object) | ||||
| { | { | ||||
| if (base == nullptr) { | OperationKey object_from_layer_entry_key( | ||||
| return; | &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_FROM_LAYER_ENTRY); | ||||
| } | OperationKey object_from_layer_exit_key( | ||||
| OperationKey view_layer_done_key( | &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_FROM_LAYER_EXIT); | ||||
| &scene_->id, NodeType::LAYER_COLLECTIONS, OperationCode::VIEW_LAYER_EVAL); | |||||
| OperationKey object_flags_key( | OperationKey object_flags_key( | ||||
| &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_BASE_FLAGS); | &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_BASE_FLAGS); | ||||
| add_relation(view_layer_done_key, object_flags_key, "Base flags flush"); | |||||
| /* Only connect Entry -> Exit if there is no OBJECT_BASE_FLAGS node. */ | |||||
| if (has_node(object_flags_key)) { | |||||
Done Inline ActionsThe base pointer is no longer used to determine whether there is an OBJECT_BASE_FLAGS node; the has_node() function is now used to do this. This allows the code to create the relations properly the first time the object is seen, rather than waiting until it is (maybe) seen with a non-nullptr base pointer. An alternative would be to always create the Entry → Exit relation, and create the Entry → OBJECT_BASE_FLAGS → Exit relations only when necessary. This would result in redundant relations, though, which the current approach avoids. sybren: The `base` pointer is no longer used to determine whether there is an `OBJECT_BASE_FLAGS` node… | |||||
| /* Entry -> OBJECT_BASE_FLAGS -> Exit */ | |||||
| add_relation(object_from_layer_entry_key, object_flags_key, "Base flags flush Entry"); | |||||
| add_relation(object_flags_key, object_from_layer_exit_key, "Base flags flush Exit"); | |||||
| /* Synchronization back to original object. */ | /* Synchronization back to original object. */ | ||||
| OperationKey synchronize_key( | OperationKey synchronize_key( | ||||
| &object->id, NodeType::SYNCHRONIZATION, OperationCode::SYNCHRONIZE_TO_ORIGINAL); | &object->id, NodeType::SYNCHRONIZATION, OperationCode::SYNCHRONIZE_TO_ORIGINAL); | ||||
| add_relation(object_flags_key, synchronize_key, "Synchronize to Original"); | add_relation(object_from_layer_exit_key, synchronize_key, "Synchronize to Original"); | ||||
Done Inline ActionsFROM_LAYER -> SYNCHRONIZATION seems to only happen when the object is build from base, and before this code was always run. Is this an intentional change? sergey: `FROM_LAYER` -> `SYNCHRONIZATION` seems to only happen when the object is build from base, and… | |||||
Done Inline ActionsThis was an intentional change. The code didn't always run. It was only run when base != nullptr. In other words, this happened:
So, in the old code the Base * is used to determine whether that FROM_LAYER → SYNCHRONIZATION needs to be added. Because of this, it needs to be called every time build_object() is called. My new approach uses has_node(object_flags_key) to determine whether that relation needs to be added or not. This means that it can do the right thing right away, without having to rely on future calls that may or may not pass a Base *. sybren: This was an intentional change.
The code didn't always run. It was only run when `base !=… | |||||
| } | |||||
| else { | |||||
| /* Directly connect Entry -> Exit. */ | |||||
| add_relation(object_from_layer_entry_key, object_from_layer_exit_key, "Object from Layer"); | |||||
| } | |||||
| OperationKey view_layer_done_key( | |||||
| &scene_->id, NodeType::LAYER_COLLECTIONS, OperationCode::VIEW_LAYER_EVAL); | |||||
| add_relation(view_layer_done_key, object_from_layer_entry_key, "View Layer flags to Object"); | |||||
| } | } | ||||
| void DepsgraphRelationBuilder::build_object_data(Object *object) | void DepsgraphRelationBuilder::build_object_data(Object *object) | ||||
| { | { | ||||
| if (object->data == nullptr) { | if (object->data == nullptr) { | ||||
| return; | return; | ||||
| } | } | ||||
| ID *obdata_id = (ID *)object->data; | ID *obdata_id = (ID *)object->data; | ||||
| ▲ Show 20 Lines • Show All 2,197 Lines • Show Last 20 Lines | |||||
This is a bit confusing terminology. In the nodes builder the build_object_from_layer()is used from the loop which iterates bases.
Here you can read this as "build relations inside of object's FROM_LAYER component", but then the lac of "symmetry" with nodes builder requires extra brain cells.
Maybe build_object_from_layer_relations would solve the mystery? What do you think?