Depsgraph: Cleanup and code simplification
This is mainly a maintenance commit which was aimed to make work with
this module more pleasant and solve such issues as:
- Annoyance with looong files, which had craftload in them
- Usage of STL for the data structures we've got in BLI
- Possible symbol conflicts
- Not real clear layout of what is located where
So in this commit the following changes are done:
- STL is prohibited, it's not really predictable on various compilers,
with our BLI algorithms we can predict things much better.
There are still few usages of std::vector, but that we'll be
solving later once we've got similar thing in BLI.
- Simplify foreach loops, avoid using const_iterator all over the place.
- New directory layout, which is hopefully easier to follow.
- Some files were split, some of them will be split soon.
The idea of this is to split huge functions into own files with
good documentation and everything.
- Removed stuff which was planned for use in the future but was never
finished, tested or anything.
Let's wipe it out for now, and bring back once we really start using
it, so it'll be more clear if it solves our needs.
- All the internal routines were moved to DEG namespace to separate
them better from rest of blender.
Some places now annoyingly using DEG::foo, but that we can olve by
moving some utility functions inside of the namespace.
While working on this we've found some hotspot in updates flush, so
now playback of blenrig is few percent faster (something like 96fps
with previous master and around 99-100fps after this change).
Not saying it's something final, there is still room for cleanup and
API simplification, but those might happen as a regular development
now without doing any global changes.
2016-05-27 18:01:18 +02:00
|
|
|
/*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2016 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup depsgraph
|
Depsgraph: Cleanup and code simplification
This is mainly a maintenance commit which was aimed to make work with
this module more pleasant and solve such issues as:
- Annoyance with looong files, which had craftload in them
- Usage of STL for the data structures we've got in BLI
- Possible symbol conflicts
- Not real clear layout of what is located where
So in this commit the following changes are done:
- STL is prohibited, it's not really predictable on various compilers,
with our BLI algorithms we can predict things much better.
There are still few usages of std::vector, but that we'll be
solving later once we've got similar thing in BLI.
- Simplify foreach loops, avoid using const_iterator all over the place.
- New directory layout, which is hopefully easier to follow.
- Some files were split, some of them will be split soon.
The idea of this is to split huge functions into own files with
good documentation and everything.
- Removed stuff which was planned for use in the future but was never
finished, tested or anything.
Let's wipe it out for now, and bring back once we really start using
it, so it'll be more clear if it solves our needs.
- All the internal routines were moved to DEG namespace to separate
them better from rest of blender.
Some places now annoyingly using DEG::foo, but that we can olve by
moving some utility functions inside of the namespace.
While working on this we've found some hotspot in updates flush, so
now playback of blenrig is few percent faster (something like 96fps
with previous master and around 99-100fps after this change).
Not saying it's something final, there is still room for cleanup and
API simplification, but those might happen as a regular development
now without doing any global changes.
2016-05-27 18:01:18 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "intern/builder/deg_builder.h"
|
|
|
|
|
|
2019-02-27 15:15:26 +01:00
|
|
|
#include <cstring>
|
|
|
|
|
|
2018-06-13 09:49:14 +02:00
|
|
|
#include "DNA_anim_types.h"
|
2019-02-27 11:17:36 +01:00
|
|
|
#include "DNA_layer_types.h"
|
2016-11-11 16:15:34 +01:00
|
|
|
#include "DNA_ID.h"
|
2019-02-27 11:17:36 +01:00
|
|
|
#include "DNA_object_types.h"
|
Depsgraph: Cleanup and code simplification
This is mainly a maintenance commit which was aimed to make work with
this module more pleasant and solve such issues as:
- Annoyance with looong files, which had craftload in them
- Usage of STL for the data structures we've got in BLI
- Possible symbol conflicts
- Not real clear layout of what is located where
So in this commit the following changes are done:
- STL is prohibited, it's not really predictable on various compilers,
with our BLI algorithms we can predict things much better.
There are still few usages of std::vector, but that we'll be
solving later once we've got similar thing in BLI.
- Simplify foreach loops, avoid using const_iterator all over the place.
- New directory layout, which is hopefully easier to follow.
- Some files were split, some of them will be split soon.
The idea of this is to split huge functions into own files with
good documentation and everything.
- Removed stuff which was planned for use in the future but was never
finished, tested or anything.
Let's wipe it out for now, and bring back once we really start using
it, so it'll be more clear if it solves our needs.
- All the internal routines were moved to DEG namespace to separate
them better from rest of blender.
Some places now annoyingly using DEG::foo, but that we can olve by
moving some utility functions inside of the namespace.
While working on this we've found some hotspot in updates flush, so
now playback of blenrig is few percent faster (something like 96fps
with previous master and around 99-100fps after this change).
Not saying it's something final, there is still room for cleanup and
API simplification, but those might happen as a regular development
now without doing any global changes.
2016-05-27 18:01:18 +02:00
|
|
|
|
2018-09-19 15:21:51 +02:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
#include "BLI_ghash.h"
|
2018-08-23 16:17:06 +02:00
|
|
|
#include "BLI_stack.h"
|
|
|
|
|
|
2018-06-13 09:49:14 +02:00
|
|
|
extern "C" {
|
|
|
|
|
#include "BKE_animsys.h"
|
|
|
|
|
}
|
|
|
|
|
|
Depsgraph: Cleanup and code simplification
This is mainly a maintenance commit which was aimed to make work with
this module more pleasant and solve such issues as:
- Annoyance with looong files, which had craftload in them
- Usage of STL for the data structures we've got in BLI
- Possible symbol conflicts
- Not real clear layout of what is located where
So in this commit the following changes are done:
- STL is prohibited, it's not really predictable on various compilers,
with our BLI algorithms we can predict things much better.
There are still few usages of std::vector, but that we'll be
solving later once we've got similar thing in BLI.
- Simplify foreach loops, avoid using const_iterator all over the place.
- New directory layout, which is hopefully easier to follow.
- Some files were split, some of them will be split soon.
The idea of this is to split huge functions into own files with
good documentation and everything.
- Removed stuff which was planned for use in the future but was never
finished, tested or anything.
Let's wipe it out for now, and bring back once we really start using
it, so it'll be more clear if it solves our needs.
- All the internal routines were moved to DEG namespace to separate
them better from rest of blender.
Some places now annoyingly using DEG::foo, but that we can olve by
moving some utility functions inside of the namespace.
While working on this we've found some hotspot in updates flush, so
now playback of blenrig is few percent faster (something like 96fps
with previous master and around 99-100fps after this change).
Not saying it's something final, there is still room for cleanup and
API simplification, but those might happen as a regular development
now without doing any global changes.
2016-05-27 18:01:18 +02:00
|
|
|
#include "intern/depsgraph.h"
|
2019-01-31 12:56:40 +01:00
|
|
|
#include "intern/depsgraph_tag.h"
|
|
|
|
|
#include "intern/depsgraph_type.h"
|
2018-05-31 16:44:34 +02:00
|
|
|
#include "intern/eval/deg_eval_copy_on_write.h"
|
2019-01-31 12:56:40 +01:00
|
|
|
#include "intern/node/deg_node.h"
|
|
|
|
|
#include "intern/node/deg_node_id.h"
|
|
|
|
|
#include "intern/node/deg_node_component.h"
|
|
|
|
|
#include "intern/node/deg_node_operation.h"
|
2017-11-08 14:48:25 +01:00
|
|
|
|
2017-07-18 16:42:24 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
|
|
|
|
|
Depsgraph: Cleanup and code simplification
This is mainly a maintenance commit which was aimed to make work with
this module more pleasant and solve such issues as:
- Annoyance with looong files, which had craftload in them
- Usage of STL for the data structures we've got in BLI
- Possible symbol conflicts
- Not real clear layout of what is located where
So in this commit the following changes are done:
- STL is prohibited, it's not really predictable on various compilers,
with our BLI algorithms we can predict things much better.
There are still few usages of std::vector, but that we'll be
solving later once we've got similar thing in BLI.
- Simplify foreach loops, avoid using const_iterator all over the place.
- New directory layout, which is hopefully easier to follow.
- Some files were split, some of them will be split soon.
The idea of this is to split huge functions into own files with
good documentation and everything.
- Removed stuff which was planned for use in the future but was never
finished, tested or anything.
Let's wipe it out for now, and bring back once we really start using
it, so it'll be more clear if it solves our needs.
- All the internal routines were moved to DEG namespace to separate
them better from rest of blender.
Some places now annoyingly using DEG::foo, but that we can olve by
moving some utility functions inside of the namespace.
While working on this we've found some hotspot in updates flush, so
now playback of blenrig is few percent faster (something like 96fps
with previous master and around 99-100fps after this change).
Not saying it's something final, there is still room for cleanup and
API simplification, but those might happen as a regular development
now without doing any global changes.
2016-05-27 18:01:18 +02:00
|
|
|
namespace DEG {
|
|
|
|
|
|
2019-02-27 11:17:36 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
|
* Base class for builders.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-04-29 12:55:29 +02:00
|
|
|
DepsgraphBuilder::DepsgraphBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache)
|
|
|
|
|
: bmain_(bmain), graph_(graph), cache_(cache)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-27 15:15:26 +01:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
struct VisibilityCheckData {
|
2019-04-17 06:17:24 +02:00
|
|
|
eEvaluationMode eval_mode;
|
|
|
|
|
bool is_visibility_animated;
|
2019-02-27 15:15:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void visibility_animated_check_cb(ID * /*id*/, FCurve *fcu, void *user_data)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
VisibilityCheckData *data = reinterpret_cast<VisibilityCheckData *>(user_data);
|
|
|
|
|
if (data->is_visibility_animated) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (data->eval_mode == DAG_EVAL_VIEWPORT) {
|
|
|
|
|
if (STREQ(fcu->rna_path, "hide_viewport")) {
|
|
|
|
|
data->is_visibility_animated = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (data->eval_mode == DAG_EVAL_RENDER) {
|
|
|
|
|
if (STREQ(fcu->rna_path, "hide_render")) {
|
|
|
|
|
data->is_visibility_animated = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-02-27 15:15:26 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-28 18:47:07 +01:00
|
|
|
bool is_object_visibility_animated(const Depsgraph *graph, Object *object)
|
2019-02-27 15:15:26 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
AnimData *anim_data = BKE_animdata_from_id(&object->id);
|
|
|
|
|
if (anim_data == NULL) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
VisibilityCheckData data;
|
|
|
|
|
data.eval_mode = graph->mode;
|
|
|
|
|
data.is_visibility_animated = false;
|
|
|
|
|
BKE_fcurves_id_cb(&object->id, visibility_animated_check_cb, &data);
|
|
|
|
|
return data.is_visibility_animated;
|
2019-02-27 15:15:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2019-02-28 18:47:07 +01:00
|
|
|
bool deg_check_base_available_for_build(const Depsgraph *graph, Base *base)
|
2019-02-28 12:15:42 +11:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
const int base_flag = (graph->mode == DAG_EVAL_VIEWPORT) ? BASE_ENABLED_VIEWPORT :
|
|
|
|
|
BASE_ENABLED_RENDER;
|
|
|
|
|
if (base->flag & base_flag) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (is_object_visibility_animated(graph, base->object)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2019-02-27 11:17:36 +01:00
|
|
|
}
|
|
|
|
|
|
2019-03-01 16:35:11 +01:00
|
|
|
bool DepsgraphBuilder::need_pull_base_into_graph(Base *base)
|
2019-02-28 18:47:07 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return deg_check_base_available_for_build(graph_, base);
|
2019-02-28 18:47:07 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-27 11:17:36 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
|
* Builder finalizer.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-08-23 16:17:06 +02:00
|
|
|
namespace {
|
|
|
|
|
|
2018-09-03 12:55:26 +02:00
|
|
|
void deg_graph_build_flush_visibility(Depsgraph *graph)
|
2018-08-23 16:17:06 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
enum {
|
|
|
|
|
DEG_NODE_VISITED = (1 << 0),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BLI_Stack *stack = BLI_stack_new(sizeof(OperationNode *), "DEG flush layers stack");
|
|
|
|
|
for (IDNode *id_node : graph->id_nodes) {
|
|
|
|
|
GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, id_node->components) {
|
|
|
|
|
comp_node->affects_directly_visible |= id_node->is_directly_visible;
|
|
|
|
|
}
|
|
|
|
|
GHASH_FOREACH_END();
|
|
|
|
|
}
|
|
|
|
|
for (OperationNode *op_node : graph->operations) {
|
|
|
|
|
op_node->custom_flags = 0;
|
|
|
|
|
op_node->num_links_pending = 0;
|
|
|
|
|
for (Relation *rel : op_node->outlinks) {
|
|
|
|
|
if ((rel->from->type == NodeType::OPERATION) && (rel->flag & RELATION_FLAG_CYCLIC) == 0) {
|
|
|
|
|
++op_node->num_links_pending;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (op_node->num_links_pending == 0) {
|
|
|
|
|
BLI_stack_push(stack, &op_node);
|
|
|
|
|
op_node->custom_flags |= DEG_NODE_VISITED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
while (!BLI_stack_is_empty(stack)) {
|
|
|
|
|
OperationNode *op_node;
|
|
|
|
|
BLI_stack_pop(stack, &op_node);
|
|
|
|
|
/* Flush layers to parents. */
|
|
|
|
|
for (Relation *rel : op_node->inlinks) {
|
|
|
|
|
if (rel->from->type == NodeType::OPERATION) {
|
|
|
|
|
OperationNode *op_from = (OperationNode *)rel->from;
|
|
|
|
|
op_from->owner->affects_directly_visible |= op_node->owner->affects_directly_visible;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* Schedule parent nodes. */
|
|
|
|
|
for (Relation *rel : op_node->inlinks) {
|
|
|
|
|
if (rel->from->type == NodeType::OPERATION) {
|
|
|
|
|
OperationNode *op_from = (OperationNode *)rel->from;
|
|
|
|
|
if ((rel->flag & RELATION_FLAG_CYCLIC) == 0) {
|
|
|
|
|
BLI_assert(op_from->num_links_pending > 0);
|
|
|
|
|
--op_from->num_links_pending;
|
|
|
|
|
}
|
|
|
|
|
if ((op_from->num_links_pending == 0) && (op_from->custom_flags & DEG_NODE_VISITED) == 0) {
|
|
|
|
|
BLI_stack_push(stack, &op_from);
|
|
|
|
|
op_from->custom_flags |= DEG_NODE_VISITED;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BLI_stack_free(stack);
|
2018-08-23 16:17:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
2017-10-25 13:27:13 +02:00
|
|
|
void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
|
2017-03-30 14:38:25 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Make sure dependencies of visible ID datablocks are visible. */
|
|
|
|
|
deg_graph_build_flush_visibility(graph);
|
|
|
|
|
/* Re-tag IDs for update if it was tagged before the relations
|
|
|
|
|
* update tag. */
|
|
|
|
|
for (IDNode *id_node : graph->id_nodes) {
|
|
|
|
|
ID *id = id_node->id_orig;
|
|
|
|
|
id_node->finalize_build(graph);
|
|
|
|
|
int flag = 0;
|
|
|
|
|
/* Tag rebuild if special evaluation flags changed. */
|
|
|
|
|
if (id_node->eval_flags != id_node->previous_eval_flags) {
|
|
|
|
|
flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY;
|
|
|
|
|
}
|
|
|
|
|
/* Tag rebuild if the custom data mask changed. */
|
|
|
|
|
if (id_node->customdata_masks != id_node->previous_customdata_masks) {
|
|
|
|
|
flag |= ID_RECALC_GEOMETRY;
|
|
|
|
|
}
|
|
|
|
|
if (!deg_copy_on_write_is_expanded(id_node->id_cow)) {
|
|
|
|
|
flag |= ID_RECALC_COPY_ON_WRITE;
|
|
|
|
|
/* This means ID is being added to the dependency graph first
|
|
|
|
|
* time, which is similar to "ob-visible-change" */
|
|
|
|
|
if (GS(id->name) == ID_OB) {
|
|
|
|
|
flag |= ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (flag != 0) {
|
|
|
|
|
graph_id_tag_update(bmain, graph, id_node->id_orig, flag, DEG_UPDATE_SOURCE_RELATIONS);
|
|
|
|
|
}
|
|
|
|
|
}
|
Depsgraph: Cleanup and code simplification
This is mainly a maintenance commit which was aimed to make work with
this module more pleasant and solve such issues as:
- Annoyance with looong files, which had craftload in them
- Usage of STL for the data structures we've got in BLI
- Possible symbol conflicts
- Not real clear layout of what is located where
So in this commit the following changes are done:
- STL is prohibited, it's not really predictable on various compilers,
with our BLI algorithms we can predict things much better.
There are still few usages of std::vector, but that we'll be
solving later once we've got similar thing in BLI.
- Simplify foreach loops, avoid using const_iterator all over the place.
- New directory layout, which is hopefully easier to follow.
- Some files were split, some of them will be split soon.
The idea of this is to split huge functions into own files with
good documentation and everything.
- Removed stuff which was planned for use in the future but was never
finished, tested or anything.
Let's wipe it out for now, and bring back once we really start using
it, so it'll be more clear if it solves our needs.
- All the internal routines were moved to DEG namespace to separate
them better from rest of blender.
Some places now annoyingly using DEG::foo, but that we can olve by
moving some utility functions inside of the namespace.
While working on this we've found some hotspot in updates flush, so
now playback of blenrig is few percent faster (something like 96fps
with previous master and around 99-100fps after this change).
Not saying it's something final, there is still room for cleanup and
API simplification, but those might happen as a regular development
now without doing any global changes.
2016-05-27 18:01:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace DEG
|