Fix T79117: dependency cycle with passive rigid body objects

Reviewers: zeddb

Differential Revision: D8431
This commit is contained in:
Jacques Lucke 2020-07-30 18:22:29 +02:00
parent 27d50d6f67
commit 8dc2fbd7b6
Notes: blender-bot 2023-09-08 04:55:43 +02:00
Referenced by issue #79117, Rigid body costraint produces dependency cycle
Referenced by issue #78952, Rigid Body Constraint on passive object causes dependency cycle
2 changed files with 24 additions and 7 deletions

View File

@ -1126,6 +1126,12 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
if (object->type != OB_MESH) {
continue;
}
if (object->rigidbody_object == nullptr) {
continue;
}
if (object->rigidbody_object->type == RBO_TYPE_PASSIVE) {
continue;
}
/* Create operation for flushing results. */
/* Object's transform component - where the rigidbody operation
* lives. */

View File

@ -1698,6 +1698,12 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
if (object->type != OB_MESH) {
continue;
}
if (object->rigidbody_object == nullptr) {
continue;
}
if (object->rigidbody_object->type == RBO_TYPE_PASSIVE) {
continue;
}
OperationKey rb_transform_copy_key(
&object->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY);
/* Rigid body synchronization depends on the actual simulation. */
@ -1747,13 +1753,18 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
/* 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);
OperationKey ob1_key(
&rbc->ob1->id, NodeType::TRANSFORM, OperationCode::RIGIDBODY_TRANSFORM_COPY);
OperationKey ob2_key(
&rbc->ob2->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");
add_relation(trans_key, ob2_key, "RigidBodyConstraint -> RBC.Object_2");
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");
}