diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-07 12:02:48 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-07 12:02:48 +0400 |
commit | a921ca86f7a008d818f0f6da930c9d25b971ab64 (patch) | |
tree | 0bd18b6f06fcf7a045defbc6606645d12dee88c8 | |
parent | c714388473115752f32d0f2a7b722d4ef3bf7d57 (diff) |
fix for error in previous commit.
- dupli-group armatures with pose bone objects set would draw with uninitialized color
- also fix old bug - armature were over-riding the constcolor option - so drawing dupli-groups for eg - would ignore the DRAW_CONSTCOLOR flag.
-rw-r--r-- | source/blender/editors/space_view3d/drawarmature.c | 28 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 43 |
2 files changed, 45 insertions, 26 deletions
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index cb8b309dc72..cf8b84b5a56 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1658,7 +1658,7 @@ static void bone_matrix_translate_y(float mat[][4], float y) /* assumes object is Armature with pose */ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, const unsigned char ob_wire_col[4], - const short is_ghost, const short is_outline) + const short do_const_color, const short is_outline) { RegionView3D *rv3d = ar->regiondata; Object *ob = base->object; @@ -1828,10 +1828,10 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } /* prepare colors */ - if (is_ghost) { + if (do_const_color) { /* 13 October 2009, Disabled this to make ghosting show the right colors (Aligorith) */ } - else if (arm->flag & ARM_POSEMODE) + else if (arm->flag & ARM_POSEMODE) set_pchan_colorset(ob, pchan); else { glColor3ubv(ob_wire_col); @@ -1993,12 +1993,22 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */ if ((G.f & G_PICKSEL) == 0) { float vec[3]; - + unsigned char col[4]; - col[0] = ob_wire_col[0]; - col[1] = ob_wire_col[1]; - col[2] = ob_wire_col[2]; - col[3] = 255; + + if (do_const_color) { + /* so we can draw bone names in current const color */ + float tcol[4]; + glGetFloatv(GL_CURRENT_COLOR, tcol); + rgb_float_to_uchar(col, tcol); + col[3] = 255; + } + else { + col[0] = ob_wire_col[0]; + col[1] = ob_wire_col[1]; + col[2] = ob_wire_col[2]; + col[3] = 255; + } if (v3d->zbuf) glDisable(GL_DEPTH_TEST); @@ -2602,7 +2612,7 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } } } - draw_pose_bones(scene, v3d, ar, base, dt, ob_wire_col, FALSE, is_outline); + draw_pose_bones(scene, v3d, ar, base, dt, ob_wire_col, (flag & DRAW_CONSTCOLOR), is_outline); arm->flag &= ~ARM_POSEMODE; if (ob->mode & OB_MODE_POSE) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 73d941f62ce..51985a2860f 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1231,19 +1231,23 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* lamp center */ copy_v3_v3(vec, ob->obmat[3]); - - /* for AA effects */ - curcol[0] = ob_wire_col[0]; - curcol[1] = ob_wire_col[1]; - curcol[2] = ob_wire_col[2]; - curcol[3] = 154; - glColor4ubv(curcol); + + if ((flag & DRAW_CONSTCOLOR) == 0) { + /* for AA effects */ + curcol[0] = ob_wire_col[0]; + curcol[1] = ob_wire_col[1]; + curcol[2] = ob_wire_col[2]; + curcol[3] = 154; + glColor4ubv(curcol); + } if (lampsize > 0.0f) { - if (ob->id.us > 1) { - if (ob == OBACT || (ob->flag & SELECT)) glColor4ub(0x88, 0xFF, 0xFF, 155); - else glColor4ub(0x77, 0xCC, 0xCC, 155); + if ((flag & DRAW_CONSTCOLOR) == 0) { + if (ob->id.us > 1) { + if (ob == OBACT || (ob->flag & SELECT)) glColor4ub(0x88, 0xFF, 0xFF, 155); + else glColor4ub(0x77, 0xCC, 0xCC, 155); + } } /* Inner Circle */ @@ -1253,8 +1257,10 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, drawcircball(GL_POLYGON, vec, lampsize, imat); /* restore */ - if (ob->id.us > 1) - glColor4ubv(curcol); + if ((flag & DRAW_CONSTCOLOR) == 0) { + if (ob->id.us > 1) + glColor4ubv(curcol); + } /* Outer circle */ circrad = 3.0f * lampsize; @@ -1486,9 +1492,10 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, glDisable(GL_BLEND); - /* restore for drawing extra stuff */ - glColor3ubv(ob_wire_col); - + if ((flag & DRAW_CONSTCOLOR) == 0) { + /* restore for drawing extra stuff */ + glColor3ubv(ob_wire_col); + } } static void draw_limit_line(float sta, float end, unsigned int col) @@ -6540,7 +6547,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) RegionView3D *rv3d = ar->regiondata; float vec1[3], vec2[3]; unsigned int col = 0; - unsigned char ob_wire_col[4]; + unsigned char _ob_wire_col[4]; /* dont initialize this */ + unsigned char *ob_wire_col = NULL; /* dont initialize this, use NULL crashes as a way to find invalid use */ int i, selstart, selend, empty_object = 0; short dt, dtx, zbufoff = 0; const short is_obact = (ob == OBACT); @@ -6601,7 +6609,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) project_short(ar, ob->obmat[3], &base->sx); - draw_object_wire_color(scene, base, ob_wire_col, warning_recursive); + draw_object_wire_color(scene, base, _ob_wire_col, warning_recursive); + ob_wire_col = _ob_wire_col; glColor3ubv(ob_wire_col); } |