[Bf-blender-cvs] [55e171be334] master: Fix T60566: Warnings in rigid body and certain conrfiguration

Sergey Sharybin noreply at git.blender.org
Mon Jan 28 16:40:50 CET 2019


Commit: 55e171be3349b22ada9b84d36067d0a6f00db7f7
Author: Sergey Sharybin
Date:   Mon Jan 28 16:38:12 2019 +0100
Branches: master
https://developer.blender.org/rB55e171be3349b22ada9b84d36067d0a6f00db7f7

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.

===================================================================

M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc

===================================================================

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index 29a31ef4f98..d44e41168a0 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -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?
-	 */
-
-	/* 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);
+	 * instead? */
 
-	/* 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,
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 27d8a414b37..42229a43428 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -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;



More information about the Bf-blender-cvs mailing list