diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-06 22:00:08 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-06 22:00:08 +0400 |
commit | b53b03ac1c9bbc194c2ac1f255f8017f1a78bdd2 (patch) | |
tree | edb05a3bbd7e187ff94c936cdab4985bc36034fe /source/blender/editors | |
parent | 47c96b6e402f23afeb2ee577745b1e9f0e1ae085 (diff) |
pass the object wire color along to drawing functions, too many places would use glGetFloatv(GL_CURRENT_COLOR, curcol), which also become confusing to debug if in some cases the color was set beforehand.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_view3d/drawarmature.c | 29 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 290 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 6 |
4 files changed, 173 insertions, 154 deletions
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 0de7e2569c0..0803654fd68 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1656,7 +1656,8 @@ 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, +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) { RegionView3D *rv3d = ar->regiondata; @@ -1833,14 +1834,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, else if (arm->flag & ARM_POSEMODE) set_pchan_colorset(ob, pchan); else { - if ((scene->basact) == base) { - if (base->flag & (SELECT + BA_WAS_SEL)) UI_ThemeColor(TH_ACTIVE); - else UI_ThemeColor(TH_WIRE); - } - else { - if (base->flag & (SELECT + BA_WAS_SEL)) UI_ThemeColor(TH_SELECT); - else UI_ThemeColor(TH_WIRE); - } + glColor3ubv(ob_wire_col); } /* catch exception for bone with hidden parent */ @@ -2353,7 +2347,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); - draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); + draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE); } glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); @@ -2432,7 +2426,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); - draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); + draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE); } glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); @@ -2502,7 +2496,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); - draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); + draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE); } } @@ -2517,7 +2511,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); - draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); + draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE); } } } @@ -2537,8 +2531,11 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) /* ********************************** Armature Drawing - Main ************************* */ -/* called from drawobject.c, return 1 if nothing was drawn */ -int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, int flag, const short is_outline) +/* called from drawobject.c, return 1 if nothing was drawn + * (ob_wire_col == NULL) when drawing ghost */ +int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, + int dt, int flag, const unsigned char ob_wire_col[4], + const short is_outline) { Object *ob = base->object; bArmature *arm = ob->data; @@ -2605,7 +2602,7 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, in } } } - draw_pose_bones(scene, v3d, ar, base, dt, FALSE, is_outline); + draw_pose_bones(scene, v3d, ar, base, dt, ob_wire_col, FALSE, 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 45c1f5ccee4..63dc6c21863 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1189,14 +1189,17 @@ static void draw_transp_spot_volume(Lamp *la, float x, float z) glCullFace(GL_BACK); } -static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt, int flag) +static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, + int dt, int flag, const unsigned char ob_wire_col[4]) { Object *ob = base->object; const float pixsize = ED_view3d_pixel_size(rv3d, ob->obmat[3]); Lamp *la = ob->data; float vec[3], lvec[3], vvec[3], circrad, x, y, z; float lampsize; - float imat[4][4], curcol[4]; + float imat[4][4]; + + unsigned char curcol[4]; unsigned char col[4]; /* cone can't be drawn for duplicated lamps, because duplilist would be freed to */ /* the moment of view3d_draw_transp() call */ @@ -1230,10 +1233,12 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, copy_v3_v3(vec, ob->obmat[3]); /* for AA effects */ - glGetFloatv(GL_CURRENT_COLOR, curcol); - curcol[3] = 0.6; - glColor4fv(curcol); - + 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) { @@ -1249,7 +1254,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, /* restore */ if (ob->id.us > 1) - glColor4fv(curcol); + glColor4ubv(curcol); /* Outer circle */ circrad = 3.0f * lampsize; @@ -1482,7 +1487,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, glDisable(GL_BLEND); /* restore for drawing extra stuff */ - glColor3fv(curcol); + glColor3ubv(ob_wire_col); } @@ -1516,7 +1521,7 @@ static void draw_focus_cross(float dist, float size) } #ifdef VIEW3D_CAMERA_BORDER_HACK -float view3d_camera_border_hack_col[4]; +unsigned char view3d_camera_border_hack_col[3]; short view3d_camera_border_hack_test = FALSE; #endif @@ -1701,11 +1706,11 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D } static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, MovieClip *clip, - int flag, int draw_selected) + int flag, const unsigned char ob_wire_col[4], + int draw_selected) { MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object; - float curcol[4]; int global_track_index = 1; if ((v3d->flag2 & V3D_SHOW_RECONSTRUCTION) == 0) @@ -1714,8 +1719,6 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, if (v3d->flag2 & V3D_RENDER_OVERRIDE) return; - glGetFloatv(GL_CURRENT_COLOR, curcol); - glEnable(GL_LIGHTING); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glEnable(GL_COLOR_MATERIAL); @@ -1734,14 +1737,15 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, glDisable(GL_COLOR_MATERIAL); glDisable(GL_LIGHTING); - glColor4fv(curcol); + glColor3ubv(ob_wire_col); if (flag & DRAW_PICKING) glLoadName(base->selcol); } /* flag similar to draw_object() */ -static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int flag) +static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, + int flag, const unsigned char ob_wire_col[4]) { /* a standing up pyramid with (0,0,0) as top */ Camera *cam; @@ -1755,13 +1759,15 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base /* draw data for movie clip set as active for scene */ if (clip) { - draw_viewport_reconstruction(scene, base, v3d, clip, flag, FALSE); - draw_viewport_reconstruction(scene, base, v3d, clip, flag, TRUE); + draw_viewport_reconstruction(scene, base, v3d, clip, flag, ob_wire_col, FALSE); + draw_viewport_reconstruction(scene, base, v3d, clip, flag, ob_wire_col, TRUE); } #ifdef VIEW3D_CAMERA_BORDER_HACK if (is_view && !(G.f & G_PICKSEL)) { - glGetFloatv(GL_CURRENT_COLOR, view3d_camera_border_hack_col); + view3d_camera_border_hack_col[0] = ob_wire_col[0]; + view3d_camera_border_hack_col[1] = ob_wire_col[1]; + view3d_camera_border_hack_col[2] = ob_wire_col[2]; view3d_camera_border_hack_test = TRUE; return; } @@ -3778,17 +3784,15 @@ static int drawDispListwire(ListBase *dlbase) return 0; } -static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) +static void drawDispListsolid(ListBase *lb, Object *ob, + const unsigned char ob_wire_col[4], int use_glsl) { DispList *dl; GPUVertexAttribs gattribs; - float *data, curcol[4]; + float *data; float *ndata; if (lb == NULL) return; - - /* for drawing wire */ - glGetFloatv(GL_CURRENT_COLOR, curcol); glEnable(GL_LIGHTING); glEnableClientState(GL_VERTEX_ARRAY); @@ -3811,7 +3815,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) int nr; glDisable(GL_LIGHTING); - glColor3fv(curcol); + glColor3ubv(ob_wire_col); // glVertexPointer(3, GL_FLOAT, 0, dl->verts); // glDrawArrays(GL_LINE_STRIP, 0, dl->nr); @@ -3845,7 +3849,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) case DL_SURF: if (dl->index) { - GPU_enable_material(dl->col + 1, (glsl) ? &gattribs : NULL); + GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL); if (dl->rt & CU_SMOOTH) glShadeModel(GL_SMOOTH); else glShadeModel(GL_FLAT); @@ -3859,7 +3863,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) break; case DL_INDEX3: - GPU_enable_material(dl->col + 1, (glsl) ? &gattribs : NULL); + GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL); glVertexPointer(3, GL_FLOAT, 0, dl->verts); @@ -3879,7 +3883,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl) break; case DL_INDEX4: - GPU_enable_material(dl->col + 1, (glsl) ? &gattribs : NULL); + GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL); glEnableClientState(GL_NORMAL_ARRAY); glVertexPointer(3, GL_FLOAT, 0, dl->verts); @@ -3937,7 +3941,8 @@ static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, B } /* returns 1 when nothing was drawn */ -static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt) +static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, + int dt, const unsigned char ob_wire_col[4]) { Object *ob = base->object; ListBase *lb = NULL; @@ -3985,12 +3990,12 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas else { if (draw_glsl_material(scene, ob, v3d, dt)) { GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); - drawDispListsolid(lb, ob, 1); + drawDispListsolid(lb, ob, ob_wire_col, TRUE); GPU_end_object_materials(); } else { GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); - drawDispListsolid(lb, ob, 0); + drawDispListsolid(lb, ob, ob_wire_col, FALSE); GPU_end_object_materials(); } if (cu->editnurb && cu->bevobj == NULL && cu->taperobj == NULL && cu->ext1 == 0.0f && cu->ext2 == 0.0f) { @@ -4022,12 +4027,12 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas if (draw_glsl_material(scene, ob, v3d, dt)) { GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); - drawDispListsolid(lb, ob, 1); + drawDispListsolid(lb, ob, ob_wire_col, TRUE); GPU_end_object_materials(); } else { GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); - drawDispListsolid(lb, ob, 0); + drawDispListsolid(lb, ob, ob_wire_col, FALSE); GPU_end_object_materials(); } } @@ -4046,12 +4051,12 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas if (draw_glsl_material(scene, ob, v3d, dt)) { GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); - drawDispListsolid(lb, ob, 1); + drawDispListsolid(lb, ob, ob_wire_col, TRUE); GPU_end_object_materials(); } else { GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); - drawDispListsolid(lb, ob, 0); + drawDispListsolid(lb, ob, ob_wire_col, FALSE); GPU_end_object_materials(); } } @@ -5563,7 +5568,8 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel) } } -static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, Nurb *nurb, int dt) +static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, Nurb *nurb, + int dt, const unsigned char ob_wire_col[4]) { ToolSettings *ts = scene->toolsettings; Object *ob = base->object; @@ -5572,10 +5578,13 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, BevList *bl; short hide_handles = (cu->drawflag & CU_HIDE_HANDLES); int index; + unsigned char wire_col[3]; /* DispList */ - UI_ThemeColor(TH_WIRE); - drawDispList(scene, v3d, rv3d, base, dt); + UI_GetThemeColor3ubv(TH_WIRE, wire_col); + glColor3ubv(wire_col); + + drawDispList(scene, v3d, rv3d, base, dt, ob_wire_col); if (v3d->zbuf) glDisable(GL_DEPTH_TEST); @@ -5887,7 +5896,8 @@ static void drawcone(const float vec[3], float radius, float height, float tmat[ glEnd(); } /* return 1 if nothing was drawn */ -static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt) +static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, + int dt, const unsigned char ob_wire_col[4]) { Object *ob = base->object; MetaBall *mb; @@ -5898,13 +5908,19 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, mb = ob->data; if (mb->editelems) { - UI_ThemeColor(TH_WIRE); - if ((G.f & G_PICKSEL) == 0) drawDispList(scene, v3d, rv3d, base, dt); + if ((G.f & G_PICKSEL) == 0) { + unsigned char wire_col[3]; + UI_GetThemeColor3ubv(TH_WIRE, wire_col); + glColor3ubv(wire_col); + + drawDispList(scene, v3d, rv3d, base, dt, wire_col); + } ml = mb->editelems->first; } else { - if ((base->flag & OB_FROMDUPLI) == 0) - drawDispList(scene, v3d, rv3d, base, dt); + if ((base->flag & OB_FROMDUPLI) == 0) { + drawDispList(scene, v3d, rv3d, base, dt, ob_wire_col); + } ml = mb->elems.first; } @@ -6276,7 +6292,8 @@ static void drawtexspace(Object *ob) } /* draws wire outline */ -static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) +static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base, + const unsigned char ob_wire_col[4]) { RegionView3D *rv3d = ar->regiondata; Object *ob = base->object; @@ -6315,7 +6332,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) } else if (ob->type == OB_ARMATURE) { if (!(ob->mode & OB_MODE_POSE && base == scene->basact)) - draw_armature(scene, v3d, ar, base, OB_WIRE, FALSE, TRUE); + draw_armature(scene, v3d, ar, base, OB_WIRE, FALSE, ob_wire_col, TRUE); } glLineWidth(1.0); @@ -6407,19 +6424,13 @@ static void draw_hooks(Object *ob) } } -static void drawRBpivot(bRigidBodyJointConstraint *data) +static void drawRBpivot(bRigidBodyJointConstraint *data, const unsigned char ob_wire_col[4]) { const char *axis_str[3] = {"px", "py", "pz"}; int axis; float mat[4][4]; /* color */ - float curcol[4]; - unsigned char tcol[4]; - - glGetFloatv(GL_CURRENT_COLOR, curcol); - rgb_float_to_uchar(tcol, curcol); - tcol[3] = 255; eul_to_mat4(mat, &data->axX); glLineWidth(4.0f); @@ -6438,12 +6449,87 @@ static void drawRBpivot(bRigidBodyJointConstraint *data) glVertex3fv(v); glEnd(); - view3d_cached_text_draw_add(v, axis_str[axis], 0, V3D_CACHE_TEXT_ASCII, tcol); + view3d_cached_text_draw_add(v, axis_str[axis], 0, V3D_CACHE_TEXT_ASCII, ob_wire_col); } glLineWidth(1.0f); setlinestyle(0); } +static void draw_object_wire_color(Scene *scene, Base *base, unsigned char r_ob_wire_col[4], + const int warning_recursive) +{ + Object *ob = base->object; + int colindex = 0; + + /* confusing logic here, there are 2 methods of setting the color + * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id. + * + * note: no theme yet for 'colindex' */ + int theme_id = TH_WIRE; + int theme_shade = 0; + + if ((scene->obedit == NULL) && + (G.moving & G_TRANSFORM_OBJ) && + (base->flag & (SELECT + BA_WAS_SEL))) + { + theme_id = TH_TRANSFORM; + } + else { + /* Sets the 'colindex' */ + if (ob->id.lib) { + colindex = (base->flag & (SELECT + BA_WAS_SEL)) ? 4 : 3; + } + else if (warning_recursive == 1) { + if (base->flag & (SELECT + BA_WAS_SEL)) { + colindex = (scene->basact == base) ? 8 : 7; + } + else { + colindex = 6; + } + } + /* Sets the 'theme_id' or fallback to wire */ + else { + if (ob->flag & OB_FROMGROUP) { + if (base->flag & (SELECT + BA_WAS_SEL)) { + /* uses darker active color for non-active + selected*/ + theme_id = TH_GROUP_ACTIVE; + + if (scene->basact != base) { + theme_shade = -16; + } + } + else { + theme_id = TH_GROUP; + } + } + else { + if (base->flag & (SELECT + BA_WAS_SEL)) { + theme_id = scene->basact == base ? TH_ACTIVE : TH_SELECT; + } + else { + if (ob->type == OB_LAMP) theme_id = TH_LAMP; + else if (ob->type == OB_SPEAKER) theme_id = TH_SPEAKER; + else if (ob->type == OB_CAMERA) theme_id = TH_CAMERA; + else if (ob->type == OB_EMPTY) theme_id = TH_EMPTY; + /* fallback to TH_WIRE */ + } + } + } + } + + /* finally set the color */ + if (colindex == 0) { + if (theme_shade == 0) UI_GetThemeColor3ubv(theme_id, r_ob_wire_col); + else UI_GetThemeColorShade3ubv(theme_id, theme_shade, r_ob_wire_col); + } + else { + cpack_cpy_3ub(r_ob_wire_col, colortab[colindex]); + } + + /* no reason to use this but some functions take col[4] */ + r_ob_wire_col[3] = 255; +} + /* flag can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET */ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) { @@ -6454,7 +6540,7 @@ 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; - int /*sel, drawtype,*/ colindex = 0; + unsigned char ob_wire_col[4]; int i, selstart, selend, empty_object = 0; short dt, dtx, zbufoff = 0; const short is_obact = (ob == OBACT); @@ -6515,73 +6601,12 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* which wire color */ if ((flag & DRAW_CONSTCOLOR) == 0) { - /* confusing logic here, there are 2 methods of setting the color - * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id. - * - * note: no theme yet for 'colindex' */ - int theme_id = TH_WIRE; - int theme_shade = 0; project_short(ar, ob->obmat[3], &base->sx); - if ((scene->obedit == NULL) && - (G.moving & G_TRANSFORM_OBJ) && - (base->flag & (SELECT + BA_WAS_SEL))) - { - theme_id = TH_TRANSFORM; - } - else { - /* Sets the 'colindex' */ - if (ob->id.lib) { - colindex = (base->flag & (SELECT + BA_WAS_SEL)) ? 4 : 3; - } - else if (warning_recursive == 1) { - if (base->flag & (SELECT + BA_WAS_SEL)) { - colindex = (scene->basact == base) ? 8 : 7; - } - else { - colindex = 6; - } - } - /* Sets the 'theme_id' or fallback to wire */ - else { - if (ob->flag & OB_FROMGROUP) { - if (base->flag & (SELECT + BA_WAS_SEL)) { - /* uses darker active color for non-active + selected*/ - theme_id = TH_GROUP_ACTIVE; - - if (scene->basact != base) { - theme_shade = -16; - } - } - else { - theme_id = TH_GROUP; - } - } - else { - if (base->flag & (SELECT + BA_WAS_SEL)) { - theme_id = scene->basact == base ? TH_ACTIVE : TH_SELECT; - } - else { - if (ob->type == OB_LAMP) theme_id = TH_LAMP; - else if (ob->type == OB_SPEAKER) theme_id = TH_SPEAKER; - else if (ob->type == OB_CAMERA) theme_id = TH_CAMERA; - else if (ob->type == OB_EMPTY) theme_id = TH_EMPTY; - /* fallback to TH_WIRE */ - } - } - } - } + draw_object_wire_color(scene, base, ob_wire_col, warning_recursive); - /* finally set the color */ - if (colindex == 0) { - if (theme_shade == 0) UI_ThemeColor(theme_id); - else UI_ThemeColorShade(theme_id, theme_shade); - } - else { - col = colortab[colindex]; - cpack(col); - } + glColor3ubv(ob_wire_col); } /* maximum drawtype */ @@ -6642,7 +6667,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if (dt > OB_WIRE && (ob->mode & OB_MODE_EDIT) == 0 && (flag & DRAW_SCENESET) == 0) { if (!(ob->dtx & OB_DRAWWIRE) && (ob->flag & SELECT) && !(flag & DRAW_PICKING)) { - drawObjectSelect(scene, v3d, ar, base); + drawObjectSelect(scene, v3d, ar, base, ob_wire_col); } } } @@ -6661,11 +6686,11 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if (cu->flag & CU_FAST) { cpack(0xFFFFFF); set_inverted_drawing(1); - drawDispList(scene, v3d, rv3d, base, OB_WIRE); + drawDispList(scene, v3d, rv3d, base, OB_WIRE, ob_wire_col); set_inverted_drawing(0); } else { - drawDispList(scene, v3d, rv3d, base, dt); + drawDispList(scene, v3d, rv3d, base, dt, ob_wire_col); } if (cu->linewidth != 0.0f) { @@ -6740,7 +6765,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } } else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { - empty_object = drawDispList(scene, v3d, rv3d, base, dt); + empty_object = drawDispList(scene, v3d, rv3d, base, dt, ob_wire_col); } break; @@ -6750,7 +6775,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if (cu->editnurb) { ListBase *nurbs = BKE_curve_editNurbs_get(cu); - drawnurb(scene, v3d, rv3d, base, nurbs->first, dt); + drawnurb(scene, v3d, rv3d, base, nurbs->first, dt, ob_wire_col); } else if (dt == OB_BOUNDBOX) { if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && (v3d->drawtype >= OB_WIRE)) == 0) { @@ -6758,7 +6783,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } } else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { - empty_object = drawDispList(scene, v3d, rv3d, base, dt); + empty_object = drawDispList(scene, v3d, rv3d, base, dt, ob_wire_col); //XXX old animsys if (cu->path) // curve_draw_speed(scene, ob); @@ -6769,14 +6794,14 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) MetaBall *mb = ob->data; if (mb->editelems) - drawmball(scene, v3d, rv3d, base, dt); + drawmball(scene, v3d, rv3d, base, dt, ob_wire_col); else if (dt == OB_BOUNDBOX) { if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && (v3d->drawtype >= OB_WIRE)) == 0) { draw_bounding_volume(scene, ob, ob->boundtype); } } else - empty_object = drawmball(scene, v3d, rv3d, base, dt); + empty_object = drawmball(scene, v3d, rv3d, base, dt, ob_wire_col); break; } case OB_EMPTY: @@ -6791,7 +6816,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) break; case OB_LAMP: if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { - drawlamp(scene, v3d, rv3d, base, dt, flag); + drawlamp(scene, v3d, rv3d, base, dt, flag, ob_wire_col); if (dtx || (base->flag & SELECT)) glMultMatrixf(ob->obmat); } break; @@ -6799,7 +6824,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0 || (rv3d->persp == RV3D_CAMOB && v3d->camera == ob)) /* special exception for active camera */ { - drawcamera(scene, v3d, rv3d, base, flag); + drawcamera(scene, v3d, rv3d, base, flag, ob_wire_col); break; } case OB_SPEAKER: @@ -6822,7 +6847,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) else { if (dt > OB_WIRE) GPU_enable_material(0, NULL); /* we use default material */ - empty_object = draw_armature(scene, v3d, ar, base, dt, flag, FALSE); + empty_object = draw_armature(scene, v3d, ar, base, dt, flag, ob_wire_col, FALSE); if (dt > OB_WIRE) GPU_disable_material(); } @@ -7026,7 +7051,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if (con->type == CONSTRAINT_TYPE_RIGIDBODYJOINT) { bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)con->data; if (data->flag & CONSTRAINT_DRAW_PIVOT) - drawRBpivot(data); + drawRBpivot(data, ob_wire_col); } } @@ -7054,13 +7079,8 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */ /* but, we also don't draw names for sets or duplicators */ if (flag == 0) { - float zero[3] = {0, 0, 0}; - float curcol[4]; - unsigned char tcol[4]; - glGetFloatv(GL_CURRENT_COLOR, curcol); - rgb_float_to_uchar(tcol, curcol); - tcol[3] = 255; - view3d_cached_text_draw_add(zero, ob->id.name + 2, 10, 0, tcol); + const float zero[3] = {0, 0, 0}; + view3d_cached_text_draw_add(zero, ob->id.name + 2, 10, 0, ob_wire_col); } } /*if (dtx & OB_DRAWIMAGE) drawDispListwire(&ob->disp);*/ diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index c42264e4dac..7c12816741d 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1127,7 +1127,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) #ifdef VIEW3D_CAMERA_BORDER_HACK if (view3d_camera_border_hack_test == TRUE) { - glColor4fv(view3d_camera_border_hack_col); + glColor3ubv(view3d_camera_border_hack_col); glRectf(x1i + 1, y1i + 1, x2i - 1, y2i - 1); view3d_camera_border_hack_test = FALSE; } diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 29edc0158d6..de259efdf59 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -128,7 +128,9 @@ void view3d_cached_text_draw_end(View3D * v3d, ARegion * ar, int depth_write, fl #define V3D_CACHE_TEXT_LOCALCLIP (1 << 4) /* drawarmature.c */ -int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, int flag, const short is_outline); +int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, + int dt, int flag, const unsigned char ob_wire_col[4], + const short is_outline); /* drawmesh.c */ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, @@ -211,7 +213,7 @@ void draw_volume(struct ARegion *ar, struct GPUTexture *tex, float min[3], float * any direction it starts to fail */ #define VIEW3D_CAMERA_BORDER_HACK #ifdef VIEW3D_CAMERA_BORDER_HACK -extern float view3d_camera_border_hack_col[4]; +extern unsigned char view3d_camera_border_hack_col[3]; extern short view3d_camera_border_hack_test; #endif |