Commit: 5ee55caba58371d06e6437a493a93bdec804be45
Author: Campbell Barton
Date:   Wed Jun 4 14:22:29 2014 +1000
https://developer.blender.org/rB5ee55caba58371d06e6437a493a93bdec804be45

Fix for dupli's ignoring color in set-scenes

also skip setting wire color drawing depth

===================================================================

M       source/blender/editors/include/UI_resources.h
M       source/blender/editors/interface/resources.c
M       source/blender/editors/space_view3d/drawobject.c
M       source/blender/editors/space_view3d/view3d_draw.c

===================================================================

diff --git a/source/blender/editors/include/UI_resources.h 
b/source/blender/editors/include/UI_resources.h
index 0f11994..2e78940 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -48,6 +48,9 @@ typedef enum {
 #undef DEF_ICON
 #undef DEF_VICO
 
+/* use to denote intentionally unset theme color */
+#define TH_UNDEFINED -1
+
 enum {
        TH_REDALERT,
 
@@ -311,6 +314,7 @@ int     UI_GetThemeValue(int colorid);
 
 // get three color values, scaled to 0.0-1.0 range
 void    UI_GetThemeColor3fv(int colorid, float col[3]);
+void    UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, 
unsigned char col[3]);
 // 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 998577a..daf28bc 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -92,6 +92,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int 
spacetype, int colo
        
        /* ensure we're not getting a color after running BKE_userdef_free */
        BLI_assert(BLI_findindex(&U.themes, theme_active) != -1);
+       BLI_assert(colorid != TH_UNDEFINED);
 
        if (btheme) {
        
@@ -1224,21 +1225,25 @@ void UI_ThemeColorShadeAlpha(int colorid, int 
coloffset, int alphaoffset)
        glColor4ub(r, g, b, a);
 }
 
-/* blend between to theme colors, and set it */
-void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
+void UI_GetThemeColorBlend3ubv(int colorid1, int colorid2, float fac, unsigned 
char col[3])
 {
-       int r, g, b;
        const unsigned char *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 = floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
-       g = floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
-       b = floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
-       
-       glColor3ub(r, g, b);
+       col[0] = floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
+       col[1] = floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
+       col[2] = floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
+}
+
+/* blend between to theme colors, and set it */
+void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
+{
+       unsigned char col[3];
+       UI_GetThemeColorBlend3ubv(colorid1, colorid2, fac, col);
+       glColor3ubv(col);
 }
 
 /* blend between to theme colors, shade it, and set it */
diff --git a/source/blender/editors/space_view3d/drawobject.c 
b/source/blender/editors/space_view3d/drawobject.c
index a940a71..07b635c 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -1408,8 +1408,10 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, 
Base *base,
                drawshadbuflimits(la, ob->obmat);
        }
        
-       UI_GetThemeColor4ubv(TH_LAMP, col);
-       glColor4ubv(col);
+       if ((dflag & DRAW_CONSTCOLOR) == 0) {
+               UI_GetThemeColor4ubv(TH_LAMP, col);
+               glColor4ubv(col);
+       }
 
        glEnable(GL_BLEND);
        
