From d43e3f34d26daca4f2b0f4c524a35a98cc85d1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 6 Oct 2020 17:49:57 +0200 Subject: Fix T81218: Crash in pose mode using a driver on bendy bone Segment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The example file in T81218 has a driver that maps a bone's X-location to the number of BBone segments. This caused a dependency cycle, which resulted in bad thread serialisation, which caused the crash. This patch breaks the dependency cycle `BONE_LOCAL` → `DRIVER(bones["Bone"].bbone_segments)` → `BONE_LOCAL`. The 'Driver Data' relation now points to `BONE_SEGMENTS` when the driven property starts with `bbone_`. Differential Revision: https://developer.blender.org/D9122 --- source/blender/depsgraph/intern/builder/deg_builder_relations.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 26839c67324..c0630cd47c6 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -1489,6 +1489,9 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu) return; } + const char *prop_identifier = RNA_property_identifier(property_entry_key.prop); + const bool driver_targets_bbone = STRPREFIX(prop_identifier, "bbone_"); + /* Find objects which use this, and make their eval callbacks depend on this. */ for (IDNode *to_node : graph_->id_nodes) { if (GS(to_node->id_orig->name) != ID_OB) { @@ -1506,7 +1509,9 @@ void DepsgraphRelationBuilder::build_driver_data(ID *id, FCurve *fcu) continue; } - OperationKey bone_key(&object->id, NodeType::BONE, pchan->name, OperationCode::BONE_LOCAL); + OperationCode target_op = driver_targets_bbone ? OperationCode::BONE_SEGMENTS : + OperationCode::BONE_LOCAL; + OperationKey bone_key(&object->id, NodeType::BONE, pchan->name, target_op); add_relation(driver_key, bone_key, "Arm Bone -> Driver -> Bone"); } /* Make the driver depend on COW, similar to the generic case below. */ -- cgit v1.2.3