Page Menu
Home
Search
Configure Global Search
Log In
Files
F13494
world_color_paper_real_ideasman42.diff
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Campbell Barton (campbellbarton)
Nov 13 2013, 2:43 PM
Size
9 KB
Subscribers
None
world_color_paper_real_ideasman42.diff
View Options
Index: intern/guardedalloc/intern/mallocn.c
===================================================================
--- intern/guardedalloc/intern/mallocn.c (revision 53574)
+++ intern/guardedalloc/intern/mallocn.c (working copy)
@@ -36,6 +36,11 @@
#include <string.h> /* memcpy */
#include <stdarg.h>
#include <sys/types.h>
+
+#ifdef __linux__
+# include <malloc.h>
+#endif
+
/* Blame Microsoft for LLP64 and no inttypes.h, quick workaround needed: */
#if defined(WIN64)
# define SIZET_FORMAT "%I64u"
@@ -306,7 +311,7 @@
return newp;
}
-
+#include <assert.h>
void *MEM_reallocN(void *vmemh, size_t len)
{
void *newp = NULL;
@@ -315,8 +320,25 @@
MemHead *memh = vmemh;
memh--;
+#ifdef __linux__
+ if (len > memh->len) {
+ MemTail *memt;
+ /* allocate in units of 4 */
+ const size_t len_align = (len + 3) & ~3;
+ const size_t len_real = len_align + sizeof(MemHead) + sizeof(MemTail);
+ if (len_real <= malloc_usable_size(memh)) {
+ memh->len = len;
+ memt = (MemTail *)(((char *) memh) + sizeof(MemHead) + len_align);
+ memt->tag3 = MEMTAG3;
+ printf("%s, reusing: %s\n", __func__, memh->name);
+ return vmemh;
+ }
+ }
+#endif
+
newp = MEM_mallocN(len, memh->name);
if (newp) {
+ assert(len != memh->len);
if (len < memh->len) {
/* shrink */
memcpy(newp, vmemh, len);
@@ -341,8 +363,31 @@
MemHead *memh = vmemh;
memh--;
+#ifdef __linux__
+ if (len > memh->len) {
+ MemTail *memt;
+ /* allocate in units of 4 */
+ const size_t len_align = (len + 3) & ~3;
+ const size_t len_real = len_align + sizeof(MemHead) + sizeof(MemTail);
+ if (len_real <= malloc_usable_size(memh)) {
+ memh->len = len;
+ memt = (MemTail *)(((char *) memh) + sizeof(MemHead) + len_align);
+ memt->tag3 = MEMTAG3;
+
+ {
+ /* grow */
+ /* zero new bytes */
+ memset(((char *)vmemh) + memh->len, 0, len - memh->len);
+ }
+ printf("%s, reusing: %s\n", __func__, memh->name);
+ return vmemh;
+ }
+ }
+#endif
+
newp = MEM_mallocN(len, memh->name);
if (newp) {
+ assert(len != memh->len);
if (len < memh->len) {
/* shrink */
memcpy(newp, vmemh, len);
Index: release/scripts/startup/bl_ui/space_view3d.py
===================================================================
--- release/scripts/startup/bl_ui/space_view3d.py (revision 53574)
+++ release/scripts/startup/bl_ui/space_view3d.py (working copy)
@@ -2404,6 +2404,9 @@
subsub.active = scene.unit_settings.system == 'NONE'
subsub.prop(view, "grid_subdivisions", text="Subdivisions")
+ col = layout.column()
+ col.prop(view, "display_world_color")
+
if not scene.render.use_shading_nodes:
col = layout.column()
col.label(text="Shading:")
Index: source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- source/blender/editors/space_view3d/view3d_draw.c (revision 53579)
+++ source/blender/editors/space_view3d/view3d_draw.c (working copy)
@@ -2995,17 +2995,103 @@
}
/* clear background */
- if ((v3d->flag2 & V3D_RENDER_OVERRIDE) && scene->world) {
- IMB_colormanagement_pixel_to_display_space_v3(backcol, &scene->world->horr, &scene->view_settings,
- &scene->display_settings);
+ if (!scene->world || (v3d->flag2 & V3D_WORLD_COLOR) == 0) { /* clear with solid color */
+ if ((v3d->flag2 & V3D_RENDER_OVERRIDE) && scene->world) {
+ IMB_colormanagement_pixel_to_display_space_v3(backcol, &scene->world->horr, &scene->view_settings,
+ &scene->display_settings);
- glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
+ glClearColor(backcol[0], backcol[1], backcol[2], 0.0);
+ }
+ else {
+ UI_ThemeClearColor(TH_BACK);
+ }
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+}
+ else { /* clear with gradient */
+ if(scene->world->skytype & WO_SKYBLEND) { /* blend sky */
+ glClearColor(scene->world->horr, scene->world->horg, scene->world->horb, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+#define XTOT 16
+#define YTOT 16
+ {
+ int x,y;
+
+ GLubyte grid_col[XTOT][YTOT][3];
+ float grid_pos[XTOT][YTOT][2];
+
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glShadeModel(GL_SMOOTH);
+
+
+ for (x = 0; x < XTOT; x++) {
+ for (y = 0; y < YTOT; y++) {
+ const float xf= (float)x / (float)(XTOT-1);
+ const float yf= (float)y / (float)(YTOT-1);
+ const float mval[2] = {xf * (float)ar->winx, yf * ar->winy};
+ float out[3];
+ const float up[3] = {0.0f, 0.0f, 1.0f};
+ GLubyte *col_ub = grid_col[x][y];
+
+ float col_fac;
+ float col_fl[3];
+
+ /* -1..1 range */
+ grid_pos[x][y][0] = (xf - 0.5f) * 2.0f;
+ grid_pos[x][y][1] = (yf - 0.5f) * 2.0f;
+
+ ED_view3d_win_to_vector(ar, mval, out);
+
+ if (scene->world->skytype & WO_SKYPAPER) {
+ col_fac = (float)y / (float)YTOT;
+ }
+ else {
+ //col_fac = (GLubyte)(((out[2] + 1.0f) / 2.0f) * 255.0f);
+ col_fac = 1.0f - ((((angle_v3v3(up, out) + ((float)M_PI)) / ((float)M_PI))) - 1.0f);
+ }
+
+ interp_v3_v3v3(col_fl, &scene->world->horr, &scene->world->zenr, col_fac);
+
+ rgb_float_to_uchar(col_ub, col_fl);
+ }
+ }
+
+ glBegin(GL_QUADS);
+ for (x = 0; x < XTOT - 1; x++) {
+ for (y = 0; y < YTOT - 1; y++) {
+ glColor3ubv(grid_col[x][y]);
+ glVertex2fv(grid_pos[x][y]);
+ glColor3ubv(grid_col[x][y + 1]);
+ glVertex2fv(grid_pos[x][y + 1]);
+ glColor3ubv(grid_col[x + 1][y + 1]);
+ glVertex2fv(grid_pos[x + 1][y + 1]);
+ glColor3ubv(grid_col[x + 1][y]);
+ glVertex2fv(grid_pos[x + 1][y]);
+ }
+ }
+ glEnd();
+
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+
+ glShadeModel(GL_FLAT);
+ }
+#undef XTOT
+#undef YTOT
+ }
+ else { /* solid sky */
+ glClearColor(scene->world->horr, scene->world->horg, scene->world->horb, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ }
}
- else
- UI_ThemeClearColor(TH_BACK);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
/* setup view matrices */
view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL);
Index: source/blender/makesdna/DNA_view3d_types.h
===================================================================
--- source/blender/makesdna/DNA_view3d_types.h (revision 53574)
+++ source/blender/makesdna/DNA_view3d_types.h (working copy)
@@ -270,6 +270,7 @@
#define V3D_SHOW_BUNDLENAME 512
#define V3D_BACKFACE_CULLING 1024
#define V3D_RENDER_BORDER 2048
+#define V3D_WORLD_COLOR 4096
/* View3D->around */
#define V3D_CENTER 0
Index: source/blender/makesrna/intern/rna_space.c
===================================================================
--- source/blender/makesrna/intern/rna_space.c (revision 53574)
+++ source/blender/makesrna/intern/rna_space.c (working copy)
@@ -1578,6 +1578,11 @@
RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4);
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, "lens", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "lens");
RNA_def_property_ui_text(prop, "Lens", "Viewport lens angle (mm)");
Index: source/blender/makesrna/intern/rna_world.c
===================================================================
--- source/blender/makesrna/intern/rna_world.c (revision 53574)
+++ source/blender/makesrna/intern/rna_world.c (working copy)
@@ -522,14 +522,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 */
- RNA_def_property_update(prop, NC_WORLD | ND_WORLD_DRAW, "rna_World_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");
@@ -554,17 +554,17 @@
prop = RNA_def_property(srna, "use_sky_blend", 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, "use_sky_paper", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYPAPER);
RNA_def_property_ui_text(prop, "Paper Sky", "Flatten blend or texture coordinates");
- 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, "use_sky_real", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "skytype", WO_SKYREAL);
RNA_def_property_ui_text(prop, "Real Sky", "Render background with a real horizon, relative to the camera angle");
- RNA_def_property_update(prop, 0, "rna_World_update");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_World_update");
/* nested structs */
prop = RNA_def_property(srna, "light_settings", PROP_POINTER, PROP_NONE);
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d0/c3/996aa398091a96f906ecf3862f49
Event Timeline
Log In to Comment