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_build.cc')
-rw-r--r--source/blender/depsgraph/intern/depsgraph_build.cc122
1 files changed, 57 insertions, 65 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 3884cfe49e7..902cbe039cd 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -36,6 +36,7 @@
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
+#include "BLI_listbase.h"
#ifdef DEBUG_TIME
# include "PIL_time.h"
@@ -52,6 +53,7 @@ extern "C" {
#include "BKE_collision.h"
#include "BKE_effect.h"
#include "BKE_modifier.h"
+#include "BKE_scene.h"
} /* extern "C" */
#include "DEG_depsgraph.h"
@@ -192,31 +194,46 @@ void DEG_add_special_eval_flag(Depsgraph *graph, ID *id, short flag)
/* ******************** */
/* Graph Building API's */
-/* Build depsgraph for the given scene, and dump results in given
+/* Build depsgraph for the given scene layer, and dump results in given
* graph container.
*/
-/* XXX: assume that this is called from outside, given the current scene as
- * the "main" scene.
- */
-void DEG_graph_build_from_scene(Depsgraph *graph, Main *bmain, Scene *scene)
+void DEG_graph_build_from_view_layer(Depsgraph *graph,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer)
{
#ifdef DEBUG_TIME
- TIMEIT_START(DEG_graph_build_from_scene);
+ TIMEIT_START(DEG_graph_build_from_view_layer);
#endif
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
+ BLI_assert(BLI_findindex(&scene->view_layers, view_layer) != -1);
+
+ /* TODO(sergey): This is a bit tricky, but ensures that all the data
+ * is evaluated properly when depsgraph is becoming "visible".
+ *
+ * This now could happen for both visible scene is changed and extra
+ * dependency graph was created for render engine.
+ */
+ const bool need_on_visible_update = (deg_graph->scene == NULL);
/* 1) Generate all the nodes in the graph first */
DEG::DepsgraphNodeBuilder node_builder(bmain, deg_graph);
node_builder.begin_build();
- node_builder.build_scene(scene);
+ node_builder.build_view_layer(scene,
+ view_layer,
+ DEG::DEG_ID_LINKED_DIRECTLY);
+ node_builder.end_build();
/* 2) Hook up relationships between operations - to determine evaluation
* order.
*/
DEG::DepsgraphRelationBuilder relation_builder(bmain, deg_graph);
relation_builder.begin_build();
- relation_builder.build_scene(scene);
+ relation_builder.build_view_layer(scene, view_layer);
+ if (DEG_depsgraph_use_copy_on_write()) {
+ relation_builder.build_copy_on_write_relations();
+ }
/* Detect and solve cycles. */
DEG::deg_graph_detect_cycles(deg_graph);
@@ -231,7 +248,7 @@ void DEG_graph_build_from_scene(Depsgraph *graph, Main *bmain, Scene *scene)
}
/* 4) Flush visibility layer and re-schedule nodes for update. */
- DEG::deg_graph_build_finalize(deg_graph);
+ DEG::deg_graph_build_finalize(bmain, deg_graph);
#if 0
if (!DEG_debug_consistency_check(deg_graph)) {
@@ -241,8 +258,15 @@ void DEG_graph_build_from_scene(Depsgraph *graph, Main *bmain, Scene *scene)
#endif
#ifdef DEBUG_TIME
- TIMEIT_END(DEG_graph_build_from_scene);
+ TIMEIT_END(DEG_graph_build_from_view_layer);
#endif
+
+ /* Relations are up to date. */
+ deg_graph->need_update = false;
+
+ if (need_on_visible_update) {
+ DEG_graph_on_visible_update(bmain, graph);
+ }
}
/* Tag graph relations for update. */
@@ -252,64 +276,34 @@ void DEG_graph_tag_relations_update(Depsgraph *graph)
deg_graph->need_update = true;
}
-/* Tag all relations for update. */
-void DEG_relations_tag_update(Main *bmain)
-{
- for (Scene *scene = (Scene *)bmain->scene.first;
- scene != NULL;
- scene = (Scene *)scene->id.next)
- {
- if (scene->depsgraph != NULL) {
- DEG_graph_tag_relations_update(scene->depsgraph);
- }
- }
-}
-
-/* Create new graph if didn't exist yet,
- * or update relations if graph was tagged for update.
- */
-void DEG_scene_relations_update(Main *bmain, Scene *scene)
+/* Create or update relations in the specified graph. */
+void DEG_graph_relations_update(Depsgraph *graph,
+ Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer)
{
- if (scene->depsgraph == NULL) {
- /* Rebuild graph from scratch and exit. */
- scene->depsgraph = DEG_graph_new();
- DEG_graph_build_from_scene(scene->depsgraph, bmain, scene);
- return;
- }
-
- DEG::Depsgraph *graph = reinterpret_cast<DEG::Depsgraph *>(scene->depsgraph);
- if (!graph->need_update) {
+ DEG::Depsgraph *deg_graph = (DEG::Depsgraph *)graph;
+ if (!deg_graph->need_update) {
/* Graph is up to date, nothing to do. */
return;
}
-
- /* Clear all previous nodes and operations. */
- graph->clear_all_nodes();
- graph->operations.clear();
- BLI_gset_clear(graph->entry_tags, NULL);
-
- /* Build new nodes and relations. */
- DEG_graph_build_from_scene(reinterpret_cast< ::Depsgraph * >(graph),
- bmain,
- scene);
-
- graph->need_update = false;
-}
-
-/* Rebuild dependency graph only for a given scene. */
-void DEG_scene_relations_rebuild(Main *bmain, Scene *scene)
-{
- if (scene->depsgraph != NULL) {
- DEG_graph_tag_relations_update(scene->depsgraph);
- }
- DEG_scene_relations_update(bmain, scene);
+ DEG_graph_build_from_view_layer(graph, bmain, scene, view_layer);
}
-void DEG_scene_graph_free(Scene *scene)
+/* Tag all relations for update. */
+void DEG_relations_tag_update(Main *bmain)
{
- if (scene->depsgraph) {
- DEG_graph_free(scene->depsgraph);
- scene->depsgraph = NULL;
+ DEG_DEBUG_PRINTF("%s: Tagging relations for update.\n", __func__);
+ BLI_LISTBASE_FOREACH (Scene *, scene, &bmain->scene) {
+ BLI_LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
+ Depsgraph *depsgraph =
+ (Depsgraph *)BKE_scene_get_depsgraph(scene,
+ view_layer,
+ false);
+ if (depsgraph != NULL) {
+ DEG_graph_tag_relations_update(depsgraph);
+ }
+ }
}
}
@@ -317,14 +311,13 @@ void DEG_add_collision_relations(DepsNodeHandle *handle,
Scene *scene,
Object *object,
Group *group,
- int layer,
unsigned int modifier_type,
DEG_CollobjFilterFunction fn,
bool dupli,
const char *name)
{
unsigned int numcollobj;
- Object **collobjs = get_collisionobjects_ext(scene, object, group, layer, &numcollobj, modifier_type, dupli);
+ Object **collobjs = get_collisionobjects_ext(scene, object, group, &numcollobj, modifier_type, dupli);
for (unsigned int i = 0; i < numcollobj; i++) {
Object *ob1 = collobjs[i];
@@ -347,7 +340,7 @@ void DEG_add_forcefield_relations(DepsNodeHandle *handle,
int skip_forcefield,
const char *name)
{
- ListBase *effectors = pdInitEffectors(scene, object, NULL, effector_weights, false);
+ ListBase *effectors = pdInitEffectors(NULL, scene, object, NULL, effector_weights, false);
if (effectors) {
for (EffectorCache *eff = (EffectorCache*)effectors->first; eff; eff = eff->next) {
@@ -379,7 +372,6 @@ void DEG_add_forcefield_relations(DepsNodeHandle *handle,
scene,
object,
NULL,
- eff->ob->lay,
eModifierType_Collision,
NULL,
true,