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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-13 00:16:53 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-13 00:16:53 +0300
commitbdfe7d89e2f1292644577972c716931b4ce3c6c3 (patch)
treed00eb50b749cb001e2b08272c91791e66740b05d /source/blender/radiosity
parent78a1c27c4a6abe0ed31ca93ad21910f3df04da56 (diff)
parent7e4db234cee71ead34ee81a12e27da4bd548eb4b (diff)
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416 Issues: * GHOST/X11 had conflicting changes. Some code was added in 2.5, which was later added in trunk also, but reverted partially, specifically revision 16683. I have left out this reversion in the 2.5 branch since I think it is needed there. http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683 * Scons had various conflicting changes, I decided to go with trunk version for everything except priorities and some library renaming. * In creator.c, there were various fixes and fixes for fixes related to the -w -W and -p options. In 2.5 -w and -W is not coded yet, and -p is done differently. Since this is changed so much, and I don't think those fixes would be needed in 2.5, I've left them out. * Also in creator.c: there was code for a python bugfix where the screen was not initialized when running with -P. The code that initializes the screen there I had to disable, that can't work in 2.5 anymore but left it commented as a reminder. Further I had to disable some new function calls. using src/ and python/, as was done already in this branch, disabled function calls: * bpath.c: error reporting * BME_conversions.c: editmesh conversion functions. * SHD_dynamic: disabled almost completely, there is no python/. * KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled. * text.c: clipboard copy call. * object.c: OB_SUPPORT_MATERIAL. * DerivedMesh.c and subsurf_ccg, stipple_quarttone. Still to be done: * Go over files and functions that were moved to a different location but could still use changes that were done in trunk.
Diffstat (limited to 'source/blender/radiosity')
-rw-r--r--source/blender/radiosity/CMakeLists.txt4
-rw-r--r--source/blender/radiosity/SConscript2
-rw-r--r--source/blender/radiosity/intern/source/Makefile2
-rw-r--r--source/blender/radiosity/intern/source/radfactors.c18
-rw-r--r--source/blender/radiosity/intern/source/radnode.c26
-rw-r--r--source/blender/radiosity/intern/source/radpreprocess.c6
-rw-r--r--source/blender/radiosity/intern/source/radrender.c138
7 files changed, 109 insertions, 87 deletions
diff --git a/source/blender/radiosity/CMakeLists.txt b/source/blender/radiosity/CMakeLists.txt
index 9ffa0e61d6a..e76f7409f99 100644
--- a/source/blender/radiosity/CMakeLists.txt
+++ b/source/blender/radiosity/CMakeLists.txt
@@ -27,9 +27,9 @@
FILE(GLOB SRC intern/source/*.c)
SET(INC
- extern/include ../blenlib ../blenkernel ../makesdna ../include
+ extern/include ../blenlib ../blenkernel ../makesdna ../editors/include
../../../intern/guardedalloc ../render/extern/include
- ../render/intern/include ../editors/include
+ ../render/intern/include ../blenloader ../../../extern/glew/include
)
BLENDERLIB_NOLIST(blender_radiosity "${SRC}" "${INC}")
diff --git a/source/blender/radiosity/SConscript b/source/blender/radiosity/SConscript
index 9939690b664..528b4e29c04 100644
--- a/source/blender/radiosity/SConscript
+++ b/source/blender/radiosity/SConscript
@@ -5,7 +5,7 @@ sources = env.Glob('intern/source/*.c')
incs = 'extern/include ../blenlib ../blenkernel ../makesdna ../editors/include'
incs += ' #/intern/guardedalloc ../render/extern/include'
-incs += ' ../render/intern/include'
+incs += ' ../render/intern/include ../blenloader #/extern/glew/include'
incs += ' ' + env['BF_OPENGL_INC']
diff --git a/source/blender/radiosity/intern/source/Makefile b/source/blender/radiosity/intern/source/Makefile
index bd4ebce742f..44b38de9bae 100644
--- a/source/blender/radiosity/intern/source/Makefile
+++ b/source/blender/radiosity/intern/source/Makefile
@@ -36,6 +36,7 @@ include nan_compile.mk
CFLAGS += $(LEVEL_1_C_WARNINGS)
+CPPFLAGS += -I$(NAN_GLEW)/include
CPPFLAGS += -I$(OPENGL_HEADERS)
# not very neat....
@@ -44,6 +45,7 @@ CPPFLAGS += -I../../../blenlib
CPPFLAGS += -I../../../makesdna
CPPFLAGS += -I../../../imbuf
CPPFLAGS += -I../../../
+CPPFLAGS += -I../../../blenloader
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
# first /include is my own includes, second are the external includes
diff --git a/source/blender/radiosity/intern/source/radfactors.c b/source/blender/radiosity/intern/source/radfactors.c
index 0065d993b15..1a400ff57a8 100644
--- a/source/blender/radiosity/intern/source/radfactors.c
+++ b/source/blender/radiosity/intern/source/radfactors.c
@@ -51,9 +51,9 @@
#include "RE_render_ext.h" /* for `RE_zbufferall_radio and RE_zbufferall_radio */
/* locals */
-void rad_setmatrices(RadView *vw);
-void clearsubflagelem(RNode *rn);
-void setsubflagelem(RNode *rn);
+static void rad_setmatrices(RadView *vw);
+static void clearsubflagelem(RNode *rn);
+static void setsubflagelem(RNode *rn);
RadView hemitop, hemiside;
@@ -252,7 +252,7 @@ void rad_make_hocos(RadView *vw)
/* } */
}
-void rad_setmatrices(RadView *vw) /* for hemi's */
+static void rad_setmatrices(RadView *vw) /* for hemi's */
{
float up1[3], len, twist;
@@ -626,7 +626,7 @@ void minmaxradelemfilt(RNode *rn, float *min, float *max, float *errmin, float *
}
}
-void setsubflagelem(RNode *rn)
+static void setsubflagelem(RNode *rn)
{
if(rn->down1) {
@@ -638,7 +638,7 @@ void setsubflagelem(RNode *rn)
}
}
-void clearsubflagelem(RNode *rn)
+static void clearsubflagelem(RNode *rn)
{
if(rn->down1) {
@@ -739,11 +739,9 @@ void subdivideshootElements(int it)
}
}
if(rn) {
- min[0]= min[1]= min[2]= 1.0e10;
- max[0]= max[1]= max[2]= -1.0e10;
+ INIT_MINMAX(min, max);
/* errmin and max are the filtered colors */
- errmin[0]= errmin[1]= errmin[2]= 1.0e10;
- errmax[0]= errmax[1]= errmax[2]= -1.0e10;
+ INIT_MINMAX(errmin, errmax);
minmaxradelemfilt(rp->first, min, max, errmin, errmax);
/* if small difference between colors: no subdiv */
diff --git a/source/blender/radiosity/intern/source/radnode.c b/source/blender/radiosity/intern/source/radnode.c
index ca37d021639..fa23ca5da57 100644
--- a/source/blender/radiosity/intern/source/radnode.c
+++ b/source/blender/radiosity/intern/source/radnode.c
@@ -48,15 +48,17 @@
#include "radio.h"
+#include "BLO_sys_types.h" // for intptr_t support
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* locals */
-void *malloc_fast(int size);
-void *calloc_fast(int size);
-void free_fast(void *poin, int siz);
-void deleteTriNodes(RNode *node);
+static void *malloc_fast(int size);
+static void *calloc_fast(int size);
+static void free_fast(void *poin, int siz);
+static void deleteTriNodes(RNode *node);
/* lower because of local type define */
/* void check_mallocgroup(MallocGroup *mg); */
@@ -118,7 +120,7 @@ void check_mallocgroup(MallocGroup *mg)
printf("fastmalloc: shouldnt be here\n");
}
-void *malloc_fast(int size)
+static void *malloc_fast(int size)
{
MallocGroup *mg;
void *retval;
@@ -152,7 +154,7 @@ void *malloc_fast(int size)
return mg->data;
}
-void *calloc_fast(int size)
+static void *calloc_fast(int size)
{
void *poin;
@@ -162,17 +164,17 @@ void *calloc_fast(int size)
return poin;
}
-void free_fast(void *poin, int size)
+static void free_fast(void *poin, int size)
{
MallocGroup *mg;
- long val;
+ intptr_t val;
mg= MallocBase.last;
while(mg) {
if(mg->size==size) {
- if( ((long)poin) >= ((long)mg->data) ) {
- if( ((long)poin) < ((long)(mg->data+MAL_GROUPSIZE*size)) ) {
- val= ((long)poin) - ((long)mg->data);
+ if( ((intptr_t)poin) >= ((intptr_t)mg->data) ) {
+ if( ((intptr_t)poin) < ((intptr_t)(mg->data+MAL_GROUPSIZE*size)) ) {
+ val= ((intptr_t)poin) - ((intptr_t)mg->data);
val/= size;
mg->curfree= val;
mg->flags[val]= 0;
@@ -954,7 +956,7 @@ int comparelevel(RNode *node, RNode *nb, int level)
return 1;
}
-void deleteTriNodes(RNode *node) /* both children of node */
+static void deleteTriNodes(RNode *node) /* both children of node */
{
RNode *n1, *n2;
diff --git a/source/blender/radiosity/intern/source/radpreprocess.c b/source/blender/radiosity/intern/source/radpreprocess.c
index 345a5911ac8..eec75942da0 100644
--- a/source/blender/radiosity/intern/source/radpreprocess.c
+++ b/source/blender/radiosity/intern/source/radpreprocess.c
@@ -64,6 +64,8 @@
#include "radio.h"
+#include "BLO_sys_types.h" // for intptr_t support
+
void setparelem(RNode *rn, RPatch *par);
void splitconnected()
@@ -171,7 +173,7 @@ int vergedge(const void *v1,const void *v2)
void addedge(float *v1, float *v2, EdSort *es)
{
- if( ((long)v1)<((long)v2) ) {
+ if( ((intptr_t)v1)<((intptr_t)v2) ) {
es->v1= v1;
es->v2= v2;
}
@@ -279,7 +281,7 @@ void setedgepointers()
MEM_freeN(esblock);
}
-int materialIndex(Material *ma)
+static int materialIndex(Material *ma)
{
int i = 0;
for(i=0;i< RG.totmat; i++)
diff --git a/source/blender/radiosity/intern/source/radrender.c b/source/blender/radiosity/intern/source/radrender.c
index 9a97690de54..0233ffbcf9f 100644
--- a/source/blender/radiosity/intern/source/radrender.c
+++ b/source/blender/radiosity/intern/source/radrender.c
@@ -76,22 +76,23 @@ static float maxenergy;
/* find the face with maximum energy to become shooter */
/* nb: _rr means rad-render version of existing radio call */
-static VlakRen *findshoot_rr(Render *re)
+static void findshoot_rr(Render *re, VlakRen **shoot_p, RadFace **shootrf_p)
{
- RadFace *rf;
+ RadFace *rf, *shootrf, **radface;
ObjectRen *obr;
VlakRen *vlr=NULL, *shoot;
float energy;
int a;
shoot= NULL;
+ shootrf= NULL;
maxenergy= 0.0;
for(obr=re->objecttable.first; obr; obr=obr->next) {
for(a=0; a<obr->totvlak; a++) {
if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
- if(vlr->radface) {
- rf= vlr->radface;
+ if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
+ rf= *radface;
rf->flag &= ~RAD_SHOOT;
energy= rf->unshot[0]*rf->area;
@@ -100,26 +101,32 @@ static VlakRen *findshoot_rr(Render *re)
if(energy>maxenergy) {
shoot= vlr;
+ shootrf= rf;
maxenergy= energy;
}
}
}
}
- if(shoot) {
+ if(shootrf) {
maxenergy/= RG.totenergy;
- if(maxenergy<RG.convergence) return NULL;
- shoot->radface->flag |= RAD_SHOOT;
+ if(maxenergy<RG.convergence) {
+ *shoot_p= NULL;
+ *shootrf_p= NULL;
+ return;
+ }
+ shootrf->flag |= RAD_SHOOT;
}
- return shoot;
+ *shoot_p= shoot;
+ *shootrf_p= shootrf;
}
-static void backface_test_rr(Render *re, VlakRen *shoot)
+static void backface_test_rr(Render *re, VlakRen *shoot, RadFace *shootrf)
{
ObjectRen *obr;
VlakRen *vlr=NULL;
- RadFace *rf;
+ RadFace *rf, **radface;
float tvec[3];
int a;
@@ -127,9 +134,9 @@ static void backface_test_rr(Render *re, VlakRen *shoot)
for(obr=re->objecttable.first; obr; obr=obr->next) {
for(a=0; a<obr->totvlak; a++) {
if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
- if(vlr->radface && vlr!=shoot) {
- rf= vlr->radface;
- VecSubf(tvec, shoot->radface->cent, rf->cent);
+ if(vlr != shoot && (radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
+ rf= *radface;
+ VecSubf(tvec, shootrf->cent, rf->cent);
if(tvec[0]*rf->norm[0]+ tvec[1]*rf->norm[1]+ tvec[2]*rf->norm[2] < 0.0)
rf->flag |= RAD_BACKFACE;
@@ -142,7 +149,7 @@ static void clear_backface_test_rr(Render *re)
{
ObjectRen *obr;
VlakRen *vlr=NULL;
- RadFace *rf;
+ RadFace *rf, **radface;
int a;
/* backface flag clear */
@@ -150,8 +157,8 @@ static void clear_backface_test_rr(Render *re)
for(a=0; a<obr->totvlak; a++) {
if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
- if(vlr->radface) {
- rf= vlr->radface;
+ if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
+ rf= *radface;
rf->flag &= ~RAD_BACKFACE;
}
}
@@ -161,11 +168,11 @@ static void clear_backface_test_rr(Render *re)
extern RadView hemitop, hemiside; // radfactors.c
/* hemi-zbuffering, delivers formfactors array */
-static void makeformfactors_rr(Render *re, VlakRen *shoot)
+static void makeformfactors_rr(Render *re, VlakRen *shoot, RadFace *shootrf)
{
ObjectRen *obr;
VlakRen *vlr=NULL;
- RadFace *rf;
+ RadFace *rf, **radface;
float len, vec[3], up[3], side[3], tar[5][3], *fp;
int a;
@@ -174,25 +181,25 @@ static void makeformfactors_rr(Render *re, VlakRen *shoot)
/* set up hemiview */
/* first: upvector for hemitop, we use diagonal hemicubes to prevent aliasing */
- VecSubf(vec, shoot->v1->co, shoot->radface->cent);
- Crossf(up, shoot->radface->norm, vec);
+ VecSubf(vec, shoot->v1->co, shootrf->cent);
+ Crossf(up, shootrf->norm, vec);
len= Normalize(up);
VECCOPY(hemitop.up, up);
- VECCOPY(hemiside.up, shoot->radface->norm);
+ VECCOPY(hemiside.up, shootrf->norm);
- Crossf(side, shoot->radface->norm, up);
+ Crossf(side, shootrf->norm, up);
/* five targets */
- VecAddf(tar[0], shoot->radface->cent, shoot->radface->norm);
- VecAddf(tar[1], shoot->radface->cent, up);
- VecSubf(tar[2], shoot->radface->cent, up);
- VecAddf(tar[3], shoot->radface->cent, side);
- VecSubf(tar[4], shoot->radface->cent, side);
+ VecAddf(tar[0], shootrf->cent, shootrf->norm);
+ VecAddf(tar[1], shootrf->cent, up);
+ VecSubf(tar[2], shootrf->cent, up);
+ VecAddf(tar[3], shootrf->cent, side);
+ VecSubf(tar[4], shootrf->cent, side);
/* camera */
- VECCOPY(hemiside.cam, shoot->radface->cent);
- VECCOPY(hemitop.cam, shoot->radface->cent);
+ VECCOPY(hemiside.cam, shootrf->cent);
+ VECCOPY(hemitop.cam, shootrf->cent);
/* do it! */
VECCOPY(hemitop.tar, tar[0]);
@@ -210,10 +217,10 @@ static void makeformfactors_rr(Render *re, VlakRen *shoot)
for(a=0; a<obr->totvlak; a++) {
if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
- if(vlr->radface) {
- rf= vlr->radface;
+ if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
+ rf= *radface;
if(*fp!=0.0 && rf->area!=0.0) {
- *fp *= shoot->radface->area/rf->area;
+ *fp *= shootrf->area/rf->area;
if(*fp>1.0) *fp= 1.0001;
}
fp++;
@@ -223,17 +230,17 @@ static void makeformfactors_rr(Render *re, VlakRen *shoot)
}
/* based at RG.formfactors array, distribute shoot energy over other faces */
-static void applyformfactors_rr(Render *re, VlakRen *shoot)
+static void applyformfactors_rr(Render *re, VlakRen *shoot, RadFace *shootrf)
{
ObjectRen *obr;
VlakRen *vlr=NULL;
- RadFace *rf;
+ RadFace *rf, **radface;
float *fp, *ref, unr, ung, unb, r, g, b;
int a;
- unr= shoot->radface->unshot[0];
- ung= shoot->radface->unshot[1];
- unb= shoot->radface->unshot[2];
+ unr= shootrf->unshot[0];
+ ung= shootrf->unshot[1];
+ unb= shootrf->unshot[2];
fp= RG.formfactors;
@@ -241,8 +248,8 @@ static void applyformfactors_rr(Render *re, VlakRen *shoot)
for(a=0; a<obr->totvlak; a++) {
if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
- if(vlr->radface) {
- rf= vlr->radface;
+ if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
+ rf= *radface;
if(*fp!= 0.0) {
ref= &(vlr->mat->r);
@@ -266,7 +273,7 @@ static void applyformfactors_rr(Render *re, VlakRen *shoot)
}
}
/* shoot energy has been shot */
- shoot->radface->unshot[0]= shoot->radface->unshot[1]= shoot->radface->unshot[2]= 0.0;
+ shootrf->unshot[0]= shootrf->unshot[1]= shootrf->unshot[2]= 0.0;
}
@@ -274,29 +281,30 @@ static void applyformfactors_rr(Render *re, VlakRen *shoot)
static void progressiverad_rr(Render *re)
{
VlakRen *shoot;
+ RadFace *shootrf;
float unshot[3];
int it= 0;
- shoot= findshoot_rr(re);
+ findshoot_rr(re, &shoot, &shootrf);
while( shoot ) {
/* backfaces receive no energy, but are zbuffered... */
- backface_test_rr(re, shoot);
+ backface_test_rr(re, shoot, shootrf);
/* ...unless it's two sided */
- if(shoot->radface->flag & RAD_TWOSIDED) {
- VECCOPY(unshot, shoot->radface->unshot);
- VecMulf(shoot->radface->norm, -1.0);
- makeformfactors_rr(re, shoot);
- applyformfactors_rr(re, shoot);
- VecMulf(shoot->radface->norm, -1.0);
- VECCOPY(shoot->radface->unshot, unshot);
+ if(shootrf->flag & RAD_TWOSIDED) {
+ VECCOPY(unshot, shootrf->unshot);
+ VecMulf(shootrf->norm, -1.0);
+ makeformfactors_rr(re, shoot, shootrf);
+ applyformfactors_rr(re, shoot, shootrf);
+ VecMulf(shootrf->norm, -1.0);
+ VECCOPY(shootrf->unshot, unshot);
}
/* hemi-zbuffers */
- makeformfactors_rr(re, shoot);
+ makeformfactors_rr(re, shoot, shootrf);
/* based at RG.formfactors array, distribute shoot energy over other faces */
- applyformfactors_rr(re, shoot);
+ applyformfactors_rr(re, shoot, shootrf);
it++;
re->timecursor(it);
@@ -306,7 +314,7 @@ static void progressiverad_rr(Render *re)
if(re->test_break()) break;
if(RG.maxiter && RG.maxiter<=it) break;
- shoot= findshoot_rr(re);
+ findshoot_rr(re, &shoot, &shootrf);
}
printf(" Unshot energy:%f\n", 1000.0*maxenergy);
@@ -319,7 +327,7 @@ static void initradfaces(Render *re)
{
ObjectRen *obr;
VlakRen *vlr= NULL;
- RadFace *rf;
+ RadFace *rf, **radface;
int a, b;
/* globals */
@@ -356,9 +364,18 @@ printf(" Rad elems: %d emittors %d\n", RG.totelem, RG.totpatch);
if(vlr->mat->mode & MA_RADIO) {
/* during render, vlr->n gets flipped/corrected, we cannot have that */
- if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co, rf->norm);
- else CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, rf->norm);
-
+ if (obr->ob->transflag & OB_NEG_SCALE){
+ /* The object has negative scale that will cause the normals to flip.
+ To counter this unwanted normal flip, swap vertex 2 and 4 for a quad
+ or vertex 2 and 3 (see flip_face) for a triangle in the call to CalcNormFloat4
+ in order to flip the normals back to the way they were in the original mesh. */
+ if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v4->co, vlr->v3->co, vlr->v2->co, rf->norm);
+ else CalcNormFloat(vlr->v1->co, vlr->v3->co, vlr->v2->co, rf->norm);
+ }else{
+ if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co, rf->norm);
+ else CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, rf->norm);
+ }
+
rf->totrad[0]= vlr->mat->emit*vlr->mat->r;
rf->totrad[1]= vlr->mat->emit*vlr->mat->g;
rf->totrad[2]= vlr->mat->emit*vlr->mat->b;
@@ -385,7 +402,8 @@ printf(" Rad elems: %d emittors %d\n", RG.totelem, RG.totpatch);
// uncommented; this isnt satisfying, but i leave it in the code for now (ton)
// if(vlr->mat->translucency!=0.0) rf->flag |= RAD_TWOSIDED;
- vlr->radface= rf++;
+ radface=RE_vlakren_get_radface(obr, vlr, 1);
+ *radface= rf++;
}
}
}
@@ -420,7 +438,7 @@ static void make_vertex_rad_values(Render *re)
ObjectRen *obr;
VertRen *v1=NULL;
VlakRen *vlr=NULL;
- RadFace *rf;
+ RadFace *rf, **radface;
float *col;
int a;
@@ -432,8 +450,8 @@ static void make_vertex_rad_values(Render *re)
for(a=0; a<obr->totvlak; a++) {
if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; else vlr++;
- if(vlr->radface) {
- rf= vlr->radface;
+ if((radface=RE_vlakren_get_radface(obr, vlr, 0)) && *radface) {
+ rf= *radface;
/* apply correction */
rf->totrad[0]= RG.radfactor*pow( rf->totrad[0], RG.igamma);