Page Menu
Home
Search
Configure Global Search
Log In
Files
F13475
world_color.diff
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Jacob F (raccoon)
Nov 13 2013, 2:43 PM
Size
9 KB
Subscribers
None
world_color.diff
View Options
Index: release/scripts/ui/space_view3d.py
===================================================================
--- release/scripts/ui/space_view3d.py (revision 30778)
+++ release/scripts/ui/space_view3d.py (working copy)
@@ -2025,6 +2025,9 @@
sub.prop(view, "grid_lines", text="Lines")
sub.prop(view, "grid_spacing", text="Spacing")
sub.prop(view, "grid_subdivisions", text="Subdivisions")
+
+ col = layout.column()
+ col.prop(view, "display_world_color")
col = layout.column()
col.label(text="Shading:")
Index: source/blender/makesdna/DNA_view3d_types.h
===================================================================
--- source/blender/makesdna/DNA_view3d_types.h (revision 30778)
+++ source/blender/makesdna/DNA_view3d_types.h (working copy)
@@ -250,6 +250,7 @@
#define V3D_RENDER_OVERRIDE 4
#define V3D_SOLID_TEX 8
#define V3D_DISPGP 16
+#define V3D_WORLD_COLOR 32
/* View3D->around */
#define V3D_CENTER 0
Index: source/blender/makesrna/intern/rna_world.c
===================================================================
--- source/blender/makesrna/intern/rna_world.c (revision 30778)
+++ source/blender/makesrna/intern/rna_world.c (working copy)
@@ -479,15 +479,14 @@
RNA_def_property_ui_text(prop, "Horizon Color", "Color at the horizon");
/* RNA_def_property_update(prop, 0, "rna_World_update"); */
/* render-only uses this, the notifier could be made to be more spesific */
+ /* Could just use RNA_def_property_update(prop, 0, "rna_World_draw_update"); ? */
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_World_update");
-
-
prop= RNA_def_property(srna, "zenith_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "zenr");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Zenith Color", "Color at the zenith");
- RNA_def_property_update(prop, 0, "rna_World_update");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_World_update");
prop= RNA_def_property(srna, "ambient_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "ambr");
@@ -512,7 +511,7 @@
prop= RNA_def_property(srna, "blend_sky", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYBLEND);
RNA_def_property_ui_text(prop, "Blend Sky", "Render background with natural progression from horizon to zenith");
- RNA_def_property_update(prop, 0, "rna_World_update");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, "rna_World_update");
prop= RNA_def_property(srna, "paper_sky", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYPAPER);
Index: source/blender/makesrna/intern/rna_space.c
===================================================================
--- source/blender/makesrna/intern/rna_space.c (revision 30778)
+++ source/blender/makesrna/intern/rna_space.c (working copy)
@@ -1063,6 +1063,11 @@
RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_RENDER_OVERRIDE);
RNA_def_property_ui_text(prop, "Only Render", "Display only objects which will be rendered");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
+
+ prop= RNA_def_property(srna, "display_world_color", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_WORLD_COLOR);
+ RNA_def_property_ui_text(prop, "Use World Color", "Use the world settings for the background");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
prop= RNA_def_property(srna, "occlude_geometry", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_ZBUF_SELECT);
Index: source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- source/blender/editors/space_view3d/view3d_draw.c (revision 30778)
+++ source/blender/editors/space_view3d/view3d_draw.c (working copy)
@@ -237,7 +237,7 @@
#define GRID_MIN_PX 6.0f
-static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_unit)
+static void drawgrid(UnitSettings *unit, ARegion *ar, Scene *scene, View3D *v3d, char **grid_unit)
{
/* extern short bgpicmode; */
RegionView3D *rv3d= ar->regiondata;
@@ -277,6 +277,11 @@
/* check zoom out */
UI_ThemeColor(TH_GRID);
+ if(v3d->flag2 & V3D_WORLD_COLOR) {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+
if(unit->system) {
/* Use GRID_MIN_PX*2 for units because very very small grid
* items are less useful when dealing with units */
@@ -307,10 +312,12 @@
/* tweak to have the fade a bit nicer */
blend_fac= (blend_fac * blend_fac) * 2.0f;
CLAMP(blend_fac, 0.3f, 1.0f);
+
+ if((v3d->flag2 & V3D_WORLD_COLOR)==0)
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, blend_fac);
+ else
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, blend_fac * 255 - 255);
-
- UI_ThemeColorBlend(TH_BACK, TH_GRID, blend_fac);
-
drawgrid_draw(ar, wx, wy, x, y, dx_scalar);
}
}
@@ -336,7 +343,11 @@
}
}
else { // start blending out
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ if((v3d->flag2 & V3D_WORLD_COLOR)==0)
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ else
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, dx/(GRID_MIN_PX*6) * 255 - 255);
+
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
@@ -344,7 +355,11 @@
}
}
else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10))
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ if((v3d->flag2 & V3D_WORLD_COLOR)==0)
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ else
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, dx/(GRID_MIN_PX*6) * 255 - 255);
+
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
@@ -363,21 +378,32 @@
drawgrid_draw(ar, wx, wy, x, y, dx);
}
else {
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ if((v3d->flag2 & V3D_WORLD_COLOR)==0)
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ else
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, dx/(GRID_MIN_PX*6) * 255 - 255);
+
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
drawgrid_draw(ar, wx, wy, x, y, dx*sublines);
}
}
else {
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ if((v3d->flag2 & V3D_WORLD_COLOR)==0)
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ else
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, dx/(GRID_MIN_PX*6) * 255 - 255);
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
drawgrid_draw(ar, wx, wy, x, y, dx*sublines);
}
}
else {
- UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ if((v3d->flag2 & V3D_WORLD_COLOR)==0)
+ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx/(GRID_MIN_PX*6));
+ else
+ UI_ThemeColorShadeAlpha(TH_GRID, 0, dx/(GRID_MIN_PX*6) * 255 - 255);
+
drawgrid_draw(ar, wx, wy, x, y, dx);
UI_ThemeColor(TH_GRID);
drawgrid_draw(ar, wx, wy, x, y, dx*sublines);
@@ -385,6 +411,8 @@
}
}
+ if(v3d->flag2 & V3D_WORLD_COLOR)
+ glDisable(GL_BLEND);
x+= (wx);
y+= (wy);
@@ -666,10 +694,10 @@
icon= ICON_AXIS_FRONT;
else if( ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT))
icon= ICON_AXIS_SIDE;
- else return ;
+ else return;
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
UI_icon_draw(5.0, 5.0, icon);
@@ -2223,12 +2251,43 @@
}
/* clear background */
- if((v3d->flag2 & V3D_RENDER_OVERRIDE) && scene->world)
- glClearColor(scene->world->horr, scene->world->horg, scene->world->horb, 0.0);
- else
- UI_ThemeClearColor(TH_BACK);
+ if (!scene->world || (v3d->flag2 & V3D_WORLD_COLOR)==0) { // clear with solid color
+ if((v3d->flag2 & V3D_RENDER_OVERRIDE) && scene->world)
+ glClearColor(scene->world->horr, scene->world->horg, scene->world->horb, 0.0);
+ else
+ UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ }
+ else { // clear with gradient
+ if(scene->world->skytype & WO_SKYBLEND) { // blend sky
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glShadeModel(GL_SMOOTH);
+ glBegin(GL_QUADS);
+ //horizon
+ glColor3f(scene->world->horr, scene->world->horg, scene->world->horb);
+ glVertex2f(-1.0,-1.0);
+ glVertex2f(1.0,-1.0);
+ //zenith
+ glColor3f(scene->world->zenr, scene->world->zeng, scene->world->zenb);
+ glVertex2f(1.0, 1.0);
+ glVertex2f(-1.0, 1.0);
+ glEnd();
+
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glShadeModel(GL_FLAT);
+ }
+ else { // solid sky
+ glClearColor(scene->world->horr, scene->world->horg, scene->world->horb, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ }
+ }
/* setup view matrices */
view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL);
@@ -2269,7 +2328,7 @@
}
else {
ED_region_pixelspace(ar);
- drawgrid(&scene->unit, ar, v3d, &grid_unit);
+ drawgrid(&scene->unit, ar, scene, v3d, &grid_unit);
/* XXX make function? replaces persp(1) */
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(rv3d->winmat);
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
60/cc/ae2e430bf373903d72d187851e29
Event Timeline
Log In to Comment