diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-10-05 20:46:51 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-10-05 21:07:51 +0300 |
commit | 975af239ed6dcc7ad987f06df171dc2f7be884d0 (patch) | |
tree | db2f7417d9b7d82673a627f898545e6617c21e49 /source/blender/makesrna/intern/rna_pose.c | |
parent | 0b8e92783e92045cbc951fa0e9d73f60089ad79a (diff) |
Fix wrong RNA handling of some internal pchan pointers.
There were two issues here:
* cutsom_shape_transform was not properly tagged as not-owned pointer.
* custom_shape_transform and bbone_start/_end could be set to a pchan from
another data-block (not from UI, but RNA access code itself allowed it).
Those two issues were specificaly breaking complex rigs in static
override case.
EDIT: since yesterday, bbone_start/_end are mere accessors to edit_bone
data in RNA, so most of fix related to those was ditched (they still needed
to be 'deactivated' from RNA diffing with PROPOVERRIDE_NO_COMPARISON).
Diffstat (limited to 'source/blender/makesrna/intern/rna_pose.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_pose.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 56ba29d277c..61a63bc939f 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -743,6 +743,25 @@ static void rna_PoseChannel_matrix_set(PointerRNA *ptr, const float *values) BKE_pchan_apply_mat4(pchan, tmat, false); /* no compat for predictable result */ } +static bPoseChannel *rna_PoseChannel_ensure_own_pchan(Object *ob, Object *ref_ob, bPoseChannel *ref_pchan) +{ + if (ref_ob != ob) { + /* We are trying to set a pchan from another object! Forbidden, try to find by name, or abort. */ + if (ref_pchan != NULL) { + ref_pchan = BKE_pose_channel_find_name(ob->pose, ref_pchan->name); + } + } + return ref_pchan; +} + +static void rna_PoseChannel_custom_shape_transform_set(PointerRNA *ptr, PointerRNA value) +{ + bPoseChannel *pchan = (bPoseChannel *)ptr->data; + Object *ob = (Object *)ptr->id.data; + + pchan->custom_tx = rna_PoseChannel_ensure_own_pchan(ob, value.id.data, value.data); +} + #else /* common properties for Action/Bone Groups - related to color */ @@ -969,6 +988,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "bbone_prev"); RNA_def_property_struct_type(prop, "PoseBone"); RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP); + RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON); RNA_def_property_ui_text(prop, "B-Bone Start Handle", "Bone that serves as the start handle for the B-Bone curve"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_dependency_update"); @@ -977,6 +997,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "bbone_next"); RNA_def_property_struct_type(prop, "PoseBone"); RNA_def_property_flag(prop, PROP_PTR_NO_OWNERSHIP); + RNA_def_property_override_flag(prop, PROPOVERRIDE_NO_COMPARISON); RNA_def_property_ui_text(prop, "B-Bone End Handle", "Bone that serves as the end handle for the B-Bone curve"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_dependency_update"); @@ -1185,10 +1206,12 @@ static void rna_def_pose_channel(BlenderRNA *brna) prop = RNA_def_property(srna, "custom_shape_transform", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "custom_tx"); RNA_def_property_struct_type(prop, "PoseBone"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_PTR_NO_OWNERSHIP); + RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_text(prop, "Custom Shape Transform", "Bone that defines the display transform of this custom shape"); RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_PoseChannel_custom_shape_transform_set", NULL, NULL); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); /* bone groups */ |