Page MenuHome

Color Wireframe (option)
AbandonedPublic

Authored by Campbell Barton (campbellbarton) on Apr 11 2014, 6:30 AM.
Tags
None
Tokens
"Like" token, awarded by Alphisto."Love" token, awarded by nirenyang."Love" token, awarded by leon_cheung."Like" token, awarded by gandalf3.

Details

Summary

This is a long requested feature, however currently the color is already used for group, selection and object types.

So this is an attempt to add the ability to show colored wireframe without interfering with existing display options.

Implementation

  • Color wireframe is an option which applies to wire and bounding box draw modes.
  • When enabled, color from the object draw_color is used (a separate color setting).
  • The background draws grey (so themes don't interfere with user-specified colors), Overlay guides draw black (cursor cross-hair for example).
  • Selection state is shown by a white wire-outline.
  • Active objects draw a brighter outline.
  • Use the depth buffer when drawing colored wire (needed so the frontmost color draws ontop.)

Rationale

In certain cases this is a very useful feature, but it conflicts with other features too much, so this works like Matcaps, optionally changing the draw mode for all objects.

Limitations

  • none left :)

Screenshot

Heres a screenshot:

Possible Improvements

  • Tools to manage colors, randomize, set based on rules etc (outside the scope of this patch)

Background Color

Adding a section for this, since it seems to be one of the more controversial topics.

When custom color is set, if the user has their own theme, they will set the wire to contrast against the current theme,
This is a problem if someone else tries to use their file, so. I've opted to hard-code the background color when custom wireframes are enabled. See image below.

Testing Colors

This script is for quickly testing colors:

from random import random
from mathutils import Color
import bpy
for ob in bpy.data.objects:
    c = Color(ob.draw_color[0:3])
    v = c.v
    
    c.h = 0.0
    c.s = 1.0
    c.h = random()
    c.s = 0.2 * random()
    c.v = v
 
    ob.draw_color[0:3] = c[:]

Diff Detail

Event Timeline

Campbell Barton (campbellbarton) updated this revision to Unknown Object (????).Apr 11 2014, 6:44 AM

some silly errors corrected

Campbell Barton (campbellbarton) updated this revision to Unknown Object (????).Apr 11 2014, 7:08 AM

Now stipple can work like color, it can be set by the caller of draw_object without having to worry about it changing.

see: DRAW_CONSTSTIPPLE

Would it make sense to restrict user colour selection to hue only? That way Blender can still use value/saturation to indicate selectedness/activeness.

Dull = unselected.
Bright = selected.
Very bright = active.

Thanks Cambell

Been waiting for this for a long time. Thank you.

I like the stippled lines (reminds me of Multigen).

How hard will it be to get the depth buffer (hidden line removal?) working?

I've attached a screengrab to show how Maya indicates which objects are selected

The top row of spheres are unselected

The bottom row are all selected. Selected objects are drawn in white apart from the last selected which is drawn in bright green.

If memory serves you can customise Maya wireframes colours even if they break the guideline/defaults.

cheers

Campbell Barton (campbellbarton) updated this revision to Unknown Object (????).Apr 12 2014, 5:36 AM

Colored wire now uses depth buffer, fixed issue in drawing stipple selection and correctly set dflag for set-scenes.

Campbell Barton (campbellbarton) updated this revision to Unknown Object (????).Apr 12 2014, 8:13 AM

updated for refactoring in master

I've been wanting this for a long while, thanks for working on it! :) I've had some thoughts about how this could be implemented - though it seems you have this under control.

I think the main reason people want this feature is to allow them to distinguish key objects visually in wireframe mode (eg. make character A green, character B red and animated props blue...), or make unimportant objects less visible (eg. background set objects a dull grey).

Users know that there will be issues like wireframe colours being too similar to the viewport background. The best design here imo is a simple and predictable one. Let them make whatever colours they like, and don't try to handle cases where the wire is not so visible relative to the background - that's the user's problem that they would rather solve themselves than have limitations like only being allowed to adjust hue and saturation, or being forced to have a specific background colour.

The reason I think that's ok is because whoever builds the model and assigns the wireframe colours (which should definitely be separate from the object colour) is probably the guy who will be using it - or works with the guy who will be using it. Thus he knows what theme(s) will be used and will choose colours that don't contest with the theme.

