Fix T81218: Crash in pose mode using a driver on bendy bone Segment

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
This commit is contained in:
Sybren A. Stüvel 2020-10-06 17:49:57 +02:00
parent a2b1842358
commit d43e3f34d2
Notes: blender-bot 2023-02-13 22:19:27 +01:00
Referenced by issue #81218, Crash in pose mode using a driver on bendy bone Segments.
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
1 changed files with 6 additions and 1 deletions

View File

@ -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. */