@@ -1448,7 +1450,9 @@ static void draw_limit_line(float sta, float end, const 
short dflag, unsigned in
        if (!(dflag & DRAW_PICKING)) {
                glPointSize(3.0);
                glBegin(GL_POINTS);
-               cpack(col);
+               if ((dflag & DRAW_CONSTCOLOR) == 0) {
+                       cpack(col);
+               }
                glVertex3f(0.0, 0.0, -sta);
                glVertex3f(0.0, 0.0, -end);
                glEnd();
@@ -4531,7 +4535,8 @@ static void draw_particle_data(ParticleSystem *psys, 
RegionView3D *rv3d,
 /* 6. draw the arrays                                          */
 /* 7. clean up                                                         */
 static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D 
*rv3d,
-                                     Base *base, ParticleSystem *psys, int 
ob_dt)
+                                     Base *base, ParticleSystem *psys,
+                                     const char ob_dt, const short dflag)
 {
        Object *ob = base->object;
        ParticleEditSettings *pset = PE_settings(scene);
@@ -4609,7 +4614,9 @@ static void draw_new_particle_system(Scene *scene, View3D 
*v3d, RegionView3D *rv
                copy_v3_v3(ma_col, &ma->r);
        }
 
-       glColor3ubv(tcol);
+       if ((dflag & DRAW_CONSTCOLOR) == 0) {
+               glColor3ubv(tcol);
+       }
 
        timestep = psys_get_timestep(&sim);
 
@@ -4944,8 +4951,10 @@ static void draw_new_particle_system(Scene *scene, 
View3D *v3d, RegionView3D *rv
                if (1) { //ob_dt > OB_WIRE) {
                        glEnableClientState(GL_NORMAL_ARRAY);
 
-                       if (part->draw_col == PART_DRAW_COL_MAT)
-                               glEnableClientState(GL_COLOR_ARRAY);
+                       if ((dflag & DRAW_CONSTCOLOR) == 0) {
+                               if (part->draw_col == PART_DRAW_COL_MAT)
+                                       glEnableClientState(GL_COLOR_ARRAY);
+                       }
 
                        glEnable(GL_LIGHTING);
                        glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
@@ -4975,8 +4984,11 @@ static void draw_new_particle_system(Scene *scene, 
View3D *v3d, RegionView3D *rv
 
                                if (1) { //ob_dt > OB_WIRE) {
                                        glNormalPointer(GL_FLOAT, 
sizeof(ParticleCacheKey), path->vel);
-                                       if (part->draw_col == PART_DRAW_COL_MAT)
-                                               glColorPointer(3, GL_FLOAT, 
sizeof(ParticleCacheKey), path->col);
+                                       if ((dflag & DRAW_CONSTCOLOR) == 0) {
+                                               if (part->draw_col == 
PART_DRAW_COL_MAT) {
+                                                       glColorPointer(3, 
GL_FLOAT, sizeof(ParticleCacheKey), path->col);
+                                               }
+                                       }
                                }
 
                                glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
@@ -4991,8 +5003,11 @@ static void draw_new_particle_system(Scene *scene, 
View3D *v3d, RegionView3D *rv
 
                        if (1) { //ob_dt > OB_WIRE) {
                                glNormalPointer(GL_FLOAT, 
sizeof(ParticleCacheKey), path->vel);
-                               if (part->draw_col == PART_DRAW_COL_MAT)
-                                       glColorPointer(3, GL_FLOAT, 
sizeof(ParticleCacheKey), path->col);
+                               if ((dflag & DRAW_CONSTCOLOR) == 0) {
+                                       if (part->draw_col == 
PART_DRAW_COL_MAT) {
+                                               glColorPointer(3, GL_FLOAT, 
sizeof(ParticleCacheKey), path->col);
+                                       }
+                               }
                        }
 
                        glDrawArrays(GL_LINE_STRIP, 0, path->steps + 1);
@@ -5036,21 +5051,24 @@ static void draw_new_particle_system(Scene *scene, 
View3D *v3d, RegionView3D *rv
                else
                        glDisableClientState(GL_VERTEX_ARRAY);
 
-               if (select) {
-                       UI_ThemeColor(TH_ACTIVE);
-                       
-                       if (part->draw_size)
-                               glPointSize(part->draw_size + 2);
-                       else
-                               glPointSize(4.0);
+               if ((dflag & DRAW_CONSTCOLOR) == 0) {
+                       if (select) {
+                               UI_ThemeColor(TH_ACTIVE);
 
-                       glLineWidth(3.0);
+                               if (part->draw_size)
+                                       glPointSize(part->draw_size + 2);
+                               else
+                                       glPointSize(4.0);
+
+                               glLineWidth(3.0);
+
+                               draw_particle_arrays(draw_as, totpoint, ob_dt, 
1);
+                       }
 
-                       draw_particle_arrays(draw_as, totpoint, ob_dt, 1);
+                       /* restore from select */
+                       glColor3fv(ma_col);
                }
 
-               /* restore from select */
-               glColor3fv(ma_col);
                glPointSize(part->draw_size ? part->draw_size : 2.0);
                glLineWidth(1.0);
 
@@ -5067,9 +5085,11 @@ static void draw_new_particle_system(Scene *scene, 
View3D *v3d, RegionView3D *rv
                        glDisable(GL_LIGHTING);
                }
 
-               if (pdd->cdata) {
-                       glEnableClientState(GL_COLOR_ARRAY);
-                       glColorPointer(3, GL_FLOAT, 0, pdd->cdata);
+               if ((dflag & DRAW_CONSTCOLOR) == 0) {
+                       if (pdd->cdata) {
+                               glEnableClientState(GL_COLOR_ARRAY);
+                               glColorPointer(3, GL_FLOAT, 0, pdd->cdata);
+                       }
                }
 
                draw_particle_arrays(draw_as, totpoint, ob_dt, 0);
@@ -5079,8 +5099,10 @@ static void draw_new_particle_system(Scene *scene, 
View3D *v3d, RegionView3D *rv
        }
 
        if (pdd && pdd->vedata) {
-               glDisableClientState(GL_COLOR_ARRAY);
-               cpack(0xC0C0C0);
+               if ((dflag & DRAW_CONSTCOLOR) == 0) {
+                       glDisableClientState(GL_COLOR_ARRAY);
+                       cpack(0xC0C0C0);
+               }
                
                glVertexPointer(3, GL_FLOAT, 0, pdd->vedata);
                
@@ -7285,7 +7307,12 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, 
Base *base, const short
        {
                ParticleSystem *psys;
 
-               if (col || (ob->flag & SELECT)) cpack(0xFFFFFF);    /* for 
visibility, also while wpaint */
+               if ((dflag & DRAW_CONSTCOLOR) == 0) {
+                       /* for visibility, also while wpaint */
+                       if (col || (ob->flag & SELECT)) {
+                               cpack(0xFFFFFF);
+                       }
+               }
                //glDepthMask(GL_FALSE);
 
                glLoadMatrixf(rv3d->viewmat);
@@ -7300,7 +7327,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, 
Base *base, const short
                                        draw_update_ptcache_edit(scene, ob, 
edit);
                        }
 
-                       draw_new_particle_system(scene, v3d, rv3d, base, psys, 
dt);
+                       draw_new_particle_system(scene, v3d, rv3d, base, psys, 
dt, dflag);
                }
                invert_m4_m4(ob->imat, ob->obmat);
                view3d_cached_text_draw_end(v3d, ar, 0, NULL);
diff --git a/source/blender/editors/space_view3d/view3d_draw.c 
b/source/blender/editors/space_view3d/view3d_draw.c
index 2eef7d9..217c5d7 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1961,7 +1961,9 @@ static DupliObject *dupli_step(DupliObject *dob)
        return dob;
 }
 
-static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, 
Base *base, int color)
+static void draw_dupli_objects_color(
+        Scene *scene, ARegion *ar, View3D *v3d, Base *base,
+        const short dflag, const int color)
 {
        RegionView3D *rv3d = ar->regiondata;
        ListBase *lb;
@@ -1970,13 +1972,22 @@ static void draw_dupli_objects_color(Scene *scene, 
ARegion *ar, View3D *v3d, Bas
        Base tbase = {NULL};
        BoundBox bb, *bb_tmp; /* use a copy because draw_object, calls 
clear_mesh_caches */
        GLuint displist = 0;
+       unsigned char color_rgb[3];
+       const short dflag_dupli = dflag | DRAW_CONSTCOLOR;
        short transflag, use_displist = -1;  /* -1 is initialize */
        char dt;
        short dtx;
        DupliApplyData *apply_data;
 
        if (base->object->restrictflag & OB_RESTRICT_VIEW) return;
-       
+
+       if (dflag & DRAW_CONSTCOLOR) {
+               BLI_assert(color == TH_UNDEFINED);
+       }
+       else {
+               UI_GetThemeColorBlend3ubv(color, TH_BACK, 0.5f, color_rgb);
+       }
+
        tbase.flag = OB_FROMDUPLI | base->flag;
        lb = object_duplilist(G.main->eval_ctx, scene, base->object);
        // BLI_sortlist(lb, dupli_ob_sort); /* might be nice to have if we have 
a dupli list with mixed objects. */
@@ -2019,7 +2030,10 @@ static void draw_dupli_objects_color(Scene *scene, 
ARegion *ar, View3D *v3d, Bas
                else
                        tbase.object->transflag &= ~OB_NEG_SCALE;
 
-               UI_ThemeColorBlend(color, TH_B

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to