Fix T60566: Warnings in rigid body and certain conrfiguration

Was visible when constraint object is not directly visible via
view layers, need to indirectly pull it into the graph.
This commit is contained in:
Sergey Sharybin 2019-01-28 16:38:12 +01:00
parent a8c0a57fc3
commit 55e171be33
Notes: blender-bot 2023-02-14 04:04:23 +01:00
Referenced by issue #60566, Warning is displayed when disabling viewport of constraint object
2 changed files with 39 additions and 33 deletions

View File

@ -1061,37 +1061,28 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
/* Create nodes --------------------------------------------------------- */
/* XXX: is this the right component, or do we want to use another one
* instead?
*/
* instead? */
/* init/rebuild operation */
/*OperationDepsNode *init_node =*/ add_operation_node(
&scene->id, DEG_NODE_TYPE_TRANSFORM,
function_bind(BKE_rigidbody_rebuild_sim, _1, scene_cow),
DEG_OPCODE_RIGIDBODY_REBUILD);
/* do-sim operation */
// XXX: what happens if we need to split into several groups?
/* Init/rebuild operation. */
add_operation_node(&scene->id, DEG_NODE_TYPE_TRANSFORM,
function_bind(BKE_rigidbody_rebuild_sim, _1, scene_cow),
DEG_OPCODE_RIGIDBODY_REBUILD);
/* Do-sim operation. */
OperationDepsNode *sim_node = add_operation_node(
&scene->id, DEG_NODE_TYPE_TRANSFORM,
function_bind(BKE_rigidbody_eval_simulation, _1, scene_cow),
DEG_OPCODE_RIGIDBODY_SIM);
/* XXX: For now, the sim node is the only one that really matters here.
* If any other sims get added later, we may have to remove these hacks...
*/
sim_node->set_as_entry();
sim_node->set_as_exit();
sim_node->owner->entry_operation = sim_node;
sim_node->owner->exit_operation = sim_node;
/* objects - simulation participants */
if (rbw->group) {
/* Objects - simulation participants. */
if (rbw->group != NULL) {
build_collection(NULL, rbw->group);
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(rbw->group, object)
{
if (object->type != OB_MESH)
if (object->type != OB_MESH) {
continue;
}
/* 2) create operation for flushing results */
/* object's transform component - where the rigidbody operation
* lives. */
@ -1105,6 +1096,22 @@ void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
/* Constraints. */
if (rbw->constraints != NULL) {
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(rbw->constraints, object)
{
RigidBodyCon *rbc = object->rigidbody_constraint;
if (rbc == NULL || rbc->ob1 == NULL || rbc->ob2 == NULL) {
/* When either ob1 or ob2 is NULL, the constraint doesn't work. */
continue;
}
/* Make sure indirectly linked objects are fully built. */
build_object(-1, object, DEG_ID_LINKED_INDIRECTLY, false);
build_object(-1, rbc->ob1, DEG_ID_LINKED_INDIRECTLY, false);
build_object(-1, rbc->ob2, DEG_ID_LINKED_INDIRECTLY, false);
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
}
void DepsgraphNodeBuilder::build_particle_systems(Object *object,

View File

@ -1622,7 +1622,7 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
add_relation(time_src_key, init_key, "TimeSrc -> Rigidbody Reset/Rebuild (Optional)");
/* objects - simulation participants */
if (rbw->group) {
if (rbw->group != NULL) {
build_collection(NULL, NULL, rbw->group);
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(rbw->group, object)
@ -1684,9 +1684,8 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
}
/* constraints */
if (rbw->constraints) {
/* Constraints. */
if (rbw->constraints != NULL) {
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(rbw->constraints, object)
{
RigidBodyCon *rbc = object->rigidbody_constraint;
@ -1694,19 +1693,19 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
/* When either ob1 or ob2 is NULL, the constraint doesn't work. */
continue;
}
/* final result of the constraint object's transform controls how the
* constraint affects the physics sim for these objects
*/
/* Make sure indirectly linked objects are fully built. */
build_object(NULL, object);
build_object(NULL, rbc->ob1);
build_object(NULL, 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, DEG_NODE_TYPE_TRANSFORM);
OperationKey ob1_key(&rbc->ob1->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_RIGIDBODY_TRANSFORM_COPY);
OperationKey ob2_key(&rbc->ob2->id, DEG_NODE_TYPE_TRANSFORM, DEG_OPCODE_RIGIDBODY_TRANSFORM_COPY);
/* - constrained-objects sync depends on the constraint-holder */
/* 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");
/* - ensure that sim depends on this constraint's transform */
/* Ensure that sim depends on this constraint's transform. */
add_relation(trans_key, sim_key, "RigidBodyConstraint Transform -> RB Simulation");
}
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;