[Bf-blender-cvs] [a01c1849e9f] blender2.8: Depsgraph: Add utility function to initialize evaluation context from scene and layer

Sergey Sharybin noreply at git.blender.org
Wed Jul 26 16:39:24 CEST 2017


Commit: a01c1849e9f593e277da044c4f30a459d9391d75
Author: Sergey Sharybin
Date:   Wed Jul 26 16:27:15 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBa01c1849e9f593e277da044c4f30a459d9391d75

Depsgraph: Add utility function to initialize evaluation context from scene and layer

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

M	source/blender/depsgraph/DEG_depsgraph.h
M	source/blender/depsgraph/intern/depsgraph_eval.cc

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

diff --git a/source/blender/depsgraph/DEG_depsgraph.h b/source/blender/depsgraph/DEG_depsgraph.h
index 8af186eae05..540367712f1 100644
--- a/source/blender/depsgraph/DEG_depsgraph.h
+++ b/source/blender/depsgraph/DEG_depsgraph.h
@@ -65,26 +65,27 @@ struct Main;
 
 struct PointerRNA;
 struct PropertyRNA;
+struct Scene;
 struct SceneLayer;
 
+typedef enum eEvaluationMode {
+	DAG_EVAL_VIEWPORT       = 0,    /* evaluate for OpenGL viewport */
+	DAG_EVAL_PREVIEW        = 1,    /* evaluate for render with preview settings */
+	DAG_EVAL_RENDER         = 2,    /* evaluate for render purposes */
+} eEvaluationMode;
+
 /* Dependency graph evaluation context
  *
  * This structure stores all the local dependency graph data,
  * which is needed for it's evaluation,
  */
 typedef struct EvaluationContext {
-	int mode;
+	eEvaluationMode mode;
 	float ctime;
 
 	struct SceneLayer *scene_layer;
 } EvaluationContext;
 
-typedef enum eEvaluationMode {
-	DAG_EVAL_VIEWPORT       = 0,    /* evaluate for OpenGL viewport */
-	DAG_EVAL_PREVIEW        = 1,    /* evaluate for render with preview settings */
-	DAG_EVAL_RENDER         = 2,    /* evaluate for render purposes */
-} eEvaluationMode;
-
 /* DagNode->eval_flags */
 enum {
 	/* Regardless to curve->path animation flag path is to be evaluated anyway,
@@ -198,13 +199,18 @@ void DEG_ids_check_recalc(struct Main *bmain,
 /* Evaluation Context ---------------------------- */
 
 /* Create new evaluation context. */
-struct EvaluationContext *DEG_evaluation_context_new(int mode);
+struct EvaluationContext *DEG_evaluation_context_new(eEvaluationMode mode);
 
 /* Initialize evaluation context.
  * Used by the areas which currently overrides the context or doesn't have
  * access to a proper one.
  */
-void DEG_evaluation_context_init(struct EvaluationContext *eval_ctx, int mode);
+void DEG_evaluation_context_init(struct EvaluationContext *eval_ctx,
+                                 eEvaluationMode mode);
+void DEG_evaluation_context_init_from_scene(struct EvaluationContext *eval_ctx,
+                                            struct Scene *scene,
+                                            struct SceneLayer *scene_layer,
+                                            eEvaluationMode mode);
 
 /* Free evaluation context. */
 void DEG_evaluation_context_free(struct EvaluationContext *eval_ctx);
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc
index 73a0428c264..77a32740524 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cc
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cc
@@ -56,7 +56,7 @@ extern "C" {
 /* Evaluation Context */
 
 /* Create new evaluation context. */
-EvaluationContext *DEG_evaluation_context_new(int mode)
+EvaluationContext *DEG_evaluation_context_new(eEvaluationMode mode)
 {
 	EvaluationContext *eval_ctx =
 		(EvaluationContext *)MEM_callocN(sizeof(EvaluationContext),
@@ -70,11 +70,22 @@ EvaluationContext *DEG_evaluation_context_new(int mode)
  * Used by the areas which currently overrides the context or doesn't have
  * access to a proper one.
  */
-void DEG_evaluation_context_init(EvaluationContext *eval_ctx, int mode)
+void DEG_evaluation_context_init(EvaluationContext *eval_ctx,
+                                 eEvaluationMode mode)
 {
 	eval_ctx->mode = mode;
 }
 
+void DEG_evaluation_context_init_from_scene(EvaluationContext *eval_ctx,
+                                            Scene *scene,
+                                            SceneLayer *scene_layer,
+                                            eEvaluationMode mode)
+{
+	DEG_evaluation_context_init(eval_ctx, mode);
+	eval_ctx->scene_layer = scene_layer;
+	eval_ctx->ctime = BKE_scene_frame_get(scene);
+}
+
 /* Free evaluation context. */
 void DEG_evaluation_context_free(EvaluationContext *eval_ctx)
 {




More information about the Bf-blender-cvs mailing list