Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2005-07-27 14:37:20 +0400
committerTon Roosendaal <ton@blender.org>2005-07-27 14:37:20 +0400
commit59672145a98f144a0d2eab059937d6d9bf3194ca (patch)
tree0f3f12c5d8008973310adea1daa34f75e9f7f276 /source/blender
parent8f15f9805aa006ab7b66aa150d3774e37f28e701 (diff)
Cleanup & goodies for rigging geeks! :)
- PoseMode: Wkey menu, "Flip Left/Right Names". On selected bones, it flips the L/R tags in names, and calls the proper code to rename everything that's related (constraint targets, bone-childs, etc). - PoseMode: Shift+S snapmenu: snap cursor to selected now works - Outliner: select bones now correctly sets 'active' flag for bones, updating the UI as well. Also made sure you cannot select hidden bones in outliner. - 3DWindow: in PoseMode/EditMode draws name of active Bone too (with user option "Draw active object name" set. - Added the new Armature/PoseMode options in View3D pulldowns. Cleanup: - moved Pose code from editaction.c to poseobject.c - removed BSE_editaction.h and BSE_editaction_types.h, moved contents of it to BIF_editaction.h. One include per C file should be fine. :) I know the src/ structure would require more elaborated includes, but we don't have that now...
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/include/BIF_editaction.h45
-rw-r--r--source/blender/include/BIF_poseobject.h23
-rw-r--r--source/blender/include/BSE_editaction.h62
-rw-r--r--source/blender/include/BSE_editaction_types.h52
-rw-r--r--source/blender/python/api2_2x/Bone.c24
-rw-r--r--source/blender/src/drawaction.c10
-rw-r--r--source/blender/src/drawarmature.c9
-rw-r--r--source/blender/src/drawipo.c1
-rw-r--r--source/blender/src/drawview.c33
-rw-r--r--source/blender/src/edit.c30
-rw-r--r--source/blender/src/editaction.c246
-rw-r--r--source/blender/src/editarmature.c48
-rw-r--r--source/blender/src/editconstraint.c3
-rw-r--r--source/blender/src/editipo.c2
-rw-r--r--source/blender/src/editobject.c8
-rw-r--r--source/blender/src/editview.c2
-rw-r--r--source/blender/src/header_action.c4
-rw-r--r--source/blender/src/header_view3d.c46
-rw-r--r--source/blender/src/headerbuttons.c3
-rw-r--r--source/blender/src/outliner.c43
-rw-r--r--source/blender/src/poseobject.c340
-rwxr-xr-xsource/blender/src/transform_conversions.c30
-rw-r--r--source/blender/src/usiblender.c2
23 files changed, 581 insertions, 485 deletions
diff --git a/source/blender/include/BIF_editaction.h b/source/blender/include/BIF_editaction.h
index 6463e075995..c2443d24ea9 100644
--- a/source/blender/include/BIF_editaction.h
+++ b/source/blender/include/BIF_editaction.h
@@ -38,13 +38,39 @@
#define SET_IPO_LINEAR 2
#define SET_IPO_BEZIER 3
+#define CHANNELHEIGHT 16
+#define CHANNELSKIP 2
+#define NAMEWIDTH 128
+#define SLIDERWIDTH 125
+
+#define CHANNEL_FILTER_LOC 0x00000001 /* Show location keys */
+#define CHANNEL_FILTER_ROT 0x00000002 /* Show rotation keys */
+#define CHANNEL_FILTER_SIZE 0x00000004 /* Show size keys */
+#define CHANNEL_FILTER_CON 0x00000008 /* Show constraint keys */
+#define CHANNEL_FILTER_RGB 0x00000010 /* Show object color keys */
+
+#define CHANNEL_FILTER_CU 0x00010000 /* Show curve keys */
+#define CHANNEL_FILTER_ME 0x00020000 /* Show mesh keys */
+#define CHANNEL_FILTER_LA 0x00040000 /* Show lamp keys */
+
+
+struct bAction;
+struct bActionChannel;
+struct bPoseChannel;
+struct Object;
+struct Ipo;
+struct BWinEvent;
+struct Key;
+
/* Key operations */
void delete_meshchannel_keys(struct Key *key);
void delete_actionchannel_keys(void);
void duplicate_meshchannel_keys(struct Key *key);
void duplicate_actionchannel_keys(void);
void transform_actionchannel_keys(char mode);
-void transform_meshchannel_keys(char mode, Key *key);
+void transform_meshchannel_keys(char mode, struct Key *key);
+struct Key *get_action_mesh_key(void);
+int get_nearest_key_num(struct Key *key, short *mval, float *x);
/* Handles */
void sethandles_meshchannel_keys(int code, struct Key *key);
@@ -52,14 +78,25 @@ void sethandles_actionchannel_keys(int code);
/* Ipo type */
void set_ipotype_actionchannels(int ipotype);
+void set_exprap_action(int mode);
/* Select */
void borderselect_mesh(struct Key *key);
void borderselect_action(void);
-void deselect_actionchannel_keys(bAction *act, int test);
-void deselect_meshchannel_keys (Key *key, int test);
+void deselect_actionchannel_keys(struct bAction *act, int test);
+void deselect_actionchannels (struct bAction *act, int test);
+void deselect_meshchannel_keys (struct Key *key, int test);
+int select_channel(struct bAction *act, struct bActionChannel *chan, int selectmode);
+void select_actionchannel_by_name (struct bAction *act, char *name, int select);
+
+/* Action */
+struct bActionChannel* get_hilighted_action_channel(struct bAction* action);
+void set_action_key (struct bAction *act, struct bPoseChannel *chan, int adrcode, short makecurve);
+struct bAction *add_empty_action(void);
+void winqreadactionspace(struct ScrArea *sa, void *spacedata, struct BWinEvent *evt);
+struct bAction *bake_action_with_client (struct bAction *act, struct Object *arm, float tolerance);
-int select_channel(bAction *act, bActionChannel *chan, int selectmode);
+void remake_action_ipos(struct bAction *act);
#endif
diff --git a/source/blender/include/BIF_poseobject.h b/source/blender/include/BIF_poseobject.h
index 0091d4dfe1e..3b707ad8dcc 100644
--- a/source/blender/include/BIF_poseobject.h
+++ b/source/blender/include/BIF_poseobject.h
@@ -33,28 +33,29 @@
#ifndef BIF_POSEOBJECT
#define BIF_POSEOBJECT
-/**
- * Activates posemode
- */
-void enter_posemode(void);
-/**
-* If bones are selected, it sets the flags
-*/
struct Object;
-void set_pose_keys(struct Object *ob);
-/**
- * Deactivates posemode
- */
+void enter_posemode(void);
void exit_posemode(void);
+ // sets chan->flag to POSE_KEY if bone selected
+void set_pose_keys(struct Object *ob);
+
+
/* tools */
+void pose_select_constraint_target(void);
void pose_special_editmenu(void);
void pose_add_IK(void);
void pose_clear_IK(void);
void pose_clear_constraints(void);
void pose_copy_menu(void);
+void free_posebuf(void);
+void copy_posebuf (void);
+void paste_posebuf (int flip);
+
+void pose_flip_names(void);
+
#endif
diff --git a/source/blender/include/BSE_editaction.h b/source/blender/include/BSE_editaction.h
deleted file mode 100644
index d3ef1e71dc2..00000000000
--- a/source/blender/include/BSE_editaction.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef BSE_EDITACTION_H
-#define BSE_EDITACTION_H
-
-struct bAction;
-struct bActionChannel;
-struct bPoseChannel;
-struct Object;
-struct Ipo;
-struct BWinEvent;
-struct Key;
-
-struct bActionChannel* get_hilighted_action_channel(struct bAction* action);
-void set_exprap_action(int mode);
-void free_posebuf(void);
-void copy_posebuf (void);
-void paste_posebuf (int flip);
-void set_action_key (struct bAction *act, struct bPoseChannel *chan, int adrcode, short makecurve);
-struct bAction *add_empty_action(void);
-void deselect_actionchannel_keys (struct bAction *act, int test);
-void deselect_actionchannels (struct bAction *act, int test);
-void deselect_meshchannel_keys (struct Key *key, int test);
-void winqreadactionspace(struct ScrArea *sa, void *spacedata, struct BWinEvent *evt);
-void remake_action_ipos(struct bAction *act);
-void select_actionchannel_by_name (struct bAction *act, char *name, int select);
-struct bAction *bake_action_with_client (struct bAction *act, struct Object *arm, float tolerance);
-struct Key *get_action_mesh_key(void);
-int get_nearest_key_num(struct Key *key, short *mval, float *x);
-
-#endif /* BSE_EDITACTION_H */
-
diff --git a/source/blender/include/BSE_editaction_types.h b/source/blender/include/BSE_editaction_types.h
deleted file mode 100644
index 4df6c6712fb..00000000000
--- a/source/blender/include/BSE_editaction_types.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License. See http://www.blender.org/BL/ for information
- * about this.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): none yet.
- *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
- */
-
-#ifndef BSE_EDITACTION_TYPES_H
-#define BSE_EDITACTION_TYPES_H
-
-#define CHANNELHEIGHT 16
-#define CHANNELSKIP 2
-#define NAMEWIDTH 128
-#define SLIDERWIDTH 125
-
-#define CHANNEL_FILTER_LOC 0x00000001 /* Show location keys */
-#define CHANNEL_FILTER_ROT 0x00000002 /* Show rotation keys */
-#define CHANNEL_FILTER_SIZE 0x00000004 /* Show size keys */
-#define CHANNEL_FILTER_CON 0x00000008 /* Show constraint keys */
-#define CHANNEL_FILTER_RGB 0x00000010 /* Show object color keys */
-
-#define CHANNEL_FILTER_CU 0x00010000 /* Show curve keys */
-#define CHANNEL_FILTER_ME 0x00020000 /* Show mesh keys */
-#define CHANNEL_FILTER_LA 0x00040000 /* Show lamp keys */
-
-#endif /* BSE_EDITACTION_TYPES_H */
-
diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c
index 6a80182faac..0d494e91ddf 100644
--- a/source/blender/python/api2_2x/Bone.c
+++ b/source/blender/python/api2_2x/Bone.c
@@ -33,20 +33,26 @@ struct ScrArea; /*keep me up here */
#include "Bone.h" /*This must come first */
-#include "BKE_main.h"
-#include "BKE_global.h"
+#include "MEM_guardedalloc.h"
+
+#include "DNA_object_types.h"
+#include "DNA_ipo_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+
#include "BKE_armature.h"
#include "BKE_action.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
#include "BKE_utildefines.h"
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "BSE_editaction.h"
-#include "DNA_object_types.h"
-#include "DNA_ipo_types.h"
-#include "MEM_guardedalloc.h"
-#include "gen_utils.h"
+
+#include "BIF_editaction.h"
+
#include "NLA.h"
+#include "gen_utils.h"
+
//--------------------Python API function prototypes for the Bone module----
static PyObject *M_Bone_New( PyObject * self, PyObject * args );
diff --git a/source/blender/src/drawaction.c b/source/blender/src/drawaction.c
index 819db45ffa4..3f98f689099 100644
--- a/source/blender/src/drawaction.c
+++ b/source/blender/src/drawaction.c
@@ -59,31 +59,31 @@
#include "DNA_key_types.h"
#include "BKE_action.h"
+#include "BKE_ipo.h"
#include "BKE_global.h"
/* Everything from source (BIF, BDR, BSE) ------------------------------ */
+#include "BIF_editaction.h"
+#include "BIF_interface.h"
#include "BIF_gl.h"
#include "BIF_glutil.h"
#include "BIF_resources.h"
#include "BIF_screen.h"
-#include "BIF_interface.h"
#include "BIF_mywindow.h"
#include "BIF_space.h"
+#include "BDR_drawaction.h"
#include "BDR_editcurve.h"
+
#include "BSE_view.h"
#include "BSE_drawipo.h"
-#include "BSE_editaction.h"
-#include "BSE_editaction_types.h"
-#include "BDR_drawaction.h"
/* 'old' stuff": defines and types, and own include -------------------- */
#include "blendef.h"
#include "mydevice.h"
-#include "BKE_ipo.h"
/* local functions ----------------------------------------------------- */
void drawactionspace(ScrArea *sa, void *spacedata);
diff --git a/source/blender/src/drawarmature.c b/source/blender/src/drawarmature.c
index 54d6bcb7d70..407dabc8aaf 100644
--- a/source/blender/src/drawarmature.c
+++ b/source/blender/src/drawarmature.c
@@ -76,7 +76,6 @@
#include "BSE_edit.h"
#include "BSE_view.h"
-#include "BSE_editaction.h"
#include "mydevice.h"
#include "blendef.h"
@@ -376,6 +375,10 @@ static void draw_bone_points(int dt, int armflag, unsigned int boneflag, int id)
static char bm_dot6[]= {0x0, 0x18, 0x3C, 0x7E, 0x7E, 0x3C, 0x18, 0x0};
static char bm_dot8[]= {0x3C, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C};
+static char bm_dot5[]= {0x0, 0x0, 0x10, 0x38, 0x7c, 0x38, 0x10, 0x0};
+static char bm_dot7[]= {0x0, 0x38, 0x7C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38};
+
+
static void draw_line_bone(int armflag, int boneflag, int constflag, unsigned int id, bPoseChannel *pchan, EditBone *ebone)
{
float length;
@@ -434,7 +437,7 @@ static void draw_line_bone(int armflag, int boneflag, int constflag, unsigned in
}
else {
glRasterPos3f(0.0f, 1.0f, 0.0f);
- glBitmap(8, 8, 4, 4, 0, 0, bm_dot8);
+ glBitmap(8, 8, 4, 4, 0, 0, bm_dot7);
}
/* further we send no names */
@@ -482,7 +485,7 @@ static void draw_line_bone(int armflag, int boneflag, int constflag, unsigned in
else BIF_ThemeColor(TH_VERTEX);
}
glRasterPos3f(0.0f, 1.0f, 0.0f);
- glBitmap(8, 8, 4, 4, 0, 0, bm_dot6);
+ glBitmap(8, 8, 4, 4, 0, 0, bm_dot5);
}
glLineWidth(1.0);
diff --git a/source/blender/src/drawipo.c b/source/blender/src/drawipo.c
index 68dfd5732cc..58c4013db47 100644
--- a/source/blender/src/drawipo.c
+++ b/source/blender/src/drawipo.c
@@ -77,7 +77,6 @@
#include "BSE_view.h"
#include "BSE_editipo.h"
#include "BSE_editipo_types.h"
-#include "BSE_editaction_types.h"
#include "BSE_editnla_types.h"
#include "mydevice.h"
diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c
index c1f1bc89303..57a9698860c 100644
--- a/source/blender/src/drawview.c
+++ b/source/blender/src/drawview.c
@@ -990,11 +990,37 @@ void drawname(Object *ob)
}
-static void draw_selected_name(char *name)
+static void draw_selected_name(Object *ob)
{
char info[128];
- sprintf(info, "(%d) %s", CFRA, name);
+ if(ob->type==OB_ARMATURE) {
+ char *name= NULL;
+
+ if(ob==G.obedit) {
+ EditBone *ebo;
+ for (ebo=G.edbo.first; ebo; ebo=ebo->next){
+ if (ebo->flag & BONE_ACTIVE) {
+ name= ebo->name;
+ break;
+ }
+ }
+ }
+ else if(ob->pose && (ob->flag & OB_POSEMODE)) {
+ bPoseChannel *pchan;
+ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if(pchan->bone->flag & BONE_ACTIVE) {
+ name= pchan->name;
+ break;
+ }
+ }
+ }
+ if(name)
+ sprintf(info, "(%d) %s %s", CFRA, ob->id.name+2, name);
+ else
+ sprintf(info, "(%d) %s", CFRA, ob->id.name+2);
+ }
+ else sprintf(info, "(%d) %s", CFRA, ob->id.name+2);
BIF_ThemeColor(TH_TEXT_HI);
glRasterPos2i(30, 10);
@@ -2069,7 +2095,8 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
draw_view_icon();
ob= OBACT;
- if(ob!=0 && (U.uiflag & USER_DRAWVIEWINFO)) draw_selected_name(ob->id.name+2);
+ if(ob && (U.uiflag & USER_DRAWVIEWINFO))
+ draw_selected_name(ob);
draw_area_emboss(sa);
diff --git a/source/blender/src/edit.c b/source/blender/src/edit.c
index b9b01756de4..4812c2c0753 100644
--- a/source/blender/src/edit.c
+++ b/source/blender/src/edit.c
@@ -1229,15 +1229,29 @@ void snap_curs_to_sel()
transvmain= 0;
}
else {
- base= (G.scene->base.first);
- while(base) {
- if(((base)->flag & SELECT) && ((base)->lay & G.vd->lay) ) {
- VECCOPY(vec, base->object->obmat[3]);
- VecAddf(centroid, centroid, vec);
- DO_MINMAX(vec, min, max);
- count++;
+ Object *ob= OBACT;
+
+ if(ob && (ob->flag & OB_POSEMODE)) {
+ bPoseChannel *pchan;
+ for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) {
+ if(pchan->bone->flag & BONE_SELECTED) {
+ VECCOPY(vec, pchan->pose_head);
+ Mat4MulVecfl(ob->obmat, vec);
+ VecAddf(centroid, centroid, vec);
+ DO_MINMAX(vec, min, max);
+ count++;
+ }
+ }
+ }
+ else {
+ for(base= G.scene->base.first; base; base= base->next) {
+ if(((base)->flag & SELECT) && ((base)->lay & G.vd->lay) ) {
+ VECCOPY(vec, base->object->obmat[3]);
+ VecAddf(centroid, centroid, vec);
+ DO_MINMAX(vec, min, max);
+ count++;
+ }
}
- base= base->next;
}
if(count) {
if(G.vd->around==V3D_CENTROID) {
diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c
index 72971bf306f..6b91958da1a 100644
--- a/source/blender/src/editaction.c
+++ b/source/blender/src/editaction.c
@@ -69,25 +69,23 @@
#include "BKE_main.h"
#include "BKE_utildefines.h"
+#include "BIF_butspace.h"
+#include "BIF_editaction.h"
+#include "BIF_editview.h"
+#include "BIF_editarmature.h"
#include "BIF_gl.h"
+#include "BIF_interface.h"
#include "BIF_mywindow.h"
-#include "BIF_toolbox.h"
+#include "BIF_poseobject.h"
#include "BIF_screen.h"
#include "BIF_space.h"
-#include "BIF_butspace.h"
-#include "BIF_interface.h"
-#include "BIF_editview.h"
-#include "BIF_poseobject.h"
-#include "BIF_editarmature.h"
-#include "BIF_editaction.h"
+#include "BIF_toolbox.h"
#include "BSE_edit.h"
#include "BSE_drawipo.h"
#include "BSE_headerbuttons.h"
#include "BSE_editipo.h"
-#include "BSE_editaction.h"
#include "BSE_trans_types.h"
-#include "BSE_editaction_types.h"
#include "BDR_editobject.h"
@@ -95,7 +93,6 @@
#include "blendef.h"
#include "nla.h"
-static bPose *g_posebuf=NULL;
extern int count_action_levels (bAction *act);
#define BEZSELECTED(bezt) (((bezt)->f1 & 1) || ((bezt)->f2 & 1) || ((bezt)->f3 & 1))
@@ -770,235 +767,6 @@ void set_exprap_action(int mode)
error ("Not yet implemented!");
}
-void free_posebuf(void)
-{
- if (g_posebuf) {
- // was copied without constraints
- BLI_freelistN (&g_posebuf->chanbase);
- MEM_freeN (g_posebuf);
- }
- g_posebuf=NULL;
-}
-
-void copy_posebuf (void)
-{
- Object *ob= OBACT;
-
- if (!ob || !ob->pose){
- error ("No Pose");
- return;
- }
-
- free_posebuf();
-
- set_pose_keys(ob); // sets chan->flag to POSE_KEY if bone selected
- copy_pose(&g_posebuf, ob->pose, 0);
-
-}
-
-static void flip_name (char *name)
-{
-
- char prefix[128]={""}; /* The part before the facing */
- char suffix[128]={""}; /* The part after the facing */
- char replace[128]={""}; /* The replacement string */
-
- char *index=NULL;
- /* Find the last period */
-
- strcpy (prefix, name);
-
- /* Check for an instance of .Right */
- if (!index){
- index = strstr (prefix, "Right");
- if (index){
- *index=0;
- strcpy (replace, "Left");
- strcpy (suffix, index+6);
- }
- }
-
- /* Che ck for an instance of .RIGHT */
- if (!index){
- index = strstr (prefix, "RIGHT");
- if (index){
- *index=0;
- strcpy (replace, "LEFT");
- strcpy (suffix, index+6);
- }
- }
-
-
- /* Check for an instance of .right */
- if (!index){
- index = strstr (prefix, "right");
- if (index){
- *index=0;
- strcpy (replace, "left");
- strcpy (suffix, index+6);
- }
- }
-
- /* Check for an instance of .left */
- if (!index){
- index = strstr (prefix, "left");
- if (index){
- *index=0;
- strcpy (replace, "right");
- strcpy (suffix, index+5);
- }
- }
-
- /* Check for an instance of .LEFT */
- if (!index){
- index = strstr (prefix, "LEFT");
- if (index){
- *index=0;
- strcpy (replace, "RIGHT");
- strcpy (suffix, index+5);
- }
- }
-
- /* Check for an instance of .Left */
- if (!index){
- index = strstr (prefix, "Left");
- if (index){
- *index=0;
- strcpy (replace, "Right");
- strcpy (suffix, index+5);
- }
- }
-
- /* check for an instance of .L */
- if (!index){
- index = strstr (prefix, ".L");
- if (index){
- *index=0;
- strcpy (replace, ".R");
- strcpy (suffix, index+2);
- }
- }
-
- /* check for an instance of .l */
- if (!index){
- index = strstr (prefix, ".l");
- if (index){
- *index=0;
- strcpy (replace, ".r");
- strcpy (suffix, index+2);
- }
- }
-
- /* Checl for an instance of .R */
- if (!index){
- index = strstr (prefix, ".R");
- if (index){
- *index=0;
- strcpy (replace, ".L");
- strcpy (suffix, index+2);
- }
- }
-
- /* Checl for an instance of .r */
- if (!index){
- index = strstr (prefix, ".r");
- if (index){
- *index=0;
- strcpy (replace, ".l");
- strcpy (suffix, index+2);
- }
- }
-
- sprintf (name, "%s%s%s", prefix, replace, suffix);
-}
-
-void paste_posebuf (int flip)
-{
- Object *ob= OBACT;
- bPoseChannel *chan, *pchan;
- float eul[4];
- int newchan = 0;
- char name[32];
-
- if (!ob || !ob->pose)
- return;
-
- if (!g_posebuf){
- error ("Copy buffer is empty");
- return;
- }
-
- /* Safely merge all of the channels in this pose into
- any existing pose */
- for (chan=g_posebuf->chanbase.first; chan; chan=chan->next){
- if (chan->flag & POSE_KEY) {
- BLI_strncpy(name, chan->name, sizeof(name));
- if (flip)
- flip_name (name);
-
- /* only copy when channel exists, poses are not meant to add random channels to anymore */
- pchan= get_pose_channel(ob->pose, name);
-
- if(pchan) {
- /* only loc rot size */
- /* only copies transform info for the pose */
- VECCOPY(pchan->loc, chan->loc);
- VECCOPY(pchan->size, chan->size);
- QUATCOPY(pchan->quat, chan->quat);
- pchan->flag= chan->flag;
-
- if (flip){
- pchan->loc[0]*= -1;
-
- QuatToEul(pchan->quat, eul);
- eul[1]*= -1;
- eul[2]*= -1;
- EulToQuat(eul, pchan->quat);
- }
-
- if (G.flags & G_RECORDKEYS){
- /* Set keys on pose */
- if (chan->flag & POSE_ROT){
- set_action_key(ob->action, pchan, AC_QUAT_X, newchan);
- set_action_key(ob->action, pchan, AC_QUAT_Y, newchan);
- set_action_key(ob->action, pchan, AC_QUAT_Z, newchan);
- set_action_key(ob->action, pchan, AC_QUAT_W, newchan);
- }
- if (chan->flag & POSE_SIZE){
- set_action_key(ob->action, pchan, AC_SIZE_X, newchan);
- set_action_key(ob->action, pchan, AC_SIZE_Y, newchan);
- set_action_key(ob->action, pchan, AC_SIZE_Z, newchan);
- }
- if (chan->flag & POSE_LOC){
- set_action_key(ob->action, pchan, AC_LOC_X, newchan);
- set_action_key(ob->action, pchan, AC_LOC_Y, newchan);
- set_action_key(ob->action, pchan, AC_LOC_Z, newchan);
- }
- }
- }
- }
- }
-
- /* Update event for pose and deformation children */
- ob->pose->ctime= -123456.0f;
- DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
-
- if (G.flags & G_RECORDKEYS) {
- remake_action_ipos(ob->action);
- allqueue (REDRAWIPO, 0);
- allqueue (REDRAWVIEW3D, 0);
- allqueue (REDRAWACTION, 0);
- allqueue(REDRAWNLA, 0);
- }
- else {
- /* need to trick depgraph, action is not allowed to execute on pose */
- where_is_pose(ob);
- ob->recalc= 0;
- }
-
- BIF_undo_push("Paste Action Pose");
-}
-
void set_action_key (struct bAction *act, struct bPoseChannel *chan, int adrcode, short makecurve)
{
set_action_key_time (act, chan, adrcode, makecurve, frame_to_float(CFRA));
diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c
index 6d172df0020..06827b2bdf1 100644
--- a/source/blender/src/editarmature.c
+++ b/source/blender/src/editarmature.c
@@ -70,6 +70,7 @@
#include "BKE_subsurf.h"
#include "BKE_utildefines.h"
+#include "BIF_editaction.h"
#include "BIF_editmode_undo.h"
#include "BIF_editdeform.h"
#include "BIF_editarmature.h"
@@ -91,7 +92,6 @@
#include "BSE_edit.h"
#include "BSE_view.h"
#include "BSE_trans_types.h"
-#include "BSE_editaction.h"
#include "PIL_time.h"
@@ -1012,13 +1012,16 @@ void load_editArmature(void)
editbones_to_armature(&G.edbo, G.obedit);
}
-
+/* toggle==0: deselect
+ toggle==1: swap
+ toggle==2: only active tag
+*/
void deselectall_armature(int toggle)
{
EditBone *eBone;
int sel=1;
- if(toggle) {
+ if(toggle==1) {
/* Determine if there are any selected bones
And therefore whether we are selecting or deselecting */
for (eBone=G.edbo.first;eBone;eBone=eBone->next){
@@ -1028,12 +1031,14 @@ void deselectall_armature(int toggle)
}
}
}
- else sel= 0;
+ else sel= toggle;
/* Set the flags */
for (eBone=G.edbo.first;eBone;eBone=eBone->next){
- if (sel)
+ if (sel==1)
eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ else if (sel==2)
+ eBone->flag &= ~(BONE_ACTIVE);
else
eBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL | BONE_ACTIVE);
}
@@ -1695,7 +1700,10 @@ void do_pose_selectbuffer(Base *base, unsigned int *buffer, short hits)
}
-
+/* mode==0: deselect
+ mode==1: select
+ mode==2: clear active tag
+*/
static void deselect_bonechildren (Object *ob, Bone *bone, int mode)
{
Bone *curBone;
@@ -1705,31 +1713,40 @@ static void deselect_bonechildren (Object *ob, Bone *bone, int mode)
if (mode==0)
bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL|BONE_ACTIVE);
- else if (!(bone->flag & BONE_HIDDEN))
- bone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
-
- select_actionchannel_by_name(ob->action, bone->name, mode);
+ else if (mode==1) {
+ if(!(bone->flag & BONE_HIDDEN))
+ bone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+ }
+ else bone->flag &= ~BONE_ACTIVE;
+
+ if(mode!=2) select_actionchannel_by_name(ob->action, bone->name, mode);
for (curBone=bone->childbase.first; curBone; curBone=curBone->next){
deselect_bonechildren(ob, curBone, mode);
}
}
+/* test==0: deselect all
+ test==1: swap select
+ test==2: only clear active tag
+*/
void deselectall_posearmature (Object *ob, int test)
{
bArmature *arm;
Bone *curBone;
- int selectmode = 0;
+ int selectmode= 0;
/* we call this from outliner too, but with OBACT set OK */
if(!ob || !ob->pose) return;
arm= get_armature(ob);
/* Determine if we're selecting or deselecting */
- if (test){
+ if (test==1) {
if (!count_bones (arm, BONE_SELECTED, 0))
- selectmode = 1;
+ selectmode= 1;
}
+ else if(test==2)
+ selectmode= 2;
/* Set the flags accordingly */
for (curBone=arm->bonebase.first; curBone; curBone=curBone->next)
@@ -2232,13 +2249,16 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldnam
/* called by UI for renaming a bone */
/* warning: make sure the original bone was not renamed yet! */
/* seems messy, but thats what you get with not using pointers but channel names :) */
-void armature_bone_rename(bArmature *arm, char *oldname, char *newnamep)
+void armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep)
{
Object *ob;
char newname[MAXBONENAME];
+ char oldname[MAXBONENAME];
/* we alter newname string... so make copy */
BLI_strncpy(newname, newnamep, MAXBONENAME);
+ /* we use oldname for search... so make copy */
+ BLI_strncpy(oldname, oldnamep, MAXBONENAME);
/* now check if we're in editmode, we need to find the unique name */
if(G.obedit && G.obedit->data==arm) {
diff --git a/source/blender/src/editconstraint.c b/source/blender/src/editconstraint.c
index 58786e30282..f929704156a 100644
--- a/source/blender/src/editconstraint.c
+++ b/source/blender/src/editconstraint.c
@@ -53,14 +53,13 @@
#include "BKE_constraint.h"
#include "BKE_ipo.h"
+#include "BIF_editaction.h"
#include "BIF_editarmature.h"
#include "BIF_editconstraint.h"
#include "BIF_interface.h"
#include "BIF_screen.h"
#include "BIF_toolbox.h"
-#include "BSE_editaction.h"
-
#include "blendef.h"
#include "nla.h"
diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c
index 06dae9de624..24f18bb7f71 100644
--- a/source/blender/src/editipo.c
+++ b/source/blender/src/editipo.c
@@ -91,6 +91,7 @@
#include "BKE_utildefines.h"
#include "BIF_butspace.h"
+#include "BIF_editaction.h"
#include "BIF_editkey.h"
#include "BIF_editseq.h"
#include "BIF_editview.h"
@@ -109,7 +110,6 @@
#include "BSE_editipo_types.h"
#include "BSE_drawipo.h"
#include "BSE_editipo.h"
-#include "BSE_editaction.h"
#include "BSE_edit.h"
#include "BSE_drawview.h"
#include "BSE_headerbuttons.h"
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c
index 704d6c301e2..17976a61a4a 100644
--- a/source/blender/src/editobject.c
+++ b/source/blender/src/editobject.c
@@ -138,7 +138,6 @@
#include "BIF_resources.h"
#include "BSE_edit.h"
-#include "BSE_editaction.h"
#include "BSE_editipo.h"
#include "BSE_filesel.h" /* For activate_databrowse() */
#include "BSE_view.h"
@@ -592,9 +591,14 @@ void add_hook(void)
else {
if(mode==1) {
- Base *base= BASACT;
+ Base *base= BASACT, *newbase;
ob= add_object(OB_EMPTY);
+ /* set layers OK */
+ newbase= BASACT;
+ newbase->lay= base->lay;
+ ob->lay= newbase->lay;
+
/* transform cent to global coords for loc */
VecMat4MulVecfl(ob->loc, G.obedit->obmat, cent);
diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c
index 00a18c27126..770d7287235 100644
--- a/source/blender/src/editview.c
+++ b/source/blender/src/editview.c
@@ -67,6 +67,7 @@
#include "BKE_utildefines.h"
#include "BIF_butspace.h"
+#include "BIF_editaction.h"
#include "BIF_editarmature.h"
#include "BIF_editgroup.h"
#include "BIF_editmesh.h"
@@ -91,7 +92,6 @@
#include "BSE_view.h" /* give_cursor() */
#include "BSE_editipo.h"
#include "BSE_drawview.h"
-#include "BSE_editaction.h"
#include "editmesh.h" // borderselect uses it...
#include "blendef.h"
diff --git a/source/blender/src/header_action.c b/source/blender/src/header_action.c
index 13a004d14d1..3a6cafe28e2 100644
--- a/source/blender/src/header_action.c
+++ b/source/blender/src/header_action.c
@@ -53,11 +53,12 @@
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
+#include "BIF_editaction.h"
#include "BIF_interface.h"
+#include "BIF_poseobject.h"
#include "BIF_resources.h"
#include "BIF_screen.h"
#include "BIF_space.h"
-#include "BIF_editaction.h"
#include "BKE_action.h"
#include "BKE_armature.h"
@@ -68,7 +69,6 @@
#include "BKE_utildefines.h"
#include "BSE_drawipo.h"
-#include "BSE_editaction.h"
#include "BSE_headerbuttons.h"
#include "nla.h"
diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c
index 7241bfe7273..0fd155fa855 100644
--- a/source/blender/src/header_view3d.c
+++ b/source/blender/src/header_view3d.c
@@ -72,7 +72,6 @@
#include "BLI_blenlib.h"
#include "BSE_edit.h"
-#include "BSE_editaction.h"
#include "BSE_editipo.h"
#include "BSE_headerbuttons.h"
#include "BSE_view.h"
@@ -1077,6 +1076,9 @@ static void do_view3d_select_pose_armaturemenu(void *arg, int event)
case 2: /* Select/Deselect all */
deselectall_posearmature(OBACT, 1);
break;
+ case 3:
+ pose_select_constraint_target();
+ break;
}
allqueue(REDRAWVIEW3D, 0);
}
@@ -1094,6 +1096,7 @@ static uiBlock *view3d_select_pose_armaturemenu(void *arg_unused)
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Constraint Target|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
if(curarea->headertype==HEADERTOP) {
uiBlockSetDirection(block, UI_DOWN);
@@ -3057,6 +3060,11 @@ static void do_view3d_edit_armaturemenu(void *arg, int event)
case 7: /* Warp */
initTransform(TFM_WARP, CTX_NONE);
Transform();
+ case 8:
+ make_bone_parent();
+ break;
+ case 9:
+ clear_bone_parent();
break;
}
allqueue(REDRAWVIEW3D, 0);
@@ -3082,8 +3090,10 @@ static uiBlock *view3d_edit_armaturemenu(void *arg_unused)
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extrude|E", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Duplicate|Shift D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Duplicate|Shift D", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Delete|X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make Parent...|Ctrl P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Clear Parent...|Alt P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
if(curarea->headertype==HEADERTOP) {
uiBlockSetDirection(block, UI_DOWN);
@@ -3154,6 +3164,21 @@ static void do_view3d_pose_armaturemenu(void *arg, int event)
case 4: /* insert keyframe */
common_insertkey();
break;
+ case 5:
+ pose_copy_menu();
+ break;
+ case 6:
+ pose_add_IK();
+ break;
+ case 7:
+ pose_clear_IK();
+ break;
+ case 8:
+ pose_clear_constraints();
+ break;
+ case 9:
+ pose_flip_names();
+ break;
}
allqueue(REDRAWVIEW3D, 0);
}
@@ -3219,9 +3244,18 @@ static uiBlock *view3d_pose_armaturemenu(void *arg_unused)
menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBlockBut(block, view3d_pose_armature_showhidemenu,
- NULL, ICON_RIGHTARROW_THIN,
- "Show/Hide Bones", 0, yco-=20, 120, 19, "");
+ NULL, ICON_RIGHTARROW_THIN, "Show/Hide Bones", 0, yco-=20, 120, 19, "");
+ uiDefBut(block, SEPR, 0, "", 0, yco-=6,
+ menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
+
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Copy Attributes...|Ctrl C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Flip L/R Names|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Add IK to Bone...|Ctrl I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Clear IK...|Alt I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Clear Constraints...|Alt C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, "");
+
+
if(curarea->headertype==HEADERTOP) {
uiBlockSetDirection(block, UI_DOWN);
}
@@ -3968,8 +4002,8 @@ static void view3d_header_pulldowns(uiBlock *block, short *xcoord)
Object *ob= OBACT;
if (ob && (ob->flag & OB_POSEMODE)) {
- xmax= GetButStringLength("Armature");
- uiDefPulldownBut(block, view3d_pose_armaturemenu, NULL, "Armature", xco,-2, xmax-3, 24, "");
+ xmax= GetButStringLength("Pose");
+ uiDefPulldownBut(block, view3d_pose_armaturemenu, NULL, "Pose", xco,-2, xmax-3, 24, "");
xco+= xmax;
}
else {
diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c
index 6c81ff2f4d6..3ae318c359e 100644
--- a/source/blender/src/headerbuttons.c
+++ b/source/blender/src/headerbuttons.c
@@ -119,6 +119,7 @@
#include "BIF_drawoops.h"
#include "BIF_drawscene.h"
#include "BIF_drawtext.h"
+#include "BIF_editaction.h"
#include "BIF_editarmature.h"
#include "BIF_editfont.h"
#include "BIF_editlattice.h"
@@ -151,8 +152,6 @@
#include "BSE_headerbuttons.h"
#include "BSE_view.h"
#include "BSE_sequence.h"
-#include "BSE_editaction.h"
-#include "BSE_editaction_types.h"
#include "BSE_editipo.h"
#include "BSE_drawipo.h"
diff --git a/source/blender/src/outliner.c b/source/blender/src/outliner.c
index fcfe0a3173a..9957ef2bfdb 100644
--- a/source/blender/src/outliner.c
+++ b/source/blender/src/outliner.c
@@ -98,7 +98,6 @@
#include "BDR_editobject.h"
#include "BSE_drawipo.h"
#include "BSE_edit.h"
-#include "BSE_editaction.h"
#include "blendef.h"
#include "mydevice.h"
@@ -1230,13 +1229,16 @@ static int tree_element_active_posechannel(TreeElement *te, TreeStoreElem *tsele
bPoseChannel *pchan= te->directdata;
if(set) {
- if(G.qual & LR_SHIFTKEY);
- else deselectall_posearmature(ob, 0);
- pchan->bone->flag |= BONE_SELECTED|BONE_ACTIVE;
-
- allqueue(REDRAWVIEW3D, 0);
- allqueue(REDRAWOOPS, 0);
- allqueue(REDRAWACTION, 0);
+ if(!(pchan->bone->flag & BONE_HIDDEN)) {
+
+ if(G.qual & LR_SHIFTKEY) deselectall_posearmature(ob, 2); // 2 = clear active tag
+ else deselectall_posearmature(ob, 0); // 0 = deselect
+ pchan->bone->flag |= BONE_SELECTED|BONE_ACTIVE;
+
+ allqueue(REDRAWVIEW3D, 0);
+ allqueue(REDRAWOOPS, 0);
+ allqueue(REDRAWACTION, 0);
+ }
}
else {
if(ob==OBACT && ob->pose) {
@@ -1252,13 +1254,15 @@ static int tree_element_active_bone(TreeElement *te, TreeStoreElem *tselem, int
Bone *bone= te->directdata;
if(set) {
- if(G.qual & LR_SHIFTKEY);
- else deselectall_posearmature(OBACT, 0);
- bone->flag |= BONE_SELECTED;
-
- allqueue(REDRAWVIEW3D, 0);
- allqueue(REDRAWOOPS, 0);
- allqueue(REDRAWACTION, 0);
+ if(!(bone->flag & BONE_HIDDEN)) {
+ if(G.qual & LR_SHIFTKEY) deselectall_posearmature(OBACT, 2); // 2 is clear active tag
+ else deselectall_posearmature(OBACT, 0);
+ bone->flag |= BONE_SELECTED|BONE_ACTIVE;
+
+ allqueue(REDRAWVIEW3D, 0);
+ allqueue(REDRAWOOPS, 0);
+ allqueue(REDRAWACTION, 0);
+ }
}
else {
Object *ob= OBACT;
@@ -1277,11 +1281,10 @@ static int tree_element_active_ebone(TreeElement *te, TreeStoreElem *tselem, int
EditBone *ebone= te->directdata;
if(set) {
- if(G.qual & LR_SHIFTKEY);
- else {
- deselectall_armature(0);
- }
- ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL;
+ if(G.qual & LR_SHIFTKEY) deselectall_armature(2); // only clear active tag
+ else deselectall_armature(0); // deselect
+
+ ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL|BONE_ACTIVE;
// flush to parent?
if(ebone->parent && (ebone->flag & BONE_IK_TOPARENT)) ebone->parent->flag |= BONE_TIPSEL;
diff --git a/source/blender/src/poseobject.c b/source/blender/src/poseobject.c
index 76fb388f475..ad28c6fca53 100644
--- a/source/blender/src/poseobject.c
+++ b/source/blender/src/poseobject.c
@@ -27,6 +27,7 @@
*/
#include <stdlib.h>
+#include <string.h>
#include "MEM_guardedalloc.h"
@@ -50,6 +51,8 @@
#include "BKE_object.h"
#include "BKE_utildefines.h"
+#include "BIF_editarmature.h"
+#include "BIF_editaction.h"
#include "BIF_editconstraint.h"
#include "BIF_gl.h"
#include "BIF_graphics.h"
@@ -141,41 +144,61 @@ void exit_posemode(void)
scrarea_queue_headredraw(curarea);
}
-/* context: active channel */
-void pose_special_editmenu(void)
+void pose_select_constraint_target(void)
{
Object *ob= OBACT;
bPoseChannel *pchan;
- short nr;
+ bConstraint *con;
/* paranoia checks */
if(!ob && !ob->pose) return;
if(ob==G.obedit || (ob->flag & OB_POSEMODE)==0) return;
- for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next)
- if(pchan->bone->flag & BONE_ACTIVE) break;
- if(pchan==NULL) return;
-
- nr= pupmenu("Specials%t|Select constraint target%x1");
- if(nr==1) {
- bConstraint *con;
-
- for(con= pchan->constraints.first; con; con= con->next) {
- char *subtarget;
- Object *target= get_constraint_target(con, &subtarget);
+ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if(pchan->bone->flag & (BONE_ACTIVE|BONE_SELECTED)) {
- if(ob==target) {
- if(subtarget) {
- pchan= get_pose_channel(ob->pose, subtarget);
- pchan->bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
+ for(con= pchan->constraints.first; con; con= con->next) {
+ char *subtarget;
+ Object *target= get_constraint_target(con, &subtarget);
+
+ if(ob==target) {
+ if(subtarget) {
+ bPoseChannel *pchanc= get_pose_channel(ob->pose, subtarget);
+ pchanc->bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
+ }
}
}
}
- allqueue(REDRAWVIEW3D, 0);
+ }
+
+ allqueue (REDRAWVIEW3D, 0);
+ allqueue (REDRAWBUTSOBJECT, 0);
+ allqueue (REDRAWOOPS, 0);
+
+ BIF_undo_push("Select constraint target");
+
+}
+
+/* context: active channel */
+void pose_special_editmenu(void)
+{
+ Object *ob= OBACT;
+ short nr;
+
+ /* paranoia checks */
+ if(!ob && !ob->pose) return;
+ if(ob==G.obedit || (ob->flag & OB_POSEMODE)==0) return;
+
+ nr= pupmenu("Specials%t|Select Constraint Target%x1|Flip Left-Right Names");
+ if(nr==1) {
+ pose_select_constraint_target();
+ }
+ else if(nr==2) {
+ pose_flip_names();
}
}
-/* context: active channel, optional selected channel */
+/* context: active object, active channel, optional selected channel */
void pose_add_IK(void)
{
Object *ob= OBACT;
@@ -234,10 +257,15 @@ void pose_add_IK(void)
/* add new empty as target */
if(nr==1) {
- Base *base= BASACT;
+ Base *base= BASACT, *newbase;
Object *obt;
obt= add_object(OB_EMPTY);
+ /* set layers OK */
+ newbase= BASACT;
+ newbase->lay= base->lay;
+ obt->lay= newbase->lay;
+
/* transform cent to global coords for loc */
VecMat4MulVecfl(obt->loc, ob->obmat, pchanact->pose_tail);
@@ -258,7 +286,8 @@ void pose_add_IK(void)
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSOBJECT, 0);
-
+ allqueue (REDRAWOOPS, 0);
+
BIF_undo_push("Add IK constraint");
}
@@ -295,6 +324,7 @@ void pose_clear_IK(void)
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSOBJECT, 0);
+ allqueue (REDRAWOOPS, 0);
BIF_undo_push("Remove IK constraint(s)");
}
@@ -322,11 +352,13 @@ void pose_clear_constraints(void)
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSOBJECT, 0);
+ allqueue (REDRAWOOPS, 0);
BIF_undo_push("Remove Constraint(s)");
}
+
void pose_copy_menu(void)
{
Object *ob= OBACT;
@@ -372,8 +404,272 @@ void pose_copy_menu(void)
allqueue (REDRAWVIEW3D, 0);
allqueue (REDRAWBUTSOBJECT, 0);
+ allqueue (REDRAWOOPS, 0);
BIF_undo_push("Copy Pose Attributes");
}
+/* ******************** copy/paste pose ********************** */
+
+static bPose *g_posebuf=NULL;
+
+void free_posebuf(void)
+{
+ if (g_posebuf) {
+ // was copied without constraints
+ BLI_freelistN (&g_posebuf->chanbase);
+ MEM_freeN (g_posebuf);
+ }
+ g_posebuf=NULL;
+}
+
+void copy_posebuf (void)
+{
+ Object *ob= OBACT;
+
+ if (!ob || !ob->pose){
+ error ("No Pose");
+ return;
+ }
+
+ free_posebuf();
+
+ set_pose_keys(ob); // sets chan->flag to POSE_KEY if bone selected
+ copy_pose(&g_posebuf, ob->pose, 0);
+
+}
+
+static void flip_name (char *name)
+{
+
+ char prefix[128]={""}; /* The part before the facing */
+ char suffix[128]={""}; /* The part after the facing */
+ char replace[128]={""}; /* The replacement string */
+
+ char *index=NULL;
+ /* Find the last period */
+
+ strcpy (prefix, name);
+
+ /* Check for an instance of .Right */
+ if (!index){
+ index = strstr (prefix, "Right");
+ if (index){
+ *index=0;
+ strcpy (replace, "Left");
+ strcpy (suffix, index+6);
+ }
+ }
+
+ /* Che ck for an instance of .RIGHT */
+ if (!index){
+ index = strstr (prefix, "RIGHT");
+ if (index){
+ *index=0;
+ strcpy (replace, "LEFT");
+ strcpy (suffix, index+6);
+ }
+ }
+
+
+ /* Check for an instance of .right */
+ if (!index){
+ index = strstr (prefix, "right");
+ if (index){
+ *index=0;
+ strcpy (replace, "left");
+ strcpy (suffix, index+6);
+ }
+ }
+
+ /* Check for an instance of .left */
+ if (!index){
+ index = strstr (prefix, "left");
+ if (index){
+ *index=0;
+ strcpy (replace, "right");
+ strcpy (suffix, index+5);
+ }
+ }
+
+ /* Check for an instance of .LEFT */
+ if (!index){
+ index = strstr (prefix, "LEFT");
+ if (index){
+ *index=0;
+ strcpy (replace, "RIGHT");
+ strcpy (suffix, index+5);
+ }
+ }
+
+ /* Check for an instance of .Left */
+ if (!index){
+ index = strstr (prefix, "Left");
+ if (index){
+ *index=0;
+ strcpy (replace, "Right");
+ strcpy (suffix, index+5);
+ }
+ }
+
+ /* check for an instance of .L */
+ if (!index){
+ index = strstr (prefix, ".L");
+ if (index){
+ *index=0;
+ strcpy (replace, ".R");
+ strcpy (suffix, index+2);
+ }
+ }
+
+ /* check for an instance of .l */
+ if (!index){
+ index = strstr (prefix, ".l");
+ if (index){
+ *index=0;
+ strcpy (replace, ".r");
+ strcpy (suffix, index+2);
+ }
+ }
+
+ /* Checl for an instance of .R */
+ if (!index){
+ index = strstr (prefix, ".R");
+ if (index){
+ *index=0;
+ strcpy (replace, ".L");
+ strcpy (suffix, index+2);
+ }
+ }
+
+ /* Checl for an instance of .r */
+ if (!index){
+ index = strstr (prefix, ".r");
+ if (index){
+ *index=0;
+ strcpy (replace, ".l");
+ strcpy (suffix, index+2);
+ }
+ }
+
+ sprintf (name, "%s%s%s", prefix, replace, suffix);
+}
+
+void paste_posebuf (int flip)
+{
+ Object *ob= OBACT;
+ bPoseChannel *chan, *pchan;
+ float eul[4];
+ int newchan = 0;
+ char name[32];
+
+ if (!ob || !ob->pose)
+ return;
+
+ if (!g_posebuf){
+ error ("Copy buffer is empty");
+ return;
+ }
+
+ /* Safely merge all of the channels in this pose into
+ any existing pose */
+ for (chan=g_posebuf->chanbase.first; chan; chan=chan->next){
+ if (chan->flag & POSE_KEY) {
+ BLI_strncpy(name, chan->name, sizeof(name));
+ if (flip)
+ flip_name (name);
+
+ /* only copy when channel exists, poses are not meant to add random channels to anymore */
+ pchan= get_pose_channel(ob->pose, name);
+
+ if(pchan) {
+ /* only loc rot size */
+ /* only copies transform info for the pose */
+ VECCOPY(pchan->loc, chan->loc);
+ VECCOPY(pchan->size, chan->size);
+ QUATCOPY(pchan->quat, chan->quat);
+ pchan->flag= chan->flag;
+
+ if (flip){
+ pchan->loc[0]*= -1;
+
+ QuatToEul(pchan->quat, eul);
+ eul[1]*= -1;
+ eul[2]*= -1;
+ EulToQuat(eul, pchan->quat);
+ }
+
+ if (G.flags & G_RECORDKEYS){
+ /* Set keys on pose */
+ if (chan->flag & POSE_ROT){
+ set_action_key(ob->action, pchan, AC_QUAT_X, newchan);
+ set_action_key(ob->action, pchan, AC_QUAT_Y, newchan);
+ set_action_key(ob->action, pchan, AC_QUAT_Z, newchan);
+ set_action_key(ob->action, pchan, AC_QUAT_W, newchan);
+ }
+ if (chan->flag & POSE_SIZE){
+ set_action_key(ob->action, pchan, AC_SIZE_X, newchan);
+ set_action_key(ob->action, pchan, AC_SIZE_Y, newchan);
+ set_action_key(ob->action, pchan, AC_SIZE_Z, newchan);
+ }
+ if (chan->flag & POSE_LOC){
+ set_action_key(ob->action, pchan, AC_LOC_X, newchan);
+ set_action_key(ob->action, pchan, AC_LOC_Y, newchan);
+ set_action_key(ob->action, pchan, AC_LOC_Z, newchan);
+ }
+ }
+ }
+ }
+ }
+
+ /* Update event for pose and deformation children */
+ ob->pose->ctime= -123456.0f;
+ DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
+
+ if (G.flags & G_RECORDKEYS) {
+ remake_action_ipos(ob->action);
+ allqueue (REDRAWIPO, 0);
+ allqueue (REDRAWVIEW3D, 0);
+ allqueue (REDRAWACTION, 0);
+ allqueue(REDRAWNLA, 0);
+ }
+ else {
+ /* need to trick depgraph, action is not allowed to execute on pose */
+ where_is_pose(ob);
+ ob->recalc= 0;
+ }
+
+ BIF_undo_push("Paste Action Pose");
+}
+
+
+/* ********************************************** */
+
+/* context active object */
+void pose_flip_names(void)
+{
+ Object *ob= OBACT;
+ bPoseChannel *pchan;
+ char newname[32];
+
+ /* paranoia checks */
+ if(!ob && !ob->pose) return;
+ if(ob==G.obedit || (ob->flag & OB_POSEMODE)==0) return;
+
+ for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if(pchan->bone->flag & (BONE_ACTIVE|BONE_SELECTED)) {
+ BLI_strncpy(newname, pchan->name, sizeof(newname));
+ flip_name(newname);
+ armature_bone_rename(ob->data, pchan->name, newname);
+ }
+ }
+
+ allqueue(REDRAWVIEW3D, 0);
+ allqueue(REDRAWBUTSEDIT, 0);
+ allqueue(REDRAWBUTSOBJECT, 0);
+ allqueue (REDRAWACTION, 0);
+ allqueue(REDRAWOOPS, 0);
+ BIF_undo_push("Flip names");
+
+} \ No newline at end of file
diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c
index 013e0d51bba..3926783c4e3 100755
--- a/source/blender/src/transform_conversions.c
+++ b/source/blender/src/transform_conversions.c
@@ -67,19 +67,6 @@
#include "DNA_vfont_types.h"
#include "DNA_constraint_types.h"
-#include "BIF_editview.h"
-#include "BIF_resources.h"
-#include "BIF_mywindow.h"
-#include "BIF_gl.h"
-#include "BIF_editlattice.h"
-#include "BIF_editconstraint.h"
-#include "BIF_editarmature.h"
-#include "BIF_editmesh.h"
-#include "BIF_poseobject.h"
-#include "BIF_screen.h"
-#include "BIF_space.h"
-#include "BIF_toolbox.h"
-
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_blender.h"
@@ -97,12 +84,25 @@
#include "BKE_softbody.h"
#include "BKE_utildefines.h"
+
+#include "BIF_editaction.h"
+#include "BIF_editview.h"
+#include "BIF_editlattice.h"
+#include "BIF_editconstraint.h"
+#include "BIF_editarmature.h"
+#include "BIF_editmesh.h"
+#include "BIF_gl.h"
+#include "BIF_poseobject.h"
+#include "BIF_mywindow.h"
+#include "BIF_resources.h"
+#include "BIF_screen.h"
+#include "BIF_space.h"
+#include "BIF_toolbox.h"
+
#include "BSE_view.h"
#include "BSE_edit.h"
-#include "BSE_editaction.h"
#include "BSE_editipo.h"
#include "BSE_editipo_types.h"
-#include "BSE_editaction.h"
#include "BDR_editobject.h" // reset_slowparents()
diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c
index ed4103f94bb..d81f67d0440 100644
--- a/source/blender/src/usiblender.c
+++ b/source/blender/src/usiblender.c
@@ -89,6 +89,7 @@
#include "BIF_editmesh.h"
#include "BIF_editmode_undo.h"
#include "BIF_editsound.h"
+#include "BIF_poseobject.h"
#include "BIF_renderwin.h"
#include "BIF_resources.h"
#include "BIF_screen.h"
@@ -99,7 +100,6 @@
#include "BSE_drawview.h"
#include "BSE_headerbuttons.h"
#include "BSE_editipo.h"
-#include "BSE_editaction.h"
#include "BSE_filesel.h"
#include "BSE_edit.h"