diff options
author | Joseph Eagar <joeedh@gmail.com> | 2021-06-26 23:00:26 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2021-06-26 23:00:26 +0300 |
commit | 83c491f044db0072143801b03aded573ed7093f9 (patch) | |
tree | 45376aedcded9033be0b795a205c42638c345ef9 /source/blender/depsgraph/intern/builder | |
parent | 7ef7843ada944a5530ff4de812a5684e39809142 (diff) | |
parent | abc62003314af2b39136bf43031590d4fbfb72df (diff) |
Merge branch 'master' into temp_bmesh_multires
Diffstat (limited to 'source/blender/depsgraph/intern/builder')
6 files changed, 39 insertions, 11 deletions
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index ae530cc010e..56168739fae 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -450,6 +450,22 @@ void DepsgraphNodeBuilder::update_invalid_cow_pointers() /* Node/ID already tagged for COW flush, no need to check it. */ continue; } + if ((id_node->id_cow->flag & LIB_EMBEDDED_DATA) != 0) { + /* For now, we assume embedded data are managed by their owner IDs and do not need to be + * checked here. + * + * NOTE: This exception somewhat weak, and ideally should not be needed. Currently however, + * embedded data are handled as full local (private) data of their owner IDs in part of + * Blender (like read/write code, including undo/redo), while depsgraph generally treat them + * as regular independent IDs. This leads to inconsistencies that can lead to bad level + * memory accesses. + * + * E.g. when undoing creation/deletion of a collection directly child of a scene's master + * collection, the scene itself is re-read in place, but its master collection becomes a + * completely new different pointer, and the existing COW of the old master collection in the + * matching deg node is therefore pointing to fully invalid (freed) memory. */ + continue; + } BKE_library_foreach_ID_link(nullptr, id_node->id_cow, deg::foreach_id_cow_detect_need_for_update_callback, @@ -1199,7 +1215,19 @@ void DepsgraphNodeBuilder::build_parameters(ID *id) op_node = add_operation_node(id, NodeType::PARAMETERS, OperationCode::PARAMETERS_ENTRY); op_node->set_as_entry(); /* Generic evaluation node. */ - add_operation_node(id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EVAL); + + if (ID_TYPE_SUPPORTS_PARAMS_WITHOUT_COW(GS(id->name))) { + ID *id_cow = get_cow_id(id); + add_operation_node( + id, + NodeType::PARAMETERS, + OperationCode::PARAMETERS_EVAL, + [id_cow, id](::Depsgraph * /*depsgraph*/) { BKE_id_eval_properties_copy(id_cow, id); }); + } + else { + add_operation_node(id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EVAL); + } + /* Explicit exit operation. */ op_node = add_operation_node(id, NodeType::PARAMETERS, OperationCode::PARAMETERS_EXIT); op_node->set_as_exit(); @@ -1352,7 +1380,7 @@ void DepsgraphNodeBuilder::build_particle_systems(Object *object, bool is_object ParticleSettings *part = psys->part; /* Build particle settings operations. * - * NOTE: The call itself ensures settings are only build once. */ + * NOTE: The call itself ensures settings are only build once. */ build_particle_settings(part); /* Particle system evaluation. */ add_operation_node(psys_comp, OperationCode::PARTICLE_SYSTEM_EVAL, nullptr, psys->name); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc index 21a32b0d005..090b7f9dcb3 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc @@ -68,7 +68,7 @@ void DepsgraphNodeBuilder::build_scene_parameters(Scene *scene) * * Would be nice to find some reliable way of ignoring compositor here, but it's already pulled * in when building scene from view layer, so this particular case does not make things - * marginally worse. */ + * marginally worse. */ build_scene_compositor(scene); LISTBASE_FOREACH (TimeMarker *, marker, &scene->markers) { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 8a02228146a..c269ad16824 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -220,7 +220,7 @@ OperationCode bone_target_opcode(ID *target, const char *component_subdata, RootPChanMap *root_map) { - /* Same armature. */ + /* Same armature. */ if (target == id) { /* Using "done" here breaks in-chain deps, while using * "ready" here breaks most production rigs instead. @@ -240,7 +240,7 @@ bool object_have_geometry_component(const Object *object) } // namespace -/* **** General purpose functions **** */ +/* **** General purpose functions **** */ DepsgraphRelationBuilder::DepsgraphRelationBuilder(Main *bmain, Depsgraph *graph, @@ -1148,7 +1148,7 @@ void DepsgraphRelationBuilder::build_constraints(ID *id, /* Special case for camera tracking -- it doesn't use targets to * define relations. */ /* TODO: we can now represent dependencies in a much richer manner, - * so review how this is done. */ + * so review how this is done. */ if (ELEM(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, @@ -1911,7 +1911,7 @@ void DepsgraphRelationBuilder::build_particle_systems(Object *object) /* Effectors. */ add_particle_forcefield_relations( psys_key, object, psys, part->effector_weights, part->type == PART_HAIR, "Particle Field"); - /* Boids .*/ + /* Boids. */ if (part->boids != nullptr) { LISTBASE_FOREACH (BoidState *, state, &part->boids->states) { LISTBASE_FOREACH (BoidRule *, rule, &state->rules) { @@ -1947,7 +1947,7 @@ void DepsgraphRelationBuilder::build_particle_systems(Object *object) switch (part->ren_as) { case PART_DRAW_OB: if (part->instance_object != nullptr) { - /* Make sure object's relations are all built. */ + /* Make sure object's relations are all built. */ build_object(part->instance_object); /* Build relation for the particle visualization. */ build_particle_system_visualization_object(object, psys, part->instance_object); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h index cab20dadc50..035d636b977 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_impl.h @@ -192,7 +192,7 @@ bool DepsgraphRelationBuilder::is_same_bone_dependency(const KeyFrom &key_from, op_to->opcode == OperationCode::BONE_LOCAL)) { return false; } - /* ... BUT, we also need to check if it's same bone. */ + /* ... BUT, we also need to check if it's same bone. */ if (op_from->owner->name != op_to->owner->name) { return false; } diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc index e4591e2e994..4754749e2e5 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc @@ -397,7 +397,7 @@ void DepsgraphRelationBuilder::build_rig(Object *object) add_relation(bone_local_key, constraints_key, "Local -> Constraints Stack"); /* Constraints -> ready/ */ /* TODO(sergey): When constraint stack is exploded, this step should - * occur before the first IK solver. */ + * occur before the first IK solver. */ add_relation(constraints_key, bone_ready_key, "Constraints -> Ready"); } else { diff --git a/source/blender/depsgraph/intern/builder/pipeline.cc b/source/blender/depsgraph/intern/builder/pipeline.cc index 10bc7213061..28e4c973c1e 100644 --- a/source/blender/depsgraph/intern/builder/pipeline.cc +++ b/source/blender/depsgraph/intern/builder/pipeline.cc @@ -98,7 +98,7 @@ void AbstractBuilderPipeline::build_step_finalize() deg_graph_->scene_cow = (Scene *)deg_graph_->get_cow_id(°_graph_->scene->id); /* Flush visibility layer and re-schedule nodes for update. */ deg_graph_build_finalize(bmain_, deg_graph_); - DEG_graph_on_visible_update(bmain_, reinterpret_cast<::Depsgraph *>(deg_graph_), false); + DEG_graph_tag_on_visible_update(reinterpret_cast<::Depsgraph *>(deg_graph_), false); #if 0 if (!DEG_debug_consistency_check(deg_graph_)) { printf("Consistency validation failed, ABORTING!\n"); |