Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Susano Pinto <andresusanopinto@gmail.com>2008-07-15 16:54:57 +0400
committerAndre Susano Pinto <andresusanopinto@gmail.com>2008-07-15 16:54:57 +0400
commitafc30d1a33506d8c0fb08f6b2df7856071383430 (patch)
tree0ecaa106c0f38987024e12fbbdb90179808af70b /source/blender
parent785123cc5ab2d9681817bee6ee6bd8c11ac476f0 (diff)
There was a problem with the last merge :S
Somehow it didnt finished and didnt added some files under the svn control (found thanks to lguillaume that reported some files were missing) Last merge fixed and also merged modifications up to revision 15584. I checked the diff svn diff --new . --old https://svn.blender.org/svnroot/bf-blender/trunk/blender And everything seems to be right now
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenlib/BLI_mempool.h44
-rw-r--r--source/blender/blenlib/intern/BLI_mempool.c140
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp2
-rw-r--r--source/blender/render/intern/include/sunsky.h141
-rw-r--r--source/blender/render/intern/source/sunsky.c492
-rw-r--r--source/blender/render/intern/source/zbuf.c24
-rw-r--r--source/blender/src/buttons_editing.c4
-rw-r--r--source/blender/src/buttons_scene.c72
-rw-r--r--source/blender/src/transform_conversions.c2
9 files changed, 876 insertions, 45 deletions
diff --git a/source/blender/blenlib/BLI_mempool.h b/source/blender/blenlib/BLI_mempool.h
new file mode 100644
index 00000000000..8b31459dd38
--- /dev/null
+++ b/source/blender/blenlib/BLI_mempool.h
@@ -0,0 +1,44 @@
+/**
+ * Simple fast memory allocator
+ *
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Geoffrey Bantle.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef BLI_MEMPOOL_H
+#define BLI_MEMPOOL_H
+
+struct BLI_mempool;
+typedef struct BLI_mempool BLI_mempool;
+
+BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk);
+void *BLI_mempool_alloc(BLI_mempool *pool);
+void *BLI_mempool_calloc(BLI_mempool *pool);
+void BLI_mempool_free(BLI_mempool *pool, void *addr);
+void BLI_mempool_destroy(BLI_mempool *pool);
+
+
+#endif
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
new file mode 100644
index 00000000000..7ac7b8b1791
--- /dev/null
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -0,0 +1,140 @@
+/**
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 by Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/*
+ Simple, fast memory allocator for allocating many elements of the same size.
+*/
+
+#include "MEM_guardedalloc.h"
+#include "BLI_blenlib.h"
+#include "DNA_listBase.h"
+#include "BLI_linklist.h"
+#include <string.h>
+
+typedef struct BLI_freenode{
+ struct BLI_freenode *next;
+}BLI_freenode;
+
+typedef struct BLI_mempool_chunk{
+ struct BLI_mempool_chunk *next, *prev;
+ void *data;
+}BLI_mempool_chunk;
+
+typedef struct BLI_mempool{
+ struct ListBase chunks;
+ int esize, csize, pchunk; /*size of elements and chunks in bytes and number of elements per chunk*/
+ struct BLI_freenode *free; /*free element list. Interleaved into chunk datas.*/
+}BLI_mempool;
+
+BLI_mempool *BLI_mempool_create(int esize, int tote, int pchunk)
+{ BLI_mempool *pool = NULL;
+ BLI_freenode *lasttail = NULL, *curnode = NULL;
+ int i,j, maxchunks;
+ char *addr;
+
+ /*allocate the pool structure*/
+ pool = MEM_mallocN(sizeof(BLI_mempool),"memory pool");
+ pool->esize = esize;
+ pool->pchunk = pchunk;
+ pool->csize = esize * pchunk;
+ pool->chunks.first = pool->chunks.last = NULL;
+
+ maxchunks = tote / pchunk;
+
+ /*allocate the actual chunks*/
+ for(i=0; i < maxchunks; i++){
+ BLI_mempool_chunk *mpchunk = MEM_mallocN(sizeof(BLI_mempool_chunk), "BLI_Mempool Chunk");
+ mpchunk->next = mpchunk->prev = NULL;
+ mpchunk->data = MEM_mallocN(pool->csize, "BLI Mempool Chunk Data");
+ BLI_addtail(&(pool->chunks), mpchunk);
+
+ if(i==0) pool->free = mpchunk->data; /*start of the list*/
+ /*loop through the allocated data, building the pointer structures*/
+ for(addr = mpchunk->data, j=0; j < pool->pchunk; j++){
+ curnode = ((BLI_freenode*)addr);
+ addr += pool->esize;
+ curnode->next = (BLI_freenode*)addr;
+ }
+ /*final pointer in the previously allocated chunk is wrong.*/
+ if(lasttail) lasttail->next = mpchunk->data;
+ /*set the end of this chunks memoryy to the new tail for next iteration*/
+ lasttail = curnode;
+ }
+ /*terminate the list*/
+ curnode->next = NULL;
+ return pool;
+}
+void *BLI_mempool_alloc(BLI_mempool *pool){
+ void *retval=NULL;
+ BLI_freenode *curnode=NULL;
+ char *addr=NULL;
+ int j;
+
+ if(!(pool->free)){
+ /*need to allocate a new chunk*/
+ BLI_mempool_chunk *mpchunk = MEM_mallocN(sizeof(BLI_mempool_chunk), "BLI_Mempool Chunk");
+ mpchunk->next = mpchunk->prev = NULL;
+ mpchunk->data = MEM_mallocN(pool->csize, "BLI_Mempool Chunk Data");
+ BLI_addtail(&(pool->chunks), mpchunk);
+
+ pool->free = mpchunk->data; /*start of the list*/
+ for(addr = mpchunk->data, j=0; j < pool->pchunk; j++){
+ curnode = ((BLI_freenode*)addr);
+ addr += pool->esize;
+ curnode->next = (BLI_freenode*)addr;
+ }
+ curnode->next = NULL; /*terminate the list*/
+ }
+
+ retval = pool->free;
+ pool->free = pool->free->next;
+ //memset(retval, 0, pool->esize);
+ return retval;
+}
+
+void *BLI_mempool_calloc(BLI_mempool *pool){
+ void *retval=NULL;
+ retval = BLI_mempool_alloc(pool);
+ memset(retval, 0, pool->esize);
+ return retval;
+}
+
+
+
+void BLI_mempool_free(BLI_mempool *pool, void *addr){ //doesnt protect against double frees, dont be stupid!
+ BLI_freenode *newhead = addr;
+ newhead->next = pool->free;
+ pool->free = newhead;
+}
+void BLI_mempool_destroy(BLI_mempool *pool)
+{
+ BLI_mempool_chunk *mpchunk=NULL;
+ for(mpchunk = pool->chunks.first; mpchunk; mpchunk = mpchunk->next) MEM_freeN(mpchunk->data);
+ BLI_freelistN(&(pool->chunks));
+ MEM_freeN(pool);
+}
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index fe352610a40..3e618a483e3 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -451,7 +451,7 @@ void IMB_exr_begin_write(void *handle, char *filename, int width, int height, in
openexr_header_compression(&header, compress);
/* header.lineOrder() = DECREASING_Y; this crashes in windows for file read! */
- header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.43"));
+ header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.43 and newer"));
data->ofile = new OutputFile(filename, header);
}
diff --git a/source/blender/render/intern/include/sunsky.h b/source/blender/render/intern/include/sunsky.h
new file mode 100644
index 00000000000..c61a637269a
--- /dev/null
+++ b/source/blender/render/intern/include/sunsky.h
@@ -0,0 +1,141 @@
+ /**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Contributor(s): zaghaghi
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+/**
+ * This feature comes from Preetham paper on "A Practical Analytic Model for Daylight"
+ * and example code from Brian Smits, another author of that paper in
+ * http://www.cs.utah.edu/vissim/papers/sunsky/code/
+ * */
+#ifndef SUNSKY_H_
+#define SUNSKY_H_
+
+#define SPECTRUM_MAX_COMPONENTS 100
+#define SPECTRUM_START 350.0
+#define SPECTRUM_END 800.0
+
+typedef struct SunSky
+{
+ short effect_type;
+ float turbidity;
+ float theta, phi;
+
+ float toSun[3];
+
+ /*float sunSpectralRaddata[SPECTRUM_MAX_COMPONENTS];*/
+ float sunSolidAngle;
+
+ float zenith_Y, zenith_x, zenith_y;
+
+ float perez_Y[5], perez_x[5], perez_y[5];
+
+ /* suggested by glome in
+ * http://projects.blender.org/tracker/?func=detail&atid=127&aid=8063&group_id=9*/
+ float horizon_brightness;
+ float spread;
+ float sun_brightness;
+ float sun_size;
+ float backscattered_light;
+
+ float atm_HGg;
+
+ float atm_SunIntensity;
+ float atm_InscatteringMultiplier;
+ float atm_ExtinctionMultiplier;
+ float atm_BetaRayMultiplier;
+ float atm_BetaMieMultiplier;
+ float atm_DistanceMultiplier;
+
+ float atm_BetaRay[3];
+ float atm_BetaDashRay[3];
+ float atm_BetaMie[3];
+ float atm_BetaDashMie[3];
+ float atm_BetaRM[3];
+}SunSky;
+
+/**
+ * InitSunSky:
+ * this function compute some sun,sky parameters according to input parameters and also initiate some other sun, sky parameters
+ * parameters:
+ * sunSky, is a structure that contains informtion about sun, sky and atmosphere, in this function, most of its values initiated
+ * turb, is atmosphere turbidity
+ * toSun, contains sun direction
+ * horizon_brighness, controls the brightness of the horizon colors
+ * spread, controls colors spreed at horizon
+ * sun_brightness, controls sun's brightness
+ * sun_size, controls sun's size
+ * back_scatter, controls back scatter light
+ * */
+void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_brightness,
+ float spread,float sun_brightness, float sun_size, float back_scatter);
+
+/**
+ * GetSkyXYZRadiance:
+ * this function compute sky radiance according to a view parameters `theta' and `phi'and sunSky values
+ * parameters:
+ * sunSky, sontains sun and sky parameters
+ * theta, is sun's theta
+ * phi, is sun's phi
+ * color_out, is computed color that shows sky radiance in XYZ color format
+ * */
+void GetSkyXYZRadiance(struct SunSky* sunsky, float theta, float phi, float color_out[3]);
+
+/**
+ * GetSkyXYZRadiancef:
+ * this function compute sky radiance according to a view direction `varg' and sunSky values
+ * parameters:
+ * sunSky, sontains sun and sky parameters
+ * varg, shows direction
+ * color_out, is computed color that shows sky radiance in XYZ color format
+ * */
+void GetSkyXYZRadiancef(struct SunSky* sunsky, const float varg[3], float color_out[3]);
+
+/**
+ * InitAtmosphere:
+ * this function intiate sunSky structure with user input parameters.
+ * parameters:
+ * sunSky, contains information about sun, and in this function some atmosphere parameters will initiated
+ * sun_intens, shows sun intensity value
+ * mief, Mie scattering factor this factor currently call with 1.0
+ * rayf, Rayleigh scattering factor, this factor currently call with 1.0
+ * inscattf, inscatter light factor that range from 0.0 to 1.0, 0.0 means no inscatter light and 1.0 means full inscatter light
+ * extincf, extinction light factor that range from 0.0 to 1.0, 0.0 means no extinction and 1.0 means full extinction
+ * disf, is distance factor, multiplyed to pixle's z value to compute each pixle's distance to camera,
+ * */
+void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float rayf, float inscattf, float extincf, float disf);
+
+/**
+ * AtmospherePixleShader:
+ * this function apply atmosphere effect on a pixle color `rgb' at distance `s'
+ * parameters:
+ * sunSky, contains information about sun parameters and user values
+ * view, is camera view vector
+ * s, is distance
+ * rgb, contains rendered color value for a pixle
+ * */
+void AtmospherePixleShader( struct SunSky* sunSky, float view[3], float s, float rgb[3]);
+
+/**
+ * ClipColor:
+ * clip a color to range [0,1];
+ * */
+void ClipColor(float c[3]);
+
+#endif /*SUNSKY_H_*/
diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c
new file mode 100644
index 00000000000..191867765a3
--- /dev/null
+++ b/source/blender/render/intern/source/sunsky.c
@@ -0,0 +1,492 @@
+ /**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+
+#include "sunsky.h"
+#include "math.h"
+#include "BLI_arithb.h"
+
+
+/**
+ * These macros are defined for vector operations
+ * */
+
+/**
+ * compute v1 = v2 op v3
+ * v1, v2 and v3 are vectors contains 3 float
+ * */
+#define vec3opv(v1, v2, op, v3) \
+ v1[0] = (v2[0] op v3[0]); \
+ v1[1] = (v2[1] op v3[1]);\
+ v1[2] = (v2[2] op v3[2]);
+
+/**
+ * compute v1 = v2 op f1
+ * v1, v2 are vectors contains 3 float
+ * and f1 is a float
+ * */
+#define vec3opf(v1, v2, op, f1)\
+ v1[0] = (v2[0] op (f1));\
+ v1[1] = (v2[1] op (f1));\
+ v1[2] = (v2[2] op (f1));
+
+/**
+ * compute v1 = f1 op v2
+ * v1, v2 are vectors contains 3 float
+ * and f1 is a float
+ * */
+#define fopvec3(v1, f1, op, v2)\
+ v1[0] = ((f1) op v2[0]);\
+ v1[1] = ((f1) op v2[1]);\
+ v1[2] = ((f1) op v2[2]);
+
+/**
+ * ClipColor:
+ * clip a color to range [0,1];
+ * */
+void ClipColor(float c[3])
+{
+ if (c[0] > 1.0) c[0] = 1.0;
+ if (c[0] < 0.0) c[0] = 0.0;
+ if (c[1] > 1.0) c[1] = 1.0;
+ if (c[1] < 0.0) c[1] = 0.0;
+ if (c[2] > 1.0) c[2] = 1.0;
+ if (c[2] < 0.0) c[2] = 0.0;
+}
+
+/**
+ * AngleBetween:
+ * compute angle between to direction
+ * all angles are in radians
+ * */
+static float AngleBetween(float thetav, float phiv, float theta, float phi)
+{
+ float cospsi = sin(thetav) * sin(theta) * cos(phi - phiv) + cos(thetav) * cos(theta);
+
+ if (cospsi > 1.0)
+ return 0;
+ if (cospsi < -1.0)
+ return M_PI;
+
+ return acos(cospsi);
+}
+
+/**
+ * DirectionToThetaPhi:
+ * this function convert a direction to it's theta and phi value
+ * parameters:
+ * toSun: contains direction information
+ * theta, phi, are return values from this conversion
+ * */
+static void DirectionToThetaPhi(float *toSun, float *theta, float *phi)
+{
+ *theta = acos(toSun[2]);
+ if (fabs(*theta) < 1e-5)
+ *phi = 0;
+ else
+ *phi = atan2(toSun[1], toSun[0]);
+}
+
+/**
+ * PerezFunction:
+ * compute perez function value based on input paramters
+ * */
+float PerezFunction(struct SunSky *sunsky, const float *lam, float theta, float gamma, float lvz)
+{
+ float den, num;
+
+ den = ((1 + lam[0] * exp(lam[1])) *
+ (1 + lam[2] * exp(lam[3] * sunsky->theta) + lam[4] * cos(sunsky->theta) * cos(sunsky->theta)));
+
+ num = ((1 + lam[0] * exp(lam[1] / cos(theta))) *
+ (1 + lam[2] * exp(lam[3] * gamma) + lam[4] * cos(gamma) * cos(gamma)));
+
+ return(lvz * num / den);
+}
+
+/**
+ * InitSunSky:
+ * this function compute some sun,sky parameters according to input parameters and also initiate some other sun, sky parameters
+ * parameters:
+ * sunSky, is a structure that contains informtion about sun, sky and atmosphere, in this function, most of its values initiated
+ * turb, is atmosphere turbidity
+ * toSun, contains sun direction
+ * horizon_brighness, controls the brightness of the horizon colors
+ * spread, controls colors spreed at horizon
+ * sun_brightness, controls sun's brightness
+ * sun_size, controls sun's size
+ * back_scatter, controls back scatter light
+ * */
+void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_brightness,
+ float spread,float sun_brightness, float sun_size, float back_scatter)
+{
+
+ float theta2;
+ float theta3;
+ float T;
+ float T2;
+ float chi;
+
+ sunsky->turbidity = turb;
+
+ sunsky->horizon_brightness = horizon_brightness;
+ sunsky->spread = spread;
+ sunsky->sun_brightness = sun_brightness;
+ sunsky->sun_size = sun_size;
+ sunsky->backscattered_light = back_scatter;
+
+ sunsky->toSun[0] = toSun[0];
+ sunsky->toSun[1] = toSun[1];
+ sunsky->toSun[2] = toSun[2];
+
+ DirectionToThetaPhi(sunsky->toSun, &sunsky->theta, &sunsky->phi);
+
+ sunsky->sunSolidAngle = 0.25 * M_PI * 1.39 * 1.39 / (150 * 150); // = 6.7443e-05
+
+ theta2 = sunsky->theta*sunsky->theta;
+ theta3 = theta2 * sunsky->theta;
+ T = turb;
+ T2 = turb*turb;
+
+ chi = (4.0 / 9.0 - T / 120.0) * (M_PI - 2 * sunsky->theta);
+ sunsky->zenith_Y = (4.0453 * T - 4.9710) * tan(chi) - .2155 * T + 2.4192;
+ sunsky->zenith_Y *= 1000; // conversion from kcd/m^2 to cd/m^2
+
+ if (sunsky->zenith_Y<=0)
+ sunsky->zenith_Y = 1e-6;
+
+ sunsky->zenith_x =
+ ( + 0.00165 * theta3 - 0.00374 * theta2 + 0.00208 * sunsky->theta + 0) * T2 +
+ ( -0.02902 * theta3 + 0.06377 * theta2 - 0.03202 * sunsky->theta + 0.00394) * T +
+ ( + 0.11693 * theta3 - 0.21196 * theta2 + 0.06052 * sunsky->theta + 0.25885);
+
+ sunsky->zenith_y =
+ ( + 0.00275 * theta3 - 0.00610 * theta2 + 0.00316 * sunsky->theta + 0) * T2 +
+ ( -0.04214 * theta3 + 0.08970 * theta2 - 0.04153 * sunsky->theta + 0.00515) * T +
+ ( + 0.15346 * theta3 - 0.26756 * theta2 + 0.06669 * sunsky->theta + 0.26688);
+
+
+ sunsky->perez_Y[0] = 0.17872 * T - 1.46303;
+ sunsky->perez_Y[1] = -0.35540 * T + 0.42749;
+ sunsky->perez_Y[2] = -0.02266 * T + 5.32505;
+ sunsky->perez_Y[3] = 0.12064 * T - 2.57705;
+ sunsky->perez_Y[4] = -0.06696 * T + 0.37027;
+
+ sunsky->perez_x[0] = -0.01925 * T - 0.25922;
+ sunsky->perez_x[1] = -0.06651 * T + 0.00081;
+ sunsky->perez_x[2] = -0.00041 * T + 0.21247;
+ sunsky->perez_x[3] = -0.06409 * T - 0.89887;
+ sunsky->perez_x[4] = -0.00325 * T + 0.04517;
+
+ sunsky->perez_y[0] = -0.01669 * T - 0.26078;
+ sunsky->perez_y[1] = -0.09495 * T + 0.00921;
+ sunsky->perez_y[2] = -0.00792 * T + 0.21023;
+ sunsky->perez_y[3] = -0.04405 * T - 1.65369;
+ sunsky->perez_y[4] = -0.01092 * T + 0.05291;
+
+ /* suggested by glome in
+ * http://projects.blender.org/tracker/?func=detail&atid=127&aid=8063&group_id=9*/
+ sunsky->perez_Y[0] *= sunsky->horizon_brightness;
+ sunsky->perez_x[0] *= sunsky->horizon_brightness;
+ sunsky->perez_y[0] *= sunsky->horizon_brightness;
+
+ sunsky->perez_Y[1] *= sunsky->spread;
+ sunsky->perez_x[1] *= sunsky->spread;
+ sunsky->perez_y[1] *= sunsky->spread;
+
+ sunsky->perez_Y[2] *= sunsky->sun_brightness;
+ sunsky->perez_x[2] *= sunsky->sun_brightness;
+ sunsky->perez_y[2] *= sunsky->sun_brightness;
+
+ sunsky->perez_Y[3] *= sunsky->sun_size;
+ sunsky->perez_x[3] *= sunsky->sun_size;
+ sunsky->perez_y[3] *= sunsky->sun_size;
+
+ sunsky->perez_Y[4] *= sunsky->backscattered_light;
+ sunsky->perez_x[4] *= sunsky->backscattered_light;
+ sunsky->perez_y[4] *= sunsky->backscattered_light;
+}
+
+/**
+ * GetSkyXYZRadiance:
+ * this function compute sky radiance according to a view parameters `theta' and `phi'and sunSky values
+ * parameters:
+ * sunSky, sontains sun and sky parameters
+ * theta, is sun's theta
+ * phi, is sun's phi
+ * color_out, is computed color that shows sky radiance in XYZ color format
+ * */
+void GetSkyXYZRadiance(struct SunSky* sunsky, float theta, float phi, float color_out[3])
+{
+ float gamma;
+ float x,y,Y,X,Z;
+ float hfade=1, nfade=1;
+
+
+ if (theta>(0.5*M_PI)) {
+ hfade = 1.0-(theta*M_1_PI-0.5)*2.0;
+ hfade = hfade*hfade*(3.0-2.0*hfade);
+ theta = 0.5*M_PI;
+ }
+
+ if (sunsky->theta>(0.5*M_PI)) {
+ if (theta<=0.5*M_PI) {
+ nfade = 1.0-(0.5-theta*M_1_PI)*2.0;
+ nfade *= 1.0-(sunsky->theta*M_1_PI-0.5)*2.0;
+ nfade = nfade*nfade*(3.0-2.0*nfade);
+ }
+ }
+
+ gamma = AngleBetween(theta, phi, sunsky->theta, sunsky->phi);
+
+ // Compute xyY values
+ x = PerezFunction(sunsky, sunsky->perez_x, theta, gamma, sunsky->zenith_x);
+ y = PerezFunction(sunsky, sunsky->perez_y, theta, gamma, sunsky->zenith_y);
+ Y = nfade * hfade * PerezFunction(sunsky, sunsky->perez_Y, theta, gamma, sunsky->zenith_Y);
+
+ X = (x / y) * Y;
+ Z = ((1 - x - y) / y) * Y;
+
+ color_out[0] = X;
+ color_out[1] = Y;
+ color_out[2] = Z;
+}
+
+/**
+ * GetSkyXYZRadiancef:
+ * this function compute sky radiance according to a view direction `varg' and sunSky values
+ * parameters:
+ * sunSky, sontains sun and sky parameters
+ * varg, shows direction
+ * color_out, is computed color that shows sky radiance in XYZ color format
+ * */
+void GetSkyXYZRadiancef(struct SunSky* sunsky, const float varg[3], float color_out[3])
+{
+ float theta, phi;
+ float v[3];
+
+ VecCopyf(v, (float*)varg);
+ Normalize(v);
+
+ if (v[2] < 0.001){
+ v[2] = 0.001;
+ Normalize(v);
+ }
+
+ DirectionToThetaPhi(v, &theta, &phi);
+ GetSkyXYZRadiance(sunsky, theta, phi, color_out);
+}
+
+/**
+ * ComputeAttenuatedSunlight:
+ * this function compute attenuated sun light based on sun's theta and atmosphere turbidity
+ * parameters:
+ * theta, is sun's theta
+ * turbidity: is atmosphere turbidity
+ * fTau: contains computed attenuated sun light
+ * */
+void ComputeAttenuatedSunlight(float theta, int turbidity, float fTau[3])
+{
+ float fBeta ;
+ float fTauR, fTauA;
+ float m ;
+ float fAlpha;
+
+ int i;
+ float fLambda[3];
+ fLambda[0] = 0.65f;
+ fLambda[1] = 0.57f;
+ fLambda[2] = 0.475f;
+
+ fAlpha = 1.3f;
+ fBeta = 0.04608365822050f * turbidity - 0.04586025928522f;
+
+ m = 1.0/(cos(theta) + 0.15f*pow(93.885f-theta/M_PI*180.0f,-1.253f));
+
+ for(i = 0; i < 3; i++)
+ {
+ // Rayleigh Scattering
+ fTauR = exp( -m * 0.008735f * pow(fLambda[i], (float)(-4.08f)));
+
+ // Aerosal (water + dust) attenuation
+ fTauA = exp(-m * fBeta * pow(fLambda[i], -fAlpha));
+
+ fTau[i] = fTauR * fTauA;
+ }
+}
+
+/**
+ * InitAtmosphere:
+ * this function intiate sunSky structure with user input parameters.
+ * parameters:
+ * sunSky, contains information about sun, and in this function some atmosphere parameters will initiated
+ * sun_intens, shows sun intensity value
+ * mief, Mie scattering factor this factor currently call with 1.0
+ * rayf, Rayleigh scattering factor, this factor currently call with 1.0
+ * inscattf, inscatter light factor that range from 0.0 to 1.0, 0.0 means no inscatter light and 1.0 means full inscatter light
+ * extincf, extinction light factor that range from 0.0 to 1.0, 0.0 means no extinction and 1.0 means full extinction
+ * disf, is distance factor, multiplyed to pixle's z value to compute each pixle's distance to camera,
+ * */
+void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float rayf,
+ float inscattf, float extincf, float disf)
+{
+ const float pi = 3.14159265358f;
+ const float n = 1.003f; // refractive index
+ const float N = 2.545e25;
+ const float pn = 0.035f;
+ const float T = 2.0f;
+ float fTemp, fTemp2, fTemp3, fBeta, fBetaDash;
+ float c = (6.544*T - 6.51)*1e-17;
+ float K[3] = {0.685f, 0.679f, 0.670f};
+ float vBetaMieTemp[3];
+
+ float fLambda[3],fLambda2[3], fLambda4[3];
+ float vLambda2[3];
+ float vLambda4[3];
+
+ int i;
+
+ sunSky->atm_SunIntensity = sun_intens;
+ sunSky->atm_BetaMieMultiplier = mief;
+ sunSky->atm_BetaRayMultiplier = rayf;
+ sunSky->atm_InscatteringMultiplier = inscattf;
+ sunSky->atm_ExtinctionMultiplier = extincf;
+ sunSky->atm_DistanceMultiplier = disf;
+
+ sunSky->atm_HGg=0.8;
+
+ fLambda[0] = 1/650e-9f;
+ fLambda[1] = 1/570e-9f;
+ fLambda[2] = 1/475e-9f;
+ for (i=0; i < 3; i++)
+ {
+ fLambda2[i] = fLambda[i]*fLambda[i];
+ fLambda4[i] = fLambda2[i]*fLambda2[i];
+ }
+
+ vLambda2[0] = fLambda2[0];
+ vLambda2[1] = fLambda2[1];
+ vLambda2[2] = fLambda2[2];
+
+ vLambda4[0] = fLambda4[0];
+ vLambda4[1] = fLambda4[1];
+ vLambda4[2] = fLambda4[2];
+
+ // Rayleigh scattering constants.
+ fTemp = pi*pi*(n*n-1)*(n*n-1)*(6+3*pn)/(6-7*pn)/N;
+ fBeta = 8*fTemp*pi/3;
+
+ vec3opf(sunSky->atm_BetaRay, vLambda4, *, fBeta);
+ fBetaDash = fTemp/2;
+ vec3opf(sunSky->atm_BetaDashRay, vLambda4,*, fBetaDash);
+
+
+ // Mie scattering constants.
+ fTemp2 = 0.434*c*(2*pi)*(2*pi)*0.5f;
+ vec3opf(sunSky->atm_BetaDashMie, vLambda2, *, fTemp2);
+
+ fTemp3 = 0.434f*c*pi*(2*pi)*(2*pi);
+
+ vec3opv(vBetaMieTemp, K, *, fLambda);
+ vec3opf(sunSky->atm_BetaMie, vBetaMieTemp,*, fTemp3);
+
+}
+
+/**
+ * AtmospherePixleShader:
+ * this function apply atmosphere effect on a pixle color `rgb' at distance `s'
+ * parameters:
+ * sunSky, contains information about sun parameters and user values
+ * view, is camera view vector
+ * s, is distance
+ * rgb, contains rendered color value for a pixle
+ * */
+void AtmospherePixleShader( struct SunSky* sunSky, float view[3], float s, float rgb[3])
+{
+ float costheta;
+ float Phase_1;
+ float Phase_2;
+ float sunColor[3];
+
+ float E[3];
+ float E1[3];
+
+
+ float I[3];
+ float fTemp;
+ float vTemp1[3], vTemp2[3];
+
+ float sunDirection[3];
+
+ s *= sunSky->atm_DistanceMultiplier;
+
+ sunDirection[0] = sunSky->toSun[0];
+ sunDirection[1] = sunSky->toSun[1];
+ sunDirection[2] = sunSky->toSun[2];
+
+ costheta = Inpf(view, sunDirection); // cos(theta)
+ Phase_1 = 1 + (costheta * costheta); // Phase_1
+
+ vec3opf(sunSky->atm_BetaRay, sunSky->atm_BetaRay, *, sunSky->atm_BetaRayMultiplier);
+ vec3opf(sunSky->atm_BetaMie, sunSky->atm_BetaMie, *, sunSky->atm_BetaMieMultiplier);
+ vec3opv(sunSky->atm_BetaRM, sunSky->atm_BetaRay, +, sunSky->atm_BetaMie);
+
+ //e^(-(beta_1 + beta_2) * s) = E1
+ vec3opf(E1, sunSky->atm_BetaRM, *, -s/log(2));
+ E1[0] = exp(E1[0]);
+ E1[1] = exp(E1[1]);
+ E1[2] = exp(E1[2]);
+
+ VecCopyf(E, E1);
+
+ //Phase2(theta) = (1-g^2)/(1+g-2g*cos(theta))^(3/2)
+ fTemp = 1 + sunSky->atm_HGg - 2 * sunSky->atm_HGg * costheta;
+ fTemp = fTemp * sqrt(fTemp);
+ Phase_2 = (1 - sunSky->atm_HGg * sunSky->atm_HGg)/fTemp;
+
+ vec3opf(vTemp1, sunSky->atm_BetaDashRay, *, Phase_1);
+ vec3opf(vTemp2, sunSky->atm_BetaDashMie, *, Phase_2);
+
+ vec3opv(vTemp1, vTemp1, +, vTemp2);
+ fopvec3(vTemp2, 1.0, -, E1);
+ vec3opv(vTemp1, vTemp1, *, vTemp2);
+
+ fopvec3(vTemp2, 1.0, / , sunSky->atm_BetaRM);
+
+ vec3opv(I, vTemp1, *, vTemp2);
+
+ vec3opf(I, I, *, sunSky->atm_InscatteringMultiplier);
+ vec3opf(E, E, *, sunSky->atm_ExtinctionMultiplier);
+
+ //scale to color sun
+ ComputeAttenuatedSunlight(sunSky->theta, sunSky->turbidity, sunColor);
+ vec3opv(E, E, *, sunColor);
+
+ vec3opf(I, I, *, sunSky->atm_SunIntensity);
+
+ vec3opv(rgb, rgb, *, E);
+ vec3opv(rgb, rgb, +, I);
+}
+
+#undef vec3opv
+#undef vec3opf
+#undef fopvec3
+
+/* EOF */
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index 579905315bb..c91c9e2f799 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -3545,7 +3545,7 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr)
for(rpass= rl->passes.first; rpass; rpass= rpass->next) {
float *col= NULL;
- int pixsize= 0;
+ int pixsize= 3;
switch(rpass->passtype) {
case SCE_PASS_RGBA:
@@ -3580,6 +3580,10 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr)
col= &shr->mist;
pixsize= 1;
break;
+ case SCE_PASS_Z:
+ col= &shr->z;
+ pixsize= 1;
+ break;
case SCE_PASS_VECTOR:
{
@@ -3612,14 +3616,18 @@ void merge_transp_passes(RenderLayer *rl, ShadeResult *shr)
for(samp= 1; samp<R.osa; samp++, fp+=delta) {
col[0]+= fp[0];
- col[1]+= fp[1];
- col[2]+= fp[2];
- if(pixsize) col[3]+= fp[3];
+ if(pixsize>1) {
+ col[1]+= fp[1];
+ col[2]+= fp[2];
+ if(pixsize==4) col[3]+= fp[3];
+ }
}
col[0]*= weight;
- col[1]*= weight;
- col[2]*= weight;
- if(pixsize) col[3]*= weight;
+ if(pixsize>1) {
+ col[1]*= weight;
+ col[2]*= weight;
+ if(pixsize==4) col[3]*= weight;
+ }
}
}
@@ -3973,7 +3981,7 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas
/* general shader info, passes */
shade_sample_initialize(&ssamp, pa, rl);
- addpassflag= rl->passflag & ~(SCE_PASS_Z|SCE_PASS_COMBINED);
+ addpassflag= rl->passflag & ~(SCE_PASS_COMBINED);
addzbuf= rl->passflag & SCE_PASS_Z;
if(R.osa)
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c
index a21dc8b0f5d..c30f39b5f4c 100644
--- a/source/blender/src/buttons_editing.c
+++ b/source/blender/src/buttons_editing.c
@@ -513,7 +513,6 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
} else {
editmesh_deselect_by_material(G.obedit->actcol-1);
}
- allqueue(REDRAWVIEW3D, 0);
}
else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) {
nu= editNurb.first;
@@ -553,8 +552,9 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
nu= nu->next;
}
BIF_undo_push("Select material index");
- allqueue(REDRAWVIEW3D, 0);
}
+ allqueue(REDRAWIMAGE, 0);
+ allqueue(REDRAWVIEW3D, 0);
}
countall();
break;
diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c
index af90d01fb59..3b0167d673c 100644
--- a/source/blender/src/buttons_scene.c
+++ b/source/blender/src/buttons_scene.c
@@ -137,36 +137,42 @@ static void load_new_sample(char *str) /* called from fileselect */
bSample *sample, *newsample;
sound = G.buts->lockpoin;
+
+ /* No Sound or Selected the same sample as we alredy have, just ignore */
+ if (sound==NULL || str==sound->name)
+ return;
+
+ if (sizeof(sound->sample->name) < strlen(str)) {
+ error("Path too long: %s", str);
+ return;
+ }
+
+ // save values
+ sample = sound->sample;
+ strcpy(name, sound->sample->name);
+ strcpy(sound->name, str);
+ sound_set_sample(sound, NULL);
+ sound_initialize_sample(sound);
- if (sound) {
- // save values
- sample = sound->sample;
- strcpy(name, sound->sample->name);
-
- strcpy(sound->name, str);
- sound_set_sample(sound, NULL);
- sound_initialize_sample(sound);
-
- if (sound->sample->type == SAMPLE_INVALID) {
- error("Not a valid sample: %s", str);
+ if (sound->sample->type == SAMPLE_INVALID) {
+ error("Not a valid sample: %s", str);
- newsample = sound->sample;
+ newsample = sound->sample;
- // restore values
- strcpy(sound->name, name);
- sound_set_sample(sound, sample);
+ // restore values
+ strcpy(sound->name, name);
+ sound_set_sample(sound, sample);
- // remove invalid sample
+ // remove invalid sample
- sound_free_sample(newsample);
- BLI_remlink(samples, newsample);
- MEM_freeN(newsample);
- }
+ sound_free_sample(newsample);
+ BLI_remlink(samples, newsample);
+ MEM_freeN(newsample);
+ return;
}
-
+
BIF_undo_push("Load new audio file");
allqueue(REDRAWBUTSSCENE, 0);
-
}
@@ -403,7 +409,7 @@ static void sound_panel_sound(bSound *sound)
sample = sound->sample;
/* info string */
- if (sound->sample && sound->sample->len) {
+ if (sound->sample && sound->sample->len && sound->sample->channels && sound->sample->bits) {
char *tmp;
if (sound->sample->channels == 1) tmp= "Mono";
else if (sound->sample->channels == 2) tmp= "Stereo";
@@ -1174,18 +1180,18 @@ static void seq_panel_proxy()
130,140,120,19, &last_seq->flag,
0.0, 21.0, 100, 0,
"Use a custom directory to store data");
- }
- if (last_seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) {
- uiDefIconBut(block, BUT, B_SEQ_SEL_PROXY_DIR,
- ICON_FILESEL, 10, 120, 20, 20, 0, 0, 0, 0, 0,
- "Select the directory/name for "
- "the proxy storage");
+ if (last_seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) {
+ uiDefIconBut(block, BUT, B_SEQ_SEL_PROXY_DIR,
+ ICON_FILESEL, 10, 120, 20, 20, 0, 0, 0, 0, 0,
+ "Select the directory/name for "
+ "the proxy storage");
- uiDefBut(block, TEX,
- B_SEQ_BUT_RELOAD, "Dir: ",
- 30,120,220,20, last_seq->strip->proxy->dir,
- 0.0, 160.0, 100, 0, "");
+ uiDefBut(block, TEX,
+ B_SEQ_BUT_RELOAD, "Dir: ",
+ 30,120,220,20, last_seq->strip->proxy->dir,
+ 0.0, 160.0, 100, 0, "");
+ }
}
if (last_seq->flag & SEQ_USE_PROXY) {
diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c
index 10e49cdd218..562d9a4934d 100644
--- a/source/blender/src/transform_conversions.c
+++ b/source/blender/src/transform_conversions.c
@@ -3623,7 +3623,7 @@ void special_aftertrans_update(TransInfo *t)
}
}
}
- else if (t->spacetype == SPACE_ACTION) {
+ if (t->spacetype == SPACE_ACTION) {
void *data;
short datatype;