Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/depsgraph/intern/depsgraph_query.cc')
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query.cc56
1 files changed, 50 insertions, 6 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index 9b1961baa48..63c9aa1407a 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -33,21 +33,27 @@
#include "MEM_guardedalloc.h"
extern "C" {
+#include "BLI_utildefines.h"
#include "BKE_idcode.h"
#include "BKE_main.h"
+#include "BLI_listbase.h"
} /* extern "C" */
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "intern/depsgraph_intern.h"
#include "intern/nodes/deg_node_id.h"
-bool DEG_id_type_tagged(Main *bmain, short idtype)
+bool DEG_id_type_tagged(Main *bmain, short id_type)
{
- return bmain->id_tag_update[BKE_idcode_to_index(idtype)] != 0;
+ return bmain->id_tag_update[BKE_idcode_to_index(id_type)] != 0;
}
-short DEG_get_eval_flags_for_id(Depsgraph *graph, ID *id)
+short DEG_get_eval_flags_for_id(const Depsgraph *graph, ID *id)
{
if (graph == NULL) {
/* Happens when converting objects to mesh from a python script
@@ -59,9 +65,8 @@ short DEG_get_eval_flags_for_id(Depsgraph *graph, ID *id)
return 0;
}
- DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
-
- DEG::IDDepsNode *id_node = deg_graph->find_id_node(id);
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+ const DEG::IDDepsNode *id_node = deg_graph->find_id_node(id);
if (id_node == NULL) {
/* TODO(sergey): Does it mean we need to check set scene? */
return 0;
@@ -69,3 +74,42 @@ short DEG_get_eval_flags_for_id(Depsgraph *graph, ID *id)
return id_node->eval_flags;
}
+
+Scene *DEG_get_evaluated_scene(const Depsgraph *graph)
+{
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+ Scene *scene_orig = deg_graph->scene;
+ return reinterpret_cast<Scene *>(deg_graph->get_cow_id(&scene_orig->id));
+}
+
+ViewLayer *DEG_get_evaluated_view_layer(const Depsgraph *graph)
+{
+ const DEG::Depsgraph *deg_graph = reinterpret_cast<const DEG::Depsgraph *>(graph);
+ Scene *scene_cow = DEG_get_evaluated_scene(graph);
+ ViewLayer *view_layer_orig = deg_graph->view_layer;
+ ViewLayer *view_layer_cow =
+ (ViewLayer *)BLI_findstring(&scene_cow->view_layers,
+ view_layer_orig->name,
+ offsetof(ViewLayer, name));
+ return view_layer_cow;
+}
+
+Object *DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
+{
+ return (Object *)DEG_get_evaluated_id(depsgraph, &object->id);
+}
+
+ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
+{
+ /* TODO(sergey): This is a duplicate of Depsgraph::get_cow_id(),
+ * but here we never do assert, since we don't know nature of the
+ * incoming ID datablock.
+ */
+ const DEG::Depsgraph *deg_graph = (const DEG::Depsgraph *)depsgraph;
+ const DEG::IDDepsNode *id_node = deg_graph->find_id_node(id);
+ if (id_node == NULL) {
+ return id;
+ }
+ return id_node->id_cow;
+}
+