As for selection, the stippled line is a pretty cool idea, but perhaps not suitable for selection. It might be nice to have this as an option for each object (eg. make rig controls solid wires and character mesh wires stippled).
Having thicker wires might be a good solution for selection, but I think just overriding the colours would be best - selected and active object wires stay defined by the theme.

As for grouped objects - what about allowing for an optional custom wire colour for the whole group? Think of an enum with three options:

  • Theme: (default) Wire colours are defined by the current theme
  • Custom: A custom colour for the unselected group, selected and active wire colour would be the same as non-group objects.
  • Per-Object: Use each object's own defined wire colour

Depending on how you implement this, it might be nice to have a master switch to turn off display of custom wire colours. You might quickly want to check an issue that you can't see properly with the fancy colours, or maybe changed your theme since you made the model 6 years ago.

Attached a patch which testes outline to show active & selected, rather then dashed line.

This has the advantage that you can tell active from other selected objects.

But the disadvantage that zoomed out, you can't see the color quite as well (selection overlay becomes a bit too heavy).

Campbell Barton (campbellbarton) updated this revision to Unknown Object (????).Apr 17 2014, 6:51 PM

Updates:

  • improved method of drawing wire overlay.
  • use grey background
  • disable in editmode
Campbell Barton (campbellbarton) updated this revision to Unknown Object (????).Apr 17 2014, 6:53 PM

The selection overlay would glow too much, making it hard to see the color.

The patch now uses a light outline rather then an overlay.

Campbell Barton (campbellbarton) updated this revision to Unknown Object (????).Apr 17 2014, 7:04 PM

clear the depth buffer when drawing the selection, so selected objects are always ontop.

minor tweaks to this patch to use wire color in solid mode.

NOTE, this is a test only, not proposed patch for inclusion

As one who attempted coloured wireframe a couple of years ago, I had setup a per object colour for wireframe with group,select,active etc colours overriding the object wirecolour. I put off my next idea as bmesh was going in and never got back to it.

Something Ton said on IRC about how he wanted it to work gave me the idea to create WireColour sets - similar to bone group colour sets. Each set would define a wire, selected and active colour with group and edit colours being global colours overriding the colour set. Then each object can choose to use a set or default to the theme colours.

I had thought of the colour sets being a list at the scene level, as a user generated list rather than a preset fixed list like bone groups. Maybe the factory startup.blend could have a preset list of sets defined.

About background.. the custom background there should be such option. to use the same background with is used in them with u have created. Why i have to use gray background because it is the best compromise, + it will work with all color setups in blend.

Who cares?! if i open a blend from someone and he has some colors with dosn't work with my background i spend 1-2 minutes to just change them so they work... or i just Click a checkbox button with change the background to black or gray or whatever default..

Groups will be possible to have custom groups colors?

The request and ideas put here or on the BA forum?

so i got idea.. would be possible to make Overal Saturation/Brightnes of wire frame. let' say that u have some almost 100% red blue etc.. very contrast colors.. and u want to make them more.. eye pain.. u just turn down the saturation.. or u have white background? and the colors are to dark? u just turn more brightness... That simple stuff would make even more easly adjusting someone else blend or even your blend to your background.

how about:
-auto random wireframes on object creation.
-global turn on/off all colored wireframes to default theme.

Hi there,

Can somebody post a win 7 64 build of the patch? it seems that the one in graphicall from tungerz is not working properly in my system.

Thanks in advance.

Campbell Barton (campbellbarton) updated this revision to Unknown Object (????).May 8 2014, 6:34 AM

wire color is now a separate setting.

Campbell Barton (campbellbarton) updated this revision to Unknown Object (????).Jun 4 2014, 8:46 AM
  • Fix for dupli-objects (which now follow the wire color).
  • Minor changes to python UI (no longer cram color next to object name).
  • Update against latest master.

Abandoning, this patch applies to 2.71 release and may be useful as a reference in its current form.

Campbell Barton (campbellbarton) updated this revision to Unknown Object (????).Jun 16 2014, 3:59 PM

A quick patch to see wire colored wire in solid mode, Note that this is using solid drawing but overriding the material color with the object color.

1diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
2index 13e010d..11386f3 100644
3--- a/source/blender/editors/space_view3d/drawobject.c
4+++ b/source/blender/editors/space_view3d/drawobject.c
5@@ -3966,10 +3966,12 @@ static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3
6 }
7
8 /* backface culling */
9+#if 0
10 if (v3d->flag2 & V3D_BACKFACE_CULLING) {
11 glEnable(GL_CULL_FACE);
12 glCullFace(GL_BACK);
13 }
14+#endif
15
16 if (ob == obedit || drawlinked) {
17 DerivedMesh *finalDM, *cageDM;
18@@ -4035,8 +4037,10 @@ static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3
19 }
20 }
21
22+#if 0
23 if (v3d->flag2 & V3D_BACKFACE_CULLING)
24 glDisable(GL_CULL_FACE);
25+#endif
26
27 return retval;
28 }
29@@ -4457,11 +4461,13 @@ static bool drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *ba
30 bool retval;
31
32 /* backface culling */
33+#if 0
34 if (v3d->flag2 & V3D_BACKFACE_CULLING) {
35 /* not all displists use same in/out normal direction convention */
36 glEnable(GL_CULL_FACE);
37 glCullFace(GL_BACK);
38 }
39+#endif
40
41 #ifdef SEQUENCER_DAG_WORKAROUND
42 ensure_curve_cache(scene, base->object);
43@@ -4469,9 +4475,11 @@ static bool drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *ba
44
45 retval = drawDispList_nobackface(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
46
47+#if 0
48 if (v3d->flag2 & V3D_BACKFACE_CULLING) {
49 glDisable(GL_CULL_FACE);
50 }
51+#endif
52
53 return retval;
54 }
55@@ -7157,8 +7165,21 @@ static void draw_rigidbody_shape(Object *ob)
56 * main object drawing function, draws in selection
57 * \param dflag (draw flag) can be DRAW_PICKING and/or DRAW_CONSTCOLOR, DRAW_SCENESET
58 */
59+static void _draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short dflag);
60 void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short dflag)
61 {
62+ bool is_wire = (v3d->flag2 & V3D_BACKFACE_CULLING) != 0;
63+
64+ if (is_wire)
65+ glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
66+
67+ _draw_object(scene, ar, v3d, base, dflag);
68+
69+ if (is_wire)
70+ glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
71+}
72+static void _draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short dflag)
73+{
74 ModifierData *md = NULL;
75 Object *ob = base->object;
76 Curve *cu;
77diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
78index fa9bc73..5755ed2 100644
79--- a/source/blender/gpu/intern/gpu_draw.c
80+++ b/source/blender/gpu/intern/gpu_draw.c
81@@ -1505,6 +1505,11 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
82 if (ob->totcol==0) {
83 gpu_material_to_fixed(&GMS.matbuf[0], &defmaterial, 0, ob, new_shading_nodes);
84
85+ if (v3d->flag2 & V3D_BACKFACE_CULLING) {
86+ copy_v3_v3(GMS.matbuf[0].diff, ob->col);
87+ copy_v3_v3(GMS.matbuf[0].spec, ob->col);
88+ }
89+
90 /* do material 1 too, for displists! */
91 memcpy(&GMS.matbuf[1], &GMS.matbuf[0], sizeof(GPUMaterialFixed));
92
93@@ -1535,6 +1540,11 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
94 /* fixed function opengl materials */
95 gpu_material_to_fixed(&GMS.matbuf[a], ma, gamma, ob, new_shading_nodes);
96
97+ if (v3d->flag2 & V3D_BACKFACE_CULLING) {
98+ copy_v3_v3(GMS.matbuf[a].diff, ob->col);
99+ copy_v3_v3(GMS.matbuf[a].spec, ob->col);
100+ }
101+
102 if (GMS.use_alpha_pass && ((ma->mode & MA_TRANSP) || (new_shading_nodes && ma->alpha != 1.0f))) {
103 GMS.matbuf[a].diff[3]= ma->alpha;
104 alphablend = (ma->alpha == 1.0f)? GPU_BLEND_SOLID: GPU_BLEND_ALPHA;
- click link for screenshot.

This is a test which tints object color for selection rather then using outlines

Summary of the patch

  • Users can select any color they want.
  • Colors brightness is tinted to show selection (instead of outline)
  • Colors are adjusted if they are too closely matching the background color. (so as to avoid conflicting with themes and no need to override background color).

Other changes from previous patch:

  • Color wire option is per-object (default off)
  • Color wire is also a viewport option (default on), but can be disabled.
  • Works in solid-mode (nice with draw-wire enabled)

This way, you can op-out of viewing colors if you load someone elses file and they are getting in the way.

Usage

  • Enable per-object (toggle next to wire color button)
  • To toggle entirely, change the color-wire option in the view display panel.

Screenshot of the mango-quadbot. - random colors, ideally we have a better way to set colors.

1commit 47ec2740deb96fcdf927554c58eca5c199190034
2Author: Campbell Barton <ideasman42@gmail.com>
3Date: Wed Oct 29 18:56:51 2014 +0100
4
5 color tint
6
7diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py
8index 25367a5..095db89 100644
9--- a/release/scripts/startup/bl_ui/properties_object.py
10+++ b/release/scripts/startup/bl_ui/properties_object.py
11@@ -253,10 +253,12 @@ class OBJECT_PT_display(ObjectButtonsPanel, Panel):
12 col.prop(obj, "draw_type", text="")
13
14 col = split.column()
15- if is_geometry or is_empty_image:
16+ if 1:
17 # Only useful with object having faces/materials...
18 col.label(text="Object Color:")
19- col.prop(obj, "color", text="")
20+ row = col.row(align=True)
21+ row.prop(obj, "color", text="")
22+ row.prop(obj, "show_wire_color", text="", toggle=True, icon='WIRE')
23
24
25 class OBJECT_PT_duplication(ObjectButtonsPanel, Panel):
26diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
27index 0ea552e..d88c181 100644
28--- a/release/scripts/startup/bl_ui/space_view3d.py
29+++ b/release/scripts/startup/bl_ui/space_view3d.py
30@@ -2781,6 +2781,7 @@ class VIEW3D_PT_view3d_name(Panel):
31 def draw(self, context):
32 layout = self.layout
33
34+ view = context.space_data
35 ob = context.active_object
36 row = layout.row()
37 row.label(text="", icon='OBJECT_DATA')
38@@ -2879,6 +2880,9 @@ class VIEW3D_PT_view3d_shading(Panel):
39 if not scene.render.use_shading_nodes:
40 col.prop(gs, "material_mode", text="")
41
42+ if view.viewport_shade in {'BOUNDBOX', 'WIREFRAME', 'SOLID'}:
43+ col.prop(view, "use_wire_color")
44+
45 if view.viewport_shade == 'SOLID':
46 col.prop(view, "show_textured_solid")
47 col.prop(view, "use_matcap")
48@@ -3277,3 +3281,4 @@ def unregister():
49
50 if __name__ == "__main__":
51 register()
52+
53diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
54index db04d3c..3ffb868 100644
55--- a/source/blender/editors/space_view3d/drawobject.c
56+++ b/source/blender/editors/space_view3d/drawobject.c
57@@ -7066,6 +7066,52 @@ static void draw_object_wire_color(Scene *scene, Base *base, unsigned char r_ob_
58 r_ob_wire_col[3] = 255;
59 }
60
61+static float draw_object_wire_grey = -1.0f;
62+void draw_object_bg_wire_color_set(const float color[3])
63+{
64+ float hsv[3];
65+ rgb_to_hsv_v(color, hsv);
66+ draw_object_wire_grey = hsv[2];
67+}
68+
69+static void draw_object_wire_color_adjust_contrast(
70+ unsigned char ob_wire_col[3],
71+ /* 0 == normal, 1 == select, 2 == obact */
72+ const int select_state,
73+ const short draw_type)
74+{
75+ const float tint[3] = {0.0, 0.65f, 1.0f};
76+ const float fac[3] = {0.666f, 0.75f, 1.0f};
77+ const float contrast = 0.075f;
78+
79+ float hsv[3];
80+
81+ BLI_assert(draw_object_wire_grey != -1.0);
82+
83+ rgb_uchar_to_float(hsv, ob_wire_col);
84+ rgb_to_hsv_v(hsv, hsv);
85+
86+ hsv[2] = interpf(tint[select_state], hsv[2], fac[select_state]);
87+
88+ /* when no solid --- ensure contrast */
89+ if (draw_type <= OB_WIRE) {
90+ const float fill_bw = draw_object_wire_grey;
91+
92+ if (fabsf(fill_bw - hsv[2]) < contrast) {
93+ if (fill_bw < hsv[2]) {
94+ hsv[2] = fill_bw + contrast;
95+ }
96+ else {
97+ hsv[2] = fill_bw - contrast;
98+ }
99+ }
100+
101+ }
102+
103+ hsv_to_rgb_v(hsv, hsv);
104+ rgb_float_to_uchar(ob_wire_col, hsv);
105+}
106+
107 static void draw_object_matcap_check(View3D *v3d, Object *ob)
108 {
109 /* fixed rule, active object draws as matcap */
110@@ -7151,6 +7197,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
111 const bool render_override = (v3d->flag2 & V3D_RENDER_OVERRIDE) != 0;
112 const bool is_picking = (G.f & G_PICKSEL) != 0;
113 const bool has_particles = (ob->particlesystem.first != NULL);
114+ const bool is_wire_color = V3D_IS_WIRECOLOR_OBJECT(scene, v3d, ob);
115 bool particle_skip_object = false; /* Draw particles but not their emitter object. */
116
117 if (ob != scene->obedit) {
118@@ -7229,21 +7276,32 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
119 draw_motion_paths_cleanup(v3d);
120 }
121
122- /* multiply view with object matrix.
123- * local viewmat and persmat, to calculate projections */
124- ED_view3d_init_mats_rv3d_gl(ob, rv3d);
125-
126 /* which wire color */
127 if ((dflag & DRAW_CONSTCOLOR) == 0) {
128
129 ED_view3d_project_base(ar, base);
130
131- draw_object_wire_color(scene, base, _ob_wire_col);
132+ if (is_wire_color) {
133+ rgb_float_to_uchar(_ob_wire_col, ob->col);
134+ _ob_wire_col[3] = 255;
135+
136+ draw_object_wire_color_adjust_contrast(
137+ _ob_wire_col,
138+ (ob->flag & SELECT) ? (is_obact ? 2 : 1) : 0,
139+ v3d->drawtype);
140+ }
141+ else {
142+ draw_object_wire_color(scene, base, _ob_wire_col);
143+ }
144 ob_wire_col = _ob_wire_col;
145
146 glColor3ubv(ob_wire_col);
147 }
148
149+ /* multiply view with object matrix.
150+ * local viewmat and persmat, to calculate projections */
151+ ED_view3d_init_mats_rv3d_gl(ob, rv3d);
152+
153 /* maximum drawtype */
154 dt = v3d->drawtype;
155 if (dt == OB_RENDER) dt = OB_SOLID;
156diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
157index 32b4e4d..395a163 100644
158--- a/source/blender/editors/space_view3d/view3d_draw.c
159+++ b/source/blender/editors/space_view3d/view3d_draw.c
160@@ -2130,17 +2130,27 @@ static void draw_dupli_objects_color(
161 glDeleteLists(displist, 1);
162 }
163
164-static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *base)
165+static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const bool is_wire_color)
166 {
167 /* define the color here so draw_dupli_objects_color can be called
168 * from the set loop */
169-
170- int color = (base->flag & SELECT) ? TH_SELECT : TH_WIRE;
171- /* debug */
172- if (base->object->dup_group && base->object->dup_group->id.us < 1)
173- color = TH_REDALERT;
174-
175- draw_dupli_objects_color(scene, ar, v3d, base, 0, color);
176+ short dflag;
177+ int color;
178+
179+ if (is_wire_color) {
180+ glColor3fv(base->object->col);
181+ color = TH_UNDEFINED;
182+ dflag = DRAW_CONSTCOLOR;
183+ }
184+ else {
185+ color = (base->flag & SELECT) ? TH_SELECT : TH_WIRE;
186+ /* debug */
187+ if (base->object->dup_group && base->object->dup_group->id.us < 1)
188+ color = TH_REDALERT;
189+ dflag = 0;
190+ }
191+
192+ draw_dupli_objects_color(scene, ar, v3d, base, dflag, color);
193 }
194
195 /* XXX warning, not using gpu offscreen here */
196@@ -2614,6 +2624,7 @@ static void view3d_draw_objects(
197 RegionView3D *rv3d = ar->regiondata;
198 Base *base;
199 const bool do_camera_frame = !draw_offscreen;
200+ const bool is_wire_color = V3D_IS_WIRECOLOR(scene, v3d);
201
202 if (!draw_offscreen) {
203 ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW);
204@@ -2702,7 +2713,7 @@ static void view3d_draw_objects(
205 if (v3d->lay & base->lay) {
206 /* dupli drawing */
207 if (base->object->transflag & OB_DUPLI)
208- draw_dupli_objects(scene, ar, v3d, base);
209+ draw_dupli_objects(scene, ar, v3d, base, is_wire_color && (base->object->dtx & OB_DRAW_WIRECOLOR));
210
211 draw_object(scene, ar, v3d, base, 0);
212 }
213@@ -2719,7 +2730,7 @@ static void view3d_draw_objects(
214
215 /* dupli drawing */
216 if (base->object->transflag & OB_DUPLI) {
217- draw_dupli_objects(scene, ar, v3d, base);
218+ draw_dupli_objects(scene, ar, v3d, base, is_wire_color && (base->object->dtx & OB_DRAW_WIRECOLOR));
219 }
220 if ((base->flag & SELECT) == 0) {
221 if (base->object != scene->obedit)
222@@ -2731,6 +2742,10 @@ static void view3d_draw_objects(
223 /* mask out localview */
224 v3d->lay_used = lay_used & ((1 << 20) - 1);
225
226+ if (is_wire_color && (v3d->drawtype <= OB_WIRE)) {
227+ glClear(GL_DEPTH_BUFFER_BIT);
228+ }
229+
230 /* draw selected and editmode */
231 for (base = scene->base.first; base; base = base->next) {
232 if (v3d->lay & base->lay) {
233@@ -3210,6 +3225,8 @@ static void view3d_main_area_draw_engine_info(View3D *v3d, RegionView3D *rv3d, A
234 */
235 static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
236 {
237+ const bool is_wire_color = V3D_IS_WIRECOLOR(scene, v3d);
238+
239 /* clear background */
240 if (scene->world && (v3d->flag2 & V3D_RENDER_OVERRIDE)) { /* clear with solid color */
241 if (scene->world->skytype & WO_SKYBLEND) { /* blend sky */
242@@ -3328,6 +3345,12 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
243
244 #undef VIEWGRAD_RES_X
245 #undef VIEWGRAD_RES_Y
246+
247+ if (is_wire_color) {
248+ float col_mid[3];
249+ mid_v3_v3v3(col_mid, col_hor, col_zen);
250+ draw_object_bg_wire_color_set(col_mid);
251+ }
252 }
253 else { /* solid sky */
254 float col_hor[3];
255@@ -3336,10 +3359,19 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
256
257 glClearColor(col_hor[0], col_hor[1], col_hor[2], 0.0f);
258 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
259+
260+ if (is_wire_color) {
261+ draw_object_bg_wire_color_set(col_hor);
262+ }
263 }
264 }
265 else {
266 if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
267+ float col_low[3], col_high[3];
268+
269+ UI_GetThemeColor3fv(TH_HIGH_GRAD, col_high);
270+ UI_GetThemeColor3fv(TH_LOW_GRAD, col_low);
271+
272 glMatrixMode(GL_PROJECTION);
273 glPushMatrix();
274 glLoadIdentity();
275@@ -3351,10 +3383,10 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
276 glDepthFunc(GL_ALWAYS);
277 glShadeModel(GL_SMOOTH);
278 glBegin(GL_QUADS);
279- UI_ThemeColor(TH_LOW_GRAD);
280+ glColor3fv(col_low);
281 glVertex3f(-1.0, -1.0, 1.0);
282 glVertex3f(1.0, -1.0, 1.0);
283- UI_ThemeColor(TH_HIGH_GRAD);
284+ glColor3fv(col_high);
285 glVertex3f(1.0, 1.0, 1.0);
286 glVertex3f(-1.0, 1.0, 1.0);
287 glEnd();
288@@ -3368,10 +3400,24 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar)
289
290 glMatrixMode(GL_MODELVIEW);
291 glPopMatrix();
292+
293+ if (is_wire_color) {
294+ float col_mid[3];
295+ mid_v3_v3v3(col_mid, col_low, col_high);
296+ draw_object_bg_wire_color_set(col_mid);
297+ }
298 }
299 else {
300- UI_ThemeClearColor(TH_HIGH_GRAD);
301+ float col[3];
302+
303+ UI_GetThemeColor3fv(TH_HIGH_GRAD, col);
304+
305+ glClearColor(col[0], col[1], col[2], 0.0);
306 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
307+
308+ if (is_wire_color) {
309+ draw_object_bg_wire_color_set(col);
310+ }
311 }
312 }
313 }
314diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
315index 84ac4f7..0486730 100644
316--- a/source/blender/editors/space_view3d/view3d_intern.h
317+++ b/source/blender/editors/space_view3d/view3d_intern.h
318@@ -133,6 +133,7 @@ void draw_motion_paths_cleanup(View3D *v3d);
319
320
321 /* drawobject.c */
322+void draw_object_bg_wire_color_set(const float color[3]);
323 void draw_object(Scene *scene, struct ARegion *ar, View3D *v3d, Base *base, const short dflag);
324 bool draw_glsl_material(Scene *scene, struct Object *ob, View3D *v3d, const char dt);
325 void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob, const char dt, int outline);
326diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
327index 0bcc6bf..79e53ad 100644
328--- a/source/blender/makesdna/DNA_object_types.h
329+++ b/source/blender/makesdna/DNA_object_types.h
330@@ -454,6 +454,7 @@ enum {
331 /* enable transparent draw */
332 OB_DRAWTRANSP = 1 << 7,
333 OB_DRAW_ALL_EDGES = 1 << 8, /* only for meshes currently */
334+ OB_DRAW_WIRECOLOR = 1 << 9,
335 };
336
337 /* empty_drawtype: no flags */
338diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
339index 3efba48..e85ed70 100644
340--- a/source/blender/makesdna/DNA_view3d_types.h
341+++ b/source/blender/makesdna/DNA_view3d_types.h
342@@ -267,6 +267,7 @@ typedef struct View3D {
343 ((view >= RV3D_VIEW_FRONT) && (view <= RV3D_VIEW_BOTTOM))
344
345 /* View3d->flag2 (short) */
346+#define V3D_WIRE_COLOR_NOCUSTOM 2
347 #define V3D_RENDER_OVERRIDE 4
348 #define V3D_SOLID_TEX 8
349 #define V3D_SHOW_GPENCIL 16
350@@ -340,6 +341,13 @@ enum {
351
352 #define V3D_BGPIC_EXPANDED (V3D_BGPIC_EXPANDED | V3D_BGPIC_CAMERACLIP)
353
354+#define V3D_IS_WIRECOLOR(scene, v3d) \
355+ (((v3d)->drawtype <= OB_SOLID) && \
356+ (((v3d)->flag2 & V3D_WIRE_COLOR_NOCUSTOM) == 0))
357+
358+#define V3D_IS_WIRECOLOR_OBJECT(scene, v3d, ob) \
359+ V3D_IS_WIRECOLOR(scene, v3d) && ((ob)->dtx & OB_DRAW_WIRECOLOR)
360+
361 /* BGPic->source */
362 /* may want to use 1 for select ?*/
363 #define V3D_BGPIC_IMAGE 0
364diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
365index 690468a..1221f06 100644
366--- a/source/blender/makesrna/intern/rna_object.c
367+++ b/source/blender/makesrna/intern/rna_object.c
368@@ -2711,6 +2711,11 @@ static void rna_def_object(BlenderRNA *brna)
369 RNA_def_property_ui_text(prop, "Draw All Edges", "Display all edges for mesh objects");
370 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
371
372+ prop = RNA_def_property(srna, "show_wire_color", PROP_BOOLEAN, PROP_NONE);
373+ RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAW_WIRECOLOR);
374+ RNA_def_property_ui_text(prop, "Draw Wire Color", "Use custom wire color");
375+ RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
376+
377 prop = RNA_def_property(srna, "show_transparent", PROP_BOOLEAN, PROP_NONE);
378 RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWTRANSP);
379 RNA_def_property_ui_text(prop, "Draw Transparent",
380diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
381index a314e99..3fcafdf 100644
382--- a/source/blender/makesrna/intern/rna_space.c
383+++ b/source/blender/makesrna/intern/rna_space.c
384@@ -2165,6 +2165,11 @@ static void rna_def_space_view3d(BlenderRNA *brna)
385 RNA_def_property_ui_text(prop, "Show 3D Marker Names", "Show names for reconstructed tracks objects");
386 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
387
388+ prop = RNA_def_property(srna, "use_wire_color", PROP_BOOLEAN, PROP_NONE);
389+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag2", V3D_WIRE_COLOR_NOCUSTOM);
390+ RNA_def_property_ui_text(prop, "Color Wire", "Draw wireframes using object color");
391+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
392+
393 prop = RNA_def_property(srna, "use_matcap", PROP_BOOLEAN, PROP_NONE);
394 RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SOLID_MATCAP);
395 RNA_def_property_ui_text(prop, "Matcap", "Active Objects draw images mapped on normals, enhancing Solid Draw Mode");

Abandoning this specific patch. since the feature's in gooseberry branch now.