Code Cleanup - Replaced magic numbers with defines

This commit is contained in:
Joshua Leung
2014-06-26 16:40:35 +12:00
parent 26eae6315c
commit 796aef081b

View File

@@ -627,6 +627,13 @@ void POSE_OT_select_hierarchy(wmOperatorType *ot)
/* -------------------------------------- */
/* modes for select same */
typedef enum ePose_SelectSame_Mode {
POSE_SEL_SAME_LAYER = 0,
POSE_SEL_SAME_GROUP = 1,
POSE_SEL_SAME_KEYINGSET = 2,
} ePose_SelectSame_Mode;
static bool pose_select_same_group(bContext *C, Object *ob, bool extend)
{
bArmature *arm = (ob) ? ob->data : NULL;
@@ -785,6 +792,7 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
bArmature *arm = (bArmature *)ob->data;
const ePose_SelectSame_Mode type = RNA_enum_get(op->ptr, "type");
const bool extend = RNA_boolean_get(op->ptr, "extend");
bool changed = false;
@@ -792,18 +800,22 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
if (ob->pose == NULL)
return OPERATOR_CANCELLED;
/* selection types
* NOTE: for the order of these, see the enum in POSE_OT_select_grouped()
*/
switch (RNA_enum_get(op->ptr, "type")) {
case 1: /* group */
/* selection types */
switch (type) {
case POSE_SEL_SAME_LAYER: /* layer */
changed = pose_select_same_layer(C, ob, extend);
break;
case POSE_SEL_SAME_GROUP: /* group */
changed = pose_select_same_group(C, ob, extend);
break;
case 2: /* Keying Set */
case POSE_SEL_SAME_KEYINGSET: /* Keying Set */
changed = pose_select_same_keyingset(C, ob, extend);
break;
default: /* layer */
changed = pose_select_same_layer(C, ob, extend);
default:
printf("pose_select_grouped() - Unknown selection type %d\n", type);
break;
}
@@ -825,9 +837,9 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
void POSE_OT_select_grouped(wmOperatorType *ot)
{
static EnumPropertyItem prop_select_grouped_types[] = {
{0, "LAYER", 0, "Layer", "Shared layers"},
{1, "GROUP", 0, "Group", "Shared group"},
{2, "KEYINGSET", 0, "Keying Set", "All bones affected by active Keying Set"},
{POSE_SEL_SAME_LAYER, "LAYER", 0, "Layer", "Shared layers"},
{POSE_SEL_SAME_GROUP, "GROUP", 0, "Group", "Shared group"},
{POSE_SEL_SAME_KEYINGSET, "KEYINGSET", 0, "Keying Set", "All bones affected by active Keying Set"},
{0, NULL, 0, NULL, NULL}
};