[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26241] trunk/blender: Restored missing PoseMode Operators:
Joshua Leung
aligorith at gmail.com
Mon Jan 25 11:16:36 CET 2010
Revision: 26241
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26241
Author: aligorith
Date: 2010-01-25 11:16:36 +0100 (Mon, 25 Jan 2010)
Log Message:
-----------
Restored missing PoseMode Operators:
* Select Grouped
Selects bones in the same layer or same group as the selected ones. Optimised the code for the select same groups too.
* Flip Quats
Flips quaternion values so that the rotation progresses over a different path while maintaining the same endpoint orientations.
Modified Paths:
--------------
trunk/blender/release/scripts/ui/space_view3d.py
trunk/blender/source/blender/blenkernel/intern/fcurve.c
trunk/blender/source/blender/editors/animation/keyframing.c
trunk/blender/source/blender/editors/armature/armature_intern.h
trunk/blender/source/blender/editors/armature/armature_ops.c
trunk/blender/source/blender/editors/armature/poseobject.c
Modified: trunk/blender/release/scripts/ui/space_view3d.py
===================================================================
--- trunk/blender/release/scripts/ui/space_view3d.py 2010-01-25 10:05:17 UTC (rev 26240)
+++ trunk/blender/release/scripts/ui/space_view3d.py 2010-01-25 10:16:36 UTC (rev 26241)
@@ -419,6 +419,9 @@
props.extend = True
props.direction = 'CHILD'
+ layout.separator()
+
+ layout.operator_menu_enum("pose.select_grouped", "type", text="Grouped")
layout.operator("object.select_pattern", text="Select Pattern...")
@@ -987,6 +990,8 @@
layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
layout.operator("pose.flip_names")
+
+ layout.operator("pose.quaternions_flip")
layout.separator()
Modified: trunk/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/fcurve.c 2010-01-25 10:05:17 UTC (rev 26240)
+++ trunk/blender/source/blender/blenkernel/intern/fcurve.c 2010-01-25 10:16:36 UTC (rev 26241)
@@ -817,6 +817,7 @@
break;
}
+ /* degrees to radians (since curves are stored in degrees, but drivers need radians) */
if (RNA_SUBTYPE_UNIT(RNA_property_subtype(prop)) == PROP_UNIT_ROTATION) {
value *= 180.0/M_PI;
}
Modified: trunk/blender/source/blender/editors/animation/keyframing.c
===================================================================
--- trunk/blender/source/blender/editors/animation/keyframing.c 2010-01-25 10:05:17 UTC (rev 26240)
+++ trunk/blender/source/blender/editors/animation/keyframing.c 2010-01-25 10:16:36 UTC (rev 26241)
@@ -860,7 +860,7 @@
printf("Insert Key: Could not insert keyframe, as this type does not support animation data (ID = %s, Path = %s)\n", id->name, rna_path);
return 0;
}
-
+
/* apply NLA-mapping to frame to use (if applicable) */
cfra= BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
}
Modified: trunk/blender/source/blender/editors/armature/armature_intern.h
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_intern.h 2010-01-25 10:05:17 UTC (rev 26240)
+++ trunk/blender/source/blender/editors/armature/armature_intern.h 2010-01-25 10:16:36 UTC (rev 26241)
@@ -86,6 +86,7 @@
void POSE_OT_select_hierarchy(struct wmOperatorType *ot);
void POSE_OT_select_linked(struct wmOperatorType *ot);
void POSE_OT_select_constraint_target(struct wmOperatorType *ot);
+void POSE_OT_select_grouped(struct wmOperatorType *ot);
void POSE_OT_group_add(struct wmOperatorType *ot);
void POSE_OT_group_remove(struct wmOperatorType *ot);
@@ -99,6 +100,8 @@
void POSE_OT_autoside_names(struct wmOperatorType *ot);
void POSE_OT_flip_names(struct wmOperatorType *ot);
+void POSE_OT_quaternions_flip(struct wmOperatorType *ot);
+
void POSE_OT_flags_set(struct wmOperatorType *ot);
void POSE_OT_armature_layers(struct wmOperatorType *ot);
Modified: trunk/blender/source/blender/editors/armature/armature_ops.c
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_ops.c 2010-01-25 10:05:17 UTC (rev 26240)
+++ trunk/blender/source/blender/editors/armature/armature_ops.c 2010-01-25 10:16:36 UTC (rev 26241)
@@ -127,6 +127,7 @@
WM_operatortype_append(POSE_OT_select_hierarchy);
WM_operatortype_append(POSE_OT_select_linked);
WM_operatortype_append(POSE_OT_select_constraint_target);
+ WM_operatortype_append(POSE_OT_select_grouped);
WM_operatortype_append(POSE_OT_group_add);
WM_operatortype_append(POSE_OT_group_remove);
@@ -139,6 +140,8 @@
WM_operatortype_append(POSE_OT_autoside_names);
WM_operatortype_append(POSE_OT_flip_names);
+ WM_operatortype_append(POSE_OT_quaternions_flip);
+
WM_operatortype_append(POSE_OT_flags_set);
WM_operatortype_append(POSE_OT_armature_layers);
@@ -290,6 +293,8 @@
WM_keymap_add_item(keymap, "POSE_OT_loc_clear", GKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "POSE_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_add_item(keymap, "POSE_OT_quaternions_flip", FKEY, KM_PRESS, KM_ALT, 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);
@@ -313,6 +318,7 @@
RNA_boolean_set(kmi->ptr, "extend", 1);
WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
Modified: trunk/blender/source/blender/editors/armature/poseobject.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poseobject.c 2010-01-25 10:05:17 UTC (rev 26240)
+++ trunk/blender/source/blender/editors/armature/poseobject.c 2010-01-25 10:16:36 UTC (rev 26241)
@@ -93,8 +93,6 @@
static int pupmenu() {return 0;}
static void error() {};
static void BIF_undo_push() {}
-static void countall() {}
-static void autokeyframe_pose_cb_func() {}
/* ************* XXX *************** */
/* This function is used to indicate that a bone is selected and needs keyframes inserted */
@@ -488,7 +486,7 @@
}
}
- if(!found)
+ if (found == 0)
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
@@ -516,13 +514,172 @@
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* props */
- RNA_def_enum(ot->srna, "direction", direction_items,
- BONE_SELECT_PARENT, "Direction", "");
+ ot->prop= RNA_def_enum(ot->srna, "direction", direction_items, BONE_SELECT_PARENT, "Direction", "");
RNA_def_boolean(ot->srna, "extend", 0, "Add to Selection", "");
}
+/* ******************* select grouped operator ************* */
+static short pose_select_same_group (Object *ob, short extend)
+{
+ bPose *pose= (ob)? ob->pose : NULL;
+ bArmature *arm= (ob)? ob->data : NULL;
+ bPoseChannel *pchan;
+ char *group_flags;
+ int numGroups = 0;
+ short changed=0, tagged=0;
+
+ /* sanity checks */
+ if (ELEM3(NULL, ob, pose, arm))
+ return 0;
+
+ /* count the number of groups */
+ numGroups= BLI_countlist(&pose->agroups);
+ if (numGroups == 0)
+ return 0;
+
+ /* alloc a small array to keep track of the groups to use
+ * - each cell stores on/off state for whether group should be used
+ * - size is numGroups + 1, since index=0 is used for no-group
+ */
+ group_flags= MEM_callocN(numGroups+1, "pose_select_same_group");
+
+ for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
+ if (arm->layer & pchan->bone->layer) {
+ /* keep track of group as group to use later? */
+ if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone)) {
+ group_flags[pchan->agrp_index] = 1;
+ tagged= 1;
+ }
+
+ /* deselect all bones before selecting new ones? */
+ if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE)==0)
+ pchan->bone->flag &= ~BONE_SELECTED;
+ }
+ }
+
+ /* small optimisation: only loop through bones a second time if there are any groups tagged */
+ if (tagged) {
+ /* only if group matches (and is not selected or current bone) */
+ for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
+ if ((arm->layer & pchan->bone->layer) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) {
+ /* check if the group used by this bone is counted */
+ if (group_flags[pchan->agrp_index]) {
+ pchan->bone->flag |= BONE_SELECTED;
+ changed= 1;
+ }
+ }
+ }
+ }
+
+ /* free temp info */
+ MEM_freeN(group_flags);
+
+ return changed;
+}
+
+static short pose_select_same_layer (Object *ob, short extend)
+{
+ bPose *pose= (ob)? ob->pose : NULL;
+ bArmature *arm= (ob)? ob->data : NULL;
+ bPoseChannel *pchan;
+ short changed= 0;
+ int layers= 0;
+
+ if (ELEM3(NULL, ob, pose, arm))
+ return 0;
+
+ /* figure out what bones are selected */
+ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if (arm->layer & pchan->bone->layer) {
+ /* keep track of layers to use later? */
+ if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone))
+ layers |= pchan->bone->layer;
+
+ /* deselect all bones before selecting new ones? */
+ if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE)==0)
+ pchan->bone->flag &= ~BONE_SELECTED;
+ }
+ }
+ if (layers == 0)
+ return 0;
+
+ /* select bones that are on same layers as layers flag */
+ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if (arm->layer & pchan->bone->layer) {
+ /* if bone is on a suitable layer, and the bone can have its selection changed, select it */
+ if ((layers & pchan->bone->layer) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) {
+ pchan->bone->flag |= BONE_SELECTED;
+ changed= 1;
+ }
+ }
+ }
+
+ return changed;
+}
+
+
+static int pose_select_grouped_exec (bContext *C, wmOperator *op)
+{
+ Object *ob= CTX_data_active_object(C);
+ short extend= RNA_boolean_get(op->ptr, "extend");
+ short changed = 0;
+
+ /* sanity check */
+ if (ELEM(NULL, ob, ob->pose))
+ 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 */
+ changed= pose_select_same_group(ob, extend);
+ break;
+ default: /* layer */
+ changed= pose_select_same_layer(ob, extend);
+ break;
+ }
+
+ /* notifiers for updates */
+ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+
+ /* report done status */
+ if (changed)
+ return OPERATOR_FINISHED;
+ else
+ return OPERATOR_CANCELLED;
+}
+
+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"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
+ /* identifiers */
+ ot->name= "Select Grouped";
+ ot->description = "Select all visible bones grouped by various properties.";
+ ot->idname= "POSE_OT_select_grouped";
+
+ /* api callbacks */
+ ot->invoke= WM_menu_invoke;
+ ot->exec= pose_select_grouped_exec;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list