diff options
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 2 | ||||
-rw-r--r-- | source/blender/include/BIF_editarmature.h | 2 | ||||
-rw-r--r-- | source/blender/include/BIF_resources.h | 5 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_action_types.h | 8 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 1 | ||||
-rw-r--r-- | source/blender/src/drawobject.c | 12 | ||||
-rw-r--r-- | source/blender/src/editarmature.c | 388 | ||||
-rw-r--r-- | source/blender/src/editview.c | 2 | ||||
-rw-r--r-- | source/blender/src/resources.c | 10 | ||||
-rw-r--r-- | source/blender/src/usiblender.c | 11 |
11 files changed, 59 insertions, 396 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 31f07d9e1b3..41fee9e3899 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -448,13 +448,13 @@ void extract_pose_from_action(bPose *pose, bAction *act, float ctime) return; /* Copy the data from the action into the pose */ - for (achan=act->chanbase.first; achan; achan=achan->next){ - act->achan= achan; // for ipos - - ipo = achan->ipo; - if (ipo) { - pchan= get_pose_channel(pose, achan->name); - if(pchan) { + for (pchan= pose->chanbase.first; pchan; pchan=pchan->next) { + achan= get_named_actionchannel(act, pchan->name); + pchan->flag= 0; + if(achan) { + ipo = achan->ipo; + if (ipo) { + act->achan= achan; // for ipos act->pchan= pchan; // for ipos /* Evaluates and sets the internal ipo value */ diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index db5dee45d5d..6e3dde28a53 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -642,7 +642,7 @@ static int _object_deform(Object *ob, int applyflag) return 1; } else if(ob->parent->type==OB_ARMATURE) { - if (ob->partype != PARSKEL){ + if (ob->partype != PARSKEL || ob->parent==G.obedit){ return 0; } diff --git a/source/blender/include/BIF_editarmature.h b/source/blender/include/BIF_editarmature.h index 77540c46eb5..056888e33f6 100644 --- a/source/blender/include/BIF_editarmature.h +++ b/source/blender/include/BIF_editarmature.h @@ -81,7 +81,7 @@ void clear_armature(struct Object *ob, char mode); void delete_armature(void); void deselectall_armature(void); void deselectall_posearmature (int test); -void draw_armature(struct Object *ob); +void draw_armature(struct Object *ob, int dt); void extrude_armature(void); void free_editArmature(void); void join_armature(void); diff --git a/source/blender/include/BIF_resources.h b/source/blender/include/BIF_resources.h index 2f194a58118..70aa35a03d2 100644 --- a/source/blender/include/BIF_resources.h +++ b/source/blender/include/BIF_resources.h @@ -434,7 +434,10 @@ enum { TH_SYNTAX_V, TH_SYNTAX_C, TH_SYNTAX_L, - TH_SYNTAX_N + TH_SYNTAX_N, + + TH_BONE_SOLID, + TH_BONE_POSE }; /* XXX WARNING: previous is saved in file, so do not change order! */ diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 9e4480431e3..f88d298e5ee 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -136,11 +136,11 @@ enum { POSE_KEY = 0x1000 }; -/* Pose Channel constflag (constraint) */ +/* Pose Channel constflag (constraint detection) */ #define PCHAN_HAS_IK 1 -#define PCHAN_HAS_TRACK 2 -#define PCHAN_HAS_CONST 4 - +#define PCHAN_HAS_CONST 2 + /* only used for drawing Posemode, not stored in channel */ +#define PCHAN_HAS_ACTION 4 #endif diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index f86d087cc11..9f2e069173c 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -86,6 +86,7 @@ typedef struct ThemeSpace { char face[4], face_select[4]; // solid faces char face_dot[4]; // selected color char normal[4]; + char bone_solid[4], bone_pose[4]; char vertex_size, facedot_size; char bpad[2]; diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index e1c813de3f0..d87f4826f0d 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -46,6 +46,7 @@ #include "MTC_matrixops.h" +#include "DNA_armature_types.h" #include "DNA_camera_types.h" #include "DNA_curve_types.h" #include "DNA_constraint_types.h" // for drawing constraint @@ -3338,6 +3339,15 @@ static void drawSolidSelect(Object *ob) } else if (ob->type==OB_MBALL) { drawDispListwire(&ob->disp); } + else if(ob->type==OB_ARMATURE) { + if(ob!=G.obpose) { + bArmature *arm= ob->data; + int oldflag= arm->flag; + arm->flag &= ~ARM_DRAWXRAY; + draw_armature(ob, OB_WIRE); // patch needed for xray option... + arm->flag= oldflag; + } + } glLineWidth(1.0); glDepthMask(1); @@ -3704,7 +3714,7 @@ void draw_object(Base *base) drawlattice(ob); break; case OB_ARMATURE: - draw_armature (ob); + draw_armature (ob, dt); break; default: drawaxes(1.0); diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 4663b799b42..56fd7406fd6 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -99,16 +99,6 @@ #include "blendef.h" #include "nla.h" -/* >>>>> FIXME: ARG! Colours should be defined in a header somewhere! */ -/* Note, these came from drawobject.c They really should be in a nice header file somewhere */ -#define B_YELLOW_A 0xBBFFFF -#define B_YELLOW 0x77FFFF -#define B_PURPLE 0xFF70FF - -#define B_CYAN_A 0xFFFF88 -#define B_CYAN 0xFFFF00 -#define B_AQUA 0xFFBB55 - extern float centre[3], centroid[3]; /* Originally defined in editobject.c */ /* Macros */ @@ -482,7 +472,7 @@ void join_armature(void) /* used by posemode as well editmode */ static void * get_nearest_bone (int findunsel) { - void *firstunSel=NULL, *data; + void *firstunSel=NULL, *firstSel=NULL, *data; unsigned int buffer[MAXPICKBUF]; short hits; int i, takeNext=0; @@ -495,7 +485,7 @@ static void * get_nearest_bone (int findunsel) glInitNames(); hits= view3d_opengl_select(buffer, MAXPICKBUF, 0, 0, 0, 0); - + /* See if there are any selected bones in this group */ if (hits){ for (i=0; i< hits; i++){ @@ -524,9 +514,11 @@ static void * get_nearest_bone (int findunsel) data = ebone; } - if (sel) + if (sel) { + if(!firstSel) firstSel= data; takeNext=1; - else{ + } + else { if (!firstunSel) firstunSel=data; if (takeNext) @@ -537,14 +529,8 @@ static void * get_nearest_bone (int findunsel) if (firstunSel) return firstunSel; - - else{ - - if (G.obedit) - return BLI_findlink(&G.edbo, buffer[3] & ~(BONESEL_ANY)); - else - return get_indexed_bone(OBACT, buffer[3] & ~(BONESEL_ANY)); - } + else + return firstSel; } return NULL; @@ -1139,364 +1125,6 @@ void undo_push_armature(char *name) /* **************** END EditMode stuff ********************** */ -/* *************** Armature drawing ******************* */ - -static void draw_bonevert(void) -{ - static GLuint displist=0; - - if(displist==0) { - GLUquadricObj *qobj; - - displist= glGenLists(1); - glNewList(displist, GL_COMPILE_AND_EXECUTE); - - glPushMatrix(); - - qobj = gluNewQuadric(); - gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); - gluDisk( qobj, 0.0, 0.05, 16, 1); - - glRotatef (90, 0, 1, 0); - gluDisk( qobj, 0.0, 0.05, 16, 1); - - glRotatef (90, 1, 0, 0); - gluDisk( qobj, 0.0, 0.05, 16, 1); - - gluDeleteQuadric(qobj); - - glPopMatrix(); - glEndList(); - } - else glCallList(displist); -} - -static void draw_bone_octahedral() -{ - static GLuint displist=0; - - if(displist==0) { - float vec[6][3]; - - displist= glGenLists(1); - glNewList(displist, GL_COMPILE_AND_EXECUTE); - - vec[0][0]= vec[0][1]= vec[0][2]= 0.0; - vec[5][0]= vec[5][2]= 0.0; vec[5][1]= 1.0; - - vec[1][0]= 0.1; vec[1][2]= 0.1; vec[1][1]= 0.1; - vec[2][0]= 0.1; vec[2][2]= -0.1; vec[2][1]= 0.1; - vec[3][0]= -0.1; vec[3][2]= -0.1; vec[3][1]= 0.1; - vec[4][0]= -0.1; vec[4][2]= 0.1; vec[4][1]= 0.1; - - /* Section 1, sides */ - glBegin(GL_LINE_LOOP); - glVertex3fv(vec[0]); - glVertex3fv(vec[1]); - glVertex3fv(vec[5]); - glVertex3fv(vec[3]); - glVertex3fv(vec[0]); - glVertex3fv(vec[4]); - glVertex3fv(vec[5]); - glVertex3fv(vec[2]); - glEnd(); - - /* Section 1, square */ - glBegin(GL_LINE_LOOP); - glVertex3fv(vec[1]); - glVertex3fv(vec[2]); - glVertex3fv(vec[3]); - glVertex3fv(vec[4]); - glEnd(); - - glEndList(); - } - else glCallList(displist); -} - -static void draw_bone_solid_octahedral(void) -{ - static GLuint displist=0; - - if(displist==0) { - float vec[6][3]; - - displist= glGenLists(1); - glNewList(displist, GL_COMPILE_AND_EXECUTE); - - vec[0][0]= vec[0][1]= vec[0][2]= 0.0; - vec[5][0]= vec[5][2]= 0.0; vec[5][1]= 1.0; - - vec[1][0]= 0.1; vec[1][2]= 0.1; vec[1][1]= 0.1; - vec[2][0]= 0.1; vec[2][2]= -0.1; vec[2][1]= 0.1; - vec[3][0]= -0.1; vec[3][2]= -0.1; vec[3][1]= 0.1; - vec[4][0]= -0.1; vec[4][2]= 0.1; vec[4][1]= 0.1; - - - glBegin(GL_TRIANGLES); - /* bottom */ - glVertex3fv(vec[0]);glVertex3fv(vec[1]);glVertex3fv(vec[2]); - - glVertex3fv(vec[0]);glVertex3fv(vec[2]);glVertex3fv(vec[3]); - - glVertex3fv(vec[0]);glVertex3fv(vec[3]);glVertex3fv(vec[4]); - - glVertex3fv(vec[0]);glVertex3fv(vec[4]);glVertex3fv(vec[1]); - /* top */ - glVertex3fv(vec[5]);glVertex3fv(vec[1]);glVertex3fv(vec[2]); - - glVertex3fv(vec[5]);glVertex3fv(vec[2]);glVertex3fv(vec[3]); - - glVertex3fv(vec[5]);glVertex3fv(vec[3]);glVertex3fv(vec[4]); - - glVertex3fv(vec[5]);glVertex3fv(vec[4]);glVertex3fv(vec[1]); - - glEnd(); - - glEndList(); - } - else glCallList(displist); -} - - -static void draw_bone (int armflag, int boneflag, int constflag, unsigned int id, char *name, float length) -{ - float pointsize; - - /* Draw a 3d octahedral bone, we use normalized space based on length, - for glDisplayLists */ - - /* pointsize todo! */ - pointsize = length; - if (length<0.1) - pointsize=0.1; - - glScalef(length, length, length); - - if (id!=-1) glLoadName((GLuint) id ); - - /* Draw root point if we have no IK parent */ - if (!(boneflag & BONE_IK_TOPARENT)){ - if (id != -1) - glLoadName (id | BONESEL_ROOT); - - if (armflag & ARM_EDITMODE) { - if (boneflag & BONE_ROOTSEL) cpack (B_YELLOW); - else cpack (B_PURPLE); - } - draw_bonevert(); - } - - /* Draw tip point (for selection only ) */ - - if (id != -1) - glLoadName (id | BONESEL_TIP); - - if (armflag & ARM_EDITMODE) { - if (boneflag & BONE_TIPSEL) cpack (B_YELLOW); - else cpack (B_PURPLE); - } - - glTranslatef(0.0, 1.0, 0.0); - draw_bonevert(); - - /* Draw additional axes */ - if (armflag & ARM_DRAWAXES){ - drawaxes(0.25f); - } - - glTranslatef(0.0, -1.0, 0.0); - - if (id != -1) { - if (armflag & ARM_POSEMODE) - glLoadName((GLuint) id); - else{ - glLoadName ((GLuint) id|BONESEL_BONE); - } - } - - /* colors */ - if (armflag & ARM_EDITMODE){ - if (boneflag & BONE_ACTIVE) cpack (B_YELLOW_A); - else if (boneflag & BONE_SELECTED) cpack (B_YELLOW); - else cpack (B_PURPLE); - } - else if (armflag & ARM_POSEMODE){ - - if(constflag) { - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - if(constflag & PCHAN_HAS_IK) glColor4ub(255, 255, 0, 50); - else glColor4ub(0, 255, 120, 50); - draw_bone_solid_octahedral(); - glDisable(GL_BLEND); - } - - if (boneflag & BONE_ACTIVE) cpack (B_CYAN_A); - else if (boneflag & BONE_SELECTED) cpack (B_CYAN); - else cpack (B_AQUA); - } - draw_bone_octahedral(); - - /* Draw the bone name */ - if (armflag & ARM_DRAWNAMES) { - // patch for several 3d cards (IBM mostly) that crash on glSelect with text drawing - if((G.f & G_PICKSEL) == 0) { - glRasterPos3f(0, 0.5, 0); - BMF_DrawString(G.font, " "); - BMF_DrawString(G.font, name); - } - } -} - - -/* assumes object is Armature with pose */ -static void draw_pose_channels(Object *ob) -{ - bPoseChannel *pchan; - Bone *bone; - bArmature *arm= ob->data; - short flag; - int index= -1; - - if (arm->flag & ARM_POSEMODE) index= 0; - - for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - bone= pchan->bone; - if(bone) { - if(!(bone->flag & BONE_HIDDEN)) { - - if (index!= -1) { // set color for points */ - if (bone->flag & BONE_ACTIVE) cpack (B_CYAN_A); - else if (bone->flag & BONE_SELECTED) cpack (B_CYAN); - else cpack (B_AQUA); - } - - // Draw a line from our root to the parent's tip - if (bone->parent && !(bone->flag & BONE_IK_TOPARENT) ){ - - if (arm->flag & ARM_POSEMODE) glLoadName (-1); - - setlinestyle(3); - glBegin(GL_LINES); - glVertex3fv(pchan->pose_head); - glVertex3fv(pchan->parent->pose_tail); - glEnd(); - setlinestyle(0); - } - - glPushMatrix(); - glMultMatrixf(pchan->pose_mat); - - /* catch exception for bone with hidden parent */ - flag= bone->flag; - if(bone->parent && (bone->parent->flag & BONE_HIDDEN)) - bone->flag &= ~BONE_IK_TOPARENT; - - draw_bone(arm->flag, flag, pchan->constflag, index, bone->name, bone->length); - - glPopMatrix(); - } - if (index!= -1) index++; - } - } - -} - -/* called from drawobject.c */ -void draw_armature(Object *ob) -{ - bArmature *arm; - - if (ob==NULL) return; - - arm= ob->data; - if (arm==NULL) return; - - if (!(ob->lay & G.vd->lay)) - return; - - if (arm->flag & ARM_DRAWXRAY) { - if(G.zbuf) glDisable(GL_DEPTH_TEST); - } - - /* If we're in editmode, draw the Global edit data */ - if(ob==G.obedit || (G.obedit && ob->data==G.obedit->data)) { - EditBone *eBone; - unsigned int index; - float delta[3],offset[3]; - float mat[3][3], bmat[4][4]; - float length; - cpack (0); - - if(ob==G.obedit) arm->flag |= ARM_EDITMODE; - for (eBone=G.edbo.first, index=0; eBone; eBone=eBone->next, index++){ - if (ob==G.obedit) cpack (B_PURPLE); - else cpack (0); - - glPushMatrix(); - - /* Compose the parent transforms (i.e. their translations) */ - VECCOPY (offset,eBone->head); - - glTranslatef (offset[0],offset[1],offset[2]); - - delta[0]=eBone->tail[0]-eBone->head[0]; - delta[1]=eBone->tail[1]-eBone->head[1]; - delta[2]=eBone->tail[2]-eBone->head[2]; - - length = sqrt (delta[0]*delta[0] + delta[1]*delta[1] +delta[2]*delta[2]); - - vec_roll_to_mat3(delta, eBone->roll, mat); - Mat4CpyMat3(bmat, mat); - - glMultMatrixf (bmat); - draw_bone (arm->flag, eBone->flag, 0, index, eBone->name, length); - - glPopMatrix(); - - if (eBone->parent) { - glLoadName (-1); - setlinestyle(3); - - glBegin(GL_LINES); - glVertex3fv(eBone->parent->tail); - glVertex3fv(eBone->head); - glEnd(); - - setlinestyle(0); - } - } - arm->flag &= ~ARM_EDITMODE; - cpack (B_YELLOW); - - } - else{ - /* Draw Pose */ - if(ob->pose) { - if (G.obpose == ob) arm->flag |= ARM_POSEMODE; - draw_pose_channels(ob); - arm->flag &= ~ARM_POSEMODE; - } - -#if 0 /* Depreciated interactive ik goal drawing */ - if (arm->chainbase.first){ - glPushMatrix(); - glTranslatef(((PoseChain*)arm->chainbase.first)->goal[0], - ((PoseChain*)arm->chainbase.first)->goal[1], - ((PoseChain*)arm->chainbase.first)->goal[2]); - drawaxes(1.0); - glPopMatrix(); - } -#endif - } - - if (arm->flag & ARM_DRAWXRAY) { - if(G.zbuf) glEnable(GL_DEPTH_TEST); - } -} - -/* *************** END Armature drawing ******************* */ /* *************** Adding stuff in editmode *************** */ static void add_bone_input (Object *ob) diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c index 26760c50252..9e6e4581644 100644 --- a/source/blender/src/editview.c +++ b/source/blender/src/editview.c @@ -1258,7 +1258,7 @@ void borderselect(void) else{ if (index != -1){ bone = get_indexed_bone(G.obpose, index &~(BONESEL_TIP|BONESEL_ROOT)); - bone->flag &= ~BONE_SELECTED; + bone->flag &= ~(BONE_ACTIVE|BONE_SELECTED); select_actionchannel_by_name(G.obpose->action, bone->name, 0); } } diff --git a/source/blender/src/resources.c b/source/blender/src/resources.c index c6f3d6c8ec4..c7d0f62b2a1 100644 --- a/source/blender/src/resources.c +++ b/source/blender/src/resources.c @@ -509,6 +509,10 @@ char *BIF_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) cp= &ts->facedot_size; break; case TH_NORMAL: cp= ts->normal; break; + case TH_BONE_SOLID: + cp= ts->bone_solid; break; + case TH_BONE_POSE: + cp= ts->bone_pose; break; case TH_SYNTAX_B: cp= ts->syntaxb; break; @@ -601,6 +605,10 @@ void BIF_InitTheme(void) SETCOL(btheme->tv3d.face_dot, 255, 138, 48, 255); btheme->tv3d.facedot_size= 4; + SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255); + SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 100); // alpha 100 is not meant editable, used for wire+action draw + + /* space buttons */ /* to have something initialized */ btheme->tbuts= btheme->tv3d; @@ -759,6 +767,8 @@ char *BIF_ThemeColorsPup(int spacetype) sprintf(str, "Face Dot Selected %%x%d|", TH_FACE_DOT); strcat(cp, str); sprintf(str, "Face Dot Size %%x%d|", TH_FACEDOT_SIZE); strcat(cp, str); sprintf(str, "Normal %%x%d", TH_NORMAL); strcat(cp, str); + sprintf(str, "Bone Solid %%x%d", TH_BONE_SOLID); strcat(cp, str); + sprintf(str, "Bone Pose %%x%d", TH_BONE_POSE); strcat(cp, str); } else if(spacetype==SPACE_IPO) { sprintf(str, "Panel %%x%d|", TH_PANEL); strcat(cp, str); diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c index d9a41429451..5ce57cfbe2f 100644 --- a/source/blender/src/usiblender.c +++ b/source/blender/src/usiblender.c @@ -225,6 +225,17 @@ static void init_userdef_file(void) } } } + if (G.main->versionfile <= 237) { + bTheme *btheme; + /* bone colors */ + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + /* check for alpha==0 is safe, then color was never set */ + if(btheme->tv3d.bone_solid[3]==0) { + SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255); + SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 100); + } + } + } if (U.undosteps==0) U.undosteps=32; |