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/builder/deg_builder_relations.cc')
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc173
1 files changed, 121 insertions, 52 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index c13c6d2f870..39dad18ff2b 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -27,6 +27,7 @@
#include "DNA_collection_types.h"
#include "DNA_constraint_types.h"
#include "DNA_curve_types.h"
+#include "DNA_curves_types.h"
#include "DNA_effect_types.h"
#include "DNA_gpencil_types.h"
#include "DNA_key_types.h"
@@ -238,13 +239,8 @@ DepsgraphRelationBuilder::DepsgraphRelationBuilder(Main *bmain,
{
}
-TimeSourceNode *DepsgraphRelationBuilder::get_node(const TimeSourceKey &key) const
+TimeSourceNode *DepsgraphRelationBuilder::get_node(const TimeSourceKey & /*key*/) const
{
- if (key.id) {
- /* XXX TODO */
- return nullptr;
- }
-
return graph_->time_source;
}
@@ -297,12 +293,13 @@ bool DepsgraphRelationBuilder::has_node(const OperationKey &key) const
return find_node(key) != nullptr;
}
-void DepsgraphRelationBuilder::add_modifier_to_transform_relation(const DepsNodeHandle *handle,
- const char *description)
+void DepsgraphRelationBuilder::add_depends_on_transform_relation(const DepsNodeHandle *handle,
+ const char *description)
{
IDNode *id_node = handle->node->owner->owner;
ID *id = id_node->id_orig;
- ComponentKey geometry_key(id, NodeType::GEOMETRY);
+ const OperationKey geometry_key(
+ id, NodeType::GEOMETRY, OperationCode::MODIFIER, handle->node->name.c_str());
/* Wire up the actual relation. */
add_depends_on_transform_relation(id, geometry_key, description);
}
@@ -692,7 +689,7 @@ void DepsgraphRelationBuilder::build_object(Object *object)
const BuilderStack::ScopedEntry stack_entry = stack_.trace(object->id);
- /* Object Transforms */
+ /* Object Transforms. */
OperationCode base_op = (object->parent) ? OperationCode::TRANSFORM_PARENT :
OperationCode::TRANSFORM_LOCAL;
OperationKey base_op_key(&object->id, NodeType::TRANSFORM, base_op);
@@ -705,9 +702,12 @@ void DepsgraphRelationBuilder::build_object(Object *object)
OperationKey final_transform_key(
&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_FINAL);
OperationKey ob_eval_key(&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_EVAL);
+
add_relation(init_transform_key, local_transform_key, "Transform Init");
+
/* Various flags, flushing from bases/collections. */
build_object_layer_component_relations(object);
+
/* Parenting. */
if (object->parent != nullptr) {
/* Make sure parent object's relations are built. */
@@ -717,30 +717,31 @@ void DepsgraphRelationBuilder::build_object(Object *object)
/* Local -> parent. */
add_relation(local_transform_key, parent_transform_key, "ObLocal -> ObParent");
}
+
/* Modifiers. */
- if (object->modifiers.first != nullptr) {
- BuilderWalkUserData data;
- data.builder = this;
- BKE_modifiers_foreach_ID_link(object, modifier_walk, &data);
- }
+ build_object_modifiers(object);
+
/* Grease Pencil Modifiers. */
if (object->greasepencil_modifiers.first != nullptr) {
BuilderWalkUserData data;
data.builder = this;
BKE_gpencil_modifiers_foreach_ID_link(object, modifier_walk, &data);
}
+
/* Shader FX. */
if (object->shader_fx.first != nullptr) {
BuilderWalkUserData data;
data.builder = this;
BKE_shaderfx_foreach_ID_link(object, modifier_walk, &data);
}
+
/* Constraints. */
if (object->constraints.first != nullptr) {
BuilderWalkUserData data;
data.builder = this;
BKE_constraints_id_loop(&object->constraints, constraint_walk, &data);
}
+
/* Object constraints. */
OperationKey object_transform_simulation_init_key(
&object->id, NodeType::TRANSFORM, OperationCode::TRANSFORM_SIMULATION_INIT);
@@ -767,32 +768,48 @@ void DepsgraphRelationBuilder::build_object(Object *object)
final_transform_key,
"Simulation -> Final Transform");
}
+
build_idproperties(object->id.properties);
+
/* Animation data */
build_animdata(&object->id);
+
/* Object data. */
build_object_data(object);
+
/* Particle systems. */
if (object->particlesystem.first != nullptr) {
build_particle_systems(object);
}
+
/* Force field Texture. */
if ((object->pd != nullptr) && (object->pd->forcefield == PFIELD_TEXTURE) &&
(object->pd->tex != nullptr)) {
build_texture(object->pd->tex);
}
+
/* Object dupligroup. */
if (object->instance_collection != nullptr) {
build_collection(nullptr, object, object->instance_collection);
}
+
/* Point caches. */
build_object_pointcache(object);
+
/* Synchronization back to original object. */
OperationKey synchronize_key(
&object->id, NodeType::SYNCHRONIZATION, OperationCode::SYNCHRONIZE_TO_ORIGINAL);
add_relation(final_transform_key, synchronize_key, "Synchronize to Original");
+
/* Parameters. */
build_parameters(&object->id);
+
+ /* Visibility.
+ * Evaluate visibility node after the object's base_flags has been updated to the current state
+ * of collections restrict and object's restrict flags. */
+ const ComponentKey object_from_layer_entry_key(&object->id, NodeType::OBJECT_FROM_LAYER);
+ const ComponentKey visibility_key(&object->id, NodeType::VISIBILITY);
+ add_relation(object_from_layer_entry_key, visibility_key, "Object Visibility");
}
/* NOTE: Implies that the object has base in the current view layer. */
@@ -850,6 +867,63 @@ void DepsgraphRelationBuilder::build_object_layer_component_relations(Object *ob
add_relation(object_from_layer_exit_key, synchronize_key, "Synchronize to Original");
}
+void DepsgraphRelationBuilder::build_object_modifiers(Object *object)
+{
+ if (BLI_listbase_is_empty(&object->modifiers)) {
+ return;
+ }
+
+ const OperationKey eval_init_key(
+ &object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL_INIT);
+ const OperationKey eval_key(&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL);
+
+ const ComponentKey object_visibility_key(&object->id, NodeType::VISIBILITY);
+ const OperationKey modifier_visibility_key(
+ &object->id, NodeType::GEOMETRY, OperationCode::VISIBILITY);
+ add_relation(modifier_visibility_key,
+ object_visibility_key,
+ "modifier -> object visibility",
+ RELATION_NO_VISIBILITY_CHANGE);
+
+ add_relation(modifier_visibility_key, eval_key, "modifier visibility -> geometry eval");
+
+ ModifierUpdateDepsgraphContext ctx = {};
+ ctx.scene = scene_;
+ ctx.object = object;
+
+ OperationKey previous_key = eval_init_key;
+ LISTBASE_FOREACH (ModifierData *, modifier, &object->modifiers) {
+ const OperationKey modifier_key(
+ &object->id, NodeType::GEOMETRY, OperationCode::MODIFIER, modifier->name);
+
+ /* Relation for the modifier stack chain. */
+ add_relation(previous_key, modifier_key, "Modifier");
+
+ const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)modifier->type);
+ if (mti->updateDepsgraph) {
+ const BuilderStack::ScopedEntry stack_entry = stack_.trace(*modifier);
+
+ DepsNodeHandle handle = create_node_handle(modifier_key);
+ ctx.node = reinterpret_cast<::DepsNodeHandle *>(&handle);
+ mti->updateDepsgraph(modifier, &ctx);
+ }
+
+ /* Time dependency. */
+ if (BKE_modifier_depends_ontime(scene_, modifier)) {
+ const TimeSourceKey time_src_key;
+ add_relation(time_src_key, modifier_key, "Time Source -> Modifier");
+ }
+
+ previous_key = modifier_key;
+ }
+ add_relation(previous_key, eval_key, "modifier stack order");
+
+ /* Build IDs referenced by the modifiers. */
+ BuilderWalkUserData data;
+ data.builder = this;
+ BKE_modifiers_foreach_ID_link(object, modifier_walk, &data);
+}
+
void DepsgraphRelationBuilder::build_object_data(Object *object)
{
if (object->data == nullptr) {
@@ -1791,18 +1865,20 @@ void DepsgraphRelationBuilder::build_driver_id_property(ID *id, const char *rna_
if (RNA_struct_is_a(ptr.type, &RNA_PoseBone)) {
const bPoseChannel *pchan = static_cast<const bPoseChannel *>(ptr.data);
id_property_key = OperationKey(
- id, NodeType::BONE, pchan->name, OperationCode::ID_PROPERTY, prop_identifier);
+ ptr.owner_id, NodeType::BONE, pchan->name, OperationCode::ID_PROPERTY, prop_identifier);
/* Create relation from the parameters component so that tagging armature for parameters update
* properly propagates updates to all properties on bones and deeper (if needed). */
- OperationKey parameters_init_key(id, NodeType::PARAMETERS, OperationCode::PARAMETERS_ENTRY);
+ OperationKey parameters_init_key(
+ ptr.owner_id, NodeType::PARAMETERS, OperationCode::PARAMETERS_ENTRY);
add_relation(
parameters_init_key, id_property_key, "Init -> ID Property", RELATION_CHECK_BEFORE_ADD);
}
else {
id_property_key = OperationKey(
- id, NodeType::PARAMETERS, OperationCode::ID_PROPERTY, prop_identifier);
+ ptr.owner_id, NodeType::PARAMETERS, OperationCode::ID_PROPERTY, prop_identifier);
}
- OperationKey parameters_exit_key(id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EXIT);
+ OperationKey parameters_exit_key(
+ ptr.owner_id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EXIT);
add_relation(
id_property_key, parameters_exit_key, "ID Property -> Done", RELATION_CHECK_BEFORE_ADD);
}
@@ -1952,7 +2028,6 @@ void DepsgraphRelationBuilder::build_rigidbody(Scene *scene)
void DepsgraphRelationBuilder::build_particle_systems(Object *object)
{
- TimeSourceKey time_src_key;
OperationKey obdata_ubereval_key(&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL);
OperationKey eval_init_key(
&object->id, NodeType::PARTICLE_SYSTEM, OperationCode::PARTICLE_SYSTEM_INIT);
@@ -2142,7 +2217,7 @@ void DepsgraphRelationBuilder::build_shapekeys(Key *key)
* ==========================
*
* The evaluation of geometry on objects is as follows:
- * - The actual evaluated of the derived geometry (e.g. Mesh, DispList)
+ * - The actual evaluated of the derived geometry (e.g. #Mesh, #Curves, etc.)
* occurs in the Geometry component of the object which references this.
* This includes modifiers, and the temporary "ubereval" for geometry.
* Therefore, each user of a piece of shared geometry data ends up evaluating
@@ -2173,28 +2248,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
* data mask to be used. We add relation here to ensure object is never
* evaluated prior to Scene's CoW is ready. */
OperationKey scene_key(&scene_->id, NodeType::PARAMETERS, OperationCode::SCENE_EVAL);
- Relation *rel = add_relation(scene_key, obdata_ubereval_key, "CoW Relation");
- rel->flag |= RELATION_FLAG_NO_FLUSH;
- /* Modifiers */
- if (object->modifiers.first != nullptr) {
- ModifierUpdateDepsgraphContext ctx = {};
- ctx.scene = scene_;
- ctx.object = object;
- LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
- const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)md->type);
- if (mti->updateDepsgraph) {
- const BuilderStack::ScopedEntry stack_entry = stack_.trace(*md);
-
- DepsNodeHandle handle = create_node_handle(obdata_ubereval_key);
- ctx.node = reinterpret_cast<::DepsNodeHandle *>(&handle);
- mti->updateDepsgraph(md, &ctx);
- }
- if (BKE_object_modifier_use_time(scene_, object, md)) {
- TimeSourceKey time_src_key;
- add_relation(time_src_key, obdata_ubereval_key, "Time Source");
- }
- }
- }
+ add_relation(scene_key, obdata_ubereval_key, "CoW Relation", RELATION_FLAG_NO_FLUSH);
/* Grease Pencil Modifiers. */
if (object->greasepencil_modifiers.first != nullptr) {
ModifierUpdateDepsgraphContext ctx = {};
@@ -2208,7 +2262,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
ctx.node = reinterpret_cast<::DepsNodeHandle *>(&handle);
mti->updateDepsgraph(md, &ctx, graph_->mode);
}
- if (BKE_object_modifier_gpencil_use_time(object, md)) {
+ if (BKE_gpencil_modifier_depends_ontime(md)) {
TimeSourceKey time_src_key;
add_relation(time_src_key, obdata_ubereval_key, "Time Source");
}
@@ -2226,7 +2280,7 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
ctx.node = reinterpret_cast<::DepsNodeHandle *>(&handle);
fxi->updateDepsgraph(fx, &ctx);
}
- if (BKE_object_shaderfx_use_time(object, fx)) {
+ if (BKE_shaderfx_depends_ontime(fx)) {
TimeSourceKey time_src_key;
add_relation(time_src_key, obdata_ubereval_key, "Time Source");
}
@@ -2238,9 +2292,9 @@ void DepsgraphRelationBuilder::build_object_data_geometry(Object *object)
if (ELEM(object->type, OB_MESH, OB_CURVES_LEGACY, OB_LATTICE)) {
// add geometry collider relations
}
- /* Make sure uber update is the last in the dependencies. */
- if (object->type != OB_ARMATURE) {
- /* Armatures does no longer require uber node. */
+ /* Make sure uber update is the last in the dependencies.
+ * Only do it here unless there are modifiers. This avoids transitive relations. */
+ if (BLI_listbase_is_empty(&object->modifiers)) {
OperationKey obdata_ubereval_key(
&object->id, NodeType::GEOMETRY, OperationCode::GEOMETRY_EVAL);
add_relation(geom_init_key, obdata_ubereval_key, "Object Geometry UberEval");
@@ -2402,8 +2456,16 @@ void DepsgraphRelationBuilder::build_object_data_geometry_datablock(ID *obdata)
}
break;
}
- case ID_CV:
+ case ID_CV: {
+ Curves *curves_id = reinterpret_cast<Curves *>(obdata);
+ if (curves_id->surface != nullptr) {
+ build_object(curves_id->surface);
+
+ /* The relations between the surface and the curves are handled as part of the modifier
+ * stack building. */
+ }
break;
+ }
case ID_PT:
break;
case ID_VO: {
@@ -2459,6 +2521,13 @@ void DepsgraphRelationBuilder::build_camera(Camera *camera)
ComponentKey camera_parameters_key(&camera->id, NodeType::PARAMETERS);
ComponentKey dof_ob_key(&camera->dof.focus_object->id, NodeType::TRANSFORM);
add_relation(dof_ob_key, camera_parameters_key, "Camera DOF");
+ if (camera->dof.focus_subtarget[0]) {
+ OperationKey target_key(&camera->dof.focus_object->id,
+ NodeType::BONE,
+ camera->dof.focus_subtarget,
+ OperationCode::BONE_DONE);
+ add_relation(target_key, camera_parameters_key, "Camera DOF subtarget");
+ }
}
}
@@ -2981,9 +3050,10 @@ void DepsgraphRelationBuilder::build_scene_audio(Scene *scene)
}
}
-void DepsgraphRelationBuilder::build_scene_speakers(Scene * /*scene*/, ViewLayer *view_layer)
+void DepsgraphRelationBuilder::build_scene_speakers(Scene *scene, ViewLayer *view_layer)
{
- LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
+ BKE_view_layer_synced_ensure(scene, view_layer);
+ LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
Object *object = base->object;
if (object->type != OB_SPEAKER || !need_pull_base_into_graph(base)) {
continue;
@@ -3058,7 +3128,6 @@ void DepsgraphRelationBuilder::build_copy_on_write_relations(IDNode *id_node)
return;
}
- TimeSourceKey time_source_key;
OperationKey copy_on_write_key(id_orig, NodeType::COPY_ON_WRITE, OperationCode::COPY_ON_WRITE);
/* XXX: This is a quick hack to make Alt-A to work. */
// add_relation(time_source_key, copy_on_write_key, "Fluxgate capacitor hack");