Depsgraph: skip parentbone relation if bone prop is empty

Clearing the Parent Bone field in relations would result in something
like this:

```
add_relation(Bone Parent) - Could not find op_from
(ComponentKey(OBArmature, BONE))
add_relation(Bone Parent) - Failed, but op_to (ComponentKey(OBEmpty,
TRANSFORM)) was ok
ERROR (bke.object): /source/blender/blenkernel/intern\object.c:3330
ob_parbone: Object Empty with Bone parent: bone  doesn't exist
```

Now skip creation of a depsgraph relation if the Parent Bone field is
empty (since this would be invalid anyways).

ref. T91101

Maniphest Tasks: T91101

Differential Revision: https://developer.blender.org/D12389
This commit is contained in:
Philipp Oeser 2021-09-03 12:17:00 +02:00
parent ac97893dfc
commit a45dd52cf0
Notes: blender-bot 2023-10-18 15:23:11 +02:00
Referenced by issue #91101, Apply scale on armature breaks position of child elements with relationship 'Bone'
1 changed files with 7 additions and 5 deletions

View File

@ -1006,11 +1006,13 @@ void DepsgraphRelationBuilder::build_object_parent(Object *object)
/* Bone Parent */
case PARBONE: {
ComponentKey parent_bone_key(parent_id, NodeType::BONE, object->parsubstr);
OperationKey parent_transform_key(
parent_id, NodeType::TRANSFORM, OperationCode::TRANSFORM_FINAL);
add_relation(parent_bone_key, object_transform_key, "Bone Parent");
add_relation(parent_transform_key, object_transform_key, "Armature Parent");
if (object->parsubstr[0] != '\0') {
ComponentKey parent_bone_key(parent_id, NodeType::BONE, object->parsubstr);
OperationKey parent_transform_key(
parent_id, NodeType::TRANSFORM, OperationCode::TRANSFORM_FINAL);
add_relation(parent_bone_key, object_transform_key, "Bone Parent");
add_relation(parent_transform_key, object_transform_key, "Armature Parent");
}
break;
}