[Bf-blender-cvs] [44ba9e2] depsgraph_refactor: Drivers and their relationships are now included in the depsgraph

Joshua Leung noreply at git.blender.org
Thu Dec 4 04:58:50 CET 2014


Commit: 44ba9e2ce7805e592a6dcf89e0d12119446dab69
Author: Joshua Leung
Date:   Thu Dec 4 16:41:20 2014 +1300
Branches: depsgraph_refactor
https://developer.blender.org/rB44ba9e2ce7805e592a6dcf89e0d12119446dab69

Drivers and their relationships are now included in the depsgraph

* Each driver now gets added as a separate opnode

* ID-block targets (e.g. object ref for Transform Channel/Location Diff/Rot Diff)
  now get included when building the links
  (TODO: local space vs world space may be able to benefit from getting special
   exceptions for depending on intermediate results instead)

* Added temporary hook from "parameters" component (where drivers live) to
  "transform" component, as is done for animation now. This will need to change,
  to have greater granularity for bones, but at least this works now.

* Copied over the logic for evaluating drivers in full from the animsys code.
  (This stuff should eventually go back into blenkernel though)

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

M	source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
M	source/blender/depsgraph/intern/depsgraph_build_relations.cpp
M	source/blender/depsgraph/intern/depsgraph_type_defines.cpp

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

diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index b050bde..54ae0c4 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -366,7 +366,7 @@ void DepsgraphNodeBuilder::build_animdata(ID *id)
 		/* drivers */
 		for (FCurve *fcu = (FCurve *)adt->drivers.first; fcu; fcu = fcu->next) {
 			/* create driver */
-			/*OperationDepsNode *driver_node =*/ //build_driver(id, fcu);
+			build_driver(id, fcu);
 
 			/* hook up update callback associated with F-Curve */
 			// ...
diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
index 34ab4ee..d6ab7ac 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
@@ -321,9 +321,12 @@ void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob)
 	}
 
 	if (ob->adt) {
+		// FIXME: drivers
 		ComponentKey adt_key(&ob->id, DEPSNODE_TYPE_ANIMATION);
+		ComponentKey params_key(&ob->id, DEPSNODE_TYPE_PARAMETERS);
 		ComponentKey transform_key(&ob->id, DEPSNODE_TYPE_TRANSFORM);
 		add_relation(adt_key, local_transform_key, DEPSREL_TYPE_OPERATION, "Object Animation");
+		add_relation(params_key, local_transform_key, DEPSREL_TYPE_OPERATION, "Parameters");
 	}
 
 	/* TODO(sergey): This is a temp solution for now only. */
@@ -511,8 +514,10 @@ void DepsgraphRelationBuilder::build_animdata(ID *id)
 		/* wire up dependency to time source */
 		TimeSourceKey time_src_key;
 		add_relation(time_src_key, adt_key, DEPSREL_TYPE_TIME, "[TimeSrc -> Animation] DepsRel");
-
+		
 		// XXX: Hook up specific update callbacks for special properties which may need it...
+		
+		// XXX: animdata "hierarchy" - top-level overrides need to go after lower-down
 	}
 	
 	/* drivers */
@@ -539,6 +544,7 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcurve)
 	/* create dependency between driver and data affected by it */
 	// XXX: this should return a parameter context for dealing with this...
 	RNAPathKey affected_key(id, fcurve->rna_path);
+	
 	/* make data dependent on driver */
 	add_relation(driver_key, affected_key, DEPSREL_TYPE_DRIVER, "[Driver -> Data] DepsRel");
 	
@@ -551,13 +557,14 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcurve)
 		/* only used targets */
 		DRIVER_TARGETS_USED_LOOPER(dvar) 
 		{
-			if (!dtar->id)
+			if (dtar->id == NULL)
 				continue;
 			
 			/* special handling for directly-named bones */
 			if ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (dtar->pchan_name[0])) {
 				Object *ob = (Object *)dtar->id;
 				bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, dtar->pchan_name);
+				
 				if (pchan != NULL) {
 					/* get node associated with bone */
 					ComponentKey target_key(dtar->id, DEPSNODE_TYPE_BONE, pchan->name);
@@ -565,6 +572,12 @@ void DepsgraphRelationBuilder::build_driver(ID *id, FCurve *fcurve)
 					             "[Target -> Driver] DepsRel");
 				}
 			}
+			else if (dtar->flag & DTAR_FLAG_STRUCT_REF) {
+				/* get node associated with the object's transforms */
+				ComponentKey target_key(dtar->id, DEPSNODE_TYPE_TRANSFORM);
+				add_relation(target_key, driver_key, DEPSREL_TYPE_DRIVER_TARGET,
+				             "[Target -> Driver] DepsRel");
+			}
 			else {
 				/* resolve path to get node */
 				RNAPathKey target_key(dtar->id, dtar->rna_path ? dtar->rna_path : "");
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
index 0690aeb..c0a9eb1 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
@@ -86,20 +86,41 @@ void BKE_animsys_eval_animdata(EvaluationContext *UNUSED(eval_ctx),
 
 void BKE_animsys_eval_driver(EvaluationContext *UNUSED(eval_ctx),
                              ID *id,
-                             FCurve *fcurve,
+                             FCurve *fcu,
                              TimeSourceDepsNode *time_src)
 {
 	/* TODO(sergey): De-duplicate with BKE animsys. */
-	printf("%s on %s\n", __func__, id->name);
-	if ((fcurve->driver->flag & DRIVER_FLAG_INVALID) == 0) {
-		PointerRNA id_ptr;
-		float ctime = time_src->cfra;
-		RNA_id_pointer_create(id, &id_ptr);
-		calculate_fcurve(fcurve, ctime);
-		if (!BKE_animsys_execute_fcurve(&id_ptr, NULL, fcurve)) {
-			fcurve->driver->flag |= DRIVER_FLAG_INVALID;
+	printf("%s on %s (%s[%d])\n", __func__, id->name, fcu->rna_path, fcu->array_index);
+	
+	ChannelDriver *driver = fcu->driver;
+	PointerRNA id_ptr;
+	float ctime = time_src->cfra;
+	bool ok = false;
+	
+	RNA_id_pointer_create(id, &id_ptr);
+	
+	/* check if this driver's curve should be skipped */
+	if ((fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) == 0) {
+		/* check if driver itself is tagged for recalculation */
+		/* XXX driver recalc flag is not set yet by depsgraph! */
+		if ((driver) && !(driver->flag & DRIVER_FLAG_INVALID) /*&& (driver->flag & DRIVER_FLAG_RECALC)*/) {
+			/* evaluate this using values set already in other places
+			 * NOTE: for 'layering' option later on, we should check if we should remove old value before adding
+			 *       new to only be done when drivers only changed */
+			printf("\told val = %f\n", fcu->curval);
+			calculate_fcurve(fcu, ctime);
+			ok = BKE_animsys_execute_fcurve(&id_ptr, NULL, fcu);
+			printf("\tnew val = %f\n", fcu->curval);
+			
+			/* clear recalc flag */
+			driver->flag &= ~DRIVER_FLAG_RECALC;
+			
+			/* set error-flag if evaluation failed */
+			if (ok == 0) {
+				printf("invalid driver\n");
+				driver->flag |= DRIVER_FLAG_INVALID;
+			}
 		}
-		fcurve->driver->flag &= ~DRIVER_FLAG_RECALC;
 	}
 }




More information about the Bf-blender-cvs mailing list