Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_armature.c
| Show All 30 Lines | |||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #ifdef RNA_RUNTIME | #ifdef RNA_RUNTIME | ||||
| # include "BLI_math_vector.h" | |||||
| # include "BKE_action.h" | # include "BKE_action.h" | ||||
| # include "BKE_context.h" | # include "BKE_context.h" | ||||
| # include "BKE_global.h" | # include "BKE_global.h" | ||||
| # include "BKE_idprop.h" | # include "BKE_idprop.h" | ||||
| # include "BKE_main.h" | # include "BKE_main.h" | ||||
| # include "ED_armature.h" | # include "ED_armature.h" | ||||
| # include "BKE_armature.h" | # include "BKE_armature.h" | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void rna_EditBone_matrix_set(PointerRNA *ptr, const float *values) | static void rna_EditBone_matrix_set(PointerRNA *ptr, const float *values) | ||||
| { | { | ||||
| EditBone *ebone = (EditBone *)(ptr->data); | EditBone *ebone = (EditBone *)(ptr->data); | ||||
| ED_armature_ebone_from_mat4(ebone, (float(*)[4])values); | ED_armature_ebone_from_mat4(ebone, (float(*)[4])values); | ||||
| } | } | ||||
| static float rna_EditBone_length_get(PointerRNA *ptr) | |||||
| { | |||||
| EditBone *ebone = (EditBone *)(ptr->data); | |||||
| return len_v3v3(ebone->head, ebone->tail); | |||||
| } | |||||
| static void rna_EditBone_length_set(PointerRNA *ptr, float length) | |||||
| { | |||||
| EditBone *ebone = (EditBone *)(ptr->data); | |||||
| float delta[3]; | |||||
| sub_v3_v3v3(delta, ebone->tail, ebone->head); | |||||
| normalize_v3(delta); | |||||
| madd_v3_v3v3fl(ebone->tail, ebone->head, delta, length); | |||||
| } | |||||
| static void rna_Bone_bbone_handle_update(Main *bmain, Scene *scene, PointerRNA *ptr) | static void rna_Bone_bbone_handle_update(Main *bmain, Scene *scene, PointerRNA *ptr) | ||||
| { | { | ||||
| bArmature *arm = (bArmature *)ptr->owner_id; | bArmature *arm = (bArmature *)ptr->owner_id; | ||||
| Bone *bone = (Bone *)ptr->data; | Bone *bone = (Bone *)ptr->data; | ||||
| /* Update all users of this armature after changing B-Bone handles. */ | /* Update all users of this armature after changing B-Bone handles. */ | ||||
| for (Object *obt = bmain->objects.first; obt; obt = obt->id.next) { | for (Object *obt = bmain->objects.first; obt; obt = obt->id.next) { | ||||
| if (obt->data == arm && obt->pose) { | if (obt->data == arm && obt->pose) { | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| RNA_def_property_ui_text(prop, "Select Tail", ""); | RNA_def_property_ui_text(prop, "Select Tail", ""); | ||||
| RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | ||||
| RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); | RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); | ||||
| /* XXX better matrix descriptions possible (Arystan) */ | /* XXX better matrix descriptions possible (Arystan) */ | ||||
| prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); | prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); | ||||
| RNA_def_property_float_sdna(prop, NULL, "bone_mat"); | RNA_def_property_float_sdna(prop, NULL, "bone_mat"); | ||||
| RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_3x3); | RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_3x3); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | ||||
| RNA_def_property_ui_text(prop, "Bone Matrix", "3x3 bone matrix"); | RNA_def_property_ui_text(prop, "Bone Matrix", "3x3 bone matrix"); | ||||
| prop = RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX); | prop = RNA_def_property(srna, "matrix_local", PROP_FLOAT, PROP_MATRIX); | ||||
| RNA_def_property_float_sdna(prop, NULL, "arm_mat"); | RNA_def_property_float_sdna(prop, NULL, "arm_mat"); | ||||
| RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); | RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | ||||
| RNA_def_property_ui_text( | RNA_def_property_ui_text( | ||||
| prop, "Bone Armature-Relative Matrix", "4x4 bone matrix relative to armature"); | prop, "Bone Armature-Relative Matrix", "4x4 bone matrix relative to armature"); | ||||
| prop = RNA_def_property(srna, "tail", PROP_FLOAT, PROP_TRANSLATION); | prop = RNA_def_property(srna, "tail", PROP_FLOAT, PROP_TRANSLATION); | ||||
| RNA_def_property_float_sdna(prop, NULL, "tail"); | RNA_def_property_float_sdna(prop, NULL, "tail"); | ||||
| RNA_def_property_array(prop, 3); | RNA_def_property_array(prop, 3); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | ||||
| RNA_def_property_ui_text( | RNA_def_property_ui_text(prop, "Tail", "Location of tail end of the bone"); | ||||
| prop, "Tail", "Location of tail end of the bone relative to its parent"); | |||||
| RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); | RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); | ||||
| prop = RNA_def_property(srna, "tail_local", PROP_FLOAT, PROP_TRANSLATION); | prop = RNA_def_property(srna, "tail_local", PROP_FLOAT, PROP_TRANSLATION); | ||||
| RNA_def_property_float_sdna(prop, NULL, "arm_tail"); | RNA_def_property_float_sdna(prop, NULL, "arm_tail"); | ||||
| RNA_def_property_array(prop, 3); | RNA_def_property_array(prop, 3); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | ||||
| RNA_def_property_ui_text( | RNA_def_property_ui_text( | ||||
| prop, "Armature-Relative Tail", "Location of tail end of the bone relative to armature"); | prop, "Armature-Relative Tail", "Location of tail end of the bone relative to armature"); | ||||
| RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); | RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); | ||||
| prop = RNA_def_property(srna, "head", PROP_FLOAT, PROP_TRANSLATION); | prop = RNA_def_property(srna, "head", PROP_FLOAT, PROP_TRANSLATION); | ||||
| RNA_def_property_float_sdna(prop, NULL, "head"); | RNA_def_property_float_sdna(prop, NULL, "head"); | ||||
| RNA_def_property_array(prop, 3); | RNA_def_property_array(prop, 3); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | ||||
| RNA_def_property_ui_text( | RNA_def_property_ui_text( | ||||
| prop, "Head", "Location of head end of the bone relative to its parent"); | prop, "Head", "Location of head end of the bone relative to its parent"); | ||||
| RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); | RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); | ||||
| prop = RNA_def_property(srna, "head_local", PROP_FLOAT, PROP_TRANSLATION); | prop = RNA_def_property(srna, "head_local", PROP_FLOAT, PROP_TRANSLATION); | ||||
| RNA_def_property_float_sdna(prop, NULL, "arm_head"); | RNA_def_property_float_sdna(prop, NULL, "arm_head"); | ||||
| RNA_def_property_array(prop, 3); | RNA_def_property_array(prop, 3); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | ||||
| RNA_def_property_ui_text( | RNA_def_property_ui_text( | ||||
| prop, "Armature-Relative Head", "Location of head end of the bone relative to armature"); | prop, "Armature-Relative Head", "Location of head end of the bone relative to armature"); | ||||
| RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); | 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_sdna(prop, NULL, "length"); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| RNA_def_property_ui_text(prop, "Length", "Length of the bone"); | |||||
| RNA_api_bone(srna); | RNA_api_bone(srna); | ||||
| } | } | ||||
| static void rna_def_edit_bone(BlenderRNA *brna) | static void rna_def_edit_bone(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| Show All 29 Lines | |||||
| prop = RNA_def_property(srna, "tail", PROP_FLOAT, PROP_TRANSLATION); | prop = RNA_def_property(srna, "tail", PROP_FLOAT, PROP_TRANSLATION); | ||||
| RNA_def_property_float_sdna(prop, NULL, "tail"); | RNA_def_property_float_sdna(prop, NULL, "tail"); | ||||
| RNA_def_property_array(prop, 3); | RNA_def_property_array(prop, 3); | ||||
| RNA_def_property_ui_text(prop, "Tail", "Location of tail end of the bone"); | RNA_def_property_ui_text(prop, "Tail", "Location of tail end of the bone"); | ||||
| RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | ||||
| RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); | RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); | ||||
| prop = RNA_def_property(srna, "length", PROP_FLOAT, PROP_DISTANCE); | |||||
| RNA_def_property_float_funcs(prop, "rna_EditBone_length_get", "rna_EditBone_length_set", NULL); | |||||
| RNA_def_property_range(prop, 0, FLT_MAX); | |||||
| RNA_def_property_ui_range(prop, 0, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT); | |||||
| RNA_def_property_ui_text(prop, "Length", "Length of the bone. Changing moves the tail end"); | |||||
| RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | |||||
| RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); | |||||
| rna_def_bone_common(srna, 1); | rna_def_bone_common(srna, 1); | ||||
| rna_def_bone_curved_common(srna, false, true); | rna_def_bone_curved_common(srna, false, true); | ||||
| prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_HIDDEN_A); | RNA_def_property_boolean_sdna(prop, NULL, "flag", BONE_HIDDEN_A); | ||||
| RNA_def_property_ui_text(prop, "Hide", "Bone is not visible when in Edit Mode"); | RNA_def_property_ui_text(prop, "Hide", "Bone is not visible when in Edit Mode"); | ||||
| RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); | ||||
| RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); | RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||