diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-06-04 08:22:29 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-06-04 08:24:05 +0400 |
commit | 5ee55caba58371d06e6437a493a93bdec804be45 (patch) | |
tree | 45d83052061d66011a7c69ba6e8a2daf8d6438c9 | |
parent | b3e9a71a3dc47900afe5bad04b810a33165fa658 (diff) |
Fix for dupli's ignoring color in set-scenes
also skip setting wire color drawing depth
-rw-r--r-- | source/blender/editors/include/UI_resources.h | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 23 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 85 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 47 |
4 files changed, 106 insertions, 53 deletions
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 0f11994e2d1..2e78940a813 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 998577ab0c1..daf28bc4263 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 a940a7106ad..07b635c7f5e 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 2eef7d9573c..217c5d71af4 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_BACK, 0.5); + /* should move outside the loop but possible color is set in draw_object still */ + if ((dflag & DRAW_CONSTCOLOR) == 0) { + glColor3ubv(color_rgb); + } /* generate displist, test for new object */ if (dob_prev && dob_prev->ob != dob->ob) { @@ -2061,7 +2075,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas displist = glGenLists(1); glNewList(displist, GL_COMPILE); - draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR); + draw_object(scene, ar, v3d, &tbase, dflag_dupli); glEndList(); use_displist = true; @@ -2077,7 +2091,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas } else { copy_m4_m4(dob->ob->obmat, dob->mat); - draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR); + draw_object(scene, ar, v3d, &tbase, dflag_dupli); } tbase.object->dt = dt; @@ -2107,7 +2121,7 @@ static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *bas if (base->object->dup_group && base->object->dup_group->id.us < 1) color = TH_REDALERT; - draw_dupli_objects_color(scene, ar, v3d, base, color); + draw_dupli_objects_color(scene, ar, v3d, base, 0, color); } /* XXX warning, not using gpu offscreen here */ @@ -2256,6 +2270,8 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *), boo short flag = v3d->flag; float glalphaclip = U.glalphaclip; int obcenter_dia = U.obcenter_dia; + /* no need for color when drawing depth buffer */ + const short dflag_depth = DRAW_CONSTCOLOR; /* temp set drawtype to solid */ /* Setting these temporarily is not nice */ @@ -2290,7 +2306,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *), boo if (func == NULL || func(base)) { draw_object(scene, ar, v3d, base, 0); if (base->object->transflag & OB_DUPLI) { - draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE); + draw_dupli_objects_color(scene, ar, v3d, base, dflag_depth, TH_UNDEFINED); } } } @@ -2302,9 +2318,9 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *), boo if (func == NULL || func(base)) { /* dupli drawing */ if (base->object->transflag & OB_DUPLI) { - draw_dupli_objects(scene, ar, v3d, base); + draw_dupli_objects_color(scene, ar, v3d, base, dflag_depth, TH_UNDEFINED); } - draw_object(scene, ar, v3d, base, 0); + draw_object(scene, ar, v3d, base, dflag_depth); } } } @@ -2327,7 +2343,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *), boo glDepthFunc(GL_ALWAYS); /* always write into the depth bufer, overwriting front z values */ for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { next = v3da->next; - draw_object(scene, ar, v3d, v3da->base, 0); + draw_object(scene, ar, v3d, v3da->base, dflag_depth); } glDepthFunc(GL_LEQUAL); /* Now write the depth buffer normally */ } @@ -2337,7 +2353,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *), boo v3d->transp = true; for (v3da = v3d->afterdraw_transp.first; v3da; v3da = next) { next = v3da->next; - draw_object(scene, ar, v3d, v3da->base, 0); + draw_object(scene, ar, v3d, v3da->base, dflag_depth); BLI_remlink(&v3d->afterdraw_transp, v3da); MEM_freeN(v3da); } @@ -2346,7 +2362,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *), boo v3d->transp = false; for (v3da = v3d->afterdraw_xray.first; v3da; v3da = next) { next = v3da->next; - draw_object(scene, ar, v3d, v3da->base, 0); + draw_object(scene, ar, v3d, v3da->base, dflag_depth); BLI_remlink(&v3d->afterdraw_xray, v3da); MEM_freeN(v3da); } @@ -2355,7 +2371,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *), boo v3d->transp = true; for (v3da = v3d->afterdraw_xraytransp.first; v3da; v3da = next) { next = v3da->next; - draw_object(scene, ar, v3d, v3da->base, 0); + draw_object(scene, ar, v3d, v3da->base, dflag_depth); BLI_remlink(&v3d->afterdraw_xraytransp, v3da); MEM_freeN(v3da); } @@ -2633,14 +2649,15 @@ static void view3d_draw_objects( /* draw set first */ if (scene->set) { + const short dflag = DRAW_CONSTCOLOR | DRAW_SCENESET; Scene *sce_iter; for (SETLOOPER(scene->set, sce_iter, base)) { if (v3d->lay & base->lay) { UI_ThemeColorBlend(TH_WIRE, TH_BACK, 0.6f); - draw_object(scene, ar, v3d, base, DRAW_CONSTCOLOR | DRAW_SCENESET); + draw_object(scene, ar, v3d, base, dflag); if (base->object->transflag & OB_DUPLI) { - draw_dupli_objects_color(scene, ar, v3d, base, TH_WIRE); + draw_dupli_objects_color(scene, ar, v3d, base, dflag, TH_UNDEFINED); } } } |