[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39417] branches/soc-2011-pepper: Restoring "Clear User Transforms" operator
Joshua Leung
aligorith at gmail.com
Mon Aug 15 15:24:53 CEST 2011
Revision: 39417
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39417
Author: aligorith
Date: 2011-08-15 13:24:53 +0000 (Mon, 15 Aug 2011)
Log Message:
-----------
Restoring "Clear User Transforms" operator
This can now be found as Pose -> Clear Transforms -> Reset Unkeyed, or
via the operator search (known by its old name there)
Modified Paths:
--------------
branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_view3d.py
branches/soc-2011-pepper/source/blender/editors/armature/armature_intern.h
branches/soc-2011-pepper/source/blender/editors/armature/armature_ops.c
branches/soc-2011-pepper/source/blender/editors/armature/poseobject.c
Modified: branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_view3d.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_view3d.py 2011-08-15 13:17:39 UTC (rev 39416)
+++ branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_view3d.py 2011-08-15 13:24:53 UTC (rev 39417)
@@ -1262,13 +1262,17 @@
layout.operator("pose.transforms_clear", text="All")
+ layout.separator()
+
layout.operator("pose.loc_clear", text="Location")
layout.operator("pose.rot_clear", text="Rotation")
layout.operator("pose.scale_clear", text="Scale")
- layout.label(text="Origin")
+ layout.separator()
+ layout.operator("pose.user_transforms_clear", text="Reset unkeyed")
+
class VIEW3D_MT_pose_slide(bpy.types.Menu):
bl_label = "In-Betweens"
Modified: branches/soc-2011-pepper/source/blender/editors/armature/armature_intern.h
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/armature/armature_intern.h 2011-08-15 13:17:39 UTC (rev 39416)
+++ branches/soc-2011-pepper/source/blender/editors/armature/armature_intern.h 2011-08-15 13:24:53 UTC (rev 39417)
@@ -93,6 +93,7 @@
void POSE_OT_loc_clear(struct wmOperatorType *ot);
void POSE_OT_scale_clear(struct wmOperatorType *ot);
void POSE_OT_transforms_clear(struct wmOperatorType *ot);
+void POSE_OT_user_transforms_clear(struct wmOperatorType *ot);
void POSE_OT_copy(struct wmOperatorType *ot);
void POSE_OT_paste(struct wmOperatorType *ot);
Modified: branches/soc-2011-pepper/source/blender/editors/armature/armature_ops.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/armature/armature_ops.c 2011-08-15 13:17:39 UTC (rev 39416)
+++ branches/soc-2011-pepper/source/blender/editors/armature/armature_ops.c 2011-08-15 13:24:53 UTC (rev 39417)
@@ -108,6 +108,7 @@
WM_operatortype_append(POSE_OT_loc_clear);
WM_operatortype_append(POSE_OT_scale_clear);
WM_operatortype_append(POSE_OT_transforms_clear);
+ WM_operatortype_append(POSE_OT_user_transforms_clear);
WM_operatortype_append(POSE_OT_copy);
WM_operatortype_append(POSE_OT_paste);
Modified: branches/soc-2011-pepper/source/blender/editors/armature/poseobject.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/armature/poseobject.c 2011-08-15 13:17:39 UTC (rev 39416)
+++ branches/soc-2011-pepper/source/blender/editors/armature/poseobject.c 2011-08-15 13:24:53 UTC (rev 39417)
@@ -47,6 +47,7 @@
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
+#include "BKE_animsys.h"
#include "BKE_anim.h"
#include "BKE_idprop.h"
#include "BKE_action.h"
@@ -1006,6 +1007,130 @@
}
}
+/* perform paste pose, for a single bone
+ * < ob: object where bone to paste to lives
+ * < chan: bone that pose to paste comes from
+ * < selOnly: only paste on selected bones
+ * < flip: flip on x-axis
+ *
+ * > returns: whether the bone that we pasted to if we succeeded
+ */
+static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short selOnly, short flip)
+{
+ bPoseChannel *pchan;
+ char name[32];
+ short paste_ok;
+
+ /* get the name - if flipping, we must flip this first */
+ if (flip)
+ flip_side_name(name, chan->name, 0); /* 0 = don't strip off number extensions */
+ else
+ BLI_strncpy(name, chan->name, sizeof(name));
+
+ /* only copy when:
+ * 1) channel exists - poses are not meant to add random channels to anymore
+ * 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical
+ */
+ pchan= get_pose_channel(ob->pose, name);
+
+ if (selOnly)
+ paste_ok= ((pchan) && (pchan->bone->flag & BONE_SELECTED));
+ else
+ paste_ok= ((pchan != NULL));
+
+ /* continue? */
+ if (paste_ok) {
+ /* only loc rot size
+ * - only copies transform info for the pose
+ */
+ VECCOPY(pchan->loc, chan->loc);
+ VECCOPY(pchan->size, chan->size);
+ pchan->flag= chan->flag;
+
+ /* check if rotation modes are compatible (i.e. do they need any conversions) */
+ if (pchan->rotmode == chan->rotmode) {
+ /* copy the type of rotation in use */
+ if (pchan->rotmode > 0) {
+ VECCOPY(pchan->eul, chan->eul);
+ }
+ else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
+ VECCOPY(pchan->rotAxis, chan->rotAxis);
+ pchan->rotAngle = chan->rotAngle;
+ }
+ else {
+ QUATCOPY(pchan->quat, chan->quat);
+ }
+ }
+ else if (pchan->rotmode > 0) {
+ /* quat/axis-angle to euler */
+ if (chan->rotmode == ROT_MODE_AXISANGLE)
+ axis_angle_to_eulO( pchan->eul, pchan->rotmode,chan->rotAxis, chan->rotAngle);
+ else
+ quat_to_eulO( pchan->eul, pchan->rotmode,chan->quat);
+ }
+ else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
+ /* quat/euler to axis angle */
+ if (chan->rotmode > 0)
+ eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, chan->eul, chan->rotmode);
+ else
+ quat_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, chan->quat);
+ }
+ else {
+ /* euler/axis-angle to quat */
+ if (chan->rotmode > 0)
+ eulO_to_quat(pchan->quat, chan->eul, chan->rotmode);
+ else
+ axis_angle_to_quat(pchan->quat, chan->rotAxis, pchan->rotAngle);
+ }
+
+ /* paste flipped pose? */
+ if (flip) {
+ pchan->loc[0]*= -1;
+
+ /* has to be done as eulers... */
+ if (pchan->rotmode > 0) {
+ pchan->eul[1] *= -1;
+ pchan->eul[2] *= -1;
+ }
+ else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
+ float eul[3];
+
+ axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, pchan->rotAngle);
+ eul[1]*= -1;
+ eul[2]*= -1;
+ eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, eul, EULER_ORDER_DEFAULT);
+ }
+ else {
+ float eul[3];
+
+ normalize_qt(pchan->quat);
+ quat_to_eul(eul, pchan->quat);
+ eul[1]*= -1;
+ eul[2]*= -1;
+ eul_to_quat(pchan->quat, eul);
+ }
+ }
+
+ /* ID properties */
+ if (chan->prop) {
+ if (pchan->prop) {
+ /* if we have existing properties on a bone, just copy over the values of
+ * matching properties (i.e. ones which will have some impact) on to the
+ * target instead of just blinding replacing all [
+ */
+ IDP_SyncGroupValues(pchan->prop, chan->prop);
+ }
+ else {
+ /* no existing properties, so assume that we want copies too? */
+ pchan->prop= IDP_CopyProperty(chan->prop);
+ }
+ }
+ }
+
+ /* return whether paste went ahead */
+ return pchan;
+}
+
/* ---- */
static int pose_copy_exec (bContext *C, wmOperator *op)
@@ -1048,9 +1173,9 @@
static int pose_paste_exec (bContext *C, wmOperator *op)
{
+ Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
Scene *scene= CTX_data_scene(C);
- Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
- bPoseChannel *chan, *pchan;
+ bPoseChannel *chan;
int flip= RNA_boolean_get(op->ptr, "flipped");
int selOnly= RNA_boolean_get(op->ptr, "selected_mask");
@@ -1074,115 +1199,11 @@
/* Safely merge all of the channels in the buffer pose into any existing pose */
for (chan= g_posebuf->chanbase.first; chan; chan=chan->next) {
if (chan->flag & POSE_KEY) {
- char name[32];
- short paste_ok;
+ /* try to perform paste on this bone */
+ bPoseChannel *pchan = pose_bone_do_paste(ob, chan, selOnly, flip);
- /* get the name - if flipping, we must flip this first */
- if (flip)
- flip_side_name(name, chan->name, 0); /* 0 = don't strip off number extensions */
- else
- BLI_strncpy(name, chan->name, sizeof(name));
-
- /* only copy when:
- * 1) channel exists - poses are not meant to add random channels to anymore
- * 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical
- */
- pchan= get_pose_channel(ob->pose, name);
-
- if (selOnly)
- paste_ok= ((pchan) && (pchan->bone->flag & BONE_SELECTED));
- else
- paste_ok= ((pchan != NULL));
-
- /* continue? */
- if (paste_ok) {
- /* only loc rot size
- * - only copies transform info for the pose
- */
- VECCOPY(pchan->loc, chan->loc);
- VECCOPY(pchan->size, chan->size);
- pchan->flag= chan->flag;
-
- /* check if rotation modes are compatible (i.e. do they need any conversions) */
- if (pchan->rotmode == chan->rotmode) {
- /* copy the type of rotation in use */
- if (pchan->rotmode > 0) {
- VECCOPY(pchan->eul, chan->eul);
- }
- else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
- VECCOPY(pchan->rotAxis, chan->rotAxis);
- pchan->rotAngle = chan->rotAngle;
- }
- else {
- QUATCOPY(pchan->quat, chan->quat);
- }
- }
- else if (pchan->rotmode > 0) {
- /* quat/axis-angle to euler */
- if (chan->rotmode == ROT_MODE_AXISANGLE)
- axis_angle_to_eulO( pchan->eul, pchan->rotmode,chan->rotAxis, chan->rotAngle);
- else
- quat_to_eulO( pchan->eul, pchan->rotmode,chan->quat);
- }
- else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
- /* quat/euler to axis angle */
- if (chan->rotmode > 0)
- eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, chan->eul, chan->rotmode);
- else
- quat_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, chan->quat);
- }
- else {
- /* euler/axis-angle to quat */
- if (chan->rotmode > 0)
- eulO_to_quat(pchan->quat, chan->eul, chan->rotmode);
- else
- axis_angle_to_quat(pchan->quat, chan->rotAxis, pchan->rotAngle);
- }
-
- /* paste flipped pose? */
- if (flip) {
- pchan->loc[0]*= -1;
-
- /* has to be done as eulers... */
- if (pchan->rotmode > 0) {
- pchan->eul[1] *= -1;
- pchan->eul[2] *= -1;
- }
- else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
- float eul[3];
-
- axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, pchan->rotAngle);
- eul[1]*= -1;
- eul[2]*= -1;
- eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, eul, EULER_ORDER_DEFAULT);
- }
- else {
- float eul[3];
-
- normalize_qt(pchan->quat);
- quat_to_eul(eul, pchan->quat);
- eul[1]*= -1;
- eul[2]*= -1;
- eul_to_quat(pchan->quat, eul);
- }
- }
-
- /* ID properties */
- if (chan->prop) {
- if (pchan->prop) {
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list