diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/intern/draw_common.c | 34 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_common.h | 4 | ||||
-rw-r--r-- | source/blender/draw/modes/object_mode.c | 71 | ||||
-rw-r--r-- | source/blender/draw/modes/shaders/common_globals_lib.glsl | 4 | ||||
-rw-r--r-- | source/blender/editors/include/UI_resources.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 14 |
6 files changed, 100 insertions, 28 deletions
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 36a50dec85e..6514e4baaf3 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -60,9 +60,11 @@ void DRW_globals_update(void) UI_GetThemeColor4fv(TH_WIRE_EDIT, ts.colorWireEdit); UI_GetThemeColor4fv(TH_ACTIVE, ts.colorActive); UI_GetThemeColor4fv(TH_SELECT, ts.colorSelect); - UI_GetThemeColor4fv(TH_TRANSFORM, ts.colorTransform); + UI_GetThemeColorBlend4f(TH_SELECT, TH_HIGH_GRAD, 0.66f, ts.colorDupliSelect); + UI_GetThemeColorBlend4f(TH_WIRE, TH_HIGH_GRAD, 0.66f, ts.colorDupli); UI_COLOR_RGBA_FROM_U8(0x88, 0xFF, 0xFF, 155, ts.colorLibrarySelect); UI_COLOR_RGBA_FROM_U8(0x55, 0xCC, 0xCC, 155, ts.colorLibrary); + UI_GetThemeColor4fv(TH_TRANSFORM, ts.colorTransform); UI_GetThemeColor4fv(TH_LAMP, ts.colorLamp); UI_GetThemeColor4fv(TH_SPEAKER, ts.colorSpeaker); UI_GetThemeColor4fv(TH_CAMERA, ts.colorCamera); @@ -902,16 +904,26 @@ int DRW_object_wire_theme_get(Object *ob, ViewLayer *view_layer, float **r_color } if (r_color != NULL) { - switch (theme_id) { - case TH_WIRE_EDIT: *r_color = ts.colorWireEdit; break; - case TH_ACTIVE: *r_color = ts.colorActive; break; - case TH_SELECT: *r_color = ts.colorSelect; break; - case TH_TRANSFORM: *r_color = ts.colorTransform; break; - case TH_SPEAKER: *r_color = ts.colorSpeaker; break; - case TH_CAMERA: *r_color = ts.colorCamera; break; - case TH_EMPTY: *r_color = ts.colorEmpty; break; - case TH_LAMP: *r_color = ts.colorLamp; break; - default: *r_color = ts.colorWire; break; + if (UNLIKELY(ob->base_flag & BASE_FROMDUPLI)) { + switch (theme_id) { + case TH_ACTIVE: + case TH_SELECT: *r_color = ts.colorDupliSelect; break; + case TH_TRANSFORM: *r_color = ts.colorTransform; break; + default: *r_color = ts.colorDupli; break; + } + } + else { + switch (theme_id) { + case TH_WIRE_EDIT: *r_color = ts.colorWireEdit; break; + case TH_ACTIVE: *r_color = ts.colorActive; break; + case TH_SELECT: *r_color = ts.colorSelect; break; + case TH_TRANSFORM: *r_color = ts.colorTransform; break; + case TH_SPEAKER: *r_color = ts.colorSpeaker; break; + case TH_CAMERA: *r_color = ts.colorCamera; break; + case TH_EMPTY: *r_color = ts.colorEmpty; break; + case TH_LAMP: *r_color = ts.colorLamp; break; + default: *r_color = ts.colorWire; break; + } } } diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h index e0c1a3c0c66..ca4bf967236 100644 --- a/source/blender/draw/intern/draw_common.h +++ b/source/blender/draw/intern/draw_common.h @@ -48,9 +48,11 @@ typedef struct GlobalsUboStorage { float colorWireEdit[4]; float colorActive[4]; float colorSelect[4]; - float colorTransform[4]; + float colorDupliSelect[4]; + float colorDupli[4]; float colorLibrarySelect[4]; float colorLibrary[4]; + float colorTransform[4]; float colorLamp[4]; float colorSpeaker[4]; float colorCamera[4]; diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 7453f3f1b0e..7b07d20c7ba 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -238,12 +238,18 @@ typedef struct OBJECT_ShadingGroupList { DRWShadingGroup *wire_active; DRWShadingGroup *wire_select; DRWShadingGroup *wire_transform; + /* Wire (duplicator) */ + DRWShadingGroup *wire_dupli; + DRWShadingGroup *wire_dupli_select; /* Points */ DRWShadingGroup *points; DRWShadingGroup *points_active; DRWShadingGroup *points_select; DRWShadingGroup *points_transform; + /* Points (duplicator) */ + DRWShadingGroup *points_dupli; + DRWShadingGroup *points_dupli_select; /* Texture Space */ DRWShadingGroup *texspace; @@ -768,9 +774,21 @@ static DRWShadingGroup *shgroup_theme_id_to_outline_or( } } -static DRWShadingGroup *shgroup_theme_id_to_wire_or( - OBJECT_ShadingGroupList *sgl, int theme_id, DRWShadingGroup *fallback) +static DRWShadingGroup *shgroup_theme_id_to_wire( + OBJECT_ShadingGroupList *sgl, int theme_id, const short base_flag) { + if (UNLIKELY(base_flag & BASE_FROMDUPLI)) { + switch (theme_id) { + case TH_ACTIVE: + case TH_SELECT: + return sgl->wire_dupli_select; + case TH_TRANSFORM: + return sgl->wire_transform; + default: + return sgl->wire_dupli; + } + } + switch (theme_id) { case TH_ACTIVE: return sgl->wire_active; @@ -779,13 +797,25 @@ static DRWShadingGroup *shgroup_theme_id_to_wire_or( case TH_TRANSFORM: return sgl->wire_transform; default: - return fallback; + return sgl->wire; } } -static DRWShadingGroup *shgroup_theme_id_to_point_or( - OBJECT_ShadingGroupList *sgl, int theme_id, DRWShadingGroup *fallback) +static DRWShadingGroup *shgroup_theme_id_to_point( + OBJECT_ShadingGroupList *sgl, int theme_id, const short base_flag) { + if (UNLIKELY(base_flag & BASE_FROMDUPLI)) { + switch (theme_id) { + case TH_ACTIVE: + case TH_SELECT: + return sgl->points_dupli_select; + case TH_TRANSFORM: + return sgl->points_transform; + default: + return sgl->points_dupli; + } + } + switch (theme_id) { case TH_ACTIVE: return sgl->points_active; @@ -794,7 +824,7 @@ static DRWShadingGroup *shgroup_theme_id_to_point_or( case TH_TRANSFORM: return sgl->points_transform; default: - return fallback; + return sgl->points; } } @@ -1178,6 +1208,9 @@ static void OBJECT_cache_init(void *vedata) sgl->wire_select = shgroup_wire(sgl->non_meshes, ts.colorSelect, sh); sgl->wire_transform = shgroup_wire(sgl->non_meshes, ts.colorTransform, sh); sgl->wire_active = shgroup_wire(sgl->non_meshes, ts.colorActive, sh); + /* Wire (duplicator) */ + sgl->wire_dupli = shgroup_wire(sgl->non_meshes, ts.colorDupli, sh); + sgl->wire_dupli_select = shgroup_wire(sgl->non_meshes, ts.colorDupliSelect, sh); /* Points (loose points) */ sh = e_data.loose_points_sh; @@ -1185,10 +1218,15 @@ static void OBJECT_cache_init(void *vedata) sgl->points_select = shgroup_points(sgl->non_meshes, ts.colorSelect, sh); sgl->points_transform = shgroup_points(sgl->non_meshes, ts.colorTransform, sh); sgl->points_active = shgroup_points(sgl->non_meshes, ts.colorActive, sh); + /* Points (duplicator) */ + sgl->points_dupli = shgroup_points(sgl->non_meshes, ts.colorDupli, sh); + sgl->points_dupli_select = shgroup_points(sgl->non_meshes, ts.colorDupliSelect, sh); DRW_shgroup_state_disable(sgl->points, DRW_STATE_BLEND); DRW_shgroup_state_disable(sgl->points_select, DRW_STATE_BLEND); DRW_shgroup_state_disable(sgl->points_transform, DRW_STATE_BLEND); DRW_shgroup_state_disable(sgl->points_active, DRW_STATE_BLEND); + DRW_shgroup_state_disable(sgl->points_dupli, DRW_STATE_BLEND); + DRW_shgroup_state_disable(sgl->points_dupli_select, DRW_STATE_BLEND); /* Metaballs Handles */ sgl->mball_handle = shgroup_instance_mball_handles(sgl->non_meshes); @@ -1398,9 +1436,12 @@ static void DRW_shgroup_lamp(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLayer float (*shapemat)[4] = lamp_engine_data->shape_mat; float (*spotblendmat)[4] = lamp_engine_data->spot_blend_mat; - /* Don't draw the center if it's selected or active */ - if (theme_id == TH_LAMP) - DRW_shgroup_call_dynamic_add(sgl->lamp_center, ob->obmat[3]); + if ((ob->base_flag & (BASE_FROM_SET | BASE_FROMDUPLI)) == 0) { + /* Don't draw the center if it's selected or active */ + if (theme_id == TH_LAMP) { + DRW_shgroup_call_dynamic_add(sgl->lamp_center, ob->obmat[3]); + } + } /* First circle */ DRW_shgroup_call_dynamic_add(sgl->lamp_circle, ob->obmat[3], color); @@ -2637,7 +2678,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); } - DRWShadingGroup *shgroup = shgroup_theme_id_to_point_or(sgl, theme_id, sgl->points); + DRWShadingGroup *shgroup = shgroup_theme_id_to_point(sgl, theme_id, ob->base_flag); DRW_shgroup_call_object_add(shgroup, geom, ob); } } @@ -2658,7 +2699,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); } - DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(sgl, theme_id, sgl->wire); + DRWShadingGroup *shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag); DRW_shgroup_call_object_add(shgroup, geom, ob); } } @@ -2677,7 +2718,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); } - DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(sgl, theme_id, sgl->wire); + DRWShadingGroup *shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag); DRW_shgroup_call_object_add(shgroup, geom, ob); break; } @@ -2692,7 +2733,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); } - DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(sgl, theme_id, sgl->wire); + DRWShadingGroup *shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag); DRW_shgroup_call_object_add(shgroup, geom, ob); } break; @@ -2707,7 +2748,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); } - DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(sgl, theme_id, sgl->wire); + DRWShadingGroup *shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag); DRW_shgroup_call_object_add(shgroup, geom, ob); } break; @@ -2795,7 +2836,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob) if (theme_id == TH_UNDEFINED) { theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); } - DRWShadingGroup *shgroup = shgroup_theme_id_to_wire_or(sgl, theme_id, sgl->wire); + DRWShadingGroup *shgroup = shgroup_theme_id_to_wire(sgl, theme_id, ob->base_flag); DRW_shgroup_call_object_add(shgroup, geom, ob); } } diff --git a/source/blender/draw/modes/shaders/common_globals_lib.glsl b/source/blender/draw/modes/shaders/common_globals_lib.glsl index 520b368bbc2..7b0c48a76e5 100644 --- a/source/blender/draw/modes/shaders/common_globals_lib.glsl +++ b/source/blender/draw/modes/shaders/common_globals_lib.glsl @@ -5,9 +5,11 @@ layout(std140) uniform globalsBlock { vec4 colorWireEdit; vec4 colorActive; vec4 colorSelect; - vec4 colorTransform; + vec4 colorDupliSelect; + vec4 colorDupli; vec4 colorLibrarySelect; vec4 colorLibrary; + vec4 colorTransform; vec4 colorLamp; vec4 colorSpeaker; vec4 colorCamera; diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index d686594f334..74991ad8ab1 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -343,6 +343,7 @@ int UI_GetThemeValueType(int colorid, int spacetype); void UI_GetThemeColor3fv(int colorid, float col[3]); void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned char col[3]); void UI_GetThemeColorBlend3f(int colorid1, int colorid2, float fac, float r_col[3]); +void UI_GetThemeColorBlend4f(int colorid1, int colorid2, float fac, float r_col[4]); // get the color, range 0.0-1.0, complete with shading offset void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3]); void UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3]); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index d7451b0d0e4..5f132295c04 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -864,6 +864,20 @@ void UI_GetThemeColorBlend3f(int colorid1, int colorid2, float fac, float r_col[ r_col[2] = ((1.0f - fac) * cp1[2] + fac * cp2[2]) / 255.0f; } +void UI_GetThemeColorBlend4f(int colorid1, int colorid2, float fac, float r_col[4]) +{ + const uchar *cp1, *cp2; + + cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); + cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); + + CLAMP(fac, 0.0f, 1.0f); + r_col[0] = ((1.0f - fac) * cp1[0] + fac * cp2[0]) / 255.0f; + r_col[1] = ((1.0f - fac) * cp1[1] + fac * cp2[1]) / 255.0f; + r_col[2] = ((1.0f - fac) * cp1[2] + fac * cp2[2]) / 255.0f; + r_col[3] = ((1.0f - fac) * cp1[3] + fac * cp2[3]) / 255.0f; +} + void UI_FontThemeColor(int fontid, int colorid) { uchar color[4]; |