Depsgraph: Fix missing updates when in local view

This area is a subject of reconsideration, so for now used simplest
way possible -- ensure depsgraph's nodes have proper layer flags
when going in and out of local mode.
This commit is contained in:
Sergey Sharybin 2017-03-30 14:38:25 +02:00
parent a88801b99b
commit 843be91002
Notes: blender-bot 2023-02-14 11:28:43 +01:00
Referenced by commit 24676b535a, Fix T49981: When camera is on inactive layer, it does not evaluate constraints
4 changed files with 42 additions and 22 deletions

View File

@ -77,28 +77,8 @@ static bool check_object_needs_evaluation(Object *object)
return false;
}
void deg_graph_build_finalize(Depsgraph *graph)
void deg_graph_build_flush_layers(Depsgraph *graph)
{
/* STEP 1: Make sure new invisible dependencies are ready for use.
*
* TODO(sergey): This might do a bit of extra tagging, but it's kinda nice
* to do it ahead of a time and don't spend time on flushing updates on
* every frame change.
*/
GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, graph->id_hash)
{
if (id_node->layers == 0) {
ID *id = id_node->id;
if (GS(id->name) == ID_OB) {
Object *object = (Object *)id;
if (check_object_needs_evaluation(object)) {
id_node->tag_update(graph);
}
}
}
}
GHASH_FOREACH_END();
/* STEP 2: Flush visibility layers from children to parent. */
std::stack<OperationDepsNode *> stack;
foreach (OperationDepsNode *node, graph->operations) {
IDDepsNode *id_node = node->owner->owner;
@ -143,6 +123,31 @@ void deg_graph_build_finalize(Depsgraph *graph)
}
}
}
}
void deg_graph_build_finalize(Depsgraph *graph)
{
/* STEP 1: Make sure new invisible dependencies are ready for use.
*
* TODO(sergey): This might do a bit of extra tagging, but it's kinda nice
* to do it ahead of a time and don't spend time on flushing updates on
* every frame change.
*/
GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, graph->id_hash)
{
if (id_node->layers == 0) {
ID *id = id_node->id;
if (GS(id->name) == ID_OB) {
Object *object = (Object *)id;
if (check_object_needs_evaluation(object)) {
id_node->tag_update(graph);
}
}
}
}
GHASH_FOREACH_END();
/* STEP 2: Flush visibility layers from children to parent. */
deg_graph_build_flush_layers(graph);
/* STEP 3: Re-tag IDs for update if it was tagged before the relations
* update tag.
*/

View File

@ -42,5 +42,6 @@ struct Depsgraph;
string deg_fcurve_id_name(const FCurve *fcu);
void deg_graph_build_finalize(struct Depsgraph *graph);
void deg_graph_build_flush_layers(struct Depsgraph *graph);
} // namespace DEG

View File

@ -56,8 +56,8 @@ extern "C" {
#include "DEG_depsgraph.h"
} /* extern "C" */
#include "intern/builder/deg_builder.h"
#include "intern/eval/deg_eval_flush.h"
#include "intern/nodes/deg_node.h"
#include "intern/nodes/deg_node_component.h"
#include "intern/nodes/deg_node_operation.h"
@ -346,6 +346,18 @@ void DEG_graph_on_visible_update(Main *bmain, Scene *scene)
GHASH_FOREACH_END();
}
scene->lay_updated |= graph->layers;
/* Special trick to get local view to work. */
LINKLIST_FOREACH (Base *, base, &scene->base) {
Object *object = base->object;
DEG::IDDepsNode *node = graph->find_id_node(&object->id);
node->layers = 0;
}
LINKLIST_FOREACH (Base *, base, &scene->base) {
Object *object = base->object;
DEG::IDDepsNode *node = graph->find_id_node(&object->id);
node->layers |= base->lay;
}
DEG::deg_graph_build_flush_layers(graph);
}
void DEG_on_visible_update(Main *bmain, const bool UNUSED(do_time))

View File

@ -1405,6 +1405,8 @@ static bool view3d_localview_init(
}
}
DAG_on_visible_update(bmain, false);
return ok;
}