2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2013 Blender Foundation.
19 * All rights reserved.
21 * Original Author: Joshua Leung
22 * Contributor(s): None Yet
24 * ***** END GPL LICENSE BLOCK *****
27 /** \file blender/depsgraph/intern/depsgraph_eval.cc
30 * Evaluation engine entrypoints for Depsgraph Engine.
33 #include "MEM_guardedalloc.h"
35 #include "BLI_utildefines.h"
36 #include "BLI_ghash.h"
39 #include "BKE_scene.h"
42 #include "DEG_depsgraph.h"
44 #include "intern/eval/deg_eval.h"
45 #include "intern/eval/deg_eval_flush.h"
47 #include "intern/nodes/deg_node.h"
48 #include "intern/nodes/deg_node_operation.h"
50 #include "intern/depsgraph.h"
52 /* Unfinished and unused, and takes quite some pre-processing time. */
53 #undef USE_EVAL_PRIORITY
55 /* ****************** */
56 /* Evaluation Context */
58 /* Create new evaluation context. */
59 EvaluationContext *DEG_evaluation_context_new(int mode)
61 EvaluationContext *eval_ctx =
62 (EvaluationContext *)MEM_callocN(sizeof(EvaluationContext),
64 DEG_evaluation_context_init(eval_ctx, mode);
69 * Initialize evaluation context.
70 * Used by the areas which currently overrides the context or doesn't have
71 * access to a proper one.
73 void DEG_evaluation_context_init(EvaluationContext *eval_ctx, int mode)
75 eval_ctx->mode = mode;
78 /* Free evaluation context. */
79 void DEG_evaluation_context_free(EvaluationContext *eval_ctx)
84 /* Evaluate all nodes tagged for updating. */
85 void DEG_evaluate_on_refresh(EvaluationContext *eval_ctx,
89 DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
90 /* Update time on primary timesource. */
91 DEG::TimeSourceDepsNode *tsrc = deg_graph->find_time_source();
92 tsrc->cfra = BKE_scene_frame_get(scene);
93 DEG::deg_evaluate_on_refresh(eval_ctx, deg_graph);
96 /* Frame-change happened for root scene that graph belongs to. */
97 void DEG_evaluate_on_framechange(EvaluationContext *eval_ctx,
102 DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
103 /* Update time on primary timesource. */
104 DEG::TimeSourceDepsNode *tsrc = deg_graph->find_time_source();
106 tsrc->tag_update(deg_graph);
107 DEG::deg_graph_flush_updates(bmain, deg_graph);
108 /* Perform recalculation updates. */
109 DEG::deg_evaluate_on_refresh(eval_ctx, deg_graph);
112 bool DEG_needs_eval(Depsgraph *graph)
114 DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
115 return BLI_gset_size(deg_graph->entry_tags) != 0;