diff options
author | Ton Roosendaal <ton@blender.org> | 2005-07-23 22:52:31 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-07-23 22:52:31 +0400 |
commit | 948f27c0d888bbfe0f10c4350b4269166568b40d (patch) | |
tree | 2d582413b47bdddc8393c1815f8d7a1184bd4367 /source | |
parent | 6e98a38ea2268fdd96acd6c280286001bca949f6 (diff) |
Killed silly modal PoseMode mode! :)
- PoseMode now is a state Armature Objects can be in. So, while in PoseMode
for an Armature, you can just select another Object or Armature.
- The old PoseMode options (transform, insert keys etc) are accessible
with making the Armature Object 'active' (and have object in PoseMode).
- At this moment no multiple Poses can be transformed/edited at the same
time.
- The old hotkey CTRL+TAB, and view3d header menu, still work to set an
Object's PoseMode
It was quite a lot recode, so tests & reports are welcome.
Oh, as a bonus I added Lasso Select for Bones in PoseMode! It selects using
only the line between root and tip of the Bone.
Diffstat (limited to 'source')
38 files changed, 1357 insertions, 1409 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 5b71c5a5917..6fbf453b469 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -78,7 +78,6 @@ void calc_armature_deform (struct Object *ob, float *co, int index); void init_armature_deform(struct Object *parent, struct Object *ob); struct bArmature* get_armature (struct Object* ob); struct Bone *get_named_bone (struct bArmature *arm, const char *name); -struct Bone *get_indexed_bone (struct Object *ob, int index); float dist_to_bone (float vec[3], float b1[3], float b2[3]); diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index fff57d969b3..6dd0cfbbd9a 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -112,7 +112,6 @@ typedef struct Global { int save_over; /* Reevan's __NLA variables */ - struct Object *obpose; /* Current posable object */ struct ListBase edbo; /* Armature Editmode bones */ /* Rob's variables */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 276f16bdd1a..845cb618638 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1141,27 +1141,6 @@ void where_is_pose (Object *ob) } } - -/* *************** helper for selection code ****************** */ - - -Bone *get_indexed_bone (Object *ob, int index) -/* - Now using pose channel -*/ -{ - bPoseChannel *pchan; - int a= 0; - - if(ob->pose==NULL) return NULL; - - for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) { - if(a==index) return pchan->bone; - } - return NULL; -} - - /* ****************** Game Blender functions, called by engine ************** */ void GB_build_mats (float parmat[][4], float obmat[][4], float premat[][4], float postmat[][4]) diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 2046dcacc06..a235475c8aa 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -248,7 +248,6 @@ static void clear_global(void) G.main= NULL; G.obedit= NULL; - G.obpose= NULL; G.saction= NULL; G.buts= NULL; G.v2d= NULL; @@ -307,8 +306,6 @@ static void clean_paths(Main *main) static void setup_app_data(BlendFileData *bfd, char *filename) { - Object *ob; - Base *base; bScreen *curscreen= NULL; Scene *curscene= NULL; char mode; @@ -379,17 +376,6 @@ static void setup_app_data(BlendFileData *bfd, char *filename) G.f= bfd->globalf; - /* check posemode */ - for(base= G.scene->base.first; base; base=base->next) { - ob= base->object; - if(ob->flag & OB_POSEMODE) { - if(ob->type==OB_ARMATURE && G.scene->basact && G.scene->basact->object==ob) - G.obpose= ob; - else - ob->flag &= ~OB_POSEMODE; - } - } - if (!G.background) { setscreen(G.curscreen); } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 17bb0ab17c6..87e0a0c95c4 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -723,9 +723,6 @@ Object *add_object(int type) Base *base; char name[32]; - if (G.obpose) - exit_posemode(1); - strcpy(name, get_obdata_defname(type)); ob= alloc_libblock(&G.main->object, ID_OB, name); diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index c14a35e2c6a..41f52e2455c 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -2639,3 +2639,163 @@ void spheremap(float x, float y, float z, float *u, float *v) /* ------------------------------------------------------------------------- */ +/* ***************** m1 = m2 ***************** */ +void cpy_m3_m3(float m1[][3], float m2[][3]) +{ + memcpy(m1[0], m2[0], 9*sizeof(float)); +} + +/* ***************** m1 = m2 ***************** */ +void cpy_m4_m4(float m1[][4], float m2[][4]) +{ + memcpy(m1[0], m2[0], 16*sizeof(float)); +} + +/* ***************** identity matrix ***************** */ +void ident_m4(float m[][4]) +{ + + m[0][0]= m[1][1]= m[2][2]= m[3][3]= 1.0; + m[0][1]= m[0][2]= m[0][3]= 0.0; + m[1][0]= m[1][2]= m[1][3]= 0.0; + m[2][0]= m[2][1]= m[2][3]= 0.0; + m[3][0]= m[3][1]= m[3][2]= 0.0; +} + + +/* ***************** m1 = m2 (pre) * m3 (post) ***************** */ +void mul_m3_m3m3(float m1[][3], float m2[][3], float m3[][3]) +{ + float m[3][3]; + + m[0][0]= m2[0][0]*m3[0][0] + m2[1][0]*m3[0][1] + m2[2][0]*m3[0][2]; + m[0][1]= m2[0][1]*m3[0][0] + m2[1][1]*m3[0][1] + m2[2][1]*m3[0][2]; + m[0][2]= m2[0][2]*m3[0][0] + m2[1][2]*m3[0][1] + m2[2][2]*m3[0][2]; + + m[1][0]= m2[0][0]*m3[1][0] + m2[1][0]*m3[1][1] + m2[2][0]*m3[1][2]; + m[1][1]= m2[0][1]*m3[1][0] + m2[1][1]*m3[1][1] + m2[2][1]*m3[1][2]; + m[1][2]= m2[0][2]*m3[1][0] + m2[1][2]*m3[1][1] + m2[2][2]*m3[1][2]; + + m[2][0]= m2[0][0]*m3[2][0] + m2[1][0]*m3[2][1] + m2[2][0]*m3[2][2]; + m[2][1]= m2[0][1]*m3[2][0] + m2[1][1]*m3[2][1] + m2[2][1]*m3[2][2]; + m[2][2]= m2[0][2]*m3[2][0] + m2[1][2]*m3[2][1] + m2[2][2]*m3[2][2]; + + cpy_m3_m3(m1, m2); +} + +/* ***************** m1 = m2 (pre) * m3 (post) ***************** */ +void mul_m4_m4m4(float m1[][4], float m2[][4], float m3[][4]) +{ + float m[4][4]; + + m[0][0]= m2[0][0]*m3[0][0] + m2[1][0]*m3[0][1] + m2[2][0]*m3[0][2] + m2[3][0]*m3[0][3]; + m[0][1]= m2[0][1]*m3[0][0] + m2[1][1]*m3[0][1] + m2[2][1]*m3[0][2] + m2[3][1]*m3[0][3]; + m[0][2]= m2[0][2]*m3[0][0] + m2[1][2]*m3[0][1] + m2[2][2]*m3[0][2] + m2[3][2]*m3[0][3]; + m[0][3]= m2[0][3]*m3[0][0] + m2[1][3]*m3[0][1] + m2[2][3]*m3[0][2] + m2[3][3]*m3[0][3]; + + m[1][0]= m2[0][0]*m3[1][0] + m2[1][0]*m3[1][1] + m2[2][0]*m3[1][2] + m2[3][0]*m3[1][3]; + m[1][1]= m2[0][1]*m3[1][0] + m2[1][1]*m3[1][1] + m2[2][1]*m3[1][2] + m2[3][1]*m3[1][3]; + m[1][2]= m2[0][2]*m3[1][0] + m2[1][2]*m3[1][1] + m2[2][2]*m3[1][2] + m2[3][2]*m3[1][3]; + m[1][3]= m2[0][3]*m3[1][0] + m2[1][3]*m3[1][1] + m2[2][3]*m3[1][2] + m2[3][3]*m3[1][3]; + + m[2][0]= m2[0][0]*m3[2][0] + m2[1][0]*m3[2][1] + m2[2][0]*m3[2][2] + m2[3][0]*m3[2][3]; + m[2][1]= m2[0][1]*m3[2][0] + m2[1][1]*m3[2][1] + m2[2][1]*m3[2][2] + m2[3][1]*m3[2][3]; + m[2][2]= m2[0][2]*m3[2][0] + m2[1][2]*m3[2][1] + m2[2][2]*m3[2][2] + m2[3][2]*m3[2][3]; + m[2][3]= m2[0][3]*m3[2][0] + m2[1][3]*m3[2][1] + m2[2][3]*m3[2][2] + m2[3][3]*m3[2][3]; + + m[3][0]= m2[0][0]*m3[3][0] + m2[1][0]*m3[3][1] + m2[2][0]*m3[3][2] + m2[3][0]*m3[3][3]; + m[3][1]= m2[0][1]*m3[3][0] + m2[1][1]*m3[3][1] + m2[2][1]*m3[3][2] + m2[3][1]*m3[3][3]; + m[3][2]= m2[0][2]*m3[3][0] + m2[1][2]*m3[3][1] + m2[2][2]*m3[3][2] + m2[3][2]*m3[3][3]; + m[3][3]= m2[0][3]*m3[3][0] + m2[1][3]*m3[3][1] + m2[2][3]*m3[3][2] + m2[3][3]*m3[3][3]; + + cpy_m4_m4(m1, m2); +} + +/* ***************** m1 = inverse(m2) ***************** */ +void inv_m3_m3(float m1[][3], float m2[][3]) +{ + short a,b; + float det; + + /* calc adjoint */ + Mat3Adj(m1, m2); + + /* then determinant old matrix! */ + det= m2[0][0]* (m2[1][1]*m2[2][2] - m2[1][2]*m2[2][1]) + -m2[1][0]* (m2[0][1]*m2[2][2] - m2[0][2]*m2[2][1]) + +m2[2][0]* (m2[0][1]*m2[1][2] - m2[0][2]*m2[1][1]); + + if(det==0.0f) det=1.0f; + det= 1.0f/det; + for(a=0;a<3;a++) { + for(b=0;b<3;b++) { + m1[a][b]*=det; + } + } +} + +/* ***************** m1 = inverse(m2) ***************** */ +int inv_m4_m4(float inverse[][4], float mat[][4]) +{ + int i, j, k; + double temp; + float tempmat[4][4]; + float max; + int maxj; + + /* Set inverse to identity */ + ident_m4(inverse); + + /* Copy original matrix so we don't mess it up */ + cpy_m4_m4(tempmat, mat); + + for(i = 0; i < 4; i++) { + /* Look for row with max pivot */ + max = ABS(tempmat[i][i]); + maxj = i; + for(j = i + 1; j < 4; j++) { + if(ABS(tempmat[j][i]) > max) { + max = ABS(tempmat[j][i]); + maxj = j; + } + } + /* Swap rows if necessary */ + if (maxj != i) { + for( k = 0; k < 4; k++) { + SWAP(float, tempmat[i][k], tempmat[maxj][k]); + SWAP(float, inverse[i][k], inverse[maxj][k]); + } + } + + temp = tempmat[i][i]; + if (temp == 0) + return 0; /* No non-zero pivot */ + for(k = 0; k < 4; k++) { + tempmat[i][k] = (float)(tempmat[i][k]/temp); + inverse[i][k] = (float)(inverse[i][k]/temp); + } + for(j = 0; j < 4; j++) { + if(j != i) { + temp = tempmat[j][i]; + for(k = 0; k < 4; k++) { + tempmat[j][k] -= (float)(tempmat[i][k]*temp); + inverse[j][k] -= (float)(inverse[i][k]*temp); + } + } + } + } + return 1; +} + +/* ***************** v1 = v2 * mat ***************** */ +void mul_v3_v3m4(float *v1, float *v2, float mat[][4]) +{ + float x, y; + + x= v2[0]; // work with a copy, v1 can be same as v2 + y= v2[1]; + v1[0]= x*mat[0][0] + y*mat[1][0] + mat[2][0]*v2[2] + mat[3][0]; + v1[1]= x*mat[0][1] + y*mat[1][1] + mat[2][1]*v2[2] + mat[3][1]; + v1[2]= x*mat[0][2] + y*mat[1][2] + mat[2][2]*v2[2] + mat[3][2]; + +} diff --git a/source/blender/include/BDR_drawobject.h b/source/blender/include/BDR_drawobject.h index 855331bfd73..02b12582b2a 100644 --- a/source/blender/include/BDR_drawobject.h +++ b/source/blender/include/BDR_drawobject.h @@ -46,7 +46,6 @@ struct BoundBox; struct Base; void init_draw_rects(void); -void helpline(float *vec); void drawaxes(float size); void drawcamera(struct Object *ob); diff --git a/source/blender/include/BIF_editarmature.h b/source/blender/include/BIF_editarmature.h index da1a99314a3..7fc35197cfe 100644 --- a/source/blender/include/BIF_editarmature.h +++ b/source/blender/include/BIF_editarmature.h @@ -33,6 +33,7 @@ #define BIF_EDITARMATURE_H struct Object; +struct Base; struct Bone; struct bArmature; @@ -82,10 +83,12 @@ void clear_armature(struct Object *ob, char mode); void delete_armature(void); void deselectall_armature(int toggle); -void deselectall_posearmature (int test); -void draw_armature(struct Object *ob, int dt); +void deselectall_posearmature (struct Object *ob, int test); +void draw_armature(struct Base *base, int dt); void extrude_armature(void); void free_editArmature(void); +struct Bone *get_indexed_bone (struct Object *ob, int index); + void join_armature(void); void load_editArmature(void); @@ -94,7 +97,9 @@ void clear_bone_parent(void); void make_editArmature(void); void make_trans_bones (char mode); -void mousepose_armature(void); + +void do_pose_selectbuffer(struct Base *base, unsigned int *buffer, short hits); + void mouse_armature(void); void remake_editArmature(void); void selectconnected_armature(void); @@ -116,15 +121,14 @@ int bone_looper(Object *ob, struct Bone *bone, void *data, int (*bone_func)(Object *, struct Bone *, void *)); int ik_chain_looper(Object *ob, struct Bone *bone, void *data, int (*bone_func)(Object *, struct Bone *, void *)); -int is_delay_deform(void); void undo_push_armature(char *name); void armature_bone_rename(struct bArmature *arm, char *oldname, char *newname); -#define BONESEL_ROOT 0x02000000 -#define BONESEL_TIP 0x04000000 -#define BONESEL_BONE 0x08000000 +#define BONESEL_ROOT 0x10000000 +#define BONESEL_TIP 0x20000000 +#define BONESEL_BONE 0x40000000 #define BONESEL_ANY (BONESEL_TIP|BONESEL_ROOT|BONESEL_BONE) #define BONESEL_NOSEL 0x80000000 /* Indicates a negative number */ diff --git a/source/blender/include/BIF_poseobject.h b/source/blender/include/BIF_poseobject.h index 9859a2598ed..ac0c66ff0d1 100644 --- a/source/blender/include/BIF_poseobject.h +++ b/source/blender/include/BIF_poseobject.h @@ -46,9 +46,8 @@ void set_pose_keys(struct Object *ob); /** * Deactivates posemode - * @param freedata 0 or 1 value indicating that posedata should be deleted */ -void exit_posemode(int freedata); +void exit_posemode(void); void pose_special_editmenu(void); diff --git a/source/blender/include/blendef.h b/source/blender/include/blendef.h index bd512516d55..9f7ad98a1bc 100644 --- a/source/blender/include/blendef.h +++ b/source/blender/include/blendef.h @@ -208,9 +208,7 @@ #define B_SCENELOCK 140 #define B_LOCALVIEW 141 #define B_U_CAPSLOCK 142 -#define B_EDITMODE 143 -#define B_VPAINT 144 -#define B_FACESEL 145 + #define B_VIEWBUT 146 #define B_PERSP 147 #define B_PROPTOOL 148 @@ -218,9 +216,7 @@ #define B_VIEWTRANS 150 #define B_VIEWZOOM 151 #define B_STARTGAME 152 -#define B_POSEMODE 153 -#define B_TEXTUREPAINT 154 -#define B_WPAINT 155 + #define B_MODESELECT 156 #define B_AROUND 157 #define B_SEL_VERT 158 diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 12f006a191e..2700ddd717e 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -380,26 +380,7 @@ typedef struct SpaceImaSel { /* **************** SPACE ********************* */ -/* view3d->flag */ /* Now in DNA_view3d_types.h */ -/* -#define V3D_DISPIMAGE 1 -#define V3D_DISPBGPIC 2 -#define V3D_SETUPBUTS 4 -#define V3D_NEEDBACKBUFDRAW 8 -#define V3D_MODE (16+32+64+128) -#define V3D_EDITMODE 16 -#define V3D_VERTEXPAINT 32 -#define V3D_FACESELECT 64 -#define V3D_POSEMODE 128 -*/ - -/* view3d->around */ /* Now in DNA_view3d_types.h */ -/* -#define V3D_CENTRE 0 -#define V3D_CENTROID 3 -#define V3D_CURSOR 1 -#define V3D_LOCAL 2 -*/ +/* view3d Now in DNA_view3d_types.h */ /* buts defines in BIF_butspace.h */ diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 5198b37740b..d51d61f9b23 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -1865,6 +1865,8 @@ static void editing_panel_armature_bones(Object *ob, bArmature *arm) uiBlockEndAlign(block); by-=42; + + if(by < -200) break; // for time being... extreme long panels are very slow } } @@ -1925,7 +1927,9 @@ static void editing_panel_pose_bones(Object *ob, bArmature *arm) bx+220, by-19, 110, 19, &curBone->ease2, 0.0, 2.0, 10.0, 0.0, "Second length of Bezier handle"); uiBlockEndAlign(block); + by-=42; + if(by < -200) break; // for time being... extreme long panels are very slow } } @@ -2875,7 +2879,7 @@ void editing_panels() if(G.obedit) { editing_panel_armature_bones(ob, arm); } - else if(G.obpose==ob) { + else if(ob->flag & OB_POSEMODE) { editing_panel_pose_bones(ob, arm); } break; diff --git a/source/blender/src/drawarmature.c b/source/blender/src/drawarmature.c index 9990908bf33..d53f58fad62 100644 --- a/source/blender/src/drawarmature.c +++ b/source/blender/src/drawarmature.c @@ -405,7 +405,7 @@ static void draw_line_bone(int armflag, int boneflag, int constflag, unsigned in /* Draw root point if we have no IK parent */ if (!(boneflag & BONE_IK_TOPARENT)){ - if (id != -1) { // no bitmap in selection mode, crashes 3d cards... + if (G.f & G_PICKSEL) { // no bitmap in selection mode, crashes 3d cards... glLoadName (id | BONESEL_ROOT); glBegin(GL_POINTS); glVertex3f(0.0f, 0.0f, 0.0f); @@ -426,7 +426,7 @@ static void draw_line_bone(int armflag, int boneflag, int constflag, unsigned in glEnd(); /* tip */ - if (id != -1) { // no bitmap in selection mode, crashes 3d cards... + if (G.f & G_PICKSEL) { // no bitmap in selection mode, crashes 3d cards... glLoadName (id | BONESEL_TIP); glBegin(GL_POINTS); glVertex3f(0.0f, 1.0f, 0.0f); @@ -439,7 +439,7 @@ static void draw_line_bone(int armflag, int boneflag, int constflag, unsigned in /* further we send no names */ if (id != -1) - glLoadName (-1); + glLoadName (id & 0xFFFF); // object tag, for bordersel optim if(armflag & ARM_POSEMODE) { /* inner part in background color or constraint */ @@ -456,7 +456,7 @@ static void draw_line_bone(int armflag, int boneflag, int constflag, unsigned in /* Draw root point if we have no IK parent */ if (!(boneflag & BONE_IK_TOPARENT)){ - if (id == -1) { // no bitmap in selection mode, crashes 3d cards... + if ((G.f & G_PICKSEL)==0) { // no bitmap in selection mode, crashes 3d cards... if(armflag & ARM_EDITMODE) { if (boneflag & BONE_ROOTSEL) BIF_ThemeColor(TH_VERTEX_SELECT); else BIF_ThemeColor(TH_VERTEX); @@ -476,7 +476,7 @@ static void draw_line_bone(int armflag, int boneflag, int constflag, unsigned in glEnd(); /* tip */ - if (id == -1) { // no bitmap in selection mode, crashes 3d cards... + if ((G.f & G_PICKSEL)==0) { // no bitmap in selection mode, crashes 3d cards... if(armflag & ARM_EDITMODE) { if (boneflag & BONE_TIPSEL) BIF_ThemeColor(TH_VERTEX_SELECT); else BIF_ThemeColor(TH_VERTEX); @@ -678,11 +678,12 @@ static void draw_bone(int dt, int armflag, int boneflag, int constflag, unsigned } /* assumes object is Armature with pose */ -static void draw_pose_channels(Object *ob, int dt) +static void draw_pose_channels(Base *base, int dt) { + Object *ob= base->object; + bArmature *arm= ob->data; bPoseChannel *pchan; Bone *bone; - bArmature *arm= ob->data; GLfloat tmp; int index= -1; int do_dashed= 1; @@ -698,7 +699,7 @@ static void draw_pose_channels(Object *ob, int dt) /* if solid we draw that first, with selection codes, but without names, axes etc */ if(dt>OB_WIRE && arm->drawtype!=ARM_LINE) { - if(arm->flag & ARM_POSEMODE) index= 0; + if(arm->flag & ARM_POSEMODE) index= base->selcol; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { bone= pchan->bone; @@ -721,9 +722,9 @@ static void draw_pose_channels(Object *ob, int dt) } glPopMatrix(); } - if (index!= -1) index++; + if (index!= -1) index+= 0x10000; // pose bones count in higher 2 bytes only } - glLoadName (-1); + glLoadName (index & 0xFFFF); // object tag, for bordersel optim index= -1; } @@ -732,14 +733,14 @@ static void draw_pose_channels(Object *ob, int dt) /* draw line check first. we do selection indices */ if (arm->drawtype==ARM_LINE) { - if(G.f & G_PICKSEL) index= 0; + if (arm->flag & ARM_POSEMODE) index= base->selcol; } /* if solid && posemode, we draw again with polygonoffset */ else if (dt>OB_WIRE && (arm->flag & ARM_POSEMODE)) bglPolygonOffset(1.0); else /* and we use selection indices if not done yet */ - if (arm->flag & ARM_POSEMODE) index= 0; + if (arm->flag & ARM_POSEMODE) index= base->selcol; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { bone= pchan->bone; @@ -748,7 +749,7 @@ static void draw_pose_channels(Object *ob, int dt) // Draw a line from our root to the parent's tip if (do_dashed && bone->parent && !(bone->flag & BONE_IK_TOPARENT) ){ if (arm->flag & ARM_POSEMODE) { - glLoadName (-1); + glLoadName (index & 0xFFFF); // object tag, for bordersel optim BIF_ThemeColor(TH_WIRE); } setlinestyle(3); @@ -785,7 +786,7 @@ static void draw_pose_channels(Object *ob, int dt) glPopMatrix(); } - if (index!= -1) index++; + if (index!= -1) index+= 0x10000; // pose bones count in higher 2 bytes only } /* restore things */ if (arm->drawtype!=ARM_LINE && dt>OB_WIRE && (arm->flag & ARM_POSEMODE)) @@ -858,9 +859,9 @@ static void set_matrix_editbone(EditBone *eBone) static void draw_ebones(Object *ob, int dt) { - EditBone *eBone; + EditBone *eBone; bArmature *arm= ob->data; - unsigned int index; + unsigned int index; /* if solid we draw it first */ if(dt>OB_WIRE && arm->drawtype!=ARM_LINE) { @@ -914,7 +915,7 @@ static void draw_ebones(Object *ob, int dt) /* offset to parent */ if (eBone->parent) { BIF_ThemeColor(TH_WIRE); - glLoadName (-1); + glLoadName (index & 0xFFFF); // object tag, for bordersel optim setlinestyle(3); glBegin(GL_LINES); @@ -956,14 +957,16 @@ static void draw_ebones(Object *ob, int dt) } /* called from drawobject.c */ -void draw_armature(Object *ob, int dt) +void draw_armature(Base *base, int dt) { + Object *ob= base->object; bArmature *arm= ob->data; /* we use color for solid lighting */ glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); // only for lighting... + /* arm->flag is being used to detect mode... */ /* editmode? */ if(ob==G.obedit || (G.obedit && ob->data==G.obedit->data)) { if(ob==G.obedit) arm->flag |= ARM_EDITMODE; @@ -973,8 +976,13 @@ void draw_armature(Object *ob, int dt) else{ /* Draw Pose */ if(ob->pose) { - if (G.obpose == ob) arm->flag |= ARM_POSEMODE; - draw_pose_channels(ob, dt); + /* drawing posemode selection indices or colors only in these cases */ + if(G.f & G_PICKSEL) { + if(ob->flag & OB_POSEMODE) arm->flag |= ARM_POSEMODE; + } + else if(ob==OBACT && (ob->flag & OB_POSEMODE)) arm->flag |= ARM_POSEMODE; + + draw_pose_channels(base, dt); arm->flag &= ~ARM_POSEMODE; } } diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 391a1acb248..bb0fb52fa0f 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -289,38 +289,6 @@ static void draw_icon_centered(float *pos, unsigned int *rect, int rectsize) glDrawPixels(rectsize, rectsize, GL_RGBA, GL_UNSIGNED_BYTE, rect); } -/* bad frontbuffer call... because it is used in transform after force_draw() */ -void helpline(float *vec) -{ - float vecrot[3], cent[2]; - short mval[2]; - - VECCOPY(vecrot, vec); - if(G.obedit) Mat4MulVecfl(G.obedit->obmat, vecrot); - else if(G.obpose) Mat4MulVecfl(G.obpose->obmat, vecrot); - - getmouseco_areawin(mval); - project_float(vecrot, cent); // no overflow in extreme cases - if(cent[0]!=3200.0f) { - persp(PERSP_WIN); - - glDrawBuffer(GL_FRONT); - - BIF_ThemeColor(TH_WIRE); - - setlinestyle(3); - glBegin(GL_LINE_STRIP); - glVertex2sv(mval); - glVertex2fv(cent); - glEnd(); - setlinestyle(0); - - persp(PERSP_VIEW); - glFlush(); // flush display for frontbuffer - glDrawBuffer(GL_BACK); - } -} - void drawaxes(float size) { int axis; @@ -3330,8 +3298,10 @@ static void drawtexspace(Object *ob) } /* draws wire outline */ -static void drawSolidSelect(Object *ob) +static void drawSolidSelect(Base *base) { + Object *ob= base->object; + glLineWidth(2.0); glDepthMask(0); @@ -3344,8 +3314,8 @@ static void drawSolidSelect(Object *ob) drawDispListwire(&ob->disp); } else if(ob->type==OB_ARMATURE) { - if(ob!=G.obpose) { - draw_armature(ob, OB_WIRE); + if(!(ob->flag & OB_POSEMODE)) { + draw_armature(base, OB_WIRE); } } @@ -3587,7 +3557,7 @@ void draw_object(Base *base) if((G.vd->flag & V3D_SELECT_OUTLINE) && ob->type!=OB_MESH) { if(dt>OB_WIRE && dt<OB_TEXTURE && ob!=G.obedit) { if (!(ob->dtx&OB_DRAWWIRE) && (ob->flag&SELECT) && !(G.f&G_PICKSEL)) { - drawSolidSelect(ob); + drawSolidSelect(base); } } } @@ -3723,7 +3693,7 @@ void draw_object(Base *base) break; case OB_ARMATURE: if(dt>OB_WIRE) set_gl_material(0); // we use defmaterial - draw_armature(ob, dt); + draw_armature(base, dt); break; default: drawaxes(1.0); diff --git a/source/blender/src/drawscene.c b/source/blender/src/drawscene.c index 5808c697d73..a4c9b8d0e40 100644 --- a/source/blender/src/drawscene.c +++ b/source/blender/src/drawscene.c @@ -70,8 +70,6 @@ void set_scene(Scene *sce) /* also see scene.c: set_scene_bg() */ /* ending all modes */ if( G.obedit) exit_editmode(2); - if(G.obpose) - exit_posemode(1); if(G.f & G_FACESELECT) set_faceselect(); diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index dd55c50fa04..7b11abd9b3d 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -1589,7 +1589,7 @@ void do_viewbuts(unsigned short event) /* no break, pass on */ case B_ARMATUREPANEL2: { - DAG_object_flush_update(G.scene, G.obpose, OB_RECALC_DATA); + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); allqueue(REDRAWVIEW3D, 1); } break; @@ -1634,7 +1634,7 @@ static void view3d_panel_object(short cntrl) // VIEW3D_HANDLER_OBJECT if(ob->type==OB_MBALL) v3d_editmetaball_buts(block, ob, lim); else v3d_editvertex_buts(block, ob, lim); } - else if(ob==G.obpose) { + else if(ob->flag & OB_POSEMODE) { v3d_posearmature_buts(block, ob, lim); } else if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT)) { diff --git a/source/blender/src/edit.c b/source/blender/src/edit.c index 8a1d1088834..b9b01756de4 100644 --- a/source/blender/src/edit.c +++ b/source/blender/src/edit.c @@ -551,7 +551,7 @@ void countall() { extern ListBase editNurb; Base *base; - Object *ob; + Object *ob= OBACT; Mesh *me; Nurb *nu; BezTriple *bezt; @@ -668,10 +668,10 @@ void countall() allqueue(REDRAWINFO, 1); /* 1, because header->win==0! */ return; } - else if(G.obpose) { - if(G.obpose->pose) { + else if(ob && (ob->flag & OB_POSEMODE)) { + if(ob->pose) { bPoseChannel *pchan; - for(pchan= G.obpose->pose->chanbase.first; pchan; pchan= pchan->next) { + for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { G.totbone++; if(pchan->bone && (pchan->bone->flag & BONE_SELECTED)) G.totbonesel++; } @@ -1055,34 +1055,34 @@ void snap_sel_to_grid() return; } - if (G.obpose){ - allqueue(REDRAWVIEW3D, 0); - return; - } - base= (G.scene->base.first); while(base) { if( ( ((base)->flag & SELECT) && ((base)->lay & G.vd->lay) && ((base)->object->id.lib==0))) { ob= base->object; - ob->recalc |= OB_RECALC_OB; - - vec[0]= -ob->obmat[3][0]+G.vd->gridview*floor(.5+ ob->obmat[3][0]/gridf); - vec[1]= -ob->obmat[3][1]+G.vd->gridview*floor(.5+ ob->obmat[3][1]/gridf); - vec[2]= -ob->obmat[3][2]+G.vd->gridview*floor(.5+ ob->obmat[3][2]/gridf); - - if(ob->parent) { - where_is_object(ob); - - Mat3Inv(imat, originmat); - Mat3MulVecfl(imat, vec); - ob->loc[0]+= vec[0]; - ob->loc[1]+= vec[1]; - ob->loc[2]+= vec[2]; + if(ob->flag & OB_POSEMODE) { + ; // todo } else { - ob->loc[0]+= vec[0]; - ob->loc[1]+= vec[1]; - ob->loc[2]+= vec[2]; + ob->recalc |= OB_RECALC_OB; + + vec[0]= -ob->obmat[3][0]+G.vd->gridview*floor(.5+ ob->obmat[3][0]/gridf); + vec[1]= -ob->obmat[3][1]+G.vd->gridview*floor(.5+ ob->obmat[3][1]/gridf); + vec[2]= -ob->obmat[3][2]+G.vd->gridview*floor(.5+ ob->obmat[3][2]/gridf); + + if(ob->parent) { + where_is_object(ob); + + Mat3Inv(imat, originmat); + Mat3MulVecfl(imat, vec); + ob->loc[0]+= vec[0]; + ob->loc[1]+= vec[1]; + ob->loc[2]+= vec[2]; + } + else { + ob->loc[0]+= vec[0]; + ob->loc[1]+= vec[1]; + ob->loc[2]+= vec[2]; + } } } @@ -1133,34 +1133,34 @@ void snap_sel_to_curs() return; } - if (G.obpose){ - allqueue(REDRAWVIEW3D, 0); - return; - } - base= (G.scene->base.first); while(base) { if( ( ((base)->flag & SELECT) && ((base)->lay & G.vd->lay) && ((base)->object->id.lib==0))) { ob= base->object; - ob->recalc |= OB_RECALC_OB; - - vec[0]= -ob->obmat[3][0] + curs[0]; - vec[1]= -ob->obmat[3][1] + curs[1]; - vec[2]= -ob->obmat[3][2] + curs[2]; - - if(ob->parent) { - where_is_object(ob); - - Mat3Inv(imat, originmat); - Mat3MulVecfl(imat, vec); - ob->loc[0]+= vec[0]; - ob->loc[1]+= vec[1]; - ob->loc[2]+= vec[2]; + if(ob->flag & OB_POSEMODE) { + ; // todo } else { - ob->loc[0]+= vec[0]; - ob->loc[1]+= vec[1]; - ob->loc[2]+= vec[2]; + ob->recalc |= OB_RECALC_OB; + + vec[0]= -ob->obmat[3][0] + curs[0]; + vec[1]= -ob->obmat[3][1] + curs[1]; + vec[2]= -ob->obmat[3][2] + curs[2]; + + if(ob->parent) { + where_is_object(ob); + + Mat3Inv(imat, originmat); + Mat3MulVecfl(imat, vec); + ob->loc[0]+= vec[0]; + ob->loc[1]+= vec[1]; + ob->loc[2]+= vec[2]; + } + else { + ob->loc[0]+= vec[0]; + ob->loc[1]+= vec[1]; + ob->loc[2]+= vec[2]; + } } } @@ -1422,34 +1422,34 @@ void snap_to_center() return; } - if (G.obpose){ - allqueue(REDRAWVIEW3D, 0); - return; - } - base= (G.scene->base.first); while(base) { if( ( ((base)->flag & SELECT) && ((base)->lay & G.vd->lay) && ((base)->object->id.lib==0))) { ob= base->object; - ob->recalc |= OB_RECALC_OB; - - vec[0]= -ob->obmat[3][0] + snaploc[0]; - vec[1]= -ob->obmat[3][1] + snaploc[1]; - vec[2]= -ob->obmat[3][2] + snaploc[2]; - - if(ob->parent) { - where_is_object(ob); - - Mat3Inv(imat, originmat); - Mat3MulVecfl(imat, vec); - ob->loc[0]+= vec[0]; - ob->loc[1]+= vec[1]; - ob->loc[2]+= vec[2]; + if(ob->flag & OB_POSEMODE) { + ; // todo } else { - ob->loc[0]+= vec[0]; - ob->loc[1]+= vec[1]; - ob->loc[2]+= vec[2]; + ob->recalc |= OB_RECALC_OB; + + vec[0]= -ob->obmat[3][0] + snaploc[0]; + vec[1]= -ob->obmat[3][1] + snaploc[1]; + vec[2]= -ob->obmat[3][2] + snaploc[2]; + + if(ob->parent) { + where_is_object(ob); + + Mat3Inv(imat, originmat); + Mat3MulVecfl(imat, vec); + ob->loc[0]+= vec[0]; + ob->loc[1]+= vec[1]; + ob->loc[2]+= vec[2]; + } + else { + ob->loc[0]+= vec[0]; + ob->loc[1]+= vec[1]; + ob->loc[2]+= vec[2]; + } } } @@ -1510,7 +1510,8 @@ void mergemenu(void) } -void delete_context_selected(void) { +void delete_context_selected(void) +{ if(G.obedit) { if(G.obedit->type==OB_MESH) delete_mesh(); else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) delNurb(); @@ -1520,14 +1521,15 @@ void delete_context_selected(void) { else delete_obj(0); } -void duplicate_context_selected(void) { +void duplicate_context_selected(void) +{ if(G.obedit) { if(G.obedit->type==OB_MESH) adduplicate_mesh(); else if(G.obedit->type==OB_ARMATURE) adduplicate_armature(); else if(G.obedit->type==OB_MBALL) adduplicate_mball(); else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) adduplicate_nurb(); } - else if(!(G.obpose)){ + else { adduplicate(0); } } diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c index a88f6299822..72971bf306f 100644 --- a/source/blender/src/editaction.c +++ b/source/blender/src/editaction.c @@ -100,24 +100,11 @@ extern int count_action_levels (bAction *act); #define BEZSELECTED(bezt) (((bezt)->f1 & 1) || ((bezt)->f2 & 1) || ((bezt)->f3 & 1)) -/* Local Function prototypes, some are forward needed */ - +/* Local Function prototypes, are forward needed */ static void insertactionkey(bAction *act, bActionChannel *achan, bPoseChannel *chan, int adrcode, short makecurve, float time); -static void flip_name (char *name); -static void mouse_actionchannels(bAction *act, short *mval, - short *mvalo, int selectmode); -static void mouse_action(int selectmode); -static void mouse_mesh_action(int selectmode, Key *key); -static bActionChannel *get_nearest_actionchannel_key (float *index, short *sel, bConstraintChannel **conchan); -static void delete_actionchannels(void); -static void select_poseelement_by_name (char *name, int select); static void hilight_channel (bAction *act, bActionChannel *chan, short hilight); static void set_action_key_time (bAction *act, bPoseChannel *chan, int adrcode, short makecurve, float time); -static void remake_meshaction_ipos(Ipo *ipo); -static void select_all_keys_frames(bAction *act, short *mval, short *mvalo, int selectmode); -static void select_all_keys_channels(bAction *act, short *mval, short *mvalo, int selectmode); - /* Implementation */ short showsliders = 0; @@ -127,9 +114,8 @@ static void select_poseelement_by_name (char *name, int select) { /* Synchs selection of channels with selection of object elements in posemode */ - Object *ob; + Object *ob= OBACT; - ob = G.obpose; if (!ob) return; @@ -233,7 +219,7 @@ bAction* bake_action_with_client (bAction *act, Object *armob, float tolerance) return result; } - +/* apparently within active object context */ void select_actionchannel_by_name (bAction *act, char *name, int select) { bActionChannel *chan; @@ -541,6 +527,7 @@ static IpoCurve *get_nearest_meshchannel_key (float *index, short *sel) return firsticu; } +/* apparently within active object context */ static void mouse_action(int selectmode) { bAction *act; @@ -795,16 +782,15 @@ void free_posebuf(void) void copy_posebuf (void) { - Object *ob; - - free_posebuf(); + Object *ob= OBACT; - ob=G.obpose; - if (!ob){ - error ("Copy buffer is empty"); + 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); @@ -928,92 +914,89 @@ static void flip_name (char *name) void paste_posebuf (int flip) { - Object *ob; + Object *ob= OBACT; bPoseChannel *chan, *pchan; float eul[4]; int newchan = 0; char name[32]; - ob=G.obpose; - if (!ob) + 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 */ - if (ob->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); + 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); - 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; + /* 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); - } + 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); - } + 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"); + /* 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) @@ -1545,6 +1528,7 @@ void deselect_meshchannel_keys (Key *key, int test) set_ipo_key_selection(key->ipo, sel); } +/* apparently within active object context */ void deselect_actionchannels (bAction *act, int test) { bActionChannel *chan; @@ -1618,8 +1602,10 @@ static void hilight_channel (bAction *act, bActionChannel *chan, short select) */ /* exported for outliner (ton) */ +/* apparently within active object context */ int select_channel(bAction *act, bActionChannel *chan, - int selectmode) { + int selectmode) +{ /* Select the channel based on the selection mode */ int flag; diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 9caafa1e4d2..9976e2180d7 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -430,51 +430,66 @@ void join_armature(void) /* **************** END tools on Editmode Armature **************** */ /* **************** PoseMode & EditMode *************************** */ -/* used by posemode as well editmode */ -static void * get_nearest_bone (int findunsel) +/* only for opengl selection indices */ +Bone *get_indexed_bone (Object *ob, int index) { - void *firstunSel=NULL, *firstSel=NULL, *data; - unsigned int buffer[MAXPICKBUF]; - short hits; - int i, takeNext=0; - int sel; - unsigned int hitresult; - Bone *bone; - EditBone *ebone; + bPoseChannel *pchan; + int a= 0; - persp(PERSP_VIEW); + if(ob->pose==NULL) return NULL; + index>>=16; // bone selection codes use left 2 bytes - glInitNames(); - hits= view3d_opengl_select(buffer, MAXPICKBUF, 0, 0, 0, 0); + for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) { + if(a==index) return pchan->bone; + } + return NULL; +} - /* See if there are any selected bones in this group */ - if (hits){ - for (i=0; i< hits; i++){ - hitresult = buffer[3+(i*4)]; - if (!(hitresult & BONESEL_NOSEL)){ - - /* Determine which points are selected */ - hitresult &= ~(BONESEL_ANY); - - /* Determine what the current bone is */ - if (!G.obedit){ - bone = get_indexed_bone(OBACT, hitresult); +/* See if there are any selected bones in this buffer */ +static void *get_bone_from_selectbuffer(Base *base, unsigned int *buffer, short hits, short findunsel) +{ + Object *ob= base->object; + Bone *bone; + EditBone *ebone; + void *firstunSel=NULL, *firstSel=NULL, *data; + unsigned int hitresult; + short i, takeNext=0, sel; + + for (i=0; i< hits; i++){ + hitresult = buffer[3+(i*4)]; + if (hitresult & BONESEL_ANY){ + + /* Determine which points are selected */ + hitresult &= ~(BONESEL_ANY); + + /* Determine what the current bone is */ + if (G.obedit==NULL) { + /* no singular posemode, so check for correct object */ + if(base->selcol == (hitresult & 0xFFFF)) { + bone = get_indexed_bone(ob, hitresult); if (findunsel) sel = (bone->flag & BONE_SELECTED); else - sel = !(bone->flag & BONE_SELECTED); + sel = !(bone->flag & BONE_SELECTED); + data = bone; } - else{ - ebone = BLI_findlink(&G.edbo, hitresult); - if (findunsel) - sel = (ebone->flag & BONE_SELECTED); - else - sel = !(ebone->flag & BONE_SELECTED); - - data = ebone; + else { + data= NULL; + sel= 0; } + } + else{ + ebone = BLI_findlink(&G.edbo, hitresult); + if (findunsel) + sel = (ebone->flag & BONE_SELECTED); + else + sel = !(ebone->flag & BONE_SELECTED); + data = ebone; + } + + if(data) { if (sel) { if(!firstSel) firstSel= data; takeNext=1; @@ -487,13 +502,28 @@ static void * get_nearest_bone (int findunsel) } } } - - if (firstunSel) - return firstunSel; - else - return firstSel; } + if (firstunSel) + return firstunSel; + else + return firstSel; +} + +/* used by posemode as well editmode */ +static void *get_nearest_bone (short findunsel) +{ + unsigned int buffer[MAXPICKBUF]; + short hits; + + persp(PERSP_VIEW); + + glInitNames(); + hits= view3d_opengl_select(buffer, MAXPICKBUF, 0, 0, 0, 0); + + if (hits) + return get_bone_from_selectbuffer(BASACT, buffer, hits, findunsel); + return NULL; } @@ -534,14 +564,14 @@ void select_bone_by_name (bArmature *arm, char *name, int select) break; } -static void selectconnected_posebonechildren (Bone *bone) +static void selectconnected_posebonechildren (Object *ob, Bone *bone) { Bone *curBone; if (!(bone->flag & BONE_IK_TOPARENT)) return; - select_actionchannel_by_name (G.obpose->action, bone->name, !(G.qual & LR_SHIFTKEY)); + select_actionchannel_by_name (ob->action, bone->name, !(G.qual & LR_SHIFTKEY)); if (G.qual & LR_SHIFTKEY) bone->flag &= ~BONE_SELECTED; @@ -549,13 +579,17 @@ static void selectconnected_posebonechildren (Bone *bone) bone->flag |= BONE_SELECTED; for (curBone=bone->childbase.first; curBone; curBone=curBone->next){ - selectconnected_posebonechildren (curBone); + selectconnected_posebonechildren (ob, curBone); } } +/* within active object context */ void selectconnected_posearmature(void) { Bone *bone, *curBone, *next; + Object *ob= OBACT; + + if(!ob || !ob->pose) return; if (G.qual & LR_SHIFTKEY) bone= get_nearest_bone(0); @@ -567,7 +601,7 @@ void selectconnected_posearmature(void) /* Select parents */ for (curBone=bone; curBone; curBone=next){ - select_actionchannel_by_name (G.obpose->action, curBone->name, !(G.qual & LR_SHIFTKEY)); + select_actionchannel_by_name (ob->action, curBone->name, !(G.qual & LR_SHIFTKEY)); if (G.qual & LR_SHIFTKEY) curBone->flag &= ~BONE_SELECTED; else @@ -581,7 +615,7 @@ void selectconnected_posearmature(void) /* Select children */ for (curBone=bone->childbase.first; curBone; curBone=next){ - selectconnected_posebonechildren (curBone); + selectconnected_posebonechildren (ob, curBone); } countall(); // flushes selection! @@ -1608,56 +1642,55 @@ static int clear_active_flag(Object *ob, Bone *bone, void *data) return 0; } -/* - Handles right-clicking for selection - of bones in armature pose modes. - */ -void mousepose_armature(void) + +/* called from editview.c, for mode-less pose selection */ +void do_pose_selectbuffer(Base *base, unsigned int *buffer, short hits) { + Object *ob= base->object; Bone *nearBone; + + if (!ob || !ob->pose) return; - if (!G.obpose) return; - - nearBone = get_nearest_bone(1); + nearBone= get_bone_from_selectbuffer(base, buffer, hits, 1); if (nearBone) { if (!(G.qual & LR_SHIFTKEY)){ - deselectall_posearmature(0); + deselectall_posearmature(ob, 0); nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL|BONE_ACTIVE); - select_actionchannel_by_name(G.obpose->action, nearBone->name, 1); + select_actionchannel_by_name(ob->action, nearBone->name, 1); } else { if (nearBone->flag & BONE_SELECTED) { /* if not active, we make it active */ if((nearBone->flag & BONE_ACTIVE)==0) { - bArmature *arm= G.obpose->data; - bone_looper(G.obpose, arm->bonebase.first, NULL, clear_active_flag); + bArmature *arm= ob->data; + bone_looper(ob, arm->bonebase.first, NULL, clear_active_flag); nearBone->flag |= BONE_ACTIVE; } else { nearBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL|BONE_ACTIVE); - select_actionchannel_by_name(G.obpose->action, nearBone->name, 0); + select_actionchannel_by_name(ob->action, nearBone->name, 0); } } else{ - bArmature *arm= G.obpose->data; - bone_looper(G.obpose, arm->bonebase.first, NULL, clear_active_flag); + bArmature *arm= ob->data; + bone_looper(ob, arm->bonebase.first, NULL, clear_active_flag); nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL|BONE_ACTIVE); - select_actionchannel_by_name(G.obpose->action, nearBone->name, 1); + select_actionchannel_by_name(ob->action, nearBone->name, 1); } } - } - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWACTION, 0); - allqueue(REDRAWIPO, 0); /* To force action ipo update */ - allqueue(REDRAWBUTSEDIT, 0); - allqueue(REDRAWBUTSOBJECT, 0); - allqueue(REDRAWOOPS, 0); - - rightmouse_transform(); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWACTION, 0); + allqueue(REDRAWIPO, 0); /* To force action ipo update */ + allqueue(REDRAWBUTSEDIT, 0); + allqueue(REDRAWBUTSOBJECT, 0); + allqueue(REDRAWOOPS, 0); + } + +// rightmouse_transform(); } @@ -1681,24 +1714,24 @@ static void deselect_bonechildren (Object *ob, Bone *bone, int mode) } } - -void deselectall_posearmature (int test) +void deselectall_posearmature (Object *ob, int test) { - Object *ob= OBACT; + bArmature *arm; + Bone *curBone; int selectmode = 0; - Bone* curBone; - /* we call this from outliner, also without obpose, but with OBACT set OK */ - if(G.obpose) ob= G.obpose; + /* 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 (!count_bones (get_armature(ob), BONE_SELECTED, 0)) + if (!count_bones (arm, BONE_SELECTED, 0)) selectmode = 1; } /* Set the flags accordingly */ - for (curBone=get_armature(ob)->bonebase.first; curBone; curBone=curBone->next) + for (curBone=arm->bonebase.first; curBone; curBone=curBone->next) deselect_bonechildren (ob, curBone, selectmode); allqueue(REDRAWBUTSEDIT, 0); @@ -2089,19 +2122,20 @@ static int hide_selected_pose_bone(Object *ob, Bone *bone, void *ptr) return 0; } +/* active object is armature */ void hide_selected_pose_bones(void) { bArmature *arm; - arm=get_armature (G.obpose); + arm= get_armature (OBACT); if (!arm) return; - bone_looper(G.obpose, arm->bonebase.first, NULL, + bone_looper(OBACT, arm->bonebase.first, NULL, hide_selected_pose_bone); - force_draw(1); + allqueue(REDRAWVIEW3D, 0); } static int hide_unselected_pose_bone(Object *ob, Bone *bone, void *ptr) @@ -2112,19 +2146,20 @@ static int hide_unselected_pose_bone(Object *ob, Bone *bone, void *ptr) return 0; } +/* active object is armature */ void hide_unselected_pose_bones(void) { bArmature *arm; - arm=get_armature (G.obpose); + arm=get_armature (OBACT); if (!arm) return; - bone_looper(G.obpose, arm->bonebase.first, NULL, + bone_looper(OBACT, arm->bonebase.first, NULL, hide_unselected_pose_bone); - force_draw(1); + allqueue(REDRAWVIEW3D, 0); } static int show_pose_bone(Object *ob, Bone *bone, void *ptr) @@ -2137,32 +2172,22 @@ static int show_pose_bone(Object *ob, Bone *bone, void *ptr) return 0; } +/* active object is armature in posemode */ void show_all_pose_bones(void) { bArmature *arm; - arm=get_armature (G.obpose); + arm=get_armature (OBACT); if (!arm) return; - bone_looper(G.obpose, arm->bonebase.first, NULL, + bone_looper(OBACT, arm->bonebase.first, NULL, show_pose_bone); - force_draw(1); + allqueue(REDRAWVIEW3D, 0); } -int is_delay_deform(void) -{ - bArmature *arm; - - arm=get_armature (G.obpose); - - if (!arm) - return 0; - - return (arm->flag & ARM_DELAYDEFORM); -} /* ************* RENAMING DISASTERS ************ */ diff --git a/source/blender/src/editconstraint.c b/source/blender/src/editconstraint.c index 4a6ee3f7682..58786e30282 100644 --- a/source/blender/src/editconstraint.c +++ b/source/blender/src/editconstraint.c @@ -97,45 +97,41 @@ ListBase *get_constraint_client_channels (int forcevalid) return NULL; /* See if we are a bone constraint */ - if (G.obpose){ - switch (G.obpose->type){ - case OB_ARMATURE: - { - bActionChannel *achan; - bPoseChannel *pchan; + if (ob->flag & OB_POSEMODE) { + bActionChannel *achan; + bPoseChannel *pchan; - pchan = get_active_posechannel(); - if (!pchan) break; + pchan = get_active_posechannel(); + if (pchan) { + + /* Make sure we have an action */ + if (!ob->action){ + if (!forcevalid) + return NULL; - /* Make sure we have an action */ - if (!G.obpose->action){ - if (!forcevalid) - return NULL; - - G.obpose->action=add_empty_action(); - } + ob->action=add_empty_action(); + } + + /* Make sure we have an actionchannel */ + achan = get_named_actionchannel(ob->action, pchan->name); + if (!achan){ + if (!forcevalid) + return NULL; - /* Make sure we have an actionchannel */ - achan = get_named_actionchannel(G.obpose->action, pchan->name); - if (!achan){ - if (!forcevalid) - return NULL; - - achan = MEM_callocN (sizeof(bActionChannel), "actionChannel"); + achan = MEM_callocN (sizeof(bActionChannel), "actionChannel"); - strcpy (achan->name, pchan->name); - sprintf (ipstr, "%s.%s", G.obpose->action->id.name+2, achan->name); - ipstr[23]=0; - achan->ipo= add_ipo(ipstr, ID_AC); - - BLI_addtail (&G.obpose->action->chanbase, achan); - } + strcpy (achan->name, pchan->name); + sprintf (ipstr, "%s.%s", ob->action->id.name+2, achan->name); + ipstr[23]=0; + achan->ipo= add_ipo(ipstr, ID_AC); - return &achan->constraintChannels; + BLI_addtail (&ob->action->chanbase, achan); } + + return &achan->constraintChannels; } } - + /* else we return object constraints */ return &ob->constraintChannels; } @@ -160,26 +156,21 @@ ListBase *get_constraint_client(char *name, short *clientType, void **clientdata if (name) strcpy (name, ob->id.name+2); - if (G.obpose){ - switch (G.obpose->type){ - case OB_ARMATURE: - { - bPoseChannel *pchan; + if (ob->flag & OB_POSEMODE) { + bPoseChannel *pchan; - pchan = get_active_posechannel(); - if (!pchan) break; + pchan = get_active_posechannel(); + if (pchan) { - /* Is the bone the client? */ - if (clientType) - *clientType = TARGET_BONE; - if (clientdata) - *clientdata = pchan->bone; - if (name) - sprintf (name, "%s>>%s", name, pchan->name); + /* Is the bone the client? */ + if (clientType) + *clientType = TARGET_BONE; + if (clientdata) + *clientdata = pchan->bone; + if (name) + sprintf (name, "%s>>%s", name, pchan->name); - list = &pchan->constraints; - } - break; + list = &pchan->constraints; } } diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c index 1a360d85e90..06dae9de624 100644 --- a/source/blender/src/editipo.c +++ b/source/blender/src/editipo.c @@ -3877,9 +3877,9 @@ void common_insertkey() } else if(curarea->spacetype==SPACE_VIEW3D) { - + ob= OBACT; - if (G.obpose) { + if (ob && (ob->flag & OB_POSEMODE)) { strcpy(menustr, "Insert Key%t|Loc%x0|Rot%x1|Size%x2|LocRot%x3|LocRotSize%x4|Avail%x9"); } else { @@ -3888,12 +3888,12 @@ void common_insertkey() if TESTBASELIB(base) break; base= base->next; } - if(base==0) return; + if(base==NULL) return; strcpy(menustr, "Insert Key%t|Loc%x0|Rot%x1|Size%x2|LocRot%x3|LocRotSize%x4|Layer%x5|Avail%x9"); } - if( (ob = OBACT)) { + if(ob) { if(ob->type==OB_MESH) strcat(menustr, "| %x6|Mesh%x7"); else if(ob->type==OB_LATTICE) strcat(menustr, "| %x6|Lattice%x7"); else if(ob->type==OB_CURVE) strcat(menustr, "| %x6|Curve%x7"); @@ -3904,7 +3904,7 @@ void common_insertkey() event= pupmenu(menustr); if(event== -1) return; - if(event==7) { + if(event==7) { // ob != NULL if(ob->type==OB_MESH) insert_meshkey(ob->data, 0); else if ELEM(ob->type, OB_CURVE, OB_SURF) insert_curvekey(ob->data); else if(ob->type==OB_LATTICE) insert_lattkey(ob->data); @@ -3924,21 +3924,18 @@ void common_insertkey() } } - base= FIRSTBASE; - if (G.obpose){ + if (ob && (ob->flag & OB_POSEMODE)){ bAction *act; bPose *pose; bPoseChannel *chan; bActionChannel *achan; - ob = G.obpose; - /* Get action & pose from object */ act=ob->action; pose=ob->pose; if (!act){ - act= G.obpose->action=add_empty_action(); + act= ob->action= add_empty_action(); /* this sets the non-pinned open ipowindow(s) to show the action curve */ ob->ipowin= ID_AC; allqueue(REDRAWIPO, ob->ipowin); @@ -3950,14 +3947,13 @@ void common_insertkey() error ("No pose!"); /* Should never happen */ } - if (act->id.lib) - { + if (act->id.lib) { error ("Can't key libactions"); return; } + set_pose_keys(ob); // sets chan->flag to POSE_KEY if bone selected - for (chan=pose->chanbase.first; chan; chan=chan->next) - { + for (chan=pose->chanbase.first; chan; chan=chan->next) { if (chan->flag & POSE_KEY){ // set_action_key(act, chan); if(event==0 || event==3 ||event==4) { @@ -3990,13 +3986,14 @@ void common_insertkey() remake_action_ipos(act); } - DAG_object_flush_update(G.scene, G.obpose, OB_RECALC_DATA); + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); allqueue(REDRAWIPO, 0); allqueue(REDRAWACTION, 0); allqueue(REDRAWNLA, 0); } else { + base= FIRSTBASE; while(base) { if TESTBASELIB(base) { id= (ID *)(base->object); diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 1bf24cffb97..e82e0e6ebba 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -241,7 +241,6 @@ void delete_obj(int ok) Base *base; int islamp= 0; - if(G.obpose) return; if(G.obedit) return; if(G.scene->id.lib) return; @@ -250,7 +249,7 @@ void delete_obj(int ok) Base *nbase= base->next; if TESTBASE(base) { - if(ok==0 && (ok=okee("Erase selected"))==0) return; + if(ok==0 && (ok=okee("Erase selected Object(s)"))==0) return; if(base->object->type==OB_LAMP) islamp= 1; free_and_unlink_base(base); @@ -870,56 +869,49 @@ void clear_object(char mode) else if(mode=='o') str= "Clear origin"; else return; - if (G.obpose){ - - switch (G.obpose->type){ - case OB_ARMATURE: - clear_armature (G.obpose, mode); - break; - } - - allqueue(REDRAWVIEW3D, 0); - BIF_undo_push(str); - return; - } - base= FIRSTBASE; while(base) { if TESTBASELIB(base) { ob= base->object; - if(mode=='r') { - memset(ob->rot, 0, 3*sizeof(float)); - memset(ob->drot, 0, 3*sizeof(float)); - QuatOne(ob->quat); - QuatOne(ob->dquat); - } - else if(mode=='g') { - memset(ob->loc, 0, 3*sizeof(float)); - memset(ob->dloc, 0, 3*sizeof(float)); + if(ob->flag & OB_POSEMODE) { + // no test if we got armature; could be in future... + clear_armature(ob, mode); } - else if(mode=='s') { - memset(ob->dsize, 0, 3*sizeof(float)); - ob->size[0]= 1.0; - ob->size[1]= 1.0; - ob->size[2]= 1.0; - } - else if(mode=='o') { - if(ob->parent) { - v1= ob->loc; - v3= ob->parentinv[3]; - - Mat3CpyMat4(mat, ob->parentinv); - VECCOPY(v3, v1); - v3[0]= -v3[0]; - v3[1]= -v3[1]; - v3[2]= -v3[2]; - Mat3MulVecfl(mat, v3); + else { + + if(mode=='r') { + memset(ob->rot, 0, 3*sizeof(float)); + memset(ob->drot, 0, 3*sizeof(float)); + QuatOne(ob->quat); + QuatOne(ob->dquat); } - } - - ob->recalc |= OB_RECALC_OB; - + else if(mode=='g') { + memset(ob->loc, 0, 3*sizeof(float)); + memset(ob->dloc, 0, 3*sizeof(float)); + } + else if(mode=='s') { + memset(ob->dsize, 0, 3*sizeof(float)); + ob->size[0]= 1.0; + ob->size[1]= 1.0; + ob->size[2]= 1.0; + } + else if(mode=='o') { + if(ob->parent) { + v1= ob->loc; + v3= ob->parentinv[3]; + + Mat3CpyMat4(mat, ob->parentinv); + VECCOPY(v3, v1); + v3[0]= -v3[0]; + v3[1]= -v3[1]; + v3[2]= -v3[2]; + Mat3MulVecfl(mat, v3); + } + } + + ob->recalc |= OB_RECALC_OB; + } } base= base->next; } @@ -1120,10 +1112,8 @@ void make_parent(void) { Base *base; Object *par; - short qual, mode=0; - char *bonestr=NULL; Bone *bone=NULL; - int bonenr; + short qual, mode=0; if(G.scene->id.lib) return; if(G.obedit) { @@ -1194,57 +1184,58 @@ void make_parent(void) } } else if(par->type == OB_ARMATURE){ - - base= FIRSTBASE; - while(base) { - if TESTBASELIB(base) { - if(base!=BASACT) { - if(base->object->type==OB_MESH) { - mode= pupmenu("Make Parent To%t|Bone %x1|Armature %x2|Object %x3"); - break; - } - else { - mode= pupmenu("Make Parent To %t|Bone %x1|Object %x3"); - break; - } + int bonenr; + char *bonestr=NULL; + + base= FIRSTBASE; + while(base) { + if TESTBASELIB(base) { + if(base!=BASACT) { + if(base->object->type==OB_MESH) { + mode= pupmenu("Make Parent To%t|Bone %x1|Armature %x2|Object %x3"); + break; + } + else { + mode= pupmenu("Make Parent To %t|Bone %x1|Object %x3"); + break; } } - base= base->next; } - - switch (mode){ - case 1: - mode=PARBONE; - /* Make bone popup menu */ - - bonestr = make_bone_menu(par); + base= base->next; + } + + switch (mode){ + case 1: + mode=PARBONE; + /* Make bone popup menu */ - bonenr= pupmenu_col(bonestr, 20); - if (bonestr) - MEM_freeN (bonestr); - - if (bonenr==-1){ - allqueue(REDRAWVIEW3D, 0); - return; - } + bonestr = make_bone_menu(par); - bone=get_indexed_bone(par, bonenr); - if (!bone){ - // error ("Invalid bone!"); - allqueue(REDRAWVIEW3D, 0); - return; - } + bonenr= pupmenu_col(bonestr, 20); + if (bonestr) + MEM_freeN (bonestr); + + if (bonenr==-1){ + allqueue(REDRAWVIEW3D, 0); + return; + } - break; - case 2: - mode=PARSKEL; - break; - case 3: - mode=PAROBJECT; - break; - default: + bone= get_indexed_bone(par, bonenr<<16); // function uses selection codes + if (!bone){ + allqueue(REDRAWVIEW3D, 0); return; } + + break; + case 2: + mode=PARSKEL; + break; + case 3: + mode=PAROBJECT; + break; + default: + return; + } } else { if(qual & LR_SHIFTKEY) { @@ -1286,7 +1277,7 @@ void make_parent(void) /* the ifs below are horrible code (ton) */ - if (par->type==OB_ARMATURE){ + if (par->type==OB_ARMATURE) { base->object->partype= mode; if (bone) strcpy (base->object->parsubstr, bone->name); @@ -1449,9 +1440,6 @@ void enter_editmode(void) } else G.obedit= NULL; - if (G.obpose) - exit_posemode (1); - scrarea_queue_headredraw(curarea); } @@ -1891,21 +1879,22 @@ void split_font() void special_editmenu(void) { + Object *ob= OBACT; extern short editbutflag; extern float doublimit; float fac; int nr,ret; short randfac,numcuts; - if(G.obpose) { - pose_special_editmenu(); - } - else if(G.obedit==NULL) { - - if(!OBACT) return; + if(ob==NULL) return; + + if(G.obedit==NULL) { - if(G.f & G_FACESELECT) { - Mesh *me= get_mesh(OBACT); + if(ob->flag & OB_POSEMODE) { + pose_special_editmenu(); + } + else if(G.f & G_FACESELECT) { + Mesh *me= get_mesh(ob); TFace *tface; int a; @@ -1946,7 +1935,7 @@ void special_editmenu(void) BIF_undo_push("Change texture face"); } else if(G.f & G_VERTEXPAINT) { - Mesh *me= get_mesh(OBACT); + Mesh *me= get_mesh(ob); if(me==0 || (me->mcol==NULL && me->tface==NULL) ) return; @@ -1964,29 +1953,25 @@ void special_editmenu(void) } else { Base *base, *base_select= NULL; - Object *ob= OBACT; // Get the active object mesh. Mesh *me= get_mesh(ob); - // If the active object is a mesh... + // Booleans, if the active object is a mesh... if (me && ob->id.lib==NULL) { + // Bring up a little menu with the boolean operation choices on. nr= pupmenu("Boolean %t|Intersect%x1|Union%x2|Difference%x3"); - if (nr > 0) { // user has made a choice of a menu element. // All of the boolean functions require 2 mesh objects // we search through the object list to find the other // selected item and make sure it is distinct and a mesh. - base= FIRSTBASE; - while(base) { + for(base= FIRSTBASE; base; base= base->next) { if TESTBASELIB(base) { - if(base->object != OBACT) base_select= base; + if(base->object != ob) base_select= base; } - - base= base->next; } if (base_select) { @@ -2011,7 +1996,7 @@ void special_editmenu(void) allqueue(REDRAWVIEW3D, 0); } - else if (OBACT->type == OB_FONT) { + else if (ob->type == OB_FONT) { nr= pupmenu("Split %t|Characters%x1"); if (nr > 0) { switch(nr) { @@ -2024,7 +2009,6 @@ void special_editmenu(void) else if(G.obedit->type==OB_MESH) { nr= pupmenu("Specials%t|Subdivide%x1|Subdivide Multi%x2|Subdivide Multi Fractal%x3|Subdivide Multi Smooth - WIP%x12|Subdivide Smooth Old%x13|Merge%x4|Remove Doubles%x5|Hide%x6|Reveal%x7|Select Swap%x8|Flip Normals %x9|Smooth %x10|Bevel %x11"); - //if(nr>0) waitcursor(1); switch(nr) { case 1: @@ -2033,8 +2017,6 @@ void special_editmenu(void) esubdivideflag(1, 0.0, editbutflag,numcuts,0); BIF_undo_push("ESubdivide Single"); - //subdivideflag(1, 0.0, editbutflag); - //BIF_undo_push("Subdivide"); break; case 2: numcuts = 2; @@ -3949,159 +3931,164 @@ void adduplicate(int noTrans) if TESTBASELIB(base) { ob= base->object; - obn= copy_object(ob); - obn->recalc |= OB_RECALC; - - basen= MEM_mallocN(sizeof(Base), "duplibase"); - *basen= *base; - BLI_addhead(&G.scene->base, basen); /* addhead: prevent eternal loop */ - basen->object= obn; - base->flag &= ~SELECT; - basen->flag &= ~OB_FROMGROUP; - - if(BASACT==base) BASACT= basen; + if(ob->flag & OB_POSEMODE) { + ; // nothing? + } + else { + obn= copy_object(ob); + obn->recalc |= OB_RECALC; + + basen= MEM_mallocN(sizeof(Base), "duplibase"); + *basen= *base; + BLI_addhead(&G.scene->base, basen); /* addhead: prevent eternal loop */ + basen->object= obn; + base->flag &= ~SELECT; + basen->flag &= ~OB_FROMGROUP; + + if(BASACT==base) BASACT= basen; - /* duplicates using userflags */ - - if(dupflag & USER_DUP_IPO) { - id= (ID *)obn->ipo; - if(id) { - ID_NEW_US( obn->ipo) - else obn->ipo= copy_ipo(obn->ipo); - id->us--; - } - /* Handle constraint ipos */ - for (chan=obn->constraintChannels.first; chan; chan=chan->next){ - id= (ID *)chan->ipo; + /* duplicates using userflags */ + + if(dupflag & USER_DUP_IPO) { + id= (ID *)obn->ipo; if(id) { - ID_NEW_US( chan->ipo) - else chan->ipo= copy_ipo(chan->ipo); + ID_NEW_US( obn->ipo) + else obn->ipo= copy_ipo(obn->ipo); id->us--; } - } - } - if(dupflag & USER_DUP_ACT){ - id= (ID *)obn->action; - if (id){ - ID_NEW_US(obn->action) - else{ - obn->action= copy_action(obn->action); - obn->activecon=NULL; + /* Handle constraint ipos */ + for (chan=obn->constraintChannels.first; chan; chan=chan->next){ + id= (ID *)chan->ipo; + if(id) { + ID_NEW_US( chan->ipo) + else chan->ipo= copy_ipo(chan->ipo); + id->us--; + } } - id->us--; } - } - if(dupflag & USER_DUP_MAT) { - for(a=0; a<obn->totcol; a++) { - id= (ID *)obn->mat[a]; - if(id) { - ID_NEW_US(obn->mat[a]) - else obn->mat[a]= copy_material(obn->mat[a]); + if(dupflag & USER_DUP_ACT){ + id= (ID *)obn->action; + if (id){ + ID_NEW_US(obn->action) + else{ + obn->action= copy_action(obn->action); + obn->activecon=NULL; + } id->us--; } } - } - - id= obn->data; - didit= 0; - - switch(obn->type) { - case OB_MESH: - if(dupflag & USER_DUP_MESH) { - ID_NEW_US2( obn->data ) - else { - obn->data= copy_mesh(obn->data); - didit= 1; + if(dupflag & USER_DUP_MAT) { + for(a=0; a<obn->totcol; a++) { + id= (ID *)obn->mat[a]; + if(id) { + ID_NEW_US(obn->mat[a]) + else obn->mat[a]= copy_material(obn->mat[a]); + id->us--; + } } - id->us--; } - break; - case OB_CURVE: - if(dupflag & USER_DUP_CURVE) { - ID_NEW_US2(obn->data ) - else { - obn->data= copy_curve(obn->data); - didit= 1; + + id= obn->data; + didit= 0; + + switch(obn->type) { + case OB_MESH: + if(dupflag & USER_DUP_MESH) { + ID_NEW_US2( obn->data ) + else { + obn->data= copy_mesh(obn->data); + didit= 1; + } + id->us--; } - id->us--; - } - break; - case OB_SURF: - if(dupflag & USER_DUP_SURF) { - ID_NEW_US2( obn->data ) - else { - obn->data= copy_curve(obn->data); - didit= 1; + break; + case OB_CURVE: + if(dupflag & USER_DUP_CURVE) { + ID_NEW_US2(obn->data ) + else { + obn->data= copy_curve(obn->data); + didit= 1; + } + id->us--; } - id->us--; - } - break; - case OB_FONT: - if(dupflag & USER_DUP_FONT) { - ID_NEW_US2( obn->data ) - else { - obn->data= copy_curve(obn->data); - didit= 1; + break; + case OB_SURF: + if(dupflag & USER_DUP_SURF) { + ID_NEW_US2( obn->data ) + else { + obn->data= copy_curve(obn->data); + didit= 1; + } + id->us--; } - id->us--; - } - break; - case OB_MBALL: - if(dupflag & USER_DUP_MBALL) { - ID_NEW_US2(obn->data ) - else { - obn->data= copy_mball(obn->data); - didit= 1; + break; + case OB_FONT: + if(dupflag & USER_DUP_FONT) { + ID_NEW_US2( obn->data ) + else { + obn->data= copy_curve(obn->data); + didit= 1; + } + id->us--; } - id->us--; - } - break; - case OB_LAMP: - if(dupflag & USER_DUP_LAMP) { + break; + case OB_MBALL: + if(dupflag & USER_DUP_MBALL) { + ID_NEW_US2(obn->data ) + else { + obn->data= copy_mball(obn->data); + didit= 1; + } + id->us--; + } + break; + case OB_LAMP: + if(dupflag & USER_DUP_LAMP) { + ID_NEW_US2(obn->data ) + else obn->data= copy_lamp(obn->data); + id->us--; + } + break; + + case OB_ARMATURE: + obn->recalc |= OB_RECALC_DATA; + if(obn->pose) obn->pose->flag |= POSE_RECALC; + + if(dupflag & USER_DUP_ARM) { + ID_NEW_US2(obn->data ) + else { + obn->data= copy_armature(obn->data); + didit= 1; + } + id->us--; + } + + break; + + /* always dupli's */ + case OB_LATTICE: ID_NEW_US2(obn->data ) - else obn->data= copy_lamp(obn->data); + else obn->data= copy_lattice(obn->data); id->us--; - } - break; - - case OB_ARMATURE: - obn->recalc |= OB_RECALC_DATA; - if(obn->pose) obn->pose->flag |= POSE_RECALC; - - if(dupflag & USER_DUP_ARM) { + break; + case OB_CAMERA: ID_NEW_US2(obn->data ) - else { - obn->data= copy_armature(obn->data); - didit= 1; - } + else obn->data= copy_camera(obn->data); id->us--; + break; } - break; - - /* always dupli's */ - case OB_LATTICE: - ID_NEW_US2(obn->data ) - else obn->data= copy_lattice(obn->data); - id->us--; - break; - case OB_CAMERA: - ID_NEW_US2(obn->data ) - else obn->data= copy_camera(obn->data); - id->us--; - break; - } - - if(dupflag & USER_DUP_MAT) { - matarar= give_matarar(obn); - if(didit && matarar) { - for(a=0; a<obn->totcol; a++) { - id= (ID *)(*matarar)[a]; - if(id) { - ID_NEW_US( (*matarar)[a] ) - else (*matarar)[a]= copy_material((*matarar)[a]); - - id->us--; + if(dupflag & USER_DUP_MAT) { + matarar= give_matarar(obn); + if(didit && matarar) { + for(a=0; a<obn->totcol; a++) { + id= (ID *)(*matarar)[a]; + if(id) { + ID_NEW_US( (*matarar)[a] ) + else (*matarar)[a]= copy_material((*matarar)[a]); + + id->us--; + } } } } diff --git a/source/blender/src/editoops.c b/source/blender/src/editoops.c index 4ffdf762f58..e9eacda9753 100644 --- a/source/blender/src/editoops.c +++ b/source/blender/src/editoops.c @@ -409,7 +409,7 @@ static void do_activate_oops(Oops *oops) base= base->next; } if(base) { - if(G.obedit==NULL && G.obpose==NULL) set_active_base(base); /* editview.c */ + if(G.obedit==NULL) set_active_base(base); /* editview.c */ allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWOOPS, 0); allqueue(REDRAWINFO, 1); diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c index 20e1b4c96aa..3f60bb00157 100644 --- a/source/blender/src/editview.c +++ b/source/blender/src/editview.c @@ -44,6 +44,7 @@ #include "IMB_imbuf.h" #include "PIL_time.h" +#include "DNA_action_types.h" #include "DNA_armature_types.h" #include "DNA_meta_types.h" #include "DNA_mesh_types.h" @@ -233,6 +234,30 @@ static int lasso_inside_edge(short mcords[][2], short moves, short *v1, short *v /* warning; lasso select with backbuffer-check draws in backbuf with persp(PERSP_WIN) and returns with persp(PERSP_VIEW). After lasso select backbuf is not OK */ +void do_lasso_select_pose(Object *ob, short mcords[][2], short moves, short select) +{ + bPoseChannel *pchan; + float vec[3]; + short sco1[2], sco2[2]; + + if(ob->type!=OB_ARMATURE || ob->pose==NULL) return; + + for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + VECCOPY(vec, pchan->pose_head); + Mat4MulVecfl(ob->obmat, vec); + project_short(vec, sco1); + VECCOPY(vec, pchan->pose_tail); + Mat4MulVecfl(ob->obmat, vec); + project_short(vec, sco2); + + if(lasso_inside_edge(mcords, moves, sco1, sco2)) { + if(select) pchan->bone->flag |= BONE_SELECTED; + else pchan->bone->flag &= ~(BONE_ACTIVE|BONE_SELECTED); + } + } +} + + static void do_lasso_select_objects(short mcords[][2], short moves, short select) { Base *base; @@ -246,6 +271,9 @@ static void do_lasso_select_objects(short mcords[][2], short moves, short select else base->flag &= ~SELECT; base->object->flag= base->flag; } + if(base->object->flag & OB_POSEMODE) { + do_lasso_select_pose(base->object, mcords, moves, select); + } } } } @@ -622,19 +650,19 @@ static char interpret_move(short mcord[][2], int count) /* return 1 to denote gesture did something, also does lasso */ int gesture(void) { - short mcords[MOVES_LASSO][2]; // the larger size - int i= 1, end= 0, a; unsigned short event=0; + int i= 1, end= 0, a; + short mcords[MOVES_LASSO][2]; // the larger size short mval[2], val, timer=0, mousebut, lasso=0, maxmoves; if (U.flag & USER_LMOUSESELECT) mousebut = R_MOUSE; else mousebut = L_MOUSE; + /* check for lasso */ if(G.qual & LR_CTRLKEY) { if(curarea->spacetype==SPACE_VIEW3D) { if(G.obedit==NULL) { if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT)) return 0; - if(G.obpose) return 0; } lasso= 1; } @@ -1016,6 +1044,60 @@ static Base *mouse_select_menu(unsigned int *buffer, int hits, short *mval) } } +/* we want a select buffer with bones, if there are... */ +/* so check three selection levels and compare */ +static short mixed_bones_object_selectbuffer(unsigned int *buffer, short *mval) +{ + int offs; + short a, hits15, hits9=0, hits5=0; + short has_bones15=0, has_bones9=0, has_bones5=0; + + hits15= view3d_opengl_select(buffer, MAXPICKBUF, mval[0]-14, mval[1]-14, mval[0]+14, mval[1]+14); + if(hits15) { + for(a=0; a<hits15; a++) if(buffer[4*a+3] & 0xFFFF0000) has_bones15= 1; + + offs= 4*hits15; + hits9= view3d_opengl_select(buffer+offs, MAXPICKBUF-offs, mval[0]-9, mval[1]-9, mval[0]+9, mval[1]+9); + if(hits9) { + for(a=0; a<hits9; a++) if(buffer[offs+4*a+3] & 0xFFFF0000) has_bones9= 1; + + offs+= 4*hits9; + hits5= view3d_opengl_select(buffer+offs, MAXPICKBUF-offs, mval[0]-5, mval[1]-5, mval[0]+5, mval[1]+5); + if(hits5) { + for(a=0; a<hits5; a++) if(buffer[offs+4*a+3] & 0xFFFF0000) has_bones5= 1; + } + } + + if(has_bones5) { + offs= 4*hits15 + 4*hits9; + memcpy(buffer, buffer+offs, 4*offs); + return hits5; + } + if(has_bones9) { + offs= 4*hits15; + memcpy(buffer, buffer+offs, 4*offs); + return hits9; + } + if(has_bones15) { + return hits15; + } + + if(hits5) { + offs= 4*hits15 + 4*hits9; + memcpy(buffer, buffer+offs, 4*offs); + return hits5; + } + if(hits9) { + offs= 4*hits15; + memcpy(buffer, buffer+offs, 4*offs); + return hits9; + } + return hits15; + } + + return 0; +} + void mouse_select(void) { Base *base, *startbase=NULL, *basact=NULL, *oldbasact=NULL; @@ -1057,12 +1139,17 @@ void mouse_select(void) } } else { - hits= view3d_opengl_select(buffer, MAXPICKBUF, mval[0]-7, mval[1]-7, mval[0]+7, mval[1]+7); - if(hits==0) hits= view3d_opengl_select(buffer, MAXPICKBUF, mval[0]-21, mval[1]-21, mval[0]+21, mval[1]+21); - + /* if objects have posemode set, the bones are in the same selection buffer */ + + hits= mixed_bones_object_selectbuffer(buffer, mval); + if(hits>0) { + int has_bones= 0; - if(G.qual & LR_ALTKEY) basact= mouse_select_menu(buffer, hits, mval); + for(a=0; a<hits; a++) if(buffer[4*a+3] & 0xFFFF0000) has_bones= 1; + + if(has_bones==0 && (G.qual & LR_ALTKEY)) + basact= mouse_select_menu(buffer, hits, mval); else { static short lastmval[2]={-100, -100}; int donearest= 0; @@ -1071,7 +1158,8 @@ void mouse_select(void) if(G.vd->drawtype>OB_WIRE) { donearest= 1; if( ABS(mval[0]-lastmval[0])<3 && ABS(mval[1]-lastmval[1])<3) { - donearest= 0; + if(!has_bones) // hrms, if theres bones we always do nearest + donearest= 0; } } lastmval[0]= mval[0]; lastmval[1]= mval[1]; @@ -1080,16 +1168,28 @@ void mouse_select(void) unsigned int min= 0xFFFFFFFF; int selcol= 0, notcol=0; - /* prevent not being able to select active object... */ - if(BASACT && (BASACT->flag & SELECT) && hits>1) notcol= BASACT->selcol; + + if(has_bones) { + /* we skip non-bone hits */ + for(a=0; a<hits; a++) { + if( min > buffer[4*a+1] && (buffer[4*a+3] & 0xFFFF0000) ) { + min= buffer[4*a+1]; + selcol= buffer[4*a+3] & 0xFFFF; + } + } + } + else { + /* only exclude active object when it is selected... */ + if(BASACT && (BASACT->flag & SELECT) && hits>1) notcol= BASACT->selcol; - for(a=0; a<hits; a++) { - /* index was converted */ - if( min > buffer[4*a+1] && notcol!=buffer[4*a+3]) { - min= buffer[4*a+1]; - selcol= buffer[4*a+3]; + for(a=0; a<hits; a++) { + if( min > buffer[4*a+1] && notcol!=(buffer[4*a+3] & 0xFFFF)) { + min= buffer[4*a+1]; + selcol= buffer[4*a+3] & 0xFFFF; + } } } + base= FIRSTBASE; while(base) { if(base->lay & G.vd->lay) { @@ -1105,9 +1205,16 @@ void mouse_select(void) while(base) { if(base->lay & G.vd->lay) { for(a=0; a<hits; a++) { - /* index was converted */ - if(base->selcol==buffer[(4*a)+3]) { - basact= base; + if(has_bones) { + /* skip non-bone objects */ + if((buffer[4*a+3] & 0xFFFF0000)) { + if(base->selcol== (buffer[(4*a)+3] & 0xFFFF)) + basact= base; + } + } + else { + if(base->selcol== (buffer[(4*a)+3] & 0xFFFF)) + basact= base; } } } @@ -1115,15 +1222,21 @@ void mouse_select(void) if(basact) break; base= base->next; - if(base==0) base= FIRSTBASE; + if(base==NULL) base= FIRSTBASE; if(base==startbase) break; } } } + + if(has_bones && basact) { + do_pose_selectbuffer(basact, buffer, hits); + } } } + /* so, do we have something selected? */ if(basact) { + if(G.obedit) { /* only do select */ deselectall_except(basact); @@ -1155,11 +1268,17 @@ void mouse_select(void) // for visual speed, only in wire mode if(G.vd->drawtype==OB_WIRE) { - if(oldbasact && oldbasact != basact && (oldbasact->lay & G.vd->lay)) - draw_object_ext(oldbasact); - draw_object_ext(basact); + /* however, not for posemodes */ + if(basact->object->flag & OB_POSEMODE); + else if(oldbasact && (oldbasact->object->flag & OB_POSEMODE)); + else { + if(oldbasact && oldbasact != basact && (oldbasact->lay & G.vd->lay)) + draw_object_ext(oldbasact); + draw_object_ext(basact); + } } + /* selecting a non-mesh, should end a couple of modes... */ if(basact->object->type!=OB_MESH) { if(G.f & G_WEIGHTPAINT) { set_wpaint(); /* toggle */ @@ -1171,6 +1290,7 @@ void mouse_select(void) set_faceselect(); /* toggle */ } } + /* also because multiple 3d windows can be open */ allqueue(REDRAWVIEW3D, 0); @@ -1183,7 +1303,6 @@ void mouse_select(void) allqueue(REDRAWHEADERS, 0); /* To force display update for the posebutton */ } - } countall(); @@ -1230,335 +1349,311 @@ void borderselect(void) MetaElem *ml; unsigned int buffer[MAXPICKBUF]; int a, index; - short hits, val, tel; + short hits, val; - if(G.obedit==0 && (G.f & G_FACESELECT)) { + if(G.obedit==NULL && (G.f & G_FACESELECT)) { face_borderselect(); return; } + setlinestyle(2); val= get_border(&rect, 3); setlinestyle(0); - if(val) { - if (G.obpose){ - if(G.obpose->type==OB_ARMATURE) { - Bone *bone; - hits= view3d_opengl_select(buffer, MAXPICKBUF, rect.xmin, rect.ymin, rect.xmax, rect.ymax); - base= FIRSTBASE; - for (a=0; a<hits; a++){ - index = buffer[(4*a)+3]; - if (val==LEFTMOUSE){ - if (index != -1){ - bone = get_indexed_bone(G.obpose, index &~(BONESEL_TIP|BONESEL_ROOT)); - if(bone) { - bone->flag |= BONE_SELECTED; - select_actionchannel_by_name(G.obpose->action, bone->name, 1); - } - } - } - else{ - if (index != -1){ - bone = get_indexed_bone(G.obpose, index &~(BONESEL_TIP|BONESEL_ROOT)); - if(bone) { - bone->flag &= ~(BONE_ACTIVE|BONE_SELECTED); - select_actionchannel_by_name(G.obpose->action, bone->name, 0); + + if(val==0) + return; + + if(G.obedit) { + if(G.obedit->type==OB_MESH) { + EditMesh *em = G.editMesh; + EditVert *eve; + EditEdge *eed; + EditFace *efa; + int index, bbsel=0; // bbsel: no clip needed with screencoords + + bbsel= EM_init_backbuf_border(rect.xmin, rect.ymin, rect.xmax, rect.ymax); + + if(G.scene->selectmode & SCE_SELECT_VERTEX) { + if(bbsel==0) calc_meshverts_ext(); /* clips, drawobject.c */ + index= em_wireoffs; + for(eve= em->verts.first; eve; eve= eve->next, index++) { + if(eve->h==0) { + if(bbsel || (eve->xs>rect.xmin && eve->xs<rect.xmax && eve->ys>rect.ymin && eve->ys<rect.ymax)) { + if(EM_check_backbuf_border(index)) { + if(val==LEFTMOUSE) eve->f|= 1; + else eve->f&= 254; } } } } - - allqueue(REDRAWBUTSEDIT, 0); - allqueue(REDRAWBUTSOBJECT, 0); - allqueue(REDRAWACTION, 0); - allqueue(REDRAWNLA, 0); - allqueue(REDRAWVIEW3D, 0); } - } - else if(G.obedit) { - /* used to be a bigger test, also included sector and life */ - if(G.obedit->type==OB_MESH) { - EditMesh *em = G.editMesh; - EditVert *eve; - EditEdge *eed; - EditFace *efa; - int index, bbsel=0; // bbsel: no clip needed with screencoords + if(G.scene->selectmode & SCE_SELECT_EDGE) { + short done= 0; - bbsel= EM_init_backbuf_border(rect.xmin, rect.ymin, rect.xmax, rect.ymax); - - if(G.scene->selectmode & SCE_SELECT_VERTEX) { - if(bbsel==0) calc_meshverts_ext(); /* clips, drawobject.c */ - index= em_wireoffs; - for(eve= em->verts.first; eve; eve= eve->next, index++) { - if(eve->h==0) { - if(bbsel || (eve->xs>rect.xmin && eve->xs<rect.xmax && eve->ys>rect.ymin && eve->ys<rect.ymax)) { - if(EM_check_backbuf_border(index)) { - if(val==LEFTMOUSE) eve->f|= 1; - else eve->f&= 254; - } + calc_meshverts_ext_f2(); /* doesnt clip, drawobject.c */ + index= em_solidoffs; + /* two stages, for nice edge select first do 'both points in rect' + also when bbsel is true */ + for(eed= em->edges.first; eed; eed= eed->next, index++) { + if(eed->h==0) { + if(edge_fully_inside_rect(rect, eed->v1->xs, eed->v1->ys, eed->v2->xs, eed->v2->ys)) { + if(EM_check_backbuf_border(index)) { + EM_select_edge(eed, val==LEFTMOUSE); + done = 1; } } } } - if(G.scene->selectmode & SCE_SELECT_EDGE) { - short done= 0; - - calc_meshverts_ext_f2(); /* doesnt clip, drawobject.c */ + + if(done==0) { index= em_solidoffs; - /* two stages, for nice edge select first do 'both points in rect' - also when bbsel is true */ for(eed= em->edges.first; eed; eed= eed->next, index++) { if(eed->h==0) { - if(edge_fully_inside_rect(rect, eed->v1->xs, eed->v1->ys, eed->v2->xs, eed->v2->ys)) { - if(EM_check_backbuf_border(index)) { + if(bbsel) { + if(EM_check_backbuf_border(index)) EM_select_edge(eed, val==LEFTMOUSE); - done = 1; - } } - } - } - - if(done==0) { - index= em_solidoffs; - for(eed= em->edges.first; eed; eed= eed->next, index++) { - if(eed->h==0) { - if(bbsel) { - if(EM_check_backbuf_border(index)) - EM_select_edge(eed, val==LEFTMOUSE); - } - else if(edge_inside_rect(rect, eed->v1->xs, eed->v1->ys, eed->v2->xs, eed->v2->ys)) { - EM_select_edge(eed, val==LEFTMOUSE); - } + else if(edge_inside_rect(rect, eed->v1->xs, eed->v1->ys, eed->v2->xs, eed->v2->ys)) { + EM_select_edge(eed, val==LEFTMOUSE); } } } } - - if(G.scene->selectmode & SCE_SELECT_FACE) { - if(bbsel==0) calc_mesh_facedots_ext(); - index= 1; - for(efa= em->faces.first; efa; efa= efa->next, index++) { - if(efa->h==0) { - if(bbsel || (efa->xs>rect.xmin && efa->xs<rect.xmax && efa->ys>rect.ymin && efa->ys<rect.ymax)) { - if(EM_check_backbuf_border(index)) { - EM_select_face_fgon(efa, val==LEFTMOUSE); - } + } + + if(G.scene->selectmode & SCE_SELECT_FACE) { + if(bbsel==0) calc_mesh_facedots_ext(); + index= 1; + for(efa= em->faces.first; efa; efa= efa->next, index++) { + if(efa->h==0) { + if(bbsel || (efa->xs>rect.xmin && efa->xs<rect.xmax && efa->ys>rect.ymin && efa->ys<rect.ymax)) { + if(EM_check_backbuf_border(index)) { + EM_select_face_fgon(efa, val==LEFTMOUSE); } } } } - - EM_free_backbuf_border(); - - EM_selectmode_flush(); - allqueue(REDRAWVIEW3D, 0); - } - else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) { + + EM_free_backbuf_border(); - calc_nurbverts_ext(); /* drawobject.c */ - nu= editNurb.first; - while(nu) { - if((nu->type & 7)==CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; - while(a--) { - if(bezt->hide==0) { - if(bezt->s[0][0]>rect.xmin && bezt->s[0][0]<rect.xmax) { - if(bezt->s[0][1]>rect.ymin && bezt->s[0][1]<rect.ymax) { - if(val==LEFTMOUSE) bezt->f1|= 1; - else bezt->f1 &= ~1; - } + EM_selectmode_flush(); + allqueue(REDRAWVIEW3D, 0); + + } + else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) { + + calc_nurbverts_ext(); /* drawobject.c */ + nu= editNurb.first; + while(nu) { + if((nu->type & 7)==CU_BEZIER) { + bezt= nu->bezt; + a= nu->pntsu; + while(a--) { + if(bezt->hide==0) { + if(bezt->s[0][0]>rect.xmin && bezt->s[0][0]<rect.xmax) { + if(bezt->s[0][1]>rect.ymin && bezt->s[0][1]<rect.ymax) { + if(val==LEFTMOUSE) bezt->f1|= 1; + else bezt->f1 &= ~1; } - if(bezt->s[1][0]>rect.xmin && bezt->s[1][0]<rect.xmax) { - if(bezt->s[1][1]>rect.ymin && bezt->s[1][1]<rect.ymax) { - if(val==LEFTMOUSE) { - bezt->f1|= 1; bezt->f2|= 1; bezt->f3|= 1; - } - else { - bezt->f1 &= ~1; bezt->f2 &= ~1; bezt->f3 &= ~1; - } + } + if(bezt->s[1][0]>rect.xmin && bezt->s[1][0]<rect.xmax) { + if(bezt->s[1][1]>rect.ymin && bezt->s[1][1]<rect.ymax) { + if(val==LEFTMOUSE) { + bezt->f1|= 1; bezt->f2|= 1; bezt->f3|= 1; } - } - if(bezt->s[2][0]>rect.xmin && bezt->s[2][0]<rect.xmax) { - if(bezt->s[2][1]>rect.ymin && bezt->s[2][1]<rect.ymax) { - if(val==LEFTMOUSE) bezt->f3|= 1; - else bezt->f3 &= ~1; + else { + bezt->f1 &= ~1; bezt->f2 &= ~1; bezt->f3 &= ~1; } } } - bezt++; + if(bezt->s[2][0]>rect.xmin && bezt->s[2][0]<rect.xmax) { + if(bezt->s[2][1]>rect.ymin && bezt->s[2][1]<rect.ymax) { + if(val==LEFTMOUSE) bezt->f3|= 1; + else bezt->f3 &= ~1; + } + } } + bezt++; } - else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; - while(a--) { - if(bp->hide==0) { - if(bp->s[0]>rect.xmin && bp->s[0]<rect.xmax) { - if(bp->s[1]>rect.ymin && bp->s[1]<rect.ymax) { - if(val==LEFTMOUSE) bp->f1|= 1; - else bp->f1 &= ~1; - } + } + else { + bp= nu->bp; + a= nu->pntsu*nu->pntsv; + while(a--) { + if(bp->hide==0) { + if(bp->s[0]>rect.xmin && bp->s[0]<rect.xmax) { + if(bp->s[1]>rect.ymin && bp->s[1]<rect.ymax) { + if(val==LEFTMOUSE) bp->f1|= 1; + else bp->f1 &= ~1; } } - bp++; } + bp++; } - nu= nu->next; } - allqueue(REDRAWVIEW3D, 0); + nu= nu->next; } - else if(G.obedit->type==OB_MBALL) { - hits= view3d_opengl_select(buffer, MAXPICKBUF, rect.xmin, rect.ymin, rect.xmax, rect.ymax); - - ml= editelems.first; - - while(ml) { - for(a=0; a<hits; a++) { - if(ml->selcol1==buffer[ (4 * a) + 3 ]) { - ml->flag |= MB_SCALE_RAD; - if(val==LEFTMOUSE) ml->flag |= SELECT; - else ml->flag &= ~SELECT; - break; - } - if(ml->selcol2==buffer[ (4 * a) + 3 ]) { - ml->flag &= ~MB_SCALE_RAD; - if(val==LEFTMOUSE) ml->flag |= SELECT; - else ml->flag &= ~SELECT; - break; - } + allqueue(REDRAWVIEW3D, 0); + } + else if(G.obedit->type==OB_MBALL) { + hits= view3d_opengl_select(buffer, MAXPICKBUF, rect.xmin, rect.ymin, rect.xmax, rect.ymax); + + ml= editelems.first; + + while(ml) { + for(a=0; a<hits; a++) { + if(ml->selcol1==buffer[ (4 * a) + 3 ]) { + ml->flag |= MB_SCALE_RAD; + if(val==LEFTMOUSE) ml->flag |= SELECT; + else ml->flag &= ~SELECT; + break; + } + if(ml->selcol2==buffer[ (4 * a) + 3 ]) { + ml->flag &= ~MB_SCALE_RAD; + if(val==LEFTMOUSE) ml->flag |= SELECT; + else ml->flag &= ~SELECT; + break; } - ml= ml->next; } - allqueue(REDRAWVIEW3D, 0); + ml= ml->next; } - else if(G.obedit->type==OB_ARMATURE) { - EditBone *ebone; - - hits= view3d_opengl_select(buffer, MAXPICKBUF, rect.xmin, rect.ymin, rect.xmax, rect.ymax); - - base= FIRSTBASE; - for (a=0; a<hits; a++){ - index = buffer[(4*a)+3]; - if (val==LEFTMOUSE){ - if (index!=-1) { - ebone = BLI_findlink(&G.edbo, index & ~(BONESEL_ANY)); - if (index & (BONESEL_TIP|BONESEL_BONE)) - ebone->flag |= BONE_TIPSEL; - if (index & (BONESEL_ROOT|BONESEL_BONE)) - ebone->flag |= BONE_ROOTSEL; - } + allqueue(REDRAWVIEW3D, 0); + } + else if(G.obedit->type==OB_ARMATURE) { + EditBone *ebone; + + hits= view3d_opengl_select(buffer, MAXPICKBUF, rect.xmin, rect.ymin, rect.xmax, rect.ymax); + + base= FIRSTBASE; + for (a=0; a<hits; a++){ + index = buffer[(4*a)+3]; + if (val==LEFTMOUSE){ + if (index!=-1) { + ebone = BLI_findlink(&G.edbo, index & ~(BONESEL_ANY)); + if (index & (BONESEL_TIP|BONESEL_BONE)) + ebone->flag |= BONE_TIPSEL; + if (index & (BONESEL_ROOT|BONESEL_BONE)) + ebone->flag |= BONE_ROOTSEL; } - else{ - if (index!=-1){ - ebone = BLI_findlink(&G.edbo, index & ~(BONESEL_ANY)); - if (index & (BONESEL_TIP|BONESEL_BONE)) - ebone->flag &= ~BONE_TIPSEL; - if (index & (BONESEL_ROOT|BONESEL_BONE)) - ebone->flag &= ~BONE_ROOTSEL; - } + } + else{ + if (index!=-1){ + ebone = BLI_findlink(&G.edbo, index & ~(BONESEL_ANY)); + if (index & (BONESEL_TIP|BONESEL_BONE)) + ebone->flag &= ~BONE_TIPSEL; + if (index & (BONESEL_ROOT|BONESEL_BONE)) + ebone->flag &= ~BONE_ROOTSEL; } } - - allqueue(REDRAWBUTSEDIT, 0); - allqueue(REDRAWBUTSOBJECT, 0); - allqueue(REDRAWACTION, 0); - allqueue(REDRAWVIEW3D, 0); } - else if(G.obedit->type==OB_LATTICE) { - - calc_lattverts_ext(); - - bp= editLatt->def; - - a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw; - while(a--) { - if(bp->hide==0) { - if(bp->s[0]>rect.xmin && bp->s[0]<rect.xmax) { - if(bp->s[1]>rect.ymin && bp->s[1]<rect.ymax) { - if(val==LEFTMOUSE) bp->f1|= 1; - else bp->f1 &= ~1; - } + + allqueue(REDRAWBUTSEDIT, 0); + allqueue(REDRAWBUTSOBJECT, 0); + allqueue(REDRAWACTION, 0); + allqueue(REDRAWVIEW3D, 0); + } + else if(G.obedit->type==OB_LATTICE) { + + calc_lattverts_ext(); + + bp= editLatt->def; + + a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw; + while(a--) { + if(bp->hide==0) { + if(bp->s[0]>rect.xmin && bp->s[0]<rect.xmax) { + if(bp->s[1]>rect.ymin && bp->s[1]<rect.ymax) { + if(val==LEFTMOUSE) bp->f1|= 1; + else bp->f1 &= ~1; } } - bp++; } - allqueue(REDRAWVIEW3D, 0); + bp++; } - + allqueue(REDRAWVIEW3D, 0); } - else { - unsigned int *vbuffer=NULL; /* selection buffer */ - unsigned int *col; /* color in buffer */ - short selecting = 0; - - if (val==LEFTMOUSE) - selecting = 1; - - vbuffer = MEM_mallocN(4 * G.totobj * sizeof(unsigned int), "selection buffer"); - hits= view3d_opengl_select(vbuffer, 4*G.totobj, rect.xmin, rect.ymin, rect.xmax, rect.ymax); - /* - LOGIC NOTES (theeth): - The buffer and ListBase have the same relative order, which makes the selection - very simple. Loop through both data sets at the same time, if the color - is the same as the object, we have a hit and can move to the next color - and object pair, if not, just move to the next object, - keeping the same color until we have a hit. - - The buffer order is defined by OGL standard, hopefully no stupid GFX card - does it incorrectly. - */ - - if (hits) { /* no need to loop if there's no hit */ - base= FIRSTBASE; - col = vbuffer + 3; - while(base && hits) { - Base *next = base->next; - if(base->lay & G.vd->lay) { - if (base->selcol == *col) { + } + else { // no editmode, unified for bones and objects + Bone *bone; + unsigned int *vbuffer=NULL; /* selection buffer */ + unsigned int *col; /* color in buffer */ + short selecting = 0; + + if (val==LEFTMOUSE) + selecting = 1; + + /* selection buffer now has bones potentially too, so we add MAXPICKBUF */ + vbuffer = MEM_mallocN(4 * (G.totobj+MAXPICKBUF) * sizeof(unsigned int), "selection buffer"); + hits= view3d_opengl_select(vbuffer, 4*(G.totobj+MAXPICKBUF), rect.xmin, rect.ymin, rect.xmax, rect.ymax); + /* + LOGIC NOTES (theeth): + The buffer and ListBase have the same relative order, which makes the selection + very simple. Loop through both data sets at the same time, if the color + is the same as the object, we have a hit and can move to the next color + and object pair, if not, just move to the next object, + keeping the same color until we have a hit. + + The buffer order is defined by OGL standard, hopefully no stupid GFX card + does it incorrectly. + */ + + if (hits) { /* no need to loop if there's no hit */ + base= FIRSTBASE; + col = vbuffer + 3; + while(base && hits) { + Base *next = base->next; + if(base->lay & G.vd->lay) { + while (base->selcol == (*col & 0xFFFF)) { // we got an object + + if(*col & 0xFFFF0000) { // we got a bone + bone = get_indexed_bone(base->object, *col & ~(BONESEL_ANY)); + if(bone) { + if(selecting) { + bone->flag |= BONE_SELECTED; + select_actionchannel_by_name(base->object->action, bone->name, 1); + } + else { + bone->flag &= ~(BONE_ACTIVE|BONE_SELECTED); + select_actionchannel_by_name(base->object->action, bone->name, 0); + } + } + } + else { if (selecting) base->flag |= SELECT; else base->flag &= ~SELECT; base->object->flag= base->flag; - - col+=4; /* next color */ - hits--; } + + col+=4; /* next color */ + hits--; + if(hits==0) break; } - - base= next; } + + base= next; } - /* frontbuffer flush */ - glFlush(); - - MEM_freeN(vbuffer); - - allqueue(REDRAWDATASELECT, 0); - - /* because backbuf drawing */ - tel= 1; - base= FIRSTBASE; - while(base) { - /* each base because of multiple windows */ - base->selcol = ((tel & 0xF00)<<12) - + ((tel & 0xF0)<<8) - + ((tel & 0xF)<<4); - tel++; - base= base->next; - } - /* new */ - allqueue(REDRAWBUTSLOGIC, 0); - allqueue(REDRAWNLA, 0); } - countall(); + /* frontbuffer flush */ + glFlush(); + + MEM_freeN(vbuffer); - allqueue(REDRAWINFO, 0); + allqueue(REDRAWDATASELECT, 0); + allqueue(REDRAWBUTSLOGIC, 0); + allqueue(REDRAWNLA, 0); } - if(val) BIF_undo_push("Border select"); + countall(); + + allqueue(REDRAWBUTSOBJECT, 0); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWINFO, 0); + + BIF_undo_push("Border select"); } /* end of borderselect() */ diff --git a/source/blender/src/header_buttonswin.c b/source/blender/src/header_buttonswin.c index eaa9323b448..0aeedd64091 100644 --- a/source/blender/src/header_buttonswin.c +++ b/source/blender/src/header_buttonswin.c @@ -295,94 +295,6 @@ void buttons_active_id(ID **id, ID **idfrom) } } -#if 0 -static void validate_bonebutton(void *bonev, void *data2_unused){ - Bone *bone= bonev; - bArmature *arm; - - arm = get_armature(G.obpose); - unique_bone_name(bone, arm); -} - - -static int bonename_exists(Bone *orig, char *name, ListBase *list) -{ - Bone *curbone; - - for (curbone=list->first; curbone; curbone=curbone->next){ - /* Check this bone */ - if (orig!=curbone){ - if (!strcmp(curbone->name, name)) - return 1; - } - - /* Check Children */ - if (bonename_exists(orig, name, &curbone->childbase)) - return 1; - } - - return 0; - -} - -static void unique_bone_name (Bone *bone, bArmature *arm) -{ - char tempname[64]; - char oldname[64]; - int number; - char *dot; - - if (!arm) - return; - - strcpy(oldname, bone->name); - - /* See if we even need to do this */ - if (!bonename_exists(bone, bone->name, &arm->bonebase)) - return; - - /* Strip off the suffix */ - dot=strchr(bone->name, '.'); - if (dot) - *dot=0; - - for (number = 1; number <=999; number++){ - sprintf (tempname, "%s.%03d", bone->name, number); - - if (!bonename_exists(bone, tempname, &arm->bonebase)){ - strcpy (bone->name, tempname); - return; - } - } -} - -static uiBlock *sbuts_context_menu(void *arg_unused) -{ - uiBlock *block; - short yco = 0; - - block= uiNewBlock(&curarea->uiblocks, "context_options", UI_EMBOSSP, UI_HELV, curarea->headwin); - - /* should be branches from tree */ - uiDefIconTextButS(block, BUTM, B_REDR, ICON_SCENE_DEHLT, "Scene|F10", 0, yco-=22, 100, 20, &G.buts->mainb, 0.0, 0.0, 0, 0, ""); - uiDefIconTextButS(block, BUTM, B_REDR, ICON_EDIT, "Editing|F9", 0, yco-=22, 100, 20, &G.buts->mainb, 4.0, 0.0, 0, 0, ""); - uiDefIconTextButS(block, BUTM, B_REDR, ICON_OBJECT, "Object|F6", 0, yco-=22, 100, 20, &G.buts->mainb, 1.0, 0.0, 0, 0, ""); - uiDefIconTextButS(block, BUTM, B_REDR, ICON_MATERIAL_DEHLT, "Shading|F5", 0, yco-=22, 100, 20, &G.buts->mainb, 3.0, 0.0, 0, 0, ""); - uiDefIconTextButS(block, BUTM, B_REDR, ICON_GAME, "Logic|F4", 0, yco-=22, 100, 20, &G.buts->mainb, 6.0, 0.0, 0, 0, ""); - uiDefIconTextButS(block, BUTM, B_REDR, ICON_SCRIPT, "Script", 0, yco-=22, 100, 20, &G.buts->mainb, 5.0, 0.0, 0, 0, ""); - - if(curarea->headertype==HEADERTOP) { - uiBlockSetDirection(block, UI_DOWN); - } - else { - uiBlockSetDirection(block, UI_TOP); - uiBlockFlipOrder(block); - } - - return block; -} -#endif - static void do_buts_view_shadingmenu(void *arg, int event) { G.buts->mainb = CONTEXT_SHADING; @@ -686,15 +598,6 @@ void buts_buttons(void) // uiDefIconBut(block, BUT, B_BUTSHOME, ICON_HOME, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Zooms window to home view showing all items (HOMEKEY)"); // xco+=XIC; - /* mainb menu*/ - /* (this could be done later with a dynamic tree and branches, also for python) */ - //{ - // char mainbname[8][12]= {" Scene", " Object", " Types", " Shading", " Editing", " Script", " Logic"}; - // char mainbicon[8]= {ICON_SCENE_DEHLT, ICON_OBJECT, ICON_BBOX, ICON_MATERIAL_DEHLT, ICON_EDIT, ICON_SCRIPT, ICON_GAME}; - // uiBut *but= uiDefIconTextBlockBut(block, sbuts_context_menu, NULL, mainbicon[G.buts->mainb], mainbname[G.buts->mainb], xco, 0, 90, YIC, "Set main context for button panels"); - // uiButClearFlag(but, UI_ICON_RIGHT); // this type has both flags set, and draws icon right.. uhh - // xco+= 90-XIC+10; - //} uiBlockBeginAlign(block); uiDefIconButS(block, ROW, B_REDR, ICON_GAME, xco, 0, XIC, YIC, &(G.buts->mainb), 0.0, (float)CONTEXT_LOGIC, 0, 0, "Logic (F4) "); uiDefIconButS(block, ROW, B_REDR, ICON_SCRIPT, xco+=XIC, 0, XIC, YIC, &(G.buts->mainb), 0.0, (float)CONTEXT_SCRIPT, 0, 0, "Script "); @@ -705,8 +608,6 @@ void buts_buttons(void) xco+= XIC; - // if(curarea->headertype==HEADERTOP) t_base= -3; else t_base= 4; - /* select the context to be drawn, per contex/tab the actual context is tested */ uiBlockSetEmboss(block, UI_EMBOSS); // normal switch(G.buts->mainb) { diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index 824e1c6c48f..ebb3843a346 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -1765,7 +1765,7 @@ char info_time_str[32]=""; static void info_text(int x, int y) { - Object *ob; + Object *ob= OBACT; extern float hashvectf[]; extern int mem_in_use; unsigned int swatch_color; @@ -1797,7 +1797,7 @@ static void info_text(int x, int y) sprintf(s," | Mem:%.2fM ", (mem_in_use>>10)/1024.0); } - else if(G.obpose) { + else if(ob && (ob->flag & OB_POSEMODE)) { sprintf(infostr,"Bo:%d-%d | Mem:%.2fM ", G.totbonesel, G.totbone, (mem_in_use>>10)/1024.0); } @@ -1805,7 +1805,6 @@ static void info_text(int x, int y) sprintf(infostr,"Ve:%d | Fa:%d | Ob:%d-%d | La:%d | Mem:%.2fM | Time:%s | ", G.totvert, G.totface, G.totobj, G.totobjsel, G.totlamp, (mem_in_use>>10)/1024.0, info_time_str); } - ob= OBACT; if(ob) { strcat(infostr, ob->id.name+2); } diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index b713d8d23b3..606169a0e85 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -91,6 +91,7 @@ #include "BIF_editmesh.h" #include "BIF_editmode_undo.h" #include "BIF_editview.h" +#include "BIF_gl.h" #include "BIF_interface.h" #include "BIF_mainqueue.h" #include "BIF_meshtools.h" @@ -101,7 +102,6 @@ #include "BIF_space.h" #include "BIF_toets.h" #include "BIF_toolbox.h" -#include "BIF_gl.h" #include "BIF_transform.h" #include "BPY_extern.h" @@ -124,13 +124,13 @@ * This can be cleaned when I make some new 'mode' icons. */ -#define V3D_OBJECTMODE_SEL ICON_OBJECT -#define V3D_EDITMODE_SEL ICON_EDITMODE_HLT +#define V3D_OBJECTMODE_SEL ICON_OBJECT +#define V3D_EDITMODE_SEL ICON_EDITMODE_HLT #define V3D_FACESELECTMODE_SEL ICON_FACESEL_HLT #define V3D_VERTEXPAINTMODE_SEL ICON_VPAINT_HLT #define V3D_TEXTUREPAINTMODE_SEL ICON_TPAINT_HLT #define V3D_WEIGHTPAINTMODE_SEL ICON_WPAINT_HLT -#define V3D_POSEMODE_SEL ICON_POSE_HLT +#define V3D_POSEMODE_SEL ICON_POSE_HLT #define TEST_EDITMESH if(G.obedit==0) return; \ if( (G.vd->lay & G.obedit->lay)==0 ) return; @@ -1071,12 +1071,12 @@ static void do_view3d_select_pose_armaturemenu(void *arg, int event) // extern void borderselect(void); switch(event) { - case 0: /* border select */ - borderselect(); - break; - case 2: /* Select/Deselect all */ - deselectall_posearmature(1); - break; + case 0: /* border select */ + borderselect(); + break; + case 2: /* Select/Deselect all */ + deselectall_posearmature(OBACT, 1); + break; } allqueue(REDRAWVIEW3D, 0); } @@ -3656,136 +3656,12 @@ void do_view3d_buttons(short event) scrarea_queue_headredraw(curarea); } break; + case B_LOCALVIEW: if(G.vd->localview) initlocalview(); else endlocalview(curarea); scrarea_queue_headredraw(curarea); break; - case B_EDITMODE: - if (G.f & G_VERTEXPAINT) { - /* Switch off vertex paint */ - G.f &= ~G_VERTEXPAINT; - } - if (G.f & G_WEIGHTPAINT){ - /* Switch off weight paint */ - G.f &= ~G_WEIGHTPAINT; - } -#ifdef NAN_TPT - if (G.f & G_TEXTUREPAINT) { - /* Switch off texture paint */ - G.f &= ~G_TEXTUREPAINT; - } -#endif /* NAN_VPT */ - if(G.obedit==NULL) { - enter_editmode(); - BIF_undo_push("Original"); // here, because all over code enter_editmode is abused - } - else exit_editmode(2); // freedata, and undo - scrarea_queue_headredraw(curarea); - break; - case B_POSEMODE: - /* if (G.obedit){ - error("Unable to perform function in EditMode"); - G.vd->flag &= ~V3D_POSEMODE; - scrarea_queue_headredraw(curarea); - } - else{ - */ - if (G.obpose==NULL) enter_posemode(); - else exit_posemode(1); - - allqueue(REDRAWHEADERS, 0); - - break; - case B_WPAINT: - if (G.f & G_VERTEXPAINT) { - /* Switch off vertex paint */ - G.f &= ~G_VERTEXPAINT; - } -#ifdef NAN_TPT - if ((!(G.f & G_WEIGHTPAINT)) && (G.f & G_TEXTUREPAINT)) { - /* Switch off texture paint */ - G.f &= ~G_TEXTUREPAINT; - } -#endif /* NAN_VPT */ - if(G.obedit) { - error("Unable to perform function in EditMode"); - G.vd->flag &= ~V3D_WEIGHTPAINT; - scrarea_queue_headredraw(curarea); - } - else if(G.obpose) { - error("Unable to perform function in PoseMode"); - G.vd->flag &= ~V3D_WEIGHTPAINT; - scrarea_queue_headredraw(curarea); - } - else set_wpaint(); - break; - case B_VPAINT: - if ((!(G.f & G_VERTEXPAINT)) && (G.f & G_WEIGHTPAINT)) { - G.f &= ~G_WEIGHTPAINT; - } -#ifdef NAN_TPT - if ((!(G.f & G_VERTEXPAINT)) && (G.f & G_TEXTUREPAINT)) { - /* Switch off texture paint */ - G.f &= ~G_TEXTUREPAINT; - } -#endif /* NAN_VPT */ - if(G.obedit) { - error("Unable to perform function in EditMode"); - G.vd->flag &= ~V3D_VERTEXPAINT; - scrarea_queue_headredraw(curarea); - } - else if(G.obpose) { - error("Unable to perform function in PoseMode"); - G.vd->flag &= ~V3D_VERTEXPAINT; - scrarea_queue_headredraw(curarea); - } - else set_vpaint(); - break; - -#ifdef NAN_TPT - case B_TEXTUREPAINT: - if (G.f & G_TEXTUREPAINT) { - G.f &= ~G_TEXTUREPAINT; - } - else { - if (G.obedit) { - error("Unable to perform function in EditMode"); - G.vd->flag &= ~V3D_TEXTUREPAINT; - } - else { - if (G.f & G_WEIGHTPAINT){ - /* Switch off weight paint */ - G.f &= ~G_WEIGHTPAINT; - } - if (G.f & G_VERTEXPAINT) { - /* Switch off vertex paint */ - G.f &= ~G_VERTEXPAINT; - } - if (G.f & G_FACESELECT) { - /* Switch off face select */ - G.f &= ~G_FACESELECT; - } - G.f |= G_TEXTUREPAINT; - scrarea_queue_headredraw(curarea); - } - } - break; -#endif /* NAN_TPT */ - - case B_FACESEL: - if(G.obedit) { - error("Unable to perform function in EditMode"); - G.vd->flag &= ~V3D_FACESELECT; - scrarea_queue_headredraw(curarea); - } - else if(G.obpose) { - error("Unable to perform function in PoseMode"); - G.vd->flag &= ~V3D_FACESELECT; - scrarea_queue_headredraw(curarea); - } - else set_faceselect(); - break; case B_VIEWBUT: @@ -3826,27 +3702,31 @@ void do_view3d_buttons(short event) viewmove(1); scrarea_queue_headredraw(curarea); break; + case B_MODESELECT: - if (G.vd->modeselect == V3D_OBJECTMODE_SEL) { + if (G.vd->modeselect == V3D_OBJECTMODE_SEL) { + Object *ob= OBACT; + G.vd->flag &= ~V3D_MODE; G.f &= ~G_VERTEXPAINT; /* Switch off vertex paint */ G.f &= ~G_TEXTUREPAINT; /* Switch off texture paint */ G.f &= ~G_WEIGHTPAINT; /* Switch off weight paint */ G.f &= ~G_FACESELECT; /* Switch off face select */ - if (G.obpose) exit_posemode(1); /* exit posemode */ + if(ob) exit_posemode(); /* exit posemode for active object */ if(G.obedit) exit_editmode(2); /* exit editmode and undo */ - } else if (G.vd->modeselect == V3D_EDITMODE_SEL) { + } + else if (G.vd->modeselect == V3D_EDITMODE_SEL) { if(!G.obedit) { G.vd->flag &= ~V3D_MODE; G.f &= ~G_VERTEXPAINT; /* Switch off vertex paint */ G.f &= ~G_TEXTUREPAINT; /* Switch off texture paint */ G.f &= ~G_WEIGHTPAINT; /* Switch off weight paint */ - if (G.obpose) exit_posemode(1); /* exit posemode */ enter_editmode(); BIF_undo_push("Original"); // here, because all over code enter_editmode is abused } - } else if (G.vd->modeselect == V3D_FACESELECTMODE_SEL) { + } + else if (G.vd->modeselect == V3D_FACESELECTMODE_SEL) { if ((G.obedit) && (G.f & G_FACESELECT)) { exit_editmode(2); /* exit editmode and undo */ } else if ((G.f & G_FACESELECT) && (G.f & G_VERTEXPAINT)) { @@ -3858,43 +3738,45 @@ void do_view3d_buttons(short event) G.f &= ~G_VERTEXPAINT; /* Switch off vertex paint */ G.f &= ~G_TEXTUREPAINT; /* Switch off texture paint */ G.f &= ~G_WEIGHTPAINT; /* Switch off weight paint */ - if (G.obpose) exit_posemode(1); /* exit posemode */ if (G.obedit) exit_editmode(2); /* exit editmode and undo */ set_faceselect(); } - } else if (G.vd->modeselect == V3D_VERTEXPAINTMODE_SEL) { + } + else if (G.vd->modeselect == V3D_VERTEXPAINTMODE_SEL) { if (!(G.f & G_VERTEXPAINT)) { G.vd->flag &= ~V3D_MODE; G.f &= ~G_TEXTUREPAINT; /* Switch off texture paint */ G.f &= ~G_WEIGHTPAINT; /* Switch off weight paint */ - if (G.obpose) exit_posemode(1); /* exit posemode */ if(G.obedit) exit_editmode(2); /* exit editmode and undo */ set_vpaint(); } - } else if (G.vd->modeselect == V3D_TEXTUREPAINTMODE_SEL) { + } + else if (G.vd->modeselect == V3D_TEXTUREPAINTMODE_SEL) { if (!(G.f & G_TEXTUREPAINT)) { G.vd->flag &= ~V3D_MODE; G.f &= ~G_VERTEXPAINT; /* Switch off vertex paint */ G.f &= ~G_WEIGHTPAINT; /* Switch off weight paint */ - if (G.obpose) exit_posemode(1); /* exit posemode */ if(G.obedit) exit_editmode(2); /* exit editmode and undo */ G.f |= G_TEXTUREPAINT; /* Switch on texture paint flag */ } - } else if (G.vd->modeselect == V3D_WEIGHTPAINTMODE_SEL) { + } + else if (G.vd->modeselect == V3D_WEIGHTPAINTMODE_SEL) { if (!(G.f & G_WEIGHTPAINT) && (OBACT && OBACT->type == OB_MESH) && ((((Mesh*)(OBACT->data))->dvert))) { G.vd->flag &= ~V3D_MODE; G.f &= ~G_VERTEXPAINT; /* Switch off vertex paint */ G.f &= ~G_TEXTUREPAINT; /* Switch off texture paint */ - if (G.obpose) exit_posemode(1); /* exit posemode */ if(G.obedit) exit_editmode(2); /* exit editmode and undo */ set_wpaint(); } - } else if (G.vd->modeselect == V3D_POSEMODE_SEL) { - if (!G.obpose) { + } + else if (G.vd->modeselect == V3D_POSEMODE_SEL) { + Object *ob= OBACT; + + if (ob && !(ob->flag & OB_POSEMODE)) { G.vd->flag &= ~V3D_MODE; if(G.obedit) exit_editmode(2); /* exit editmode and undo */ @@ -3903,6 +3785,7 @@ void do_view3d_buttons(short event) } allqueue(REDRAWVIEW3D, 1); break; + case B_AROUND: handle_view3d_around(); // copies to other 3d windows allqueue(REDRAWVIEW3D, 1); @@ -4027,18 +3910,18 @@ static void view3d_header_pulldowns(uiBlock *block, short *xcoord) if (OBACT && OBACT->type == OB_MESH) { uiDefPulldownBut(block, view3d_select_faceselmenu, NULL, "Select", xco,-2, xmax-3, 24, ""); } - } else if (G.obpose) { - if (OBACT && OBACT->type == OB_ARMATURE) { - uiDefPulldownBut(block, view3d_select_pose_armaturemenu, NULL, "Select", xco,-2, xmax-3, 24, ""); - } } else if ((G.f & G_VERTEXPAINT) || (G.f & G_TEXTUREPAINT) || (G.f & G_WEIGHTPAINT)) { uiDefBut(block, LABEL,0,"", xco, 0, xmax, 20, 0, 0, 0, 0, 0, ""); } else { - uiDefPulldownBut(block, view3d_select_objectmenu, NULL, "Select", xco,-2, xmax-3, 24, ""); + Object *ob= OBACT; + + if (ob && (ob->flag & OB_POSEMODE)) + uiDefPulldownBut(block, view3d_select_pose_armaturemenu, NULL, "Select", xco,-2, xmax-3, 24, ""); + else + uiDefPulldownBut(block, view3d_select_objectmenu, NULL, "Select", xco,-2, xmax-3, 24, ""); } xco+= xmax; - if (G.obedit) { if (OBACT && OBACT->type == OB_MESH) { xmax= GetButStringLength("Mesh"); @@ -4081,16 +3964,19 @@ static void view3d_header_pulldowns(uiBlock *block, short *xcoord) uiDefPulldownBut(block, view3d_faceselmenu, NULL, "Face", xco,-2, xmax-3, 24, ""); xco+= xmax; } - } else if (G.obpose) { - if (OBACT && OBACT->type == OB_ARMATURE) { + } else { + Object *ob= OBACT; + + if (ob && (ob->flag & OB_POSEMODE)) { xmax= GetButStringLength("Armature"); uiDefPulldownBut(block, view3d_pose_armaturemenu, NULL, "Armature", xco,-2, xmax-3, 24, ""); xco+= xmax; } - } else { - xmax= GetButStringLength("Object"); - uiDefPulldownBut(block, view3d_edit_objectmenu, NULL, "Object", xco,-2, xmax-3, 24, ""); - xco+= xmax; + else { + xmax= GetButStringLength("Object"); + uiDefPulldownBut(block, view3d_edit_objectmenu, NULL, "Object", xco,-2, xmax-3, 24, ""); + xco+= xmax; + } } *xcoord= xco; @@ -4099,6 +3985,7 @@ static void view3d_header_pulldowns(uiBlock *block, short *xcoord) void view3d_buttons(void) { uiBlock *block; + Object *ob= OBACT; int a; short xco = 0; @@ -4134,24 +4021,23 @@ void view3d_buttons(void) /* mode */ G.vd->modeselect = V3D_OBJECTMODE_SEL; - if (G.f & G_WEIGHTPAINT) G.vd->modeselect = V3D_WEIGHTPAINTMODE_SEL; + + if (G.obedit) G.vd->modeselect = V3D_EDITMODE_SEL; + else if(ob && (ob->flag & OB_POSEMODE)) G.vd->modeselect = V3D_POSEMODE_SEL; + else if (G.f & G_WEIGHTPAINT) G.vd->modeselect = V3D_WEIGHTPAINTMODE_SEL; else if (G.f & G_VERTEXPAINT) G.vd->modeselect = V3D_VERTEXPAINTMODE_SEL; else if (G.f & G_TEXTUREPAINT) G.vd->modeselect = V3D_TEXTUREPAINTMODE_SEL; else if(G.f & G_FACESELECT) G.vd->modeselect = V3D_FACESELECTMODE_SEL; - if (G.obpose) G.vd->modeselect = V3D_POSEMODE_SEL; - if (G.obedit) G.vd->modeselect = V3D_EDITMODE_SEL; G.vd->flag &= ~V3D_MODE; + + /* not sure what the G.vd->flag is useful for now... modeselect is confusing */ if(G.obedit) G.vd->flag |= V3D_EDITMODE; + if(ob && (ob->flag & OB_POSEMODE)) G.vd->flag |= V3D_POSEMODE; if(G.f & G_VERTEXPAINT) G.vd->flag |= V3D_VERTEXPAINT; if(G.f & G_WEIGHTPAINT) G.vd->flag |= V3D_WEIGHTPAINT; -#ifdef NAN_TPT if (G.f & G_TEXTUREPAINT) G.vd->flag |= V3D_TEXTUREPAINT; -#endif /* NAN_TPT */ if(G.f & G_FACESELECT) G.vd->flag |= V3D_FACESELECT; - if(G.obpose){ - G.vd->flag |= V3D_POSEMODE; - } uiDefIconTextButS(block, MENU, B_MODESELECT, (G.vd->modeselect),view3d_modeselect_pup() , xco,0,126,20, &(G.vd->modeselect), 0, 0, 0, 0, "Mode:"); @@ -4253,13 +4139,13 @@ void view3d_buttons(void) uiDefIconBut(block, BUT, B_VIEWRENDER, ICON_SCENE_DEHLT, xco,0,XIC,YIC, NULL, 0, 1.0, 0, 0, "Render this window (hold CTRL for anim)"); - if (G.obpose){ + if (ob && (ob->flag & OB_POSEMODE)) { xco+= XIC/2; if(curarea->headertype==HEADERTOP) { uiDefIconBut(block, BUT, B_ACTCOPY, ICON_COPYUP, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Copies the current pose to the buffer"); - uiSetButLock(G.obpose->id.lib!=0, "Can't edit library data"); + uiSetButLock(ob->id.lib!=0, "Can't edit library data"); uiDefIconBut(block, BUT, B_ACTPASTE, ICON_PASTEUP, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the pose from the buffer"); @@ -4271,7 +4157,7 @@ void view3d_buttons(void) uiDefIconBut(block, BUT, B_ACTCOPY, ICON_COPYDOWN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Copies the current pose to the buffer"); - uiSetButLock(G.obpose->id.lib!=0, "Can't edit library data"); + uiSetButLock(ob->id.lib!=0, "Can't edit library data"); uiDefIconBut(block, BUT, B_ACTPASTE, ICON_PASTEDOWN, xco+=XIC,0,XIC,YIC, 0, 0, 0, 0, 0, "Pastes the pose from the buffer"); diff --git a/source/blender/src/outliner.c b/source/blender/src/outliner.c index b6187897722..deceb45774d 100644 --- a/source/blender/src/outliner.c +++ b/source/blender/src/outliner.c @@ -907,7 +907,6 @@ static void tree_element_active_object(SpaceOops *soops, TreeElement *te) sce= (Scene *)outliner_search_back(soops, te, ID_SCE); if(sce && G.scene != sce) { if(G.obedit) exit_editmode(2); - if(G.obpose) exit_posemode(1); set_scene(sce); } @@ -939,7 +938,6 @@ static void tree_element_active_object(SpaceOops *soops, TreeElement *te) } if(ob!=G.obedit) exit_editmode(2); - if(ob!=G.obpose) exit_posemode(1); } static int tree_element_active_material(SpaceOops *soops, TreeElement *te, int set) @@ -1096,7 +1094,6 @@ static int tree_element_active_world(SpaceOops *soops, TreeElement *te, int set) if(set) { // make new scene active if(sce && G.scene != sce) { if(G.obedit) exit_editmode(2); - if(G.obpose) exit_posemode(1); set_scene(sce); } } @@ -1139,7 +1136,7 @@ static int tree_element_active_ipo(SpaceOops *soops, TreeElement *te, int set) deselect_actionchannels(ob->action, 0); select_channel(ob->action, chan, SELECT_ADD); allqueue(REDRAWACTION, ob->ipowin); - if(G.obpose) allqueue(REDRAWVIEW3D, ob->ipowin); + allqueue(REDRAWVIEW3D, ob->ipowin); } allqueue(REDRAWIPO, ob->ipowin); @@ -1206,7 +1203,7 @@ static int tree_element_active_posechannel(TreeElement *te, TreeStoreElem *tsele if(set) { if(G.qual & LR_SHIFTKEY); - else deselectall_posearmature(0); + else deselectall_posearmature(ob, 0); pchan->bone->flag |= BONE_SELECTED|BONE_ACTIVE; allqueue(REDRAWVIEW3D, 0); @@ -1295,11 +1292,11 @@ static int tree_element_active_pose(TreeElement *te, TreeStoreElem *tselem, int if(set) { if(G.obedit) exit_editmode(2); - if(G.obpose) exit_posemode(1); + if(ob->flag & OB_POSEMODE) exit_posemode(); else enter_posemode(); } else { - if(ob==G.obpose) return 1; + if(ob->flag & OB_POSEMODE) return 1; } return 0; } @@ -1378,12 +1375,10 @@ static int do_outliner_mouse_event(SpaceOops *soops, TreeElement *te, short even if(te->idcode==ID_SCE) { if(G.scene!=(Scene *)tselem->id) { if(G.obedit) exit_editmode(2); - if(G.obpose) exit_posemode(1); set_scene((Scene *)tselem->id); } } else if(ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { - if(G.obpose) exit_posemode(1); if(G.obedit) exit_editmode(2); else { enter_editmode(); @@ -1719,7 +1714,6 @@ static void object_delete_cb(TreeElement *te, TreeStoreElem *tselem) if(base) { // check also library later - if(G.obpose==base->object) exit_posemode(1); if(G.obedit==base->object) exit_editmode(2); if(base==BASACT) { diff --git a/source/blender/src/poseobject.c b/source/blender/src/poseobject.c index 064675281c0..741b38754c8 100644 --- a/source/blender/src/poseobject.c +++ b/source/blender/src/poseobject.c @@ -78,10 +78,8 @@ void enter_posemode(void) if(G.scene->id.lib) return; base= BASACT; if(base==NULL) return; - if((base->lay & G.vd->lay)==0) return; ob= base->object; - if(ob->data==NULL) return; if (ob->id.lib){ error ("Can't pose libdata"); @@ -93,7 +91,6 @@ void enter_posemode(void) arm= get_armature(ob); if( arm==NULL ) return; - G.obpose= ob; ob->flag |= OB_POSEMODE; base->flag= ob->flag; @@ -108,8 +105,6 @@ void enter_posemode(void) if (G.obedit) exit_editmode(1); G.f &= ~(G_VERTEXPAINT | G_FACESELECT | G_TEXTUREPAINT | G_WEIGHTPAINT); - - } void set_pose_keys (Object *ob) @@ -130,41 +125,34 @@ void set_pose_keys (Object *ob) } -void exit_posemode (int freedata) +void exit_posemode(void) { - Object *ob; + Object *ob= OBACT; Base *base= BASACT; - if(G.obpose==NULL) return; - - ob= G.obpose; + if(ob==NULL) return; + ob->flag &= ~OB_POSEMODE; base->flag= ob->flag; - G.obpose= NULL; - - if(freedata) { - setcursor_space(SPACE_VIEW3D, CURSOR_STD); - - countall(); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWOOPS, 0); - allqueue(REDRAWHEADERS, 0); - allqueue(REDRAWBUTSALL, 0); - } - else { - G.obpose= ob; - } + countall(); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWOOPS, 0); + allqueue(REDRAWHEADERS, 0); + allqueue(REDRAWBUTSALL, 0); scrarea_queue_headredraw(curarea); } void pose_special_editmenu(void) { + Object *ob= OBACT; bPoseChannel *pchan; short nr; - for(pchan= G.obpose->pose->chanbase.first; pchan; pchan= pchan->next) + if(!ob && !ob->pose) return; + + for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) if(pchan->bone->flag & BONE_ACTIVE) break; if(pchan==NULL) return; @@ -174,11 +162,11 @@ void pose_special_editmenu(void) for(con= pchan->constraints.first; con; con= con->next) { char *subtarget; - Object *ob= get_constraint_target(con, &subtarget); + Object *target= get_constraint_target(con, &subtarget); - if(ob==G.obpose) { + if(ob==target) { if(subtarget) { - pchan= get_pose_channel(G.obpose->pose, subtarget); + pchan= get_pose_channel(ob->pose, subtarget); pchan->bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; } } diff --git a/source/blender/src/renderwin.c b/source/blender/src/renderwin.c index 2f27b059663..fa0d786c9f8 100644 --- a/source/blender/src/renderwin.c +++ b/source/blender/src/renderwin.c @@ -66,6 +66,7 @@ #include "DNA_vec_types.h" #include "BKE_global.h" +#include "BKE_scene.h" #include "BKE_utildefines.h" #include "BIF_gl.h" diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 72636f38ed1..a690a6e3d16 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -717,13 +717,13 @@ void BIF_undo_menu(void) static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) { - unsigned short event= evt->event; - short val= evt->val; - char ascii= evt->ascii; View3D *v3d= sa->spacedata.first; - Object *ob; + Object *ob= OBACT; // do not change! float *curs; int doredraw= 0, pupval; + unsigned short event= evt->event; + short val= evt->val; + char ascii= evt->ascii; if(curarea->win==0) return; /* when it comes from sa->headqread() */ @@ -931,10 +931,6 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) mouse_mesh(); // loop select for 1 mousebutton dudes else if((G.obedit) && (G.qual == (LR_CTRLKEY|LR_ALTKEY|LR_SHIFTKEY))) mouse_mesh(); // loop select for 1 mousebutton dudes - else if(G.obpose) { - if (G.obpose->type==OB_ARMATURE) - mousepose_armature(); - } else if(G.qual==LR_CTRLKEY) mouse_select(); // also allow in editmode, for vertex parenting else if(G.f & G_FACESELECT) @@ -942,7 +938,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) else if( G.f & (G_VERTEXPAINT|G_TEXTUREPAINT)) sample_vpaint(); else - mouse_select(); + mouse_select(); // does poses too break; case WHEELUPMOUSE: /* Regular: Zoom in */ @@ -1006,7 +1002,6 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) break; case ONEKEY: - ob= OBACT; if(G.qual==LR_CTRLKEY) { if(ob && ob->type == OB_MESH) { flip_subdivison(ob, 1); @@ -1016,7 +1011,6 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) break; case TWOKEY: - ob= OBACT; if(G.qual==LR_CTRLKEY) { if(ob && ob->type == OB_MESH) { flip_subdivison(ob, 2); @@ -1026,7 +1020,6 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) break; case THREEKEY: - ob= OBACT; if(G.qual==LR_CTRLKEY) { if(ob && ob->type == OB_MESH) { flip_subdivison(ob, 3); @@ -1036,7 +1029,6 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) break; case FOURKEY: - ob= OBACT; if(G.qual==LR_CTRLKEY) { if(ob && ob->type == OB_MESH) { flip_subdivison(ob, 4); @@ -1110,12 +1102,8 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) else if(G.obedit->type==OB_ARMATURE) deselectall_armature(1); // 1 == toggle } - else if (G.obpose){ - switch (G.obpose->type){ - case OB_ARMATURE: - deselectall_posearmature(1); - break; - } + else if (ob && (ob->flag & OB_POSEMODE)){ + deselectall_posearmature(ob, 1); } else { if(G.f & G_FACESELECT) deselectall_tface(); @@ -1167,9 +1155,9 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) duplicate_context_selected(); } else if(G.qual==LR_ALTKEY) { - if(G.obpose) + if(ob && (ob->flag & OB_POSEMODE)) error ("Duplicate not possible in posemode."); - else if((G.obedit==0)) + else if((G.obedit==NULL)) adduplicate(0); } else if(G.qual==LR_CTRLKEY) { @@ -1303,7 +1291,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) } else if(G.f & G_FACESELECT) hide_tface(); - else if(G.obpose) { + else if(ob && (ob->flag & OB_POSEMODE)) { if (G.qual==0) hide_selected_pose_bones(); else if (G.qual==LR_SHIFTKEY) @@ -1317,7 +1305,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) case JKEY: if(G.qual==LR_CTRLKEY) { - if( (ob= OBACT) ) { + if( ob ) { if(ob->type == OB_MESH) join_mesh(); else if(ob->type == OB_CURVE) @@ -1371,9 +1359,8 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) selectconnected_nurb(); } - else if(G.obpose) { - if(G.obpose->type==OB_ARMATURE) - selectconnected_posearmature(); + else if(ob && (ob->flag & OB_POSEMODE)) { + selectconnected_posearmature(); } else { if(G.f & G_FACESELECT) { @@ -1452,7 +1439,6 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) break; case OKEY: - ob= OBACT; if (G.obedit) { if (G.qual==LR_SHIFTKEY) { G.scene->prop_mode = (G.scene->prop_mode+1)%6; @@ -1646,7 +1632,6 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) break; case VKEY: - ob= OBACT; if((G.qual==LR_SHIFTKEY)) { if ((G.obedit) && G.obedit->type==OB_MESH) { align_view_to_selected(v3d); @@ -1751,7 +1736,6 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) break; case PADASTERKEY: /* '*' */ if(G.qual==0) { - ob= OBACT; if(ob) { if ((G.obedit) && (G.obedit->type == OB_MESH)) { editmesh_align_view_to_selected(G.vd, 2); diff --git a/source/blender/src/toets.c b/source/blender/src/toets.c index a1e65c08fed..bf623054892 100644 --- a/source/blender/src/toets.c +++ b/source/blender/src/toets.c @@ -761,7 +761,7 @@ int blenderqread(unsigned short event, short val) Object *ob= OBACT; if(ob) { if(ob->type==OB_ARMATURE) { - if(G.obpose) exit_posemode(1); + if(ob->flag & OB_POSEMODE) exit_posemode(); else enter_posemode(); } else if(ob->type==OB_MESH) { @@ -769,7 +769,7 @@ int blenderqread(unsigned short event, short val) } } } - else if(G.qual==LR_SHIFTKEY) { + else if(G.qual==LR_SHIFTKEY) { // ?? if(G.obedit) exit_editmode(2); // freedata, and undo if(G.f & G_FACESELECT) @@ -783,8 +783,6 @@ int blenderqread(unsigned short event, short val) } if(G.f & G_WEIGHTPAINT) set_wpaint(); - if(G.obpose) - exit_posemode(1); } break; @@ -869,7 +867,7 @@ int blenderqread(unsigned short event, short val) break; case SKEY: - if(G.obpose==0 && G.obedit==0) { + if(G.obedit==NULL) { if(G.qual==LR_CTRLKEY) { strcpy(dir, G.sce); if (untitled(dir)) { diff --git a/source/blender/src/transform.c b/source/blender/src/transform.c index 62ae855b757..70d4781b7b5 100755 --- a/source/blender/src/transform.c +++ b/source/blender/src/transform.c @@ -71,6 +71,9 @@ #include "DNA_vfont_types.h" #include "BIF_editview.h" /* arrows_move_cursor */ +#include "BIF_gl.h" +#include "BIF_mywindow.h" +#include "BIF_resources.h" #include "BIF_screen.h" #include "BIF_space.h" /* undo */ #include "BIF_toets.h" /* persptoetsen */ @@ -93,9 +96,6 @@ #include "mydevice.h" -extern void helpline(float *vec); - - #include "transform.h" /* GLOBAL VARIABLE THAT SHOULD MOVED TO SCREEN MEMBER OR SOMETHING */ @@ -103,6 +103,42 @@ TransInfo Trans = {TFM_INIT, 0}; // enforce init on first usage ListBase CSpaces = {0,0}; float MatSpace[3][3]; +/* ************************** Dashed help line **************************** */ + + +/* bad frontbuffer call... because it is used in transform after force_draw() */ +static void helpline(float *vec, int local) +{ + float vecrot[3], cent[2]; + short mval[2]; + + VECCOPY(vecrot, vec); + if(local) { + Object *ob= OBACT; + if(ob) Mat4MulVecfl(ob->obmat, vecrot); + } + getmouseco_areawin(mval); + project_float(vecrot, cent); // no overflow in extreme cases + if(cent[0]!=3200.0f) { + persp(PERSP_WIN); + + glDrawBuffer(GL_FRONT); + + BIF_ThemeColor(TH_WIRE); + + setlinestyle(3); + glBegin(GL_LINE_STRIP); + glVertex2sv(mval); + glVertex2fv(cent); + glEnd(); + setlinestyle(0); + + persp(PERSP_VIEW); + glFlush(); // flush display for frontbuffer + glDrawBuffer(GL_BACK); + } +} + /* ************************** TRANSFORMATIONS **************************** */ static void view_editmove(unsigned short event) @@ -861,7 +897,7 @@ int Warp(TransInfo *t, short mval[2]) force_draw(0); - helpline(gcursor); + helpline(gcursor, t->flag & (T_EDIT|T_POSE)); return 1; } @@ -945,7 +981,7 @@ int Shear(TransInfo *t, short mval[2]) force_draw(0); - helpline (t->center); + helpline (t->center, t->flag & (T_EDIT|T_POSE)); return 1; } @@ -1197,7 +1233,7 @@ int Resize(TransInfo *t, short mval[2]) force_draw(0); - if(!(t->flag & T_USES_MANIPULATOR)) helpline (t->center); + if(!(t->flag & T_USES_MANIPULATOR)) helpline (t->center, t->flag & (T_EDIT|T_POSE)); return 1; } @@ -1291,7 +1327,7 @@ int ToSphere(TransInfo *t, short mval[2]) force_draw(0); - helpline (t->center); + helpline (t->center, t->flag & (T_EDIT|T_POSE)); return 1; } @@ -1529,7 +1565,7 @@ int Rotation(TransInfo *t, short mval[2]) force_draw(0); - if(!(t->flag & T_USES_MANIPULATOR)) helpline (t->center); + if(!(t->flag & T_USES_MANIPULATOR)) helpline (t->center, t->flag & (T_EDIT|T_POSE)); return 1; } @@ -1631,7 +1667,7 @@ int Trackball(TransInfo *t, short mval[2]) force_draw(0); - if(!(t->flag & T_USES_MANIPULATOR)) helpline (t->center); + if(!(t->flag & T_USES_MANIPULATOR)) helpline (t->center, t->flag & (T_EDIT|T_POSE)); return 1; } @@ -1908,7 +1944,7 @@ int Tilt(TransInfo *t, short mval[2]) force_draw(0); - helpline (t->center); + helpline (t->center, t->flag & (T_EDIT|T_POSE)); return 1; } @@ -2080,7 +2116,7 @@ int Crease(TransInfo *t, short mval[2]) force_draw(0); - helpline (t->center); + helpline (t->center, t->flag & (T_EDIT|T_POSE)); return 1; } @@ -2280,7 +2316,7 @@ int BoneSize(TransInfo *t, short mval[2]) force_draw(0); - if(!(t->flag & T_USES_MANIPULATOR)) helpline (t->center); + if(!(t->flag & T_USES_MANIPULATOR)) helpline (t->center, t->flag & (T_EDIT|T_POSE)); return 1; } diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c index 60786d784d3..30b715a57a5 100755 --- a/source/blender/src/transform_conversions.c +++ b/source/blender/src/transform_conversions.c @@ -443,8 +443,10 @@ static int add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tra return 0; } +/* only called with pose mode active object now */ static void createTransPose(TransInfo *t) { + Object *ob= OBACT; bArmature *arm; bPoseChannel *pchan; TransData *td; @@ -452,14 +454,14 @@ static void createTransPose(TransInfo *t) int i; /* check validity of state */ - arm=get_armature (G.obpose); - if (arm==NULL || G.obpose->pose==NULL) return; + arm=get_armature (ob); + if (arm==NULL || ob->pose==NULL) return; if (arm->flag & ARM_RESTPOS){ notice ("Pose edit not possible while Rest Position is enabled"); return; } - if (!(G.obpose->lay & G.vd->lay)) return; + if (!(ob->lay & G.vd->lay)) return; /* count total */ count_bone_select(t, &arm->bonebase, 1); @@ -481,8 +483,8 @@ static void createTransPose(TransInfo *t) /* use pose channels to fill trans data */ td= t->data; - for(pchan= G.obpose->pose->chanbase.first; pchan; pchan= pchan->next) { - if( add_pose_transdata(t, pchan, G.obpose, td) ) td++; + for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + if( add_pose_transdata(t, pchan, ob, td) ) td++; } if(td != (t->data+t->total)) printf("Bone selection count error\n"); @@ -1343,25 +1345,26 @@ static void clear_trans_object_base_flags(void) /* inserting keys, refresh ipo-keys, softbody, redraw events... (ton) */ void special_aftertrans_update(short cancelled) { - Object *ob; + Object *ob= OBACT; Base *base; int redrawipo=0; - if (G.obpose){ + if (ob && (ob->flag & OB_POSEMODE)) { + bArmature *arm= ob->data; bAction *act; bPose *pose; bPoseChannel *pchan; if(cancelled) /* if cancelled we do the update always */ - DAG_object_flush_update(G.scene, G.obpose, OB_RECALC_DATA); + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); else if(G.flags & G_RECORDKEYS) { - act=G.obpose->action; - pose=G.obpose->pose; + act= ob->action; + pose= ob->pose; if (!act) - act=G.obpose->action=add_empty_action(); + act= ob->action= add_empty_action(); - set_pose_keys(G.obpose); // sets chan->flag to POSE_KEY if bone selected + set_pose_keys(ob); // sets chan->flag to POSE_KEY if bone selected for (pchan=pose->chanbase.first; pchan; pchan=pchan->next){ if (pchan->flag & POSE_KEY){ @@ -1386,12 +1389,12 @@ void special_aftertrans_update(short cancelled) allqueue(REDRAWIPO, 0); allqueue(REDRAWNLA, 0); - DAG_object_flush_update(G.scene, G.obpose, OB_RECALC_DATA); + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); } - else if(is_delay_deform()) { + else if(arm->flag & ARM_DELAYDEFORM) { /* old optimize trick... this enforces to bypass the depgraph */ - DAG_object_flush_update(G.scene, G.obpose, OB_RECALC_DATA); - G.obpose->recalc= 0; // is set on OK position already by recalcData() + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); + ob->recalc= 0; // is set on OK position already by recalcData() } /* do not call DAG_object_flush_update always, we dont want actions to update, for inserting keys */ } @@ -1458,15 +1461,6 @@ static void createTransObject(TransInfo *t) set_trans_object_base_flags(t); - { - /* this has to be done, or else constraints on armature - * bones that point to objects/bones that are outside - * of the armature don't work outside of posemode - * (and yes, I know it's confusing ...). - */ - //figure_pose_updating(); - } - /* count */ for(base= FIRSTBASE; base; base= base->next) { if TESTBASELIB(base) { @@ -1573,6 +1567,8 @@ static void createTransObject(TransInfo *t) void createTransData(TransInfo *t) { + Object *ob= OBACT; + if (t->context == CTX_TEXTURE) { t->flag |= T_TEXTURE; createTransTexspace(t); @@ -1587,7 +1583,7 @@ void createTransData(TransInfo *t) sort_trans_data_dist(t); } } - else if (G.obpose) { + else if (ob && (ob->flag & OB_POSEMODE)) { t->flag |= T_POSE; createTransPose(t); } diff --git a/source/blender/src/transform_generics.c b/source/blender/src/transform_generics.c index b8c11f0b70a..4875228a209 100755 --- a/source/blender/src/transform_generics.c +++ b/source/blender/src/transform_generics.c @@ -112,14 +112,16 @@ void getViewVector(float coord[3], float vec[3]) { /* called for objects updating while transform acts, once per redraw */ void recalcData(TransInfo *t) { - Base *base; + Object *ob= OBACT; - if(G.obpose) { + if(ob && (ob->flag & OB_POSEMODE)) { + bArmature *arm= ob->data; + /* old optimize trick... this enforces to bypass the depgraph */ - if (!is_delay_deform()) - DAG_object_flush_update(G.scene, G.obpose, OB_RECALC_DATA); /* sets recalc flags */ + if (!(arm->flag & ARM_DELAYDEFORM)) + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); /* sets recalc flags */ else - where_is_pose(G.obpose); + where_is_pose(ob); } else if (G.obedit) { @@ -166,6 +168,7 @@ void recalcData(TransInfo *t) } } else { + Base *base; base= FIRSTBASE; while(base) { @@ -266,9 +269,10 @@ void drawLine(float *center, float *dir, char axis, short options) void initTrans (TransInfo *t) { - + Object *ob= OBACT; + /* moving: is shown in drawobject() (transform color) */ - if(G.obedit || G.obpose) G.moving= G_TRANSFORM_EDIT; + if(G.obedit || (ob && (ob->flag & OB_POSEMODE)) ) G.moving= G_TRANSFORM_EDIT; else G.moving= G_TRANSFORM_OBJ; t->data = NULL; @@ -468,7 +472,7 @@ void calculateCenterCursor(TransInfo *t) VECCOPY(t->center, cursor); if(t->flag & (T_EDIT|T_POSE)) { - Object *ob= G.obedit?G.obedit:G.obpose; + Object *ob= G.obedit?G.obedit:OBACT; float mat[3][3], imat[3][3]; float vec[3]; @@ -506,7 +510,7 @@ void calculateCenterMedian(TransInfo *t) VECCOPY(t->center, partial); if (t->flag & (T_EDIT|T_POSE)) { - Object *ob= G.obedit?G.obedit:G.obpose; + Object *ob= G.obedit?G.obedit:OBACT; float vec[3]; VECCOPY(vec, t->center); @@ -545,7 +549,7 @@ void calculateCenterBound(TransInfo *t) VecMulf(t->center, 0.5); if (t->flag & (T_EDIT|T_POSE)) { - Object *ob= G.obedit?G.obedit:G.obpose; + Object *ob= G.obedit?G.obedit:OBACT; float vec[3]; VECCOPY(vec, t->center); @@ -589,7 +593,7 @@ void calculateCenter(TransInfo *t) /* setting constraint center */ VECCOPY(t->con.center, t->center); if(t->flag & (T_EDIT|T_POSE)) { - Object *ob= G.obedit?G.obedit:G.obpose; + Object *ob= G.obedit?G.obedit:OBACT; Mat4MulVecfl(ob->obmat, t->con.center); } diff --git a/source/blender/src/transform_manipulator.c b/source/blender/src/transform_manipulator.c index a15b686c64a..effe2f610aa 100644 --- a/source/blender/src/transform_manipulator.c +++ b/source/blender/src/transform_manipulator.c @@ -155,7 +155,7 @@ int calc_manipulator_stats(ScrArea *sa) extern ListBase editNurb; View3D *v3d= sa->spacedata.first; Base *base; - Object *ob=NULL; + Object *ob= OBACT; float normal[3]={0.0, 0.0, 0.0}; float plane[3]={0.0, 0.0, 0.0}; int a, totsel=0; @@ -331,11 +331,10 @@ int calc_manipulator_stats(ScrArea *sa) Mat4MulVecfl(G.obedit->obmat, G.scene->twmax); } } - else if(G.obpose) { - bArmature *arm= G.obpose->data; + else if(ob && (ob->flag & OB_POSEMODE)) { + bArmature *arm= ob->data; bPoseChannel *pchan; - ob= G.obpose; if((ob->lay & G.vd->lay)==0) return 0; Trans.mode= TFM_ROTATION; // mislead counting bones... bah @@ -353,9 +352,9 @@ int calc_manipulator_stats(ScrArea *sa) VecMulf(plane, -1.0); VecMulf(G.scene->twcent, 1.0f/(float)totsel); // centroid! - Mat4MulVecfl(G.obpose->obmat, G.scene->twcent); - Mat4MulVecfl(G.obpose->obmat, G.scene->twmin); - Mat4MulVecfl(G.obpose->obmat, G.scene->twmax); + Mat4MulVecfl(ob->obmat, G.scene->twcent); + Mat4MulVecfl(ob->obmat, G.scene->twmin); + Mat4MulVecfl(ob->obmat, G.scene->twmax); } } else if(G.f & (G_FACESELECT + G_VERTEXPAINT + G_TEXTUREPAINT +G_WEIGHTPAINT)) { @@ -391,7 +390,7 @@ int calc_manipulator_stats(ScrArea *sa) break; case V3D_MANIP_NORMAL: - if(G.obedit || G.obpose) { + if(G.obedit || (ob->flag & OB_POSEMODE)) { if(normal[0]!=0.0 || normal[1]!=0.0 || normal[2]!=0.0) { float imat[3][3], mat[3][3]; @@ -418,7 +417,7 @@ int calc_manipulator_stats(ScrArea *sa) } /* no break we define 'normal' as 'local' in Object mode */ case V3D_MANIP_LOCAL: - if(totsel==1 || v3d->around==V3D_LOCAL || G.obedit || G.obpose) { + if(totsel==1 || v3d->around==V3D_LOCAL || G.obedit || (ob->flag & OB_POSEMODE)) { Mat4CpyMat4(v3d->twmat, ob->obmat); Mat4Ortho(v3d->twmat); } @@ -1346,9 +1345,10 @@ void BIF_draw_manipulator(ScrArea *sa) v3d->twmat[3][0]= (G.scene->twmin[0] + G.scene->twmax[0])/2.0f; v3d->twmat[3][1]= (G.scene->twmin[1] + G.scene->twmax[1])/2.0f; v3d->twmat[3][2]= (G.scene->twmin[2] + G.scene->twmax[2])/2.0f; - if(v3d->around==V3D_ACTIVE && G.obedit==NULL && G.obpose==NULL) { + if(v3d->around==V3D_ACTIVE && G.obedit==NULL) { Object *ob= OBACT; - if(ob) VECCOPY(v3d->twmat[3], ob->obmat[3]); + if(ob && !(ob->flag & OB_POSEMODE)) + VECCOPY(v3d->twmat[3], ob->obmat[3]); } break; case V3D_LOCAL: diff --git a/source/blender/src/view.c b/source/blender/src/view.c index ff7438dc840..3304f71c79b 100644 --- a/source/blender/src/view.c +++ b/source/blender/src/view.c @@ -458,7 +458,7 @@ void viewmove(int mode) /* cumultime(0); */ - if (G.obedit==0 && G.obpose==0 && U.uiflag & USER_ORBIT_SELECTION) { + if (G.obedit==NULL && ob && !(ob->flag & OB_POSEMODE) && U.uiflag & USER_ORBIT_SELECTION) { use_sel = 1; VECCOPY(ofs, G.vd->ofs); if (ob) { @@ -862,7 +862,6 @@ void setcameratoview3d(void) short view3d_opengl_select(unsigned int *buffer, unsigned int bufsize, short x1, short y1, short x2, short y2) { rctf rect; - Base *base; short mval[2], code, hits; G.f |= G_PICKSEL; @@ -899,23 +898,24 @@ short view3d_opengl_select(unsigned int *buffer, unsigned int bufsize, short x1 if(G.obedit && G.obedit->type==OB_MBALL) { draw_object(BASACT); } - else if ((G.obedit && G.obedit->type==OB_ARMATURE)||(G.obpose && G.obpose->type==OB_ARMATURE)) { + else if ((G.obedit && G.obedit->type==OB_ARMATURE)) { draw_object(BASACT); } else { + Base *base; + G.vd->xray= TRUE; // otherwise it postpones drawing - base= G.scene->base.first; - while(base) { + for(base= G.scene->base.first; base; base= base->next) { if(base->lay & G.vd->lay) { base->selcol= code; glLoadName(code); draw_object(base); code++; } - base= base->next; } G.vd->xray= FALSE; // restore } + glPopName(); /* see above (pushname) */ hits= glRenderMode(GL_RENDER); if(hits<0) error("Too many objects in select buffer"); @@ -1077,7 +1077,7 @@ void initlocalview() void centreview() /* like a localview without local! */ { - Base *base; + Object *ob= OBACT; float size, min[3], max[3], afm[3]; int ok=0; @@ -1088,18 +1088,18 @@ void centreview() /* like a localview without local! */ minmax_verts(min, max); // ony selected ok= 1; } - else if(G.obpose) { - if(G.obpose->pose) { + else if(ob && (ob->flag & OB_POSEMODE)) { + if(ob->pose) { bPoseChannel *pchan; float vec[3]; - for(pchan= G.obpose->pose->chanbase.first; pchan; pchan= pchan->next) { + for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if(pchan->bone->flag & BONE_SELECTED) { ok= 1; VECCOPY(vec, pchan->pose_head); - Mat4MulVecfl(G.obpose->obmat, vec); + Mat4MulVecfl(ob->obmat, vec); DO_MINMAX(vec, min, max); VECCOPY(vec, pchan->pose_tail); - Mat4MulVecfl(G.obpose->obmat, vec); + Mat4MulVecfl(ob->obmat, vec); DO_MINMAX(vec, min, max); } } @@ -1110,7 +1110,7 @@ void centreview() /* like a localview without local! */ ok= 1; } else { - base= FIRSTBASE; + Base *base= FIRSTBASE; while(base) { if TESTBASE(base) { minmax_object(base->object, min, max); diff --git a/source/blender/src/vpaint.c b/source/blender/src/vpaint.c index 245e62c58d0..49395b17a98 100644 --- a/source/blender/src/vpaint.c +++ b/source/blender/src/vpaint.c @@ -753,7 +753,6 @@ void weight_paint(void) if((G.f & G_WEIGHTPAINT)==0) return; if(G.obedit) return; - if(G.obpose) return; if(indexar==NULL) init_vertexpaint(); |