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:
authorJoshua Leung <aligorith@gmail.com>2008-08-10 07:10:07 +0400
committerJoshua Leung <aligorith@gmail.com>2008-08-10 07:10:07 +0400
commit2fe31596e3fb13f723fe54a426b0695d836b464b (patch)
treed1be170b1969a9dececee5deb1db6569233103b9 /source/blender
parent00c308391a30793045a24d1f834a71834d82c6bd (diff)
== Armature Editing Tweaks ==
* New Tool: Switch Direction This tool switches the direction of selected bones in EditMode, and can be found under the Specials Menu (WKey). It also adjusts the parenting, so that continuous chains can still be linked. * Bone Locking: Removed Lock/Unlock functions from Specials menu, and moved this functionality under the Toggle/Set/Clear Bone Settings tools (Shift/Ctrl-Shift/Alt W respectively)
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/include/BIF_editarmature.h5
-rw-r--r--source/blender/src/editarmature.c86
-rw-r--r--source/blender/src/editobject.c8
3 files changed, 64 insertions, 35 deletions
diff --git a/source/blender/include/BIF_editarmature.h b/source/blender/include/BIF_editarmature.h
index 13c16749612..42833fdc186 100644
--- a/source/blender/include/BIF_editarmature.h
+++ b/source/blender/include/BIF_editarmature.h
@@ -114,6 +114,7 @@ void setflag_armature(short mode);
void unique_editbone_name (struct ListBase *ebones, char *name);
void auto_align_armature(short mode);
+void switch_direction_armature(void);
void create_vgroups_from_armature(struct Object *ob, struct Object *par);
void add_verts_to_dgroups(struct Object *ob, struct Object *par, int heat, int mirror);
@@ -135,7 +136,6 @@ void transform_armature_mirror_update(void);
void hide_selected_armature_bones(void);
void hide_unselected_armature_bones(void);
void show_all_armature_bones(void);
-void set_locks_armature_bones(short lock);
#define BONESEL_ROOT 0x10000000
#define BONESEL_TIP 0x20000000
@@ -144,6 +144,9 @@ void set_locks_armature_bones(short lock);
#define BONESEL_NOSEL 0x80000000 /* Indicates a negative number */
+#define EBONE_VISIBLE(arm, ebone) ((arm->layer & ebone->layer) && !(ebone->flag & BONE_HIDDEN_A))
+#define EBONE_EDITABLE(ebone) ((ebone->flag & BONE_SELECTED) && !(ebone->flag & BONE_EDITMODE_LOCKED))
+
/* used in bone_select_hierachy() */
#define BONE_SELECT_PARENT 0
#define BONE_SELECT_CHILD 1
diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c
index 80c24f3a989..2d5c689a754 100644
--- a/source/blender/src/editarmature.c
+++ b/source/blender/src/editarmature.c
@@ -1159,17 +1159,18 @@ void setflag_armature (short mode)
/* get flag to set (sync these with the ones used in eBone_Flag */
if (mode == 2)
- flag= pupmenu("Disable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5");
+ flag= pupmenu("Disable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6");
else if (mode == 1)
- flag= pupmenu("Enable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5");
+ flag= pupmenu("Enable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6");
else
- flag= pupmenu("Toggle Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5");
+ flag= pupmenu("Toggle Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6");
switch (flag) {
case 1: flag = BONE_DRAWWIRE; break;
case 2: flag = BONE_NO_DEFORM; break;
case 3: flag = BONE_MULT_VG_ENV; break;
case 4: flag = BONE_HINGE; break;
case 5: flag = BONE_NO_SCALE; break;
+ case 6: flag = BONE_EDITMODE_LOCKED; break;
default: return;
}
@@ -2711,32 +2712,6 @@ void show_all_armature_bones(void)
BIF_undo_push("Reveal Bones");
}
-/* Sets editmode transform locks for bones (adds if lock==1, clears otherwise) */
-void set_locks_armature_bones(short lock)
-{
- bArmature *arm= G.obedit->data;
- EditBone *ebone;
-
- for (ebone = G.edbo.first; ebone; ebone=ebone->next) {
- if (arm->layer & ebone->layer) {
- if (ebone->flag & BONE_SELECTED) {
- if (lock)
- ebone->flag |= BONE_EDITMODE_LOCKED;
- else
- ebone->flag &= ~BONE_EDITMODE_LOCKED;
- }
- }
- }
- countall();
- allqueue(REDRAWVIEW3D, 0);
- allqueue(REDRAWBUTSEDIT, 0);
-
- if (lock)
- BIF_undo_push("Lock Bones");
- else
- BIF_undo_push("Unlock Bones");
-}
-
/* check for null, before calling! */
static void bone_connect_to_existing_parent(EditBone *bone)
{
@@ -3176,6 +3151,59 @@ void subdivide_armature(int numcuts)
else BIF_undo_push("Subdivide multi");
}
+/* switch direction of bone chains */
+void switch_direction_armature (void)
+{
+ bArmature *arm= (G.obedit) ? G.obedit->data : NULL;
+ ListBase chains = {NULL, NULL};
+ LinkData *chain;
+
+ /* error checking paranoia */
+ if (arm == NULL)
+ return;
+
+ /* get chains of bones (ends on chains) */
+ chains_find_tips(&chains);
+ if (chains.first == NULL) return;
+
+ /* loop over chains, only considering selected and visible bones */
+ for (chain= chains.first; chain; chain= chain->next) {
+ EditBone *ebo, *child=NULL, *parent=NULL;
+
+ /* loop over bones in chain */
+ for (ebo= chain->data; ebo; child= ebo, ebo=parent) {
+ parent= ebo->parent;
+
+ /* only if selected and editable */
+ if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) {
+ /* swap head and tail coordinates */
+ SWAP(float, ebo->head[0], ebo->tail[0]);
+ SWAP(float, ebo->head[1], ebo->tail[1]);
+ SWAP(float, ebo->head[2], ebo->tail[2]);
+
+ /* do parent swapping:
+ * - use 'child' as new parent
+ * - connected flag is only set if points are coincidental
+ */
+ ebo->parent= child;
+ if ((child) && VecEqual(ebo->head, child->tail))
+ ebo->flag |= BONE_CONNECTED;
+ else
+ ebo->flag &= ~BONE_CONNECTED;
+
+ /* FIXME: other things that need fixing?
+ * i.e. roll?
+ */
+ }
+ }
+ }
+
+ /* free chains */
+ BLI_freelistN(&chains);
+
+ BIF_undo_push("Switch Direction");
+}
+
/* ***************** Pose tools ********************* */
void clear_armature(Object *ob, char mode)
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c
index cbf7691754d..fee967bcd9a 100644
--- a/source/blender/src/editobject.c
+++ b/source/blender/src/editobject.c
@@ -2760,7 +2760,7 @@ void special_editmenu(void)
DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
}
else if(G.obedit->type==OB_ARMATURE) {
- nr= pupmenu("Specials%t|Subdivide %x1|Subdivide Multi%x2|Flip Left-Right Names%x3|%l|AutoName Left-Right%x4|AutoName Front-Back%x5|AutoName Top-Bottom%x6|%l|Lock%x7|Unlock%x8");
+ nr= pupmenu("Specials%t|Subdivide %x1|Subdivide Multi%x2|Switch Direction%x7|Flip Left-Right Names%x3|%l|AutoName Left-Right%x4|AutoName Front-Back%x5|AutoName Top-Bottom%x6");
if(nr==1)
subdivide_armature(1);
if(nr==2) {
@@ -2773,10 +2773,8 @@ void special_editmenu(void)
else if(ELEM3(nr, 4, 5, 6)) {
armature_autoside_names(nr-4);
}
- else if(nr==7)
- set_locks_armature_bones(1);
- else if(nr==8)
- set_locks_armature_bones(0);
+ else if(nr == 7)
+ switch_direction_armature();
}
else if(G.obedit->type==OB_LATTICE) {
static float weight= 1.0f;