diff options
Diffstat (limited to 'source/blender/editors/space_view3d/drawarmature.c')
-rw-r--r-- | source/blender/editors/space_view3d/drawarmature.c | 116 |
1 files changed, 101 insertions, 15 deletions
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 103a03eece2..ecf5df4af7c 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -201,7 +201,6 @@ static short set_pchan_glColor (short colCode, int boneflag, int constflag) else if (constflag & PCHAN_HAS_IK) glColor4ub(255, 255, 0, 80); else if (constflag & PCHAN_HAS_SPLINEIK) glColor4ub(200, 255, 0, 80); else if (constflag & PCHAN_HAS_CONST) glColor4ub(0, 255, 120, 80); - else if (constflag) UI_ThemeColor4(TH_BONE_POSE); // PCHAN_HAS_ACTION return 1; } @@ -1212,6 +1211,87 @@ static void draw_b_bone(int dt, int armflag, int boneflag, int constflag, unsign } } +static void draw_wire_bone_segments(bPoseChannel *pchan, Mat4 *bbones, float length, int segments) +{ + if ((segments > 1) && (pchan)) { + float dlen= length/(float)segments; + Mat4 *bbone = bbones; + int a; + + for (a=0; a<segments; a++, bbone++) { + glPushMatrix(); + glMultMatrixf(bbone->mat); + + glBegin(GL_LINES); + glVertex3f(0.0f, 0.0f, 0.0f); + glVertex3f(0.0f, dlen, 0.0f); + glEnd(); // GL_LINES + + glPopMatrix(); + } + } + else { + glPushMatrix(); + + glBegin(GL_LINES); + glVertex3f(0.0f, 0.0f, 0.0f); + glVertex3f(0.0f, length, 0.0f); + glEnd(); + + glPopMatrix(); + } +} + +static void draw_wire_bone(int dt, int armflag, int boneflag, int constflag, unsigned int id, bPoseChannel *pchan, EditBone *ebone) +{ + Mat4 *bbones = NULL; + int segments = 0; + float length; + + if (pchan) { + segments= pchan->bone->segments; + length= pchan->bone->length; + + if (segments > 1) + bbones = b_bone_spline_setup(pchan, 0); + } + else + length= ebone->length; + + /* draw points only if... */ + if (armflag & ARM_EDITMODE) { + /* move to unitspace */ + glPushMatrix(); + glScalef(length, length, length); + draw_bone_points(dt, armflag, boneflag, id); + glPopMatrix(); + length *= 0.95f; // make vertices visible + } + + /* this chunk not in object mode */ + if (armflag & (ARM_EDITMODE|ARM_POSEMODE)) { + if (id != -1) + glLoadName((GLuint) id|BONESEL_BONE); + + draw_wire_bone_segments(pchan, bbones, length, segments); + + /* further we send no names */ + if (id != -1) + glLoadName(id & 0xFFFF); /* object tag, for bordersel optim */ + } + + /* colors for modes */ + if (armflag & ARM_POSEMODE) { + set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag); + } + else if (armflag & ARM_EDITMODE) { + set_ebone_glColor(boneflag); + } + + /* draw normal */ + draw_wire_bone_segments(pchan, bbones, length, segments); +} + static void draw_bone(int dt, int armflag, int boneflag, int constflag, unsigned int id, float length) { @@ -1651,7 +1731,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int use_custom = (pchan->custom) && !(arm->flag & ARM_NO_CUSTOM); glPushMatrix(); - if(use_custom && pchan->custom_tx) { + if (use_custom && pchan->custom_tx) { glMultMatrixf(pchan->custom_tx->pose_mat); } else { @@ -1679,6 +1759,8 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } else if (arm->drawtype==ARM_LINE) ; /* nothing in solid */ + else if (arm->drawtype==ARM_WIRE) + ; /* nothing in solid */ else if (arm->drawtype==ARM_ENVELOPE) draw_sphere_bone(OB_SOLID, arm->flag, flag, 0, index, pchan, NULL); else if (arm->drawtype==ARM_B_BONE) @@ -1697,7 +1779,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* very very confusing... but in object mode, solid draw, we cannot do glLoadName yet, * stick bones and/or wire custom-shapes are drawn in next loop */ - if ((arm->drawtype != ARM_LINE) && (draw_wire == 0)) { + if (ELEM(arm->drawtype,ARM_LINE,ARM_WIRE)==0 && (draw_wire == 0)) { /* object tag, for bordersel optim */ glLoadName(index & 0xFFFF); index= -1; @@ -1768,8 +1850,8 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (index != -1) index+= 0x10000; // pose bones count in higher 2 bytes only } - /* stick bones have not been drawn yet so dont clear object selection in this case */ - if ((arm->drawtype != ARM_LINE) && draw_wire) { + /* stick or wire bones have not been drawn yet so dont clear object selection in this case */ + if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)==0 && draw_wire) { /* object tag, for bordersel optim */ glLoadName(index & 0xFFFF); index= -1; @@ -1779,7 +1861,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* wire draw over solid only in posemode */ if ((dt <= OB_WIRE) || (arm->flag & ARM_POSEMODE) || (arm->drawtype==ARM_LINE)) { /* draw line check first. we do selection indices */ - if (arm->drawtype==ARM_LINE) { + if ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) { if (arm->flag & ARM_POSEMODE) index= base->selcol; } @@ -1858,8 +1940,6 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* extra draw service for pose mode */ constflag= pchan->constflag; - if (pchan->flag & (POSE_ROT|POSE_LOC|POSE_SIZE)) - constflag |= PCHAN_HAS_ACTION; /* set color-set to use */ set_pchan_colorset(ob, pchan); @@ -1872,6 +1952,8 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } else if (arm->drawtype==ARM_LINE) draw_line_bone(arm->flag, flag, constflag, index, pchan, NULL); + else if (arm->drawtype==ARM_WIRE) + draw_wire_bone(dt, arm->flag, flag, constflag, index, pchan, NULL); else if (arm->drawtype==ARM_B_BONE) draw_b_bone(OB_WIRE, arm->flag, flag, constflag, index, pchan, NULL); else @@ -2006,7 +2088,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) } /* if solid we draw it first */ - if ((dt > OB_WIRE) && (arm->drawtype!=ARM_LINE)) { + if ((dt > OB_WIRE) && (arm->drawtype != ARM_LINE)) { for (eBone=arm->edbo->first, index=0; eBone; eBone=eBone->next, index++) { if (eBone->layer & arm->layer) { if ((eBone->flag & BONE_HIDDEN_A)==0) { @@ -2027,6 +2109,8 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) draw_sphere_bone(OB_SOLID, arm->flag, flag, 0, index, NULL, eBone); else if(arm->drawtype==ARM_B_BONE) draw_b_bone(OB_SOLID, arm->flag, flag, 0, index, NULL, eBone); + else if (arm->drawtype==ARM_WIRE) + draw_wire_bone(OB_SOLID, arm->flag, flag, 0, index, NULL, eBone); else { draw_bone(OB_SOLID, arm->flag, flag, 0, index, eBone->length); } @@ -2040,7 +2124,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) /* if wire over solid, set offset */ index= -1; glLoadName(-1); - if (arm->drawtype==ARM_LINE) { + if ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) { if(G.f & G_PICKSEL) index= 0; } @@ -2074,6 +2158,8 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) if (arm->drawtype == ARM_LINE) draw_line_bone(arm->flag, flag, 0, index, NULL, eBone); + else if (arm->drawtype==ARM_WIRE) + draw_wire_bone(OB_WIRE, arm->flag, flag, 0, index, NULL, eBone); else if (arm->drawtype == ARM_B_BONE) draw_b_bone(OB_WIRE, arm->flag, flag, 0, index, NULL, eBone); else @@ -2102,7 +2188,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt) /* restore */ if(index!=-1) glLoadName(-1); - if (arm->drawtype==ARM_LINE); + if ELEM(arm->drawtype,ARM_LINE,ARM_WIRE); else if (dt>OB_WIRE) bglPolygonOffset(rv3d->dist, 0.0f); /* finally names and axes */ @@ -2250,7 +2336,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base colfac = (end - (float)CFRA) / range; UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0*sqrt(colfac))); - BKE_animsys_evaluate_animdata(&ob->id, adt, (float)CFRA, ADT_RECALC_ALL); + BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); where_is_pose(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } @@ -2329,7 +2415,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * CFRA= (int)ak->cfra; - BKE_animsys_evaluate_animdata(&ob->id, adt, (float)CFRA, ADT_RECALC_ALL); + BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); where_is_pose(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } @@ -2399,7 +2485,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) CFRA= (int)BKE_nla_tweakedit_remap(adt, actframe+ctime, NLATIME_CONVERT_MAP); if (CFRA != cfrao) { - BKE_animsys_evaluate_animdata(&ob->id, adt, (float)CFRA, ADT_RECALC_ALL); + BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); where_is_pose(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } @@ -2414,7 +2500,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) CFRA= (int)BKE_nla_tweakedit_remap(adt, actframe-ctime, NLATIME_CONVERT_MAP); if (CFRA != cfrao) { - BKE_animsys_evaluate_animdata(&ob->id, adt, (float)CFRA, ADT_RECALC_ALL); + BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); where_is_pose(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } |