0eb97a54ba593787be2ba1152b7a93fd40d1682f
[blender.git] / source / blender / draw / intern / draw_common.c
1 /*
2  * Copyright 2016, Blender Foundation.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor(s): Blender Institute
19  *
20  */
21
22 /** \file blender/draw/intern/draw_common.c
23  *  \ingroup draw
24  */
25
26 #include "DRW_render.h"
27
28 #include "GPU_shader.h"
29 #include "GPU_texture.h"
30
31 #include "UI_resources.h"
32
33 #include "BKE_global.h"
34 #include "BKE_colorband.h"
35
36 #include "draw_common.h"
37
38
39 #if 0
40 #define UI_COLOR_RGB_FROM_U8(r, g, b, v4) \
41         ARRAY_SET_ITEMS(v4, (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, 1.0)
42 #endif
43 #define UI_COLOR_RGBA_FROM_U8(r, g, b, a, v4) \
44         ARRAY_SET_ITEMS(v4, (float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, (float)a / 255.0f)
45
46 /* Colors & Constant */
47 GlobalsUboStorage ts;
48 struct GPUUniformBuffer *globals_ubo = NULL;
49 struct GPUTexture *globals_ramp = NULL;
50
51 void DRW_globals_update(void)
52 {
53         UI_GetThemeColor4fv(TH_WIRE, ts.colorWire);
54         UI_GetThemeColor4fv(TH_WIRE_EDIT, ts.colorWireEdit);
55         UI_GetThemeColor4fv(TH_ACTIVE, ts.colorActive);
56         UI_GetThemeColor4fv(TH_SELECT, ts.colorSelect);
57         UI_GetThemeColor4fv(TH_TRANSFORM, ts.colorTransform);
58         UI_GetThemeColor4fv(TH_GROUP_ACTIVE, ts.colorGroupActive);
59         UI_GetThemeColorShade4fv(TH_GROUP_ACTIVE, -25, ts.colorGroupSelect);
60         UI_GetThemeColor4fv(TH_GROUP, ts.colorGroup);
61         UI_COLOR_RGBA_FROM_U8(0x88, 0xFF, 0xFF, 155, ts.colorLibrarySelect);
62         UI_COLOR_RGBA_FROM_U8(0x55, 0xCC, 0xCC, 155, ts.colorLibrary);
63         UI_GetThemeColor4fv(TH_LAMP, ts.colorLamp);
64         UI_GetThemeColor4fv(TH_SPEAKER, ts.colorSpeaker);
65         UI_GetThemeColor4fv(TH_CAMERA, ts.colorCamera);
66         UI_GetThemeColor4fv(TH_EMPTY, ts.colorEmpty);
67         UI_GetThemeColor4fv(TH_VERTEX, ts.colorVertex);
68         UI_GetThemeColor4fv(TH_VERTEX_SELECT, ts.colorVertexSelect);
69         UI_GetThemeColor4fv(TH_EDITMESH_ACTIVE, ts.colorEditMeshActive);
70         UI_GetThemeColor4fv(TH_EDGE_SELECT, ts.colorEdgeSelect);
71         UI_GetThemeColor4fv(TH_EDGE_SEAM, ts.colorEdgeSeam);
72         UI_GetThemeColor4fv(TH_EDGE_SHARP, ts.colorEdgeSharp);
73         UI_GetThemeColor4fv(TH_EDGE_CREASE, ts.colorEdgeCrease);
74         UI_GetThemeColor4fv(TH_EDGE_BEVEL, ts.colorEdgeBWeight);
75         UI_GetThemeColor4fv(TH_EDGE_FACESEL, ts.colorEdgeFaceSelect);
76         UI_GetThemeColor4fv(TH_FACE, ts.colorFace);
77         UI_GetThemeColor4fv(TH_FACE_SELECT, ts.colorFaceSelect);
78         UI_GetThemeColor4fv(TH_NORMAL, ts.colorNormal);
79         UI_GetThemeColor4fv(TH_VNORMAL, ts.colorVNormal);
80         UI_GetThemeColor4fv(TH_LNORMAL, ts.colorLNormal);
81         UI_GetThemeColor4fv(TH_FACE_DOT, ts.colorFaceDot);
82         UI_GetThemeColor4fv(TH_BACK, ts.colorBackground);
83
84         /* Curve */
85         UI_GetThemeColor4fv(TH_HANDLE_FREE, ts.colorHandleFree);
86         UI_GetThemeColor4fv(TH_HANDLE_AUTO, ts.colorHandleAuto);
87         UI_GetThemeColor4fv(TH_HANDLE_VECT, ts.colorHandleVect);
88         UI_GetThemeColor4fv(TH_HANDLE_ALIGN, ts.colorHandleAlign);
89         UI_GetThemeColor4fv(TH_HANDLE_AUTOCLAMP, ts.colorHandleAutoclamp);
90         UI_GetThemeColor4fv(TH_HANDLE_SEL_FREE, ts.colorHandleSelFree);
91         UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTO, ts.colorHandleSelAuto);
92         UI_GetThemeColor4fv(TH_HANDLE_SEL_VECT, ts.colorHandleSelVect);
93         UI_GetThemeColor4fv(TH_HANDLE_SEL_ALIGN, ts.colorHandleSelAlign);
94         UI_GetThemeColor4fv(TH_HANDLE_SEL_AUTOCLAMP, ts.colorHandleSelAutoclamp);
95         UI_GetThemeColor4fv(TH_NURB_ULINE, ts.colorNurbUline);
96         UI_GetThemeColor4fv(TH_NURB_SEL_ULINE, ts.colorNurbSelUline);
97         UI_GetThemeColor4fv(TH_ACTIVE_SPLINE, ts.colorActiveSpline);
98
99         /* Grid */
100         UI_GetThemeColorShade4fv(TH_GRID, 10, ts.colorGrid);
101         /* emphasise division lines lighter instead of darker, if background is darker than grid */
102         UI_GetThemeColorShade4fv(
103                 TH_GRID,
104                 (ts.colorGrid[0] + ts.colorGrid[1] + ts.colorGrid[2] + 0.12f >
105                  ts.colorBackground[0] + ts.colorBackground[1] + ts.colorBackground[2]) ?
106                 20 : -10, ts.colorGridEmphasise);
107         /* Grid Axis */
108         UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_X, 0.5f, -10, ts.colorGridAxisX);
109         UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Y, 0.5f, -10, ts.colorGridAxisY);
110         UI_GetThemeColorBlendShade4fv(TH_GRID, TH_AXIS_Z, 0.5f, -10, ts.colorGridAxisZ);
111
112         UI_GetThemeColorShadeAlpha4fv(TH_TRANSFORM, 0, -80, ts.colorDeselect);
113         UI_GetThemeColorShadeAlpha4fv(TH_WIRE, 0, -30, ts.colorOutline);
114         UI_GetThemeColorShadeAlpha4fv(TH_LAMP, 0, 255, ts.colorLampNoAlpha);
115
116         ts.sizeLampCenter = (U.obcenter_dia + 1.5f) * U.pixelsize;
117         ts.sizeLampCircle = U.pixelsize * 9.0f;
118         ts.sizeLampCircleShadow = ts.sizeLampCircle + U.pixelsize * 3.0f;
119
120         /* M_SQRT2 to be at least the same size of the old square */
121         ts.sizeVertex = ceilf(UI_GetThemeValuef(TH_VERTEX_SIZE) * (float)M_SQRT2 / 2.0f);
122         ts.sizeFaceDot = ceilf(UI_GetThemeValuef(TH_FACEDOT_SIZE) * (float)M_SQRT2);
123         ts.sizeEdge = 1.0f / 2.0f; /* TODO Theme */
124         ts.sizeEdgeFix = 0.5f + 2.0f * (2.0f * (MAX2(ts.sizeVertex, ts.sizeEdge)) * (float)M_SQRT1_2);
125
126         /* TODO Waiting for notifiers to invalidate cache */
127         if (globals_ubo) {
128                 DRW_uniformbuffer_free(globals_ubo);
129         }
130
131         globals_ubo = DRW_uniformbuffer_create(sizeof(GlobalsUboStorage), &ts);
132
133         ColorBand ramp = {0};
134         float *colors;
135         int col_size;
136
137         ramp.tot = 3;
138         ramp.data[0].a = 1.0f;
139         ramp.data[0].b = 1.0f;
140         ramp.data[0].pos = 0.0f;
141         ramp.data[1].a = 1.0f;
142         ramp.data[1].g = 1.0f;
143         ramp.data[1].pos = 0.5f;
144         ramp.data[2].a = 1.0f;
145         ramp.data[2].r = 1.0f;
146         ramp.data[2].pos = 1.0f;
147
148         BKE_colorband_evaluate_table_rgba(&ramp, &colors, &col_size);
149
150         if (globals_ramp) {
151                 GPU_texture_free(globals_ramp);
152         }
153         globals_ramp = GPU_texture_create_1D(col_size, colors, NULL);
154
155         MEM_freeN(colors);
156 }
157
158 /* ********************************* SHGROUP ************************************* */
159
160 DRWShadingGroup *shgroup_dynlines_uniform_color(DRWPass *pass, float color[4])
161 {
162         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
163
164         DRWShadingGroup *grp = DRW_shgroup_line_batch_create(sh, pass);
165         DRW_shgroup_uniform_vec4(grp, "color", color, 1);
166
167         return grp;
168 }
169
170 DRWShadingGroup *shgroup_dynpoints_uniform_color(DRWPass *pass, float color[4], float *size)
171 {
172         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
173
174         DRWShadingGroup *grp = DRW_shgroup_point_batch_create(sh, pass);
175         DRW_shgroup_uniform_vec4(grp, "color", color, 1);
176         DRW_shgroup_uniform_float(grp, "size", size, 1);
177         DRW_shgroup_state_enable(grp, DRW_STATE_POINT);
178
179         return grp;
180 }
181
182 DRWShadingGroup *shgroup_groundlines_uniform_color(DRWPass *pass, float color[4])
183 {
184         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_GROUNDLINE);
185
186         DRWShadingGroup *grp = DRW_shgroup_point_batch_create(sh, pass);
187         DRW_shgroup_uniform_vec4(grp, "color", color, 1);
188
189         return grp;
190 }
191
192 DRWShadingGroup *shgroup_groundpoints_uniform_color(DRWPass *pass, float color[4])
193 {
194         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_GROUNDPOINT);
195
196         DRWShadingGroup *grp = DRW_shgroup_point_batch_create(sh, pass);
197         DRW_shgroup_uniform_vec4(grp, "color", color, 1);
198         DRW_shgroup_state_enable(grp, DRW_STATE_POINT);
199
200         return grp;
201 }
202
203 DRWShadingGroup *shgroup_instance_screenspace(DRWPass *pass, struct Gwn_Batch *geom, float *size)
204 {
205         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR);
206
207         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
208         DRW_shgroup_attrib_float(grp, "world_pos", 3);
209         DRW_shgroup_attrib_float(grp, "color", 3);
210         DRW_shgroup_uniform_float(grp, "size", size, 1);
211         DRW_shgroup_uniform_float(grp, "pixel_size", DRW_viewport_pixelsize_get(), 1);
212         DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
213         DRW_shgroup_state_enable(grp, DRW_STATE_STIPPLE_3);
214
215         return grp;
216 }
217
218 DRWShadingGroup *shgroup_instance_solid(DRWPass *pass, struct Gwn_Batch *geom)
219 {
220         static float light[3] = {0.0f, 0.0f, 1.0f};
221         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR);
222
223         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
224         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
225         DRW_shgroup_attrib_float(grp, "color", 4);
226         DRW_shgroup_uniform_vec3(grp, "light", light, 1);
227
228         return grp;
229 }
230
231 DRWShadingGroup *shgroup_instance_wire(DRWPass *pass, struct Gwn_Batch *geom)
232 {
233         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_VARIYING_COLOR);
234
235         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
236         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
237         DRW_shgroup_attrib_float(grp, "color", 4);
238
239         return grp;
240 }
241
242 DRWShadingGroup *shgroup_instance_screen_aligned(DRWPass *pass, struct Gwn_Batch *geom)
243 {
244         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED);
245
246         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
247         DRW_shgroup_attrib_float(grp, "color", 3);
248         DRW_shgroup_attrib_float(grp, "size", 1);
249         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
250         DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
251
252         return grp;
253 }
254
255 DRWShadingGroup *shgroup_instance_axis_names(DRWPass *pass, struct Gwn_Batch *geom)
256 {
257         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED_AXIS);
258
259         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
260         DRW_shgroup_attrib_float(grp, "color", 3);
261         DRW_shgroup_attrib_float(grp, "size", 1);
262         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
263         DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
264
265         return grp;
266 }
267
268 DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct Gwn_Batch *geom)
269 {
270         GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE);
271
272         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom);
273         DRW_shgroup_attrib_float(grp, "color", 3);
274         DRW_shgroup_attrib_float(grp, "size", 3);
275         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
276
277         return grp;
278 }
279
280 DRWShadingGroup *shgroup_instance(DRWPass *pass, struct Gwn_Batch *geom)
281 {
282         GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE);
283
284         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom);
285         DRW_shgroup_attrib_float(grp, "color", 3);
286         DRW_shgroup_attrib_float(grp, "size", 1);
287         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
288
289         return grp;
290 }
291
292 DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct Gwn_Batch *geom)
293 {
294         GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_CAMERA);
295
296         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom);
297         DRW_shgroup_attrib_float(grp, "color", 3);
298         DRW_shgroup_attrib_float(grp, "corners", 8);
299         DRW_shgroup_attrib_float(grp, "depth", 1);
300         DRW_shgroup_attrib_float(grp, "tria", 4);
301         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
302
303         return grp;
304 }
305
306 DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct Gwn_Batch *geom)
307 {
308         GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_DISTANCE_LINES);
309         static float point_size = 4.0f;
310
311         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom);
312         DRW_shgroup_attrib_float(grp, "color", 3);
313         DRW_shgroup_attrib_float(grp, "start", 1);
314         DRW_shgroup_attrib_float(grp, "end", 1);
315         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
316         DRW_shgroup_uniform_float(grp, "size", &point_size, 1);
317
318         return grp;
319 }
320
321 DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct Gwn_Batch *geom)
322 {
323         GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR);
324         static const int True = true;
325         static const int False = false;
326
327         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom);
328         DRW_shgroup_attrib_float(grp, "color", 3);
329         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
330         DRW_shgroup_uniform_bool(grp, "drawFront", &False, 1);
331         DRW_shgroup_uniform_bool(grp, "drawBack", &False, 1);
332         DRW_shgroup_uniform_bool(grp, "drawSilhouette", &True, 1);
333
334         return grp;
335 }
336
337 DRWShadingGroup *shgroup_instance_bone_envelope_wire(DRWPass *pass, struct Gwn_Batch *geom)
338 {
339         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_WIRE);
340
341         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
342         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
343         DRW_shgroup_attrib_float(grp, "color", 4);
344         DRW_shgroup_attrib_float(grp, "radius_head", 1);
345         DRW_shgroup_attrib_float(grp, "radius_tail", 1);
346         DRW_shgroup_attrib_float(grp, "distance", 1);
347
348         return grp;
349 }
350
351 DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass, struct Gwn_Batch *geom)
352 {
353         static float light[3] = {0.0f, 0.0f, 1.0f};
354         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_BONE_ENVELOPE_SOLID);
355
356         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
357         DRW_shgroup_attrib_float(grp, "InstanceModelMatrix", 16);
358         DRW_shgroup_attrib_float(grp, "color", 4);
359         DRW_shgroup_attrib_float(grp, "radius_head", 1);
360         DRW_shgroup_attrib_float(grp, "radius_tail", 1);
361         DRW_shgroup_uniform_vec3(grp, "light", light, 1);
362
363         return grp;
364 }
365
366 DRWShadingGroup *shgroup_instance_mball_helpers(DRWPass *pass, struct Gwn_Batch *geom)
367 {
368         GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_MBALL_HELPERS);
369
370         DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom);
371         DRW_shgroup_attrib_float(grp, "ScaleTranslationMatrix", 12);
372         DRW_shgroup_attrib_float(grp, "radius", 1);
373         DRW_shgroup_attrib_float(grp, "color", 3);
374         DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
375
376         return grp;
377 }
378
379
380 /* ******************************************** COLOR UTILS *********************************************** */
381
382 /* TODO FINISH */
383 /**
384  * Get the wire color theme_id of an object based on it's state
385  * \a r_color is a way to get a pointer to the static color var associated
386  */
387 int DRW_object_wire_theme_get(Object *ob, ViewLayer *view_layer, float **r_color)
388 {
389         const bool is_edit = (ob->mode & OB_MODE_EDIT) != 0;
390         const bool active = (view_layer->basact && view_layer->basact->object == ob);
391         /* confusing logic here, there are 2 methods of setting the color
392          * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id.
393          *
394          * note: no theme yet for 'colindex' */
395         int theme_id = is_edit ? TH_WIRE_EDIT : TH_WIRE;
396
397         if (//(scene->obedit == NULL) &&
398             ((G.moving & G_TRANSFORM_OBJ) != 0) &&
399             ((ob->base_flag & BASE_SELECTED) != 0))
400         {
401                 theme_id = TH_TRANSFORM;
402         }
403         else {
404                 /* Sets the 'theme_id' or fallback to wire */
405                 if ((ob->flag & OB_FROMGROUP) != 0) {
406                         if ((ob->base_flag & BASE_SELECTED) != 0) {
407                                 theme_id = TH_GROUP_ACTIVE;
408                         }
409                         else {
410                                 theme_id = TH_GROUP;
411                         }
412                 }
413                 else {
414                         if ((ob->base_flag & BASE_SELECTED) != 0) {
415                                 theme_id = (active) ? TH_ACTIVE : TH_SELECT;
416                         }
417                         else {
418                                 if (ob->type == OB_LAMP) theme_id = TH_LAMP;
419                                 else if (ob->type == OB_SPEAKER) theme_id = TH_SPEAKER;
420                                 else if (ob->type == OB_CAMERA) theme_id = TH_CAMERA;
421                                 else if (ob->type == OB_EMPTY) theme_id = TH_EMPTY;
422                                 /* fallback to TH_WIRE */
423                         }
424                 }
425         }
426
427         if (r_color != NULL) {
428                 switch (theme_id) {
429                         case TH_WIRE_EDIT:    *r_color = ts.colorTransform; break;
430                         case TH_ACTIVE:       *r_color = ts.colorActive; break;
431                         case TH_SELECT:       *r_color = ts.colorSelect; break;
432                         case TH_GROUP:        *r_color = ts.colorGroup; break;
433                         case TH_GROUP_ACTIVE: *r_color = ts.colorGroupActive; break;
434                         case TH_TRANSFORM:    *r_color = ts.colorTransform; break;
435                         case OB_SPEAKER:      *r_color = ts.colorSpeaker; break;
436                         case OB_CAMERA:       *r_color = ts.colorCamera; break;
437                         case OB_EMPTY:        *r_color = ts.colorEmpty; break;
438                         case OB_LAMP:         *r_color = ts.colorLamp; break;
439                         default:              *r_color = ts.colorWire; break;
440                 }
441
442                 /* uses darker active color for non-active + selected */
443                 if ((theme_id == TH_GROUP_ACTIVE) && !active) {
444                         *r_color = ts.colorGroupSelect;
445                 }
446         }
447
448         return theme_id;
449 }
450
451 /* XXX This is utter shit, better find something more general */
452 float *DRW_color_background_blend_get(int theme_id)
453 {
454         static float colors[11][4];
455         float *ret;
456
457         switch (theme_id) {
458                 case TH_WIRE_EDIT:    ret = colors[0]; break;
459                 case TH_ACTIVE:       ret = colors[1]; break;
460                 case TH_SELECT:       ret = colors[2]; break;
461                 case TH_GROUP:        ret = colors[3]; break;
462                 case TH_GROUP_ACTIVE: ret = colors[4]; break;
463                 case TH_TRANSFORM:    ret = colors[5]; break;
464                 case OB_SPEAKER:      ret = colors[6]; break;
465                 case OB_CAMERA:       ret = colors[7]; break;
466                 case OB_EMPTY:        ret = colors[8]; break;
467                 case OB_LAMP:         ret = colors[9]; break;
468                 default:              ret = colors[10]; break;
469         }
470
471         UI_GetThemeColorBlendShade4fv(theme_id, TH_BACK, 0.5, 0, ret);
472
473         return ret;
474 }