Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2019-09-11 12:48:52 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2019-09-11 12:49:04 +0300
commitd4f8bc80a4bd69707a92e7141a2fb67d3f668c58 (patch)
tree01b998e5e958c62f8525be0eccc671381021cbf3 /source/blender/makesrna/intern/rna_pose.c
parent69e0f485c9f7e75e6e95e66751a5fb29cbe6d4d2 (diff)
Armature: convert the length Python property of bones to a RNA property.
This allows accessing it from drivers and using it in UI, as demonstrated by adding it to the transform panel of 3D View. As an aside, properly mark transform-related properties of Bone read-only, as they can only be changed correctly in edit mode.
Diffstat (limited to 'source/blender/makesrna/intern/rna_pose.c')
-rw-r--r--source/blender/makesrna/intern/rna_pose.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index 2f460e79ec9..e514fd82aca 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -274,6 +274,12 @@ static void rna_PoseChannel_rotation_mode_set(PointerRNA *ptr, int value)
pchan->rotmode = value;
}
+static float rna_PoseChannel_length_get(PointerRNA *ptr)
+{
+ bPoseChannel *pchan = ptr->data;
+ return len_v3v3(pchan->pose_head, pchan->pose_tail);
+}
+
static void rna_PoseChannel_name_set(PointerRNA *ptr, const char *value)
{
Object *ob = (Object *)ptr->owner_id;
@@ -1135,6 +1141,11 @@ static void rna_def_pose_channel(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Pose Tail Position", "Location of tail of the channel's bone");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
+ prop = RNA_def_property(srna, "length", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_float_funcs(prop, "rna_PoseChannel_length_get", NULL, NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Length", "Length of the bone");
+
/* IK Settings */
prop = RNA_def_property(srna, "is_in_ik_chain", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_PoseChannel_has_ik_get", NULL);