Depsgraph: Allow building scene properties
This is used by driers and this is a first step towards support of scenes used for only compositor or sequencer. Fixes T61014: Assert adding a driver that uses a single property of a scene ID
This commit is contained in:
parent
b88f1d3491
commit
0ec6fa782b
Notes:
blender-bot
2023-02-14 03:54:01 +01:00
Referenced by issue #71212, Drivers referencing scene.frame_current doesn't update when animation is playing Referenced by issue #65062, Compositor doesn't update anymore Referenced by issue #61014, Assert adding a driver that uses a single property of a scene ID
|
@ -42,11 +42,13 @@ set(SRC
|
|||
intern/builder/deg_builder_map.cc
|
||||
intern/builder/deg_builder_nodes.cc
|
||||
intern/builder/deg_builder_nodes_rig.cc
|
||||
intern/builder/deg_builder_nodes_scene.cc
|
||||
intern/builder/deg_builder_nodes_view_layer.cc
|
||||
intern/builder/deg_builder_pchanmap.cc
|
||||
intern/builder/deg_builder_relations.cc
|
||||
intern/builder/deg_builder_relations_keys.cc
|
||||
intern/builder/deg_builder_relations_rig.cc
|
||||
intern/builder/deg_builder_relations_scene.cc
|
||||
intern/builder/deg_builder_relations_view_layer.cc
|
||||
intern/builder/deg_builder_rna.cc
|
||||
intern/builder/deg_builder_transitive.cc
|
||||
|
|
|
@ -453,6 +453,9 @@ void DepsgraphNodeBuilder::build_id(ID *id)
|
|||
case ID_CF:
|
||||
build_cachefile((CacheFile *)id);
|
||||
break;
|
||||
case ID_SCE:
|
||||
build_scene_parameters((Scene *)id);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unhandled ID %s\n", id->name);
|
||||
BLI_assert(!"Should never happen");
|
||||
|
|
|
@ -152,6 +152,9 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
|
|||
ID *id, NodeType comp_type, OperationCode opcode, const char *name = "", int name_tag = -1);
|
||||
|
||||
void build_id(ID *id);
|
||||
|
||||
void build_scene_parameters(Scene *scene);
|
||||
|
||||
void build_layer_collections(ListBase *lb);
|
||||
void build_view_layer(Scene *scene,
|
||||
ViewLayer *view_layer,
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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) 2013 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup depsgraph
|
||||
*/
|
||||
|
||||
#include "intern/builder/deg_builder_nodes.h"
|
||||
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
namespace DEG {
|
||||
|
||||
void DepsgraphNodeBuilder::build_scene_parameters(Scene *scene)
|
||||
{
|
||||
if (built_map_.checkIsBuiltAndTag(scene, BuilderMap::TAG_PARAMETERS)) {
|
||||
return;
|
||||
}
|
||||
add_operation_node(&scene->id, NodeType::PARAMETERS, OperationCode::SCENE_EVAL);
|
||||
add_operation_node(&scene->id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EVAL);
|
||||
}
|
||||
|
||||
} // namespace DEG
|
|
@ -157,7 +157,7 @@ void DepsgraphNodeBuilder::build_view_layer(Scene *scene,
|
|||
OperationCode::VIEW_LAYER_EVAL,
|
||||
function_bind(BKE_layer_eval_view_layer_indexed, _1, scene_cow, view_layer_index_));
|
||||
/* Parameters evaluation for scene relations mainly. */
|
||||
add_operation_node(&scene->id, NodeType::PARAMETERS, OperationCode::SCENE_EVAL);
|
||||
build_scene_parameters(scene);
|
||||
/* Build all set scenes. */
|
||||
if (scene->set != NULL) {
|
||||
ViewLayer *set_view_layer = BKE_view_layer_default_render(scene->set);
|
||||
|
|
|
@ -497,6 +497,9 @@ void DepsgraphRelationBuilder::build_id(ID *id)
|
|||
case ID_CF:
|
||||
build_cachefile((CacheFile *)id);
|
||||
break;
|
||||
case ID_SCE:
|
||||
build_scene_parameters((Scene *)id);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unhandled ID %s\n", id->name);
|
||||
BLI_assert(!"Should never happen");
|
||||
|
|
|
@ -194,6 +194,9 @@ class DepsgraphRelationBuilder : public DepsgraphBuilder {
|
|||
void add_special_eval_flag(ID *object, uint32_t flag);
|
||||
|
||||
void build_id(ID *id);
|
||||
|
||||
void build_scene_parameters(Scene *scene);
|
||||
|
||||
void build_layer_collections(ListBase *lb);
|
||||
void build_view_layer(Scene *scene, ViewLayer *view_layer);
|
||||
void build_collection(LayerCollection *from_layer_collection,
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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) 2013 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \ingroup depsgraph
|
||||
*/
|
||||
|
||||
#include "intern/builder/deg_builder_relations.h"
|
||||
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
namespace DEG {
|
||||
|
||||
void DepsgraphRelationBuilder::build_scene_parameters(Scene *scene)
|
||||
{
|
||||
if (built_map_.checkIsBuiltAndTag(scene, BuilderMap::TAG_PARAMETERS)) {
|
||||
return;
|
||||
}
|
||||
OperationKey parameters_eval_key(
|
||||
&scene->id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EVAL);
|
||||
OperationKey scene_eval_key(&scene->id, NodeType::PARAMETERS, OperationCode::SCENE_EVAL);
|
||||
add_relation(parameters_eval_key, scene_eval_key, "Parameters -> Scene Eval");
|
||||
}
|
||||
|
||||
} // namespace DEG
|
|
@ -128,6 +128,8 @@ void DepsgraphRelationBuilder::build_view_layer(Scene *scene, ViewLayer *view_la
|
|||
build_collection(NULL, NULL, fls->group);
|
||||
}
|
||||
}
|
||||
/* Scene parameters. */
|
||||
build_scene_parameters(scene);
|
||||
/* Build all set scenes. */
|
||||
if (scene->set != NULL) {
|
||||
ViewLayer *set_view_layer = BKE_view_layer_default_render(scene->set);
|
||||
|
|
|
@ -340,7 +340,15 @@ void scene_remove_unused_view_layers(const Depsgraph *depsgraph,
|
|||
const IDNode *id_node,
|
||||
Scene *scene_cow)
|
||||
{
|
||||
const ViewLayer *view_layer_input = get_original_view_layer(depsgraph, id_node);
|
||||
const ViewLayer *view_layer_input;
|
||||
/* Indirectly linked scenes means it's not an input scene and not a set scene, and is pulled via
|
||||
* some driver. Such scenes should not have view layers after copy. */
|
||||
if (id_node->linked_state == DEG_ID_LINKED_INDIRECTLY) {
|
||||
view_layer_input = NULL;
|
||||
}
|
||||
else {
|
||||
view_layer_input = get_original_view_layer(depsgraph, id_node);
|
||||
}
|
||||
ViewLayer *view_layer_eval = NULL;
|
||||
/* Find evaluated view layer. At the same time we free memory used by
|
||||
* all other of the view layers. */
|
||||
|
@ -349,16 +357,17 @@ void scene_remove_unused_view_layers(const Depsgraph *depsgraph,
|
|||
view_layer_cow != NULL;
|
||||
view_layer_cow = view_layer_next) {
|
||||
view_layer_next = view_layer_cow->next;
|
||||
if (STREQ(view_layer_input->name, view_layer_cow->name)) {
|
||||
if (view_layer_input != NULL && STREQ(view_layer_input->name, view_layer_cow->name)) {
|
||||
view_layer_eval = view_layer_cow;
|
||||
}
|
||||
else {
|
||||
BKE_view_layer_free_ex(view_layer_cow, false);
|
||||
}
|
||||
}
|
||||
BLI_assert(view_layer_eval != NULL);
|
||||
/* Make evaluated view layer the only one in the evaluated scene. */
|
||||
view_layer_eval->prev = view_layer_eval->next = NULL;
|
||||
/* Make evaluated view layer the only one in the evaluated scene (if it exists). */
|
||||
if (view_layer_eval != NULL) {
|
||||
view_layer_eval->prev = view_layer_eval->next = NULL;
|
||||
}
|
||||
scene_cow->view_layers.first = view_layer_eval;
|
||||
scene_cow->view_layers.last = view_layer_eval;
|
||||
}
|
||||
|
@ -367,6 +376,9 @@ void scene_remove_unused_view_layers(const Depsgraph *depsgraph,
|
|||
* objects. */
|
||||
void view_layer_remove_disabled_bases(const Depsgraph *depsgraph, ViewLayer *view_layer)
|
||||
{
|
||||
if (view_layer == NULL) {
|
||||
return;
|
||||
}
|
||||
ListBase enabled_bases = {NULL, NULL};
|
||||
LISTBASE_FOREACH_MUTABLE (Base *, base, &view_layer->object_bases) {
|
||||
/* TODO(sergey): Would be cool to optimize this somehow, or make it so
|
||||
|
@ -397,6 +409,10 @@ void view_layer_remove_disabled_bases(const Depsgraph *depsgraph, ViewLayer *vie
|
|||
void view_layer_update_orig_base_pointers(const ViewLayer *view_layer_orig,
|
||||
ViewLayer *view_layer_eval)
|
||||
{
|
||||
if (view_layer_orig == NULL || view_layer_eval == NULL) {
|
||||
/* Happens when scene is only used for parameters or compositor/sequencer. */
|
||||
return;
|
||||
}
|
||||
Base *base_orig = reinterpret_cast<Base *>(view_layer_orig->object_bases.first);
|
||||
LISTBASE_FOREACH (Base *, base_eval, &view_layer_eval->object_bases) {
|
||||
base_eval->base_orig = base_orig;
|
||||
|
|
Loading…
Reference in New Issue