Object Engine: Fix Selected Group Objects color.
authorClément Foucault <foucault.clem@gmail.com>
Mon, 10 Apr 2017 20:23:33 +0000 (22:23 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Mon, 10 Apr 2017 20:23:50 +0000 (22:23 +0200)
source/blender/draw/intern/draw_common.c
source/blender/draw/intern/draw_common.h
source/blender/draw/modes/shaders/common_globals_lib.glsl

index e463956c9b2544909186f6f3050081656421409e..8d9012afa506993f35fe586e87aef8aade833464 100644 (file)
@@ -45,6 +45,7 @@ void DRW_globals_update(void)
        UI_GetThemeColor4fv(TH_SELECT, ts.colorSelect);
        UI_GetThemeColor4fv(TH_TRANSFORM, ts.colorTransform);
        UI_GetThemeColor4fv(TH_GROUP_ACTIVE, ts.colorGroupActive);
+       UI_GetThemeColorShade4fv(TH_GROUP_ACTIVE, -25, ts.colorGroupSelect);
        UI_GetThemeColor4fv(TH_GROUP, ts.colorGroup);
        UI_GetThemeColor4fv(TH_LAMP, ts.colorLamp);
        UI_GetThemeColor4fv(TH_SPEAKER, ts.colorSpeaker);
@@ -282,7 +283,7 @@ DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct Batch *geom)
        return grp;
 }
 
-/* ******************************************** WIRES *********************************************** */
+/* ******************************************** COLOR UTILS *********************************************** */
 
 /* TODO FINISH */
 /* Get the wire color theme_id of an object based on it's state
@@ -290,6 +291,7 @@ DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct Batch *geom)
 int DRW_object_wire_theme_get(Object *ob, SceneLayer *sl, float **color)
 {
        const bool is_edit = (ob->mode & OB_MODE_EDIT) != 0;
+       const bool active = (sl->basact && sl->basact->object == ob);
        /* confusing logic here, there are 2 methods of setting the color
         * 'colortab[colindex]' and 'theme_id', colindex overrides theme_id.
         *
@@ -306,12 +308,7 @@ int DRW_object_wire_theme_get(Object *ob, SceneLayer *sl, float **color)
                /* Sets the 'theme_id' or fallback to wire */
                if ((ob->flag & OB_FROMGROUP) != 0) {
                        if ((ob->base_flag & BASE_SELECTED) != 0) {
-                               /* uses darker active color for non-active + selected */
                                theme_id = TH_GROUP_ACTIVE;
-
-                               // if (sl->basact->object != ob) {
-                               //      theme_shade = -16;
-                               // }
                        }
                        else {
                                theme_id = TH_GROUP;
@@ -319,7 +316,7 @@ int DRW_object_wire_theme_get(Object *ob, SceneLayer *sl, float **color)
                }
                else {
                        if ((ob->base_flag & BASE_SELECTED) != 0) {
-                               theme_id = (sl->basact && sl->basact->object == ob) ? TH_ACTIVE : TH_SELECT;
+                               theme_id = (active) ? TH_ACTIVE : TH_SELECT;
                        }
                        else {
                                if (ob->type == OB_LAMP) theme_id = TH_LAMP;
@@ -345,6 +342,11 @@ int DRW_object_wire_theme_get(Object *ob, SceneLayer *sl, float **color)
                        case OB_LAMP:         *color = ts.colorLamp; break;
                        default:              *color = ts.colorWire; break;
                }
+
+               /* uses darker active color for non-active + selected */
+               if ((theme_id == TH_GROUP_ACTIVE) && !active) {
+                       *color = ts.colorGroupSelect;
+               }
        }
 
        return theme_id;
index be41103f907aaf86bd8ec591bab8cc9a0813cfee..ad8f312825ad88ecae5ca17659347ebc9226b698 100644 (file)
@@ -43,6 +43,7 @@ typedef struct GlobalsUboStorage {
        float colorSelect[4];
        float colorTransform[4];
        float colorGroupActive[4];
+       float colorGroupSelect[4];
        float colorGroup[4];
        float colorLamp[4];
        float colorSpeaker[4];
index 579a5f5089b381a244468201ba9f72e1de18aac7..099093363a9b1f449ddaaef9d67fce6c1f03981a 100644 (file)
@@ -7,6 +7,7 @@ layout(std140) uniform globalsBlock {
        vec4 colorSelect;
        vec4 colorTransform;
        vec4 colorGroupActive;
+       vec4 colorGroupSelect;
        vec4 colorGroup;
        vec4 colorLamp;
        vec4 colorSpeaker;