From 1ba6ef25b64af4f399134faae3f9c4d7bca29dab Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 12 Jun 2017 14:41:46 +0200 Subject: Depsgraph: Add utility function to get depsgraph from node handle The idea is to use this function for modifiers' updateDepsgraph functions instead of doing direct scene->depsgraph access. --- source/blender/depsgraph/DEG_depsgraph_build.h | 2 ++ source/blender/depsgraph/intern/builder/deg_builder_relations.cc | 5 +++++ source/blender/depsgraph/intern/builder/deg_builder_relations.h | 2 ++ source/blender/depsgraph/intern/depsgraph_build.cc | 7 +++++++ 4 files changed, 16 insertions(+) (limited to 'source/blender/depsgraph') diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h index d44aea153bc..b65d921cfd1 100644 --- a/source/blender/depsgraph/DEG_depsgraph_build.h +++ b/source/blender/depsgraph/DEG_depsgraph_build.h @@ -153,6 +153,8 @@ void DEG_add_object_cache_relation(struct DepsNodeHandle *handle, eDepsObjectComponentType component, const char *description); + +struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *handle); void DEG_add_special_eval_flag(struct Depsgraph *graph, struct ID *id, short flag); /* Utility functions for physics modifiers */ diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 72a7d04f627..348501b107b 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -371,6 +371,11 @@ void DepsgraphRelationBuilder::add_forcefield_relations(const OperationKey &key, pdEndEffectors(&effectors); } +Depsgraph *DepsgraphRelationBuilder::getGraph() +{ + return m_graph; +} + /* **** Functions to build relations between entities **** */ void DepsgraphRelationBuilder::begin_build(Main *bmain) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.h b/source/blender/depsgraph/intern/builder/deg_builder_relations.h index 411f3be4036..c5a73ba2d98 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.h @@ -233,6 +233,8 @@ struct DepsgraphRelationBuilder template OperationDepsNode *find_operation_node(const KeyType &key); + Depsgraph *getGraph(); + protected: RootDepsNode *find_node(const RootKey &key) const; TimeSourceDepsNode *find_node(const TimeSourceKey &key) const; diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index f8bc8b9eb35..850c3617c46 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -166,6 +166,13 @@ void DEG_add_bone_relation(DepsNodeHandle *handle, description); } +struct Depsgraph *DEG_get_graph_from_handle(struct DepsNodeHandle *handle) +{ + DEG::DepsNodeHandle *deg_handle = get_handle(handle); + DEG::DepsgraphRelationBuilder *relation_builder = deg_handle->builder; + return reinterpret_cast(relation_builder->getGraph()); +} + void DEG_add_special_eval_flag(Depsgraph *graph, ID *id, short flag) { DEG::Depsgraph *deg_graph = reinterpret_cast(graph); -- cgit v1.2.3