[Bf-blender-cvs] [0eb5674] depsgraph_refactor: Depsgrpah: Move evaluation time into EvaluationCOntext

Sergey Sharybin noreply at git.blender.org
Wed Feb 11 15:20:26 CET 2015


Commit: 0eb5674c91311ee75744014261ec3ffb49685aae
Author: Sergey Sharybin
Date:   Wed Feb 11 19:18:49 2015 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rB0eb5674c91311ee75744014261ec3ffb49685aae

Depsgrpah: Move evaluation time into EvaluationCOntext

This way evaluation context hols all the shared data which defines how
exactly the graph needs to be evaluated, making it unnecessary to pass
time source node to callbacks. Which also makes it possible to move
those callbacks into BKE (where they're actually should be).

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

M	source/blender/blenkernel/BKE_animsys.h
M	source/blender/blenkernel/BKE_depsgraph.h
M	source/blender/blenkernel/intern/anim_sys.c
M	source/blender/depsgraph/intern/depsgraph_build.cpp
M	source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
M	source/blender/depsgraph/intern/depsgraph_eval.cpp
M	source/blender/depsgraph/intern/depsgraph_type_defines.cpp
D	source/blender/depsgraph/intern/stubs.h

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

diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h
index 458d4b8..c869533 100644
--- a/source/blender/blenkernel/BKE_animsys.h
+++ b/source/blender/blenkernel/BKE_animsys.h
@@ -195,4 +195,13 @@ void animsys_evaluate_action_group(struct PointerRNA *ptr, struct bAction *act,
 
 /* ************************************* */
 
+/* ------------ Evaluation API --------------- */
+
+struct EvaluationContext;
+
+void BKE_animsys_eval_animdata(struct EvaluationContext *eval_ctx, struct ID *id);
+void BKE_animsys_eval_driver(struct EvaluationContext *eval_ctx, struct ID *id, struct FCurve *fcurve);
+
+/* ************************************* */
+
 #endif /* __BKE_ANIMSYS_H__*/
diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h
index ebe00b0..2089167 100644
--- a/source/blender/blenkernel/BKE_depsgraph.h
+++ b/source/blender/blenkernel/BKE_depsgraph.h
@@ -57,6 +57,7 @@ struct ListBase;
  */
 typedef struct EvaluationContext {
 	int mode;               /* evaluation mode */
+	float ctime;            /* evlauaiton time */
 } EvaluationContext;
 
 typedef enum eEvaluationMode {
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 6f42166..eee5604 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -2834,3 +2834,62 @@ void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime)
 }
 
 /* ***************************************** */ 
+
+/* ************** */
+/* Evaluation API */
+
+#define DEBUG_PRINT if (G.debug & G_DEBUG_DEPSGRAPH) printf
+
+void BKE_animsys_eval_animdata(EvaluationContext *eval_ctx, ID *id)
+{
+	AnimData *adt = BKE_animdata_from_id(id);
+	Scene *scene = NULL; /* XXX: this is only needed for flushing RNA updates,
+	                      * which should get handled as part of the graph instead...
+	                      */
+	DEBUG_PRINT("%s on %s\n", __func__, id->name);
+	BKE_animsys_evaluate_animdata(scene, id, adt, eval_ctx->ctime, ADT_RECALC_ANIM);
+}
+
+void BKE_animsys_eval_driver(EvaluationContext *eval_ctx,
+                             ID *id,
+                             FCurve *fcu)
+{
+	/* TODO(sergey): De-duplicate with BKE animsys. */
+	ChannelDriver *driver = fcu->driver;
+	PointerRNA id_ptr;
+	bool ok = false;
+
+	DEBUG_PRINT("%s on %s (%s[%d])\n",
+	            __func__,
+	            id->name,
+	            fcu->rna_path,
+	            fcu->array_index);
+
+	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, eval_ctx->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 - %s[%d]\n", fcu->rna_path, fcu->array_index);
+				driver->flag |= DRIVER_FLAG_INVALID;
+			}
+		}
+	}
+}
+
+#undef DEBUG_PRINT
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index da3aef0..d6658a6 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -100,8 +100,6 @@ extern "C" {
 #include "depsgraph_eval.h"
 #include "depsgraph_intern.h"
 
-#include "stubs.h" // XXX: REMOVE THIS INCLUDE ONCE DEPSGRAPH REFACTOR PROJECT IS DONE!!!
-
 /* ************************************************* */
 /* External Build API */
 
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index 4e5d9b0..3b1c5b1 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -99,8 +99,6 @@ extern "C" {
 #include "depsgraph_eval.h"
 #include "depsgraph_intern.h"
 
-#include "stubs.h" // XXX: REMOVE THIS INCLUDE ONCE DEPSGRAPH REFACTOR PROJECT IS DONE!!!
-
 /* ************************************************* */
 /* Node Builder */
 
@@ -356,15 +354,13 @@ void DepsgraphNodeBuilder::build_animdata(ID *id)
 	
 	/* animation */
 	if (adt->action || adt->nla_tracks.first || adt->drivers.first) {
-		TimeSourceDepsNode *time_src = m_graph->find_time_source();
-		
 		// XXX: Hook up specific update callbacks for special properties which may need it...
 		
 		/* actions and NLA - as a single unit for now, as it gets complicated to schedule otherwise */
 		if ((adt->action) || (adt->nla_tracks.first)) {
 			/* create the node */
 			add_operation_node(id, DEPSNODE_TYPE_ANIMATION,
-			                   DEPSOP_TYPE_EXEC, function_bind(BKE_animsys_eval_animdata, _1, id, time_src),
+			                   DEPSOP_TYPE_EXEC, function_bind(BKE_animsys_eval_animdata, _1, id),
 			                   DEG_OPCODE_ANIMATION, id->name);
 			
 			// TODO: for each channel affected, we might also want to add some support for running RNA update callbacks on them
@@ -388,9 +384,8 @@ OperationDepsNode *DepsgraphNodeBuilder::build_driver(ID *id, FCurve *fcu)
 	ChannelDriver *driver = fcu->driver;
 	
 	/* create data node for this driver ..................................... */
-	TimeSourceDepsNode *time_src = m_graph->find_time_source();
 	OperationDepsNode *driver_op = add_operation_node(id, DEPSNODE_TYPE_PARAMETERS,
-	                                                  DEPSOP_TYPE_EXEC, function_bind(BKE_animsys_eval_driver, _1, id, fcu, time_src),
+	                                                  DEPSOP_TYPE_EXEC, function_bind(BKE_animsys_eval_driver, _1, id, fcu),
 	                                                  DEG_OPCODE_DRIVER, deg_fcurve_id_name(fcu));
 	
 	/* tag "scripted expression" drivers as needing Python (due to GIL issues, etc.) */
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cpp b/source/blender/depsgraph/intern/depsgraph_eval.cpp
index 4f26bec..23033a2 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cpp
@@ -294,6 +294,10 @@ void DEG_evaluate_on_refresh_ex(EvaluationContext *eval_ctx,
 		return;
 	}
 
+	/* Set time for the current graph evaluation context. */
+	TimeSourceDepsNode *time_src = graph->find_time_source();
+	eval_ctx->ctime = time_src->cfra;
+
 	/* XXX could use a separate pool for each eval context */
 	DepsgraphEvalState state;
 	state.eval_ctx = eval_ctx;
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
index 296c694..13c3b4f 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
@@ -30,79 +30,14 @@ extern "C" {
 #include "BLI_utildefines.h"
 #include "BLI_ghash.h"
 
-#include "DNA_anim_types.h"
-
-#include "BKE_animsys.h"
-#include "BKE_fcurve.h"
-
-#include "RNA_access.h"
-
 #include "DEG_depsgraph.h"
 } /* extern "C" */
 
-#include "depsgraph_debug.h"
 #include "depsgraph_intern.h"
 #include "depsnode.h"
 #include "depsnode_component.h"
 #include "depsnode_operation.h"
 
-#include "stubs.h" // XXX: THIS MUST BE REMOVED WHEN THE DEPSGRAPH REFACTOR IS DONE
-
-void BKE_animsys_eval_animdata(EvaluationContext *UNUSED(eval_ctx),
-                               ID *id,
-                               TimeSourceDepsNode *time_src)
-{
-	DEG_DEBUG_PRINTF("%s on %s\n", __func__, id->name);
-	AnimData *adt = BKE_animdata_from_id(id);
-	Scene *scene = NULL; // XXX: this is only needed for flushing RNA updates, which should get handled as part of the graph instead...
-	float ctime = time_src->cfra;
-	BKE_animsys_evaluate_animdata(scene, id, adt, ctime, ADT_RECALC_ANIM);
-}
-
-void BKE_animsys_eval_driver(EvaluationContext *UNUSED(eval_ctx),
-                             ID *id,
-                             FCurve *fcu,
-                             TimeSourceDepsNode *time_src)
-{
-	/* TODO(sergey): De-duplicate with BKE animsys. */
-	DEG_DEBUG_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 - %s[%d]\n", fcu->rna_path, fcu->array_index);
-				driver->flag |= DRIVER_FLAG_INVALID;
-			}
-		}
-	}
-}
-
 /* ******************************************************** */
 /* External API */
 
diff --git a/source/blender/depsgraph/intern/stubs.h b/source/blender/depsgraph/intern/stubs.h
deleted file mode 100644
index 49b0086..0000000

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list