Changeset View
Changeset View
Standalone View
Standalone View
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
| Show First 20 Lines • Show All 1,697 Lines • ▼ Show 20 Lines | if (rbw->group != nullptr) { | ||||
| build_collection(nullptr, nullptr, rbw->group); | build_collection(nullptr, nullptr, rbw->group); | ||||
| FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->group, object) { | FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->group, object) { | ||||
| if (object->type != OB_MESH) { | if (object->type != OB_MESH) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (object->rigidbody_object == nullptr) { | if (object->rigidbody_object == nullptr) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (object->rigidbody_object->type == RBO_TYPE_PASSIVE) { | |||||
| continue; | |||||
| } | |||||
| if (object->parent != nullptr && object->parent->rigidbody_object != nullptr && | if (object->parent != nullptr && object->parent->rigidbody_object != nullptr && | ||||
| object->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND) { | object->parent->rigidbody_object->shape == RB_SHAPE_COMPOUND) { | ||||
| /* If we are a child of a compound shape object, the transforms and sim evaluation will be | /* If we are a child of a compound shape object, the transforms and sim evaluation will be | ||||
| * handled by the parent compound shape object. Do not add any evaluation triggers | * handled by the parent compound shape object. Do not add any evaluation triggers | ||||
| * for the child objects. | * for the child objects. | ||||
| */ | */ | ||||
| continue; | continue; | ||||
| } | } | ||||
| OperationKey rb_transform_copy_key( | |||||
| &object->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY); | |||||
| /* Rigid body synchronization depends on the actual simulation. */ | |||||
| add_relation(rb_simulate_key, rb_transform_copy_key, "Rigidbody Sim Eval -> RBO Sync"); | |||||
| /* Simulation uses object transformation after parenting and solving constraints. */ | /* Simulation uses object transformation after parenting and solving constraints. */ | ||||
| OperationKey object_transform_simulation_init_key( | OperationKey object_transform_simulation_init_key( | ||||
| &object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_SIMULATION_INIT); | &object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_SIMULATION_INIT); | ||||
| OperationKey object_transform_eval_key( | OperationKey object_transform_eval_key( | ||||
JacquesLucke: Can this relation be moved into the `if (rigidbody_object_depends_on_evaluated_geometry)` block… | |||||
Done Inline ActionsI meant the if (BKE_rigidbody_is_affected_by_simulation) block. JacquesLucke: I meant the `if (BKE_rigidbody_is_affected_by_simulation)` block. | |||||
| &object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL); | &object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL); | ||||
| add_relation(object_transform_simulation_init_key, | add_relation(object_transform_simulation_init_key, | ||||
| rb_simulate_key, | rb_simulate_key, | ||||
| "Object Transform -> Rigidbody Sim Eval"); | "Object Transform -> Rigidbody Sim Eval"); | ||||
| /* Geometry must be known to create the rigid body. RBO_MESH_BASE | /* Geometry must be known to create the rigid body. RBO_MESH_BASE | ||||
| * uses the non-evaluated mesh, so then the evaluation is | * uses the non-evaluated mesh, so then the evaluation is | ||||
| * unnecessary. */ | * unnecessary. */ | ||||
| if (rigidbody_object_depends_on_evaluated_geometry(object->rigidbody_object)) { | if (rigidbody_object_depends_on_evaluated_geometry(object->rigidbody_object)) { | ||||
| /* NOTE: We prefer this relation to be never killed, to avoid | /* NOTE: We prefer this relation to be never killed, to avoid | ||||
| * access partially evaluated mesh from solver. */ | * access partially evaluated mesh from solver. */ | ||||
| ComponentKey object_geometry_key(&object->id, NodeType::GEOMETRY); | ComponentKey object_geometry_key(&object->id, NodeType::GEOMETRY); | ||||
| add_relation(object_geometry_key, | add_relation(object_geometry_key, | ||||
| rb_simulate_key, | rb_simulate_key, | ||||
| "Object Geom Eval -> Rigidbody Rebuild", | "Object Geom Eval -> Rigidbody Sim Eval", | ||||
| RELATION_FLAG_GODMODE); | RELATION_FLAG_GODMODE); | ||||
| } | } | ||||
| /* Final transform is whetever solver gave to us. */ | /* Final transform is whetever solver gave to us. */ | ||||
| if (BKE_rigidbody_is_affected_by_simulation(object)) { | |||||
| /* We do not have to update the objects final transform after the simulation if it is | |||||
| * passive or controlled by the animation system in blender. | |||||
| * (Bullet doesn't move the object at all in these cases) | |||||
| */ | |||||
| OperationKey rb_transform_copy_key( | |||||
| &object->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY); | |||||
| /* Rigid body synchronization depends on the actual simulation. */ | |||||
| add_relation(rb_simulate_key, rb_transform_copy_key, "Rigidbody Sim Eval -> RBO Sync"); | |||||
| OperationKey object_transform_final_key( | OperationKey object_transform_final_key( | ||||
| &object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_FINAL); | &object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_FINAL); | ||||
| add_relation( | add_relation(rb_transform_copy_key, | ||||
| rb_transform_copy_key, object_transform_final_key, "Rigidbody Sync -> Transform Final"); | object_transform_final_key, | ||||
| } | "Rigidbody Sync -> Transform Final"); | ||||
| FOREACH_COLLECTION_OBJECT_RECURSIVE_END; | |||||
| } | |||||
| /* Constraints. */ | |||||
| if (rbw->constraints != nullptr) { | |||||
| FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (rbw->constraints, object) { | |||||
| RigidBodyCon *rbc = object->rigidbody_constraint; | |||||
| if (rbc == nullptr || rbc->ob1 == nullptr || rbc->ob2 == nullptr) { | |||||
| /* When either ob1 or ob2 is nullptr, the constraint doesn't | |||||
| * work. */ | |||||
| continue; | |||||
| } | |||||
| /* Make sure indirectly linked objects are fully built. */ | |||||
| build_object(object); | |||||
| build_object(rbc->ob1); | |||||
| build_object(rbc->ob2); | |||||
| /* final result of the constraint object's transform controls how | |||||
| * the constraint affects the physics sim for these objects. */ | |||||
| ComponentKey trans_key(&object->id, NodeType::TRANSFORM); | |||||
| if (rbc->ob1->rigidbody_object->type == RBO_TYPE_ACTIVE) { | |||||
| OperationKey ob1_key( | |||||
| &rbc->ob1->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY); | |||||
| /* Constrained-objects sync depends on the constraint-holder. */ | |||||
| add_relation(trans_key, ob1_key, "RigidBodyConstraint -> RBC.Object_1"); | |||||
| } | |||||
| if (rbc->ob2->rigidbody_object->type == RBO_TYPE_ACTIVE) { | |||||
| OperationKey ob2_key( | |||||
| &rbc->ob2->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY); | |||||
| /* Constrained-objects sync depends on the constraint-holder. */ | |||||
| add_relation(trans_key, ob2_key, "RigidBodyConstraint -> RBC.Object_2"); | |||||
| } | } | ||||
| /* Ensure that sim depends on this constraint's transform. */ | |||||
| add_relation(trans_key, rb_simulate_key, "RigidBodyConstraint Transform -> RB Simulation"); | |||||
| } | } | ||||
| FOREACH_COLLECTION_OBJECT_RECURSIVE_END; | FOREACH_COLLECTION_OBJECT_RECURSIVE_END; | ||||
| } | } | ||||
| } | } | ||||
| void DepsgraphRelationBuilder::build_particle_systems(Object *object) | void DepsgraphRelationBuilder::build_particle_systems(Object *object) | ||||
| { | { | ||||
| TimeSourceKey time_src_key; | TimeSourceKey time_src_key; | ||||
| ▲ Show 20 Lines • Show All 1,154 Lines • Show Last 20 Lines | |||||
Can this relation be moved into the if (rigidbody_object_depends_on_evaluated_geometry) block below as well?