Changeset View
Standalone View
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
| Show First 20 Lines • Show All 675 Lines • ▼ Show 20 Lines | FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (collection, ob, graph_->mode) { | ||||
| } | } | ||||
| } | } | ||||
| FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; | FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; | ||||
| } | } | ||||
| } | } | ||||
| void DepsgraphRelationBuilder::build_object(Object *object) | void DepsgraphRelationBuilder::build_object(Object *object) | ||||
| { | { | ||||
| /* Various flags, flushing from bases/collections. | |||||
| * | |||||
| * NOTE: Do it before checking for whether object relations has been built because object might | |||||
| * be used by multiple view layers, order of view layers is undefined, and the layer relations | |||||
| * depend on the view layer which is currently being built. */ | |||||
| build_object_from_layer_relations_if_needed(object); | |||||
| if (built_map_.checkIsBuiltAndTag(object)) { | if (built_map_.checkIsBuiltAndTag(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. */ | |||||
| build_object_from_layer_relations(object); | |||||
| /* 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(object->parent); | build_object(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 71 Lines • ▼ Show 20 Lines | void DepsgraphRelationBuilder::build_object(Object *object) | ||||
| /* 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(final_transform_key, synchronize_key, "Synchronize to Original"); | add_relation(final_transform_key, synchronize_key, "Synchronize to Original"); | ||||
| /* Parameters. */ | /* Parameters. */ | ||||
| build_parameters(&object->id); | build_parameters(&object->id); | ||||
| } | } | ||||
| void DepsgraphRelationBuilder::build_object_from_layer_relations(Object *object) | void DepsgraphRelationBuilder::build_object_from_layer_relations_if_needed(Object *object) | ||||
| { | { | ||||
| OperationKey object_from_layer_entry_key( | OperationKey object_from_layer_entry_key( | ||||
| &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_FROM_LAYER_ENTRY); | &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_FROM_LAYER_ENTRY); | ||||
| OperationKey object_from_layer_exit_key( | OperationKey object_from_layer_exit_key( | ||||
| &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_FROM_LAYER_EXIT); | &object->id, NodeType::OBJECT_FROM_LAYER, OperationCode::OBJECT_FROM_LAYER_EXIT); | ||||
| 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); | ||||
sybren: Minor nag: it's unclear in this comment which view layer this depsgraph is built for. Is that… | |||||
Done Inline ActionsGood point. Feel free to either update comment directly or give suggestions for improvements. I've committed the patch since it is green and since it fixes rather annoying bug. sergey: Good point.
This isn't really important which view layer the depsgraph is built for. Whatever… | |||||
| if (!has_node(object_flags_key)) { | if (!has_node(object_flags_key)) { | ||||
| /* Just connect Entry -> Exit if there is no OBJECT_BASE_FLAGS node. */ | /* Just connect Entry -> Exit if there is no OBJECT_BASE_FLAGS node. */ | ||||
Not Done Inline Actionsa base sybren: a base | |||||
| add_relation(object_from_layer_entry_key, object_from_layer_exit_key, "Object from Layer"); | add_relation(object_from_layer_entry_key, | ||||
| object_from_layer_exit_key, | |||||
| "Object from Layer", | |||||
| RELATION_CHECK_BEFORE_ADD); | |||||
Not Done Inline Actionstypos (form, has) JacquesLucke: typos (`form`, `has`) | |||||
| return; | return; | ||||
Not Done Inline Actionstypo (ob) JacquesLucke: typo (`ob`) | |||||
| } | } | ||||
Not Done Inline ActionsThe last thing I don't understand yet is how the from every view layer works here. It seems like view_layer_done_key does not depend on the view layer, just on scene_. So isn't this just adding the same relation for every view layer? JacquesLucke: The last thing I don't understand yet is how the `from every view layer` works here. It seems… | |||||
Done Inline ActionsDepsgraph is per-scene per-view layer, so it is not possible to have multiple view layers of the same scene in the dependency graph. This patch will make it so that if multiple view layers from different scenes shares the same object the the relations to the OperationCode::OBJECT_BASE_FLAGS will be correct: they'll be coming from all view layers which are referencing the object. What I'm noticing now is that OperationCode::OBJECT_BASE_FLAGS operation itself is not really ready to handle this situation, but this can/should be solved separately, as the design behind what is the proper thing to do is not clear. I'll list it as a limitation of this patch. sergey: Depsgraph is per-scene per-view layer, so it is not possible to have multiple view layers of… | |||||
Not Done Inline Actionsa base sybren: a base | |||||
| /* Entry -> OBJECT_BASE_FLAGS -> Exit */ | /* Entry -> OBJECT_BASE_FLAGS -> Exit */ | ||||
| add_relation(object_from_layer_entry_key, object_flags_key, "Base flags flush Entry"); | add_relation(object_from_layer_entry_key, | ||||
| add_relation(object_flags_key, object_from_layer_exit_key, "Base flags flush Exit"); | object_flags_key, | ||||
| "Base flags flush Entry", | |||||
| RELATION_CHECK_BEFORE_ADD); | |||||
| add_relation(object_flags_key, | |||||
| object_from_layer_exit_key, | |||||
| "Base flags flush Exit", | |||||
| RELATION_CHECK_BEFORE_ADD); | |||||
| /* 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_from_layer_exit_key, synchronize_key, "Synchronize to Original"); | add_relation(object_from_layer_exit_key, | ||||
| synchronize_key, | |||||
| "Synchronize to Original", | |||||
| RELATION_CHECK_BEFORE_ADD); | |||||
| OperationKey view_layer_done_key( | OperationKey view_layer_done_key( | ||||
| &scene_->id, NodeType::LAYER_COLLECTIONS, OperationCode::VIEW_LAYER_EVAL); | &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"); | add_relation(view_layer_done_key, | ||||
| object_from_layer_entry_key, | |||||
| "View Layer flags to Object", | |||||
| RELATION_CHECK_BEFORE_ADD); | |||||
| } | } | ||||
| 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,235 Lines • Show Last 20 Lines | |||||
Minor nag: it's unclear in this comment which view layer this depsgraph is built for. Is that "View Layer C"? Or one of the alread-mentioned ones?