Ctrl-R sets rotation mode for Pose Bones
This commit is contained in:
@@ -123,6 +123,8 @@ void POSE_OT_paths_clear(struct wmOperatorType *ot);
|
||||
void POSE_OT_autoside_names(struct wmOperatorType *ot);
|
||||
void POSE_OT_flip_names(struct wmOperatorType *ot);
|
||||
|
||||
void POSE_OT_rotation_mode_set(struct wmOperatorType *ot);
|
||||
|
||||
void POSE_OT_quaternions_flip(struct wmOperatorType *ot);
|
||||
|
||||
void POSE_OT_armature_layers(struct wmOperatorType *ot);
|
||||
|
||||
@@ -138,6 +138,8 @@ void ED_operatortypes_armature(void)
|
||||
|
||||
WM_operatortype_append(POSE_OT_autoside_names);
|
||||
WM_operatortype_append(POSE_OT_flip_names);
|
||||
|
||||
WM_operatortype_append(POSE_OT_rotation_mode_set);
|
||||
|
||||
WM_operatortype_append(POSE_OT_quaternions_flip);
|
||||
|
||||
@@ -310,6 +312,8 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
|
||||
|
||||
WM_keymap_add_item(keymap, "POSE_OT_quaternions_flip", FKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "POSE_OT_rotation_mode_set", RKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "POSE_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
|
||||
kmi= WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
#include "RNA_enum_types.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
@@ -1798,6 +1799,46 @@ void POSE_OT_autoside_names (wmOperatorType *ot)
|
||||
|
||||
/* ********************************************** */
|
||||
|
||||
static int pose_bone_rotmode_exec (bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
int mode = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
/* set rotation mode of selected bones */
|
||||
CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones)
|
||||
{
|
||||
pchan->rotmode = mode;
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
/* notifiers and updates */
|
||||
DAG_id_tag_update((ID *)ob, OB_RECALC_DATA);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void POSE_OT_rotation_mode_set (wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Set Rotation Mode";
|
||||
ot->idname= "POSE_OT_rotation_mode_set";
|
||||
ot->description= "Set the rotation representation used by selected bones";
|
||||
|
||||
/* callbacks */
|
||||
ot->invoke= WM_menu_invoke;
|
||||
ot->exec= pose_bone_rotmode_exec;
|
||||
ot->poll= ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
ot->prop= RNA_def_enum(ot->srna, "type", posebone_rotmode_items, 0, "Rotation Mode", "");
|
||||
}
|
||||
|
||||
/* ********************************************** */
|
||||
|
||||
/* Show all armature layers */
|
||||
static int pose_armature_layers_showall_poll (bContext *C)
|
||||
{
|
||||
@@ -1884,7 +1925,7 @@ static int pose_armature_layers_exec (bContext *C, wmOperator *op)
|
||||
PointerRNA ptr;
|
||||
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
|
||||
|
||||
if(ob==NULL || ob->data==NULL) {
|
||||
if (ELEM(NULL, ob, ob->data)) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,6 +97,8 @@ extern EnumPropertyItem wm_report_items[];
|
||||
|
||||
extern EnumPropertyItem transform_mode_types[];
|
||||
|
||||
extern EnumPropertyItem posebone_rotmode_items[];
|
||||
|
||||
extern EnumPropertyItem property_type_items[];
|
||||
extern EnumPropertyItem property_unit_items[];
|
||||
|
||||
|
||||
@@ -45,6 +45,20 @@
|
||||
|
||||
#include "WM_types.h"
|
||||
|
||||
|
||||
|
||||
// XXX: this RNA enum define is currently duplicated for objects, since there is some text here which is not applicable
|
||||
EnumPropertyItem posebone_rotmode_items[] = {
|
||||
{ROT_MODE_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock (default)"},
|
||||
{ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order. Prone to Gimbal Lock"},
|
||||
{ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order. Prone to Gimbal Lock"},
|
||||
{ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order. Prone to Gimbal Lock"},
|
||||
{ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order. Prone to Gimbal Lock"},
|
||||
{ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order. Prone to Gimbal Lock"},
|
||||
{ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order. Prone to Gimbal Lock"},
|
||||
{ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle", "Axis Angle (W+XYZ). Defines a rotation around some axis defined by 3D-Vector"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
#ifdef RNA_RUNTIME
|
||||
|
||||
#include "BIK_api.h"
|
||||
@@ -717,19 +731,7 @@ static void rna_def_pose_channel_constraints(BlenderRNA *brna, PropertyRNA *cpro
|
||||
}
|
||||
|
||||
static void rna_def_pose_channel(BlenderRNA *brna)
|
||||
{
|
||||
// XXX: this RNA enum define is currently duplicated for objects, since there is some text here which is not applicable
|
||||
static EnumPropertyItem prop_rotmode_items[] = {
|
||||
{ROT_MODE_QUAT, "QUATERNION", 0, "Quaternion (WXYZ)", "No Gimbal Lock (default)"},
|
||||
{ROT_MODE_XYZ, "XYZ", 0, "XYZ Euler", "XYZ Rotation Order. Prone to Gimbal Lock"},
|
||||
{ROT_MODE_XZY, "XZY", 0, "XZY Euler", "XZY Rotation Order. Prone to Gimbal Lock"},
|
||||
{ROT_MODE_YXZ, "YXZ", 0, "YXZ Euler", "YXZ Rotation Order. Prone to Gimbal Lock"},
|
||||
{ROT_MODE_YZX, "YZX", 0, "YZX Euler", "YZX Rotation Order. Prone to Gimbal Lock"},
|
||||
{ROT_MODE_ZXY, "ZXY", 0, "ZXY Euler", "ZXY Rotation Order. Prone to Gimbal Lock"},
|
||||
{ROT_MODE_ZYX, "ZYX", 0, "ZYX Euler", "ZYX Rotation Order. Prone to Gimbal Lock"},
|
||||
{ROT_MODE_AXISANGLE, "AXIS_ANGLE", 0, "Axis Angle", "Axis Angle (W+XYZ). Defines a rotation around some axis defined by 3D-Vector"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
{
|
||||
static float default_quat[4] = {1,0,0,0}; /* default quaternion values */
|
||||
static float default_axisAngle[4] = {0,0,1,0}; /* default axis-angle rotation values */
|
||||
static float default_scale[3] = {1,1,1}; /* default scale values */
|
||||
@@ -807,7 +809,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
|
||||
* having a single one is better for Keyframing and other property-management situations...
|
||||
*/
|
||||
prop= RNA_def_property(srna, "rotation_axis_angle", PROP_FLOAT, PROP_AXISANGLE);
|
||||
RNA_def_property_array(prop, 4); // TODO: maybe we'll need to define the 'default value' getter too...
|
||||
RNA_def_property_array(prop, 4);
|
||||
RNA_def_property_float_funcs(prop, "rna_PoseChannel_rotation_axis_angle_get", "rna_PoseChannel_rotation_axis_angle_set", NULL);
|
||||
RNA_def_property_editable_array_func(prop, "rna_PoseChannel_rotation_4d_editable");
|
||||
RNA_def_property_float_array_default(prop, default_axisAngle);
|
||||
@@ -824,7 +826,7 @@ static void rna_def_pose_channel(BlenderRNA *brna)
|
||||
|
||||
prop= RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "rotmode");
|
||||
RNA_def_property_enum_items(prop, prop_rotmode_items); // XXX move to using a single define of this someday
|
||||
RNA_def_property_enum_items(prop, posebone_rotmode_items); // XXX move to using a single define of this someday
|
||||
RNA_def_property_enum_funcs(prop, NULL, "rna_PoseChannel_rotation_mode_set", NULL);
|
||||
RNA_def_property_editable_func(prop, "rna_PoseChannel_proxy_editable"); // XXX... disabled, since proxy-locked layers are currently used for ensuring proxy-syncing too
|
||||
RNA_def_property_ui_text(prop, "Rotation Mode", "");
|
||||
|
||||
Reference in New Issue
Block a user