[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18819] branches/blender2.5/blender/source /blender: 2.5
Michael Fox
mfoxdogg at gmail.com
Thu Feb 5 06:13:31 CET 2009
Revision: 18819
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18819
Author: mfoxdogg
Date: 2009-02-05 06:13:08 +0100 (Thu, 05 Feb 2009)
Log Message:
-----------
2.5
*******
-ported clear loc,rot,scale operators to pose mode operators
- for some reason when animated and you clear anything, the whole aramture clears. somthing to do with the depsgraph stuff that was directly ported from clear armature()
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/blenkernel/BKE_context.h
branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
branches/blender2.5/blender/source/blender/editors/object/object_edit.c
Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_context.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_context.h 2009-02-05 03:28:07 UTC (rev 18818)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_context.h 2009-02-05 05:13:08 UTC (rev 18819)
@@ -40,6 +40,8 @@
struct ListBase;
struct Main;
struct Object;
+struct Bone;
+struct bArmature;
struct PointerRNA;
struct ReportList;
struct Scene;
Modified: branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h 2009-02-05 03:28:07 UTC (rev 18818)
+++ branches/blender2.5/blender/source/blender/editors/armature/armature_intern.h 2009-02-05 05:13:08 UTC (rev 18819)
@@ -37,7 +37,9 @@
void POSE_OT_hide(struct wmOperatorType *ot);
void POSE_OT_reveil(struct wmOperatorType *ot);
+void POSE_OT_rot_clear(struct wmOperatorType *ot);
+void POSE_OT_loc_clear(struct wmOperatorType *ot);
+void POSE_OT_scale_clear(struct wmOperatorType *ot);
-
#endif /* ED_ARMATURE_INTERN_H */
Modified: branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c 2009-02-05 03:28:07 UTC (rev 18818)
+++ branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c 2009-02-05 05:13:08 UTC (rev 18819)
@@ -109,6 +109,9 @@
{
WM_operatortype_append(POSE_OT_hide);
WM_operatortype_append(POSE_OT_reveil);
+ WM_operatortype_append(POSE_OT_rot_clear);
+ WM_operatortype_append(POSE_OT_loc_clear);
+ WM_operatortype_append(POSE_OT_scale_clear);
WM_operatortype_append(ARMATURE_OT_test); // XXX temp test for context iterators... to be removed
}
@@ -133,6 +136,9 @@
kmi= WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "invert", 1);
WM_keymap_add_item(keymap, "POSE_OT_reveil", HKEY, KM_PRESS, KM_ALT, 0);
-
+ /*clear pose*/
+ WM_keymap_add_item(keymap, "POSE_OT_rot_clear", RKEY, KM_PRESS, KM_ALT, 0);
+ 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);
}
Modified: branches/blender2.5/blender/source/blender/editors/armature/editarmature.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/editarmature.c 2009-02-05 03:28:07 UTC (rev 18818)
+++ branches/blender2.5/blender/source/blender/editors/armature/editarmature.c 2009-02-05 05:13:08 UTC (rev 18819)
@@ -3483,74 +3483,6 @@
/* ***************** Pose tools ********************* */
-void clear_armature(Scene *scene, Object *ob, char mode)
-{
- bPoseChannel *pchan;
- bArmature *arm= ob->data;
-
- /* only clear those channels that are not locked */
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- if (pchan->bone && (pchan->bone->flag & BONE_SELECTED)) {
- if (arm->layer & pchan->bone->layer) {
- switch (mode) {
- case 'r':
- if (pchan->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ)) {
- float eul[3], oldeul[3], quat1[4];
-
- QUATCOPY(quat1, pchan->quat);
- QuatToEul(pchan->quat, oldeul);
- eul[0]= eul[1]= eul[2]= 0.0f;
-
- if (pchan->protectflag & OB_LOCK_ROTX)
- eul[0]= oldeul[0];
- if (pchan->protectflag & OB_LOCK_ROTY)
- eul[1]= oldeul[1];
- if (pchan->protectflag & OB_LOCK_ROTZ)
- eul[2]= oldeul[2];
-
- EulToQuat(eul, pchan->quat);
- /* quaternions flip w sign to accumulate rotations correctly */
- if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) {
- QuatMulf(pchan->quat, -1.0f);
- }
- }
- else {
- pchan->quat[1]=pchan->quat[2]=pchan->quat[3]=0.0F;
- pchan->quat[0]=1.0F;
- }
- break;
- case 'g':
- if ((pchan->protectflag & OB_LOCK_LOCX)==0)
- pchan->loc[0]= 0.0f;
- if ((pchan->protectflag & OB_LOCK_LOCY)==0)
- pchan->loc[1]= 0.0f;
- if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
- pchan->loc[2]= 0.0f;
- break;
- case 's':
- if ((pchan->protectflag & OB_LOCK_SCALEX)==0)
- pchan->size[0]= 1.0f;
- if ((pchan->protectflag & OB_LOCK_SCALEY)==0)
- pchan->size[1]= 1.0f;
- if ((pchan->protectflag & OB_LOCK_SCALEZ)==0)
- pchan->size[2]= 1.0f;
- break;
-
- }
-
- /* the current values from IPO's may not be zero, so tag as unkeyed */
- pchan->bone->flag |= BONE_UNKEYED;
- }
- }
- }
-
- DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
- /* no update for this object, this will execute the action again */
- /* is weak... like for ipo editing which uses ctime now... */
- where_is_pose (scene, ob);
- ob->recalc= 0;
-}
-
/* helper for function below */
static int clear_active_flag(Object *ob, Bone *bone, void *data)
{
@@ -4079,7 +4011,169 @@
break;
}
}
+/* ************* Clear Pose *****************************/
+static int pose_clear_scale_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *ob= CTX_data_active_object(C);
+ bArmature *arm= ob->data;
+
+ /* only clear those channels that are not locked */
+ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans){
+ if (arm->layer & pchan->bone->layer) {
+ if ((pchan->protectflag & OB_LOCK_SCALEX)==0)
+ pchan->size[0]= 1.0f;
+ if ((pchan->protectflag & OB_LOCK_SCALEY)==0)
+ pchan->size[1]= 1.0f;
+ if ((pchan->protectflag & OB_LOCK_SCALEZ)==0)
+ pchan->size[2]= 1.0f;
+ /* the current values from IPO's may not be zero, so tag as unkeyed */
+ pchan->bone->flag |= BONE_UNKEYED;
+ }
+ }
+ CTX_DATA_END;
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ /* no update for this object, this will execute the action again */
+ /* is weak... like for ipo editing which uses ctime now... */
+ where_is_pose (scene, ob);
+ ob->recalc= 0;
+ /* note, notifier might evolve */
+ WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void POSE_OT_scale_clear(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Clear Pose Scale";
+ ot->idname= "POSE_OT_scale_clear";
+
+ /* api callbacks */
+ ot->invoke = WM_operator_confirm;
+ ot->exec = pose_clear_scale_exec;
+ ot->poll = ED_operator_posemode;
+
+ /* flags */
+ ot->flag= OPTYPE_UNDO;
+}
+
+static int pose_clear_loc_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *ob= CTX_data_active_object(C);
+ bArmature *arm= ob->data;
+
+ /* only clear those channels that are not locked */
+ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans){
+ if (arm->layer & pchan->bone->layer) {
+ if ((pchan->protectflag & OB_LOCK_LOCX)==0)
+ pchan->loc[0]= 0.0f;
+ if ((pchan->protectflag & OB_LOCK_LOCY)==0)
+ pchan->loc[1]= 0.0f;
+ if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
+ pchan->loc[2]= 0.0f;
+ /* the current values from IPO's may not be zero, so tag as unkeyed */
+ pchan->bone->flag |= BONE_UNKEYED;
+ }
+ }
+ CTX_DATA_END;
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ /* no update for this object, this will execute the action again */
+ /* is weak... like for ipo editing which uses ctime now... */
+ where_is_pose (scene, ob);
+ ob->recalc= 0;
+
+ /* note, notifier might evolve */
+ WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void POSE_OT_loc_clear(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Clear Pose Location";
+ ot->idname= "POSE_OT_loc_clear";
+
+ /* api callbacks */
+ ot->invoke = WM_operator_confirm;
+ ot->exec = pose_clear_loc_exec;
+ ot->poll = ED_operator_posemode;
+
+ /* flags */
+ ot->flag= OPTYPE_UNDO;
+}
+
+static int pose_clear_rot_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *ob= CTX_data_active_object(C);
+ bArmature *arm= ob->data;
+
+ /* only clear those channels that are not locked */
+ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pchans){
+ if (arm->layer & pchan->bone->layer) {
+ if (pchan->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ)) {
+ float eul[3], oldeul[3], quat1[4];
+
+ QUATCOPY(quat1, pchan->quat);
+ QuatToEul(pchan->quat, oldeul);
+ eul[0]= eul[1]= eul[2]= 0.0f;
+
+ if (pchan->protectflag & OB_LOCK_ROTX)
+ eul[0]= oldeul[0];
+ if (pchan->protectflag & OB_LOCK_ROTY)
+ eul[1]= oldeul[1];
+ if (pchan->protectflag & OB_LOCK_ROTZ)
+ eul[2]= oldeul[2];
+
+ EulToQuat(eul, pchan->quat);
+ /* quaternions flip w sign to accumulate rotations correctly */
+ if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) {
+ QuatMulf(pchan->quat, -1.0f);
+ }
+ }
+ else {
+ pchan->quat[1]=pchan->quat[2]=pchan->quat[3]=0.0F;
+ pchan->quat[0]=1.0F;
+ }
+ /* the current values from IPO's may not be zero, so tag as unkeyed */
+ pchan->bone->flag |= BONE_UNKEYED;
+ }
+ }
+ CTX_DATA_END;
+
+ DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
+ /* no update for this object, this will execute the action again */
+ /* is weak... like for ipo editing which uses ctime now... */
+ where_is_pose (scene, ob);
+ ob->recalc= 0;
+
+ /* note, notifier might evolve */
+ WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void POSE_OT_rot_clear(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Clear Pose Rotation";
+ ot->idname= "POSE_OT_rot_clear";
+
+ /* api callbacks */
+ ot->invoke = WM_operator_confirm;
+ ot->exec = pose_clear_rot_exec;
+ ot->poll = ED_operator_posemode;
+
+ /* flags */
+ ot->flag= OPTYPE_UNDO;
+
+}
/* ************* hide/unhide pose bones ******************* */
static int hide_selected_pose_bone(Object *ob, Bone *bone, void *ptr)
Modified: branches/blender2.5/blender/source/blender/editors/object/object_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/object/object_edit.c 2009-02-05 03:28:07 UTC (rev 18818)
+++ branches/blender2.5/blender/source/blender/editors/object/object_edit.c 2009-02-05 05:13:08 UTC (rev 18819)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list