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:
Diffstat (limited to 'source/blender/render/intern/raytrace/rayobject_octree.cpp')
-rw-r--r--source/blender/render/intern/raytrace/rayobject_octree.cpp284
1 files changed, 142 insertions, 142 deletions
diff --git a/source/blender/render/intern/raytrace/rayobject_octree.cpp b/source/blender/render/intern/raytrace/rayobject_octree.cpp
index 0411173f07f..197b3f14c7a 100644
--- a/source/blender/render/intern/raytrace/rayobject_octree.cpp
+++ b/source/blender/render/intern/raytrace/rayobject_octree.cpp
@@ -133,7 +133,7 @@ static void calc_ocval_face(float *v1, float *v2, float *v3, float *v4, short x,
copy_v3_v3(max, v1);
DO_MINMAX(v2, min, max);
DO_MINMAX(v3, min, max);
- if(v4) {
+ if (v4) {
DO_MINMAX(v4, min, max);
}
@@ -155,7 +155,7 @@ static void calc_ocval_ray(OcVal *ov, float xo, float yo, float zo, float *vec1,
{
int ocmin, ocmax;
- if(vec1[0]<vec2[0]) {
+ if (vec1[0]<vec2[0]) {
ocmin= OCVALRES*(vec1[0] - xo);
ocmax= OCVALRES*(vec2[0] - xo);
}
@@ -165,7 +165,7 @@ static void calc_ocval_ray(OcVal *ov, float xo, float yo, float zo, float *vec1,
}
ov->ocx= BROW16(ocmin, ocmax);
- if(vec1[1]<vec2[1]) {
+ if (vec1[1]<vec2[1]) {
ocmin= OCVALRES*(vec1[1] - yo);
ocmax= OCVALRES*(vec2[1] - yo);
}
@@ -175,7 +175,7 @@ static void calc_ocval_ray(OcVal *ov, float xo, float yo, float zo, float *vec1,
}
ov->ocy= BROW16(ocmin, ocmax);
- if(vec1[2]<vec2[2]) {
+ if (vec1[2]<vec2[2]) {
ocmin= OCVALRES*(vec1[2] - zo);
ocmax= OCVALRES*(vec2[2] - zo);
}
@@ -192,15 +192,15 @@ static Branch *addbranch(Octree *oc, Branch *br, short ocb)
{
int index;
- if(br->b[ocb]) return br->b[ocb];
+ if (br->b[ocb]) return br->b[ocb];
oc->branchcount++;
index= oc->branchcount>>12;
- if(oc->adrbranch[index]==NULL)
+ if (oc->adrbranch[index]==NULL)
oc->adrbranch[index]= (Branch*)MEM_callocN(4096*sizeof(Branch), "new oc branch");
- if(oc->branchcount>= BRANCH_ARRAY*4096) {
+ if (oc->branchcount>= BRANCH_ARRAY*4096) {
printf("error; octree branches full\n");
oc->branchcount=0;
}
@@ -215,10 +215,10 @@ static Node *addnode(Octree *oc)
oc->nodecount++;
index= oc->nodecount>>12;
- if(oc->adrnode[index]==NULL)
+ if (oc->adrnode[index]==NULL)
oc->adrnode[index]= (Node*)MEM_callocN(4096*sizeof(Node),"addnode");
- if(oc->nodecount> NODE_ARRAY*NODE_ARRAY) {
+ if (oc->nodecount> NODE_ARRAY*NODE_ARRAY) {
printf("error; octree nodes full\n");
oc->nodecount=0;
}
@@ -232,7 +232,7 @@ static int face_in_node(RayFace *face, short x, short y, short z, float rtf[][3]
float fx, fy, fz;
// init static vars
- if(face) {
+ if (face) {
normal_tri_v3( nor,rtf[0], rtf[1], rtf[2]);
d= -nor[0]*rtf[0][0] - nor[1]*rtf[0][1] - nor[2]*rtf[0][2];
return 0;
@@ -242,25 +242,25 @@ static int face_in_node(RayFace *face, short x, short y, short z, float rtf[][3]
fy= y;
fz= z;
- if((fx)*nor[0] + (fy)*nor[1] + (fz)*nor[2] + d > 0.0f) {
- if((fx+1)*nor[0] + (fy )*nor[1] + (fz )*nor[2] + d < 0.0f) return 1;
- if((fx )*nor[0] + (fy+1)*nor[1] + (fz )*nor[2] + d < 0.0f) return 1;
- if((fx+1)*nor[0] + (fy+1)*nor[1] + (fz )*nor[2] + d < 0.0f) return 1;
+ if ((fx)*nor[0] + (fy)*nor[1] + (fz)*nor[2] + d > 0.0f) {
+ if ((fx+1)*nor[0] + (fy )*nor[1] + (fz )*nor[2] + d < 0.0f) return 1;
+ if ((fx )*nor[0] + (fy+1)*nor[1] + (fz )*nor[2] + d < 0.0f) return 1;
+ if ((fx+1)*nor[0] + (fy+1)*nor[1] + (fz )*nor[2] + d < 0.0f) return 1;
- if((fx )*nor[0] + (fy )*nor[1] + (fz+1)*nor[2] + d < 0.0f) return 1;
- if((fx+1)*nor[0] + (fy )*nor[1] + (fz+1)*nor[2] + d < 0.0f) return 1;
- if((fx )*nor[0] + (fy+1)*nor[1] + (fz+1)*nor[2] + d < 0.0f) return 1;
- if((fx+1)*nor[0] + (fy+1)*nor[1] + (fz+1)*nor[2] + d < 0.0f) return 1;
+ if ((fx )*nor[0] + (fy )*nor[1] + (fz+1)*nor[2] + d < 0.0f) return 1;
+ if ((fx+1)*nor[0] + (fy )*nor[1] + (fz+1)*nor[2] + d < 0.0f) return 1;
+ if ((fx )*nor[0] + (fy+1)*nor[1] + (fz+1)*nor[2] + d < 0.0f) return 1;
+ if ((fx+1)*nor[0] + (fy+1)*nor[1] + (fz+1)*nor[2] + d < 0.0f) return 1;
}
else {
- if((fx+1)*nor[0] + (fy )*nor[1] + (fz )*nor[2] + d > 0.0f) return 1;
- if((fx )*nor[0] + (fy+1)*nor[1] + (fz )*nor[2] + d > 0.0f) return 1;
- if((fx+1)*nor[0] + (fy+1)*nor[1] + (fz )*nor[2] + d > 0.0f) return 1;
+ if ((fx+1)*nor[0] + (fy )*nor[1] + (fz )*nor[2] + d > 0.0f) return 1;
+ if ((fx )*nor[0] + (fy+1)*nor[1] + (fz )*nor[2] + d > 0.0f) return 1;
+ if ((fx+1)*nor[0] + (fy+1)*nor[1] + (fz )*nor[2] + d > 0.0f) return 1;
- if((fx )*nor[0] + (fy )*nor[1] + (fz+1)*nor[2] + d > 0.0f) return 1;
- if((fx+1)*nor[0] + (fy )*nor[1] + (fz+1)*nor[2] + d > 0.0f) return 1;
- if((fx )*nor[0] + (fy+1)*nor[1] + (fz+1)*nor[2] + d > 0.0f) return 1;
- if((fx+1)*nor[0] + (fy+1)*nor[1] + (fz+1)*nor[2] + d > 0.0f) return 1;
+ if ((fx )*nor[0] + (fy )*nor[1] + (fz+1)*nor[2] + d > 0.0f) return 1;
+ if ((fx+1)*nor[0] + (fy )*nor[1] + (fz+1)*nor[2] + d > 0.0f) return 1;
+ if ((fx )*nor[0] + (fy+1)*nor[1] + (fz+1)*nor[2] + d > 0.0f) return 1;
+ if ((fx+1)*nor[0] + (fy+1)*nor[1] + (fz+1)*nor[2] + d > 0.0f) return 1;
}
return 0;
@@ -277,15 +277,15 @@ static void ocwrite(Octree *oc, RayFace *face, int quad, short x, short y, short
br= oc->adrbranch[0];
- if(oc->ocres==512) {
+ if (oc->ocres==512) {
oc0= ((x & 1024)+(y & 512)+(z & 256))>>8;
br= addbranch(oc, br, oc0);
}
- if(oc->ocres>=256) {
+ if (oc->ocres>=256) {
oc0= ((x & 512)+(y & 256)+(z & 128))>>7;
br= addbranch(oc, br, oc0);
}
- if(oc->ocres>=128) {
+ if (oc->ocres>=128) {
oc0= ((x & 256)+(y & 128)+(z & 64))>>6;
br= addbranch(oc, br, oc0);
}
@@ -303,12 +303,12 @@ static void ocwrite(Octree *oc, RayFace *face, int quad, short x, short y, short
br= addbranch(oc, br,oc3);
br= addbranch(oc, br,oc4);
no= (Node *)br->b[oc5];
- if(no==NULL) br->b[oc5]= (Branch *)(no= addnode(oc));
+ if (no==NULL) br->b[oc5]= (Branch *)(no= addnode(oc));
while(no->next) no= no->next;
a= 0;
- if(no->v[7]) { /* node full */
+ if (no->v[7]) { /* node full */
no->next= addnode(oc);
no= no->next;
}
@@ -318,7 +318,7 @@ static void ocwrite(Octree *oc, RayFace *face, int quad, short x, short y, short
no->v[a]= (RayFace*) RE_rayobject_align(face);
- if(quad)
+ if (quad)
calc_ocval_face(rtf[0], rtf[1], rtf[2], rtf[3], x>>2, y>>1, z, &no->ov[a]);
else
calc_ocval_face(rtf[0], rtf[1], rtf[2], NULL, x>>2, y>>1, z, &no->ov[a]);
@@ -336,7 +336,7 @@ static void d2dda(Octree *oc, short b1, short b2, short c1, short c2, char *ocfa
ocx2= rts[b2][c1];
ocy2= rts[b2][c2];
- if(ocx1==ocx2 && ocy1==ocy2) {
+ if (ocx1==ocx2 && ocy1==ocy2) {
ocface[oc->ocres*ocx1+ocy1]= 1;
return;
}
@@ -346,8 +346,8 @@ static void d2dda(Octree *oc, short b1, short b2, short c1, short c2, char *ocfa
ox2= rtf[b2][c1];
oy2= rtf[b2][c2];
- if(ox1!=ox2) {
- if(ox2-ox1>0.0f) {
+ if (ox1!=ox2) {
+ if (ox2-ox1>0.0f) {
labdax= (ox1-ocx1-1.0f)/(ox1-ox2);
ldx= -1.0f/(ox1-ox2);
dx= 1;
@@ -363,8 +363,8 @@ static void d2dda(Octree *oc, short b1, short b2, short c1, short c2, char *ocfa
ldx=0;
}
- if(oy1!=oy2) {
- if(oy2-oy1>0.0f) {
+ if (oy1!=oy2) {
+ if (oy2-oy1>0.0f) {
labday= (oy1-ocy1-1.0f)/(oy1-oy2);
ldy= -1.0f/(oy1-oy2);
dy= 1;
@@ -385,18 +385,18 @@ static void d2dda(Octree *oc, short b1, short b2, short c1, short c2, char *ocfa
while(TRUE) {
- if(x<0 || y<0 || x>=oc->ocres || y>=oc->ocres);
+ if (x<0 || y<0 || x>=oc->ocres || y>=oc->ocres);
else ocface[oc->ocres*x+y]= 1;
labdao=labda;
- if(labdax==labday) {
+ if (labdax==labday) {
labdax+=ldx;
x+=dx;
labday+=ldy;
y+=dy;
}
else {
- if(labdax<labday) {
+ if (labdax<labday) {
labdax+=ldx;
x+=dx;
}
@@ -406,8 +406,8 @@ static void d2dda(Octree *oc, short b1, short b2, short c1, short c2, char *ocfa
}
}
labda=MIN2(labdax,labday);
- if(labda==labdao) break;
- if(labda>=1.0f) break;
+ if (labda==labdao) break;
+ if (labda>=1.0f) break;
}
ocface[oc->ocres*ocx2+ocy2]=1;
}
@@ -416,15 +416,15 @@ static void filltriangle(Octree *oc, short c1, short c2, char *ocface, short *oc
{
int a, x, y, y1, y2;
- for(x=ocmin[c1];x<=ocmax[c1];x++) {
+ for (x=ocmin[c1];x<=ocmax[c1];x++) {
a= oc->ocres*x;
- for(y=ocmin[c2];y<=ocmax[c2];y++) {
- if(ocface[a+y]) {
+ for (y=ocmin[c2];y<=ocmax[c2];y++) {
+ if (ocface[a+y]) {
y++;
while(ocface[a+y] && y!=ocmax[c2]) y++;
- for(y1=ocmax[c2];y1>y;y1--) {
- if(ocface[a+y1]) {
- for(y2=y;y2<=y1;y2++) ocface[a+y2]=1;
+ for (y1=ocmax[c2];y1>y;y1--) {
+ if (ocface[a+y1]) {
+ for (y2=y;y2<=y1;y2++) ocface[a+y2]=1;
y1=0;
}
}
@@ -444,10 +444,10 @@ static void RE_rayobject_octree_free(RayObject *tree)
printf("ray coherent %d \n", coherent_ray);
printf("accepted %d rejected %d\n", accepted, rejected);
#endif
- if(oc->ocface)
+ if (oc->ocface)
MEM_freeN(oc->ocface);
- if(oc->adrbranch) {
+ if (oc->adrbranch) {
int a= 0;
while(oc->adrbranch[a]) {
MEM_freeN(oc->adrbranch[a]);
@@ -459,7 +459,7 @@ static void RE_rayobject_octree_free(RayObject *tree)
}
oc->branchcount= 0;
- if(oc->adrnode) {
+ if (oc->adrnode) {
int a= 0;
while(oc->adrnode[a]) {
MEM_freeN(oc->adrnode[a]);
@@ -520,27 +520,27 @@ static void octree_fill_rayface(Octree *oc, RayFace *face)
copy_v3_v3(co1, face->v1);
copy_v3_v3(co2, face->v2);
copy_v3_v3(co3, face->v3);
- if(face->v4)
+ if (face->v4)
copy_v3_v3(co4, face->v4);
- for(c=0;c<3;c++) {
+ for (c=0;c<3;c++) {
rtf[0][c] = (co1[c] - oc->min[c]) * ocfac[c];
rts[0][c] = (short)rtf[0][c];
rtf[1][c] = (co2[c] - oc->min[c]) * ocfac[c];
rts[1][c] = (short)rtf[1][c];
rtf[2][c] = (co3[c] - oc->min[c]) * ocfac[c];
rts[2][c] = (short)rtf[2][c];
- if(RE_rayface_isQuad(face)) {
+ if (RE_rayface_isQuad(face)) {
rtf[3][c] = (co4[c] - oc->min[c]) * ocfac[c];
rts[3][c] = (short)rtf[3][c];
}
}
- for(c=0;c<3;c++) {
+ for (c=0;c<3;c++) {
oc1= rts[0][c];
oc2= rts[1][c];
oc3= rts[2][c];
- if(!RE_rayface_isQuad(face)) {
+ if (!RE_rayface_isQuad(face)) {
ocmin[c]= MIN3(oc1,oc2,oc3);
ocmax[c]= MAX3(oc1,oc2,oc3);
}
@@ -549,11 +549,11 @@ static void octree_fill_rayface(Octree *oc, RayFace *face)
ocmin[c]= MIN4(oc1,oc2,oc3,oc4);
ocmax[c]= MAX4(oc1,oc2,oc3,oc4);
}
- if(ocmax[c]>oc->ocres-1) ocmax[c]=oc->ocres-1;
- if(ocmin[c]<0) ocmin[c]=0;
+ if (ocmax[c]>oc->ocres-1) ocmax[c]=oc->ocres-1;
+ if (ocmin[c]<0) ocmin[c]=0;
}
- if(ocmin[0]==ocmax[0] && ocmin[1]==ocmax[1] && ocmin[2]==ocmax[2]) {
+ if (ocmin[0]==ocmax[0] && ocmin[1]==ocmax[1] && ocmin[2]==ocmax[2]) {
ocwrite(oc, face, RE_rayface_isQuad(face), ocmin[0], ocmin[1], ocmin[2], rtf);
}
else {
@@ -564,7 +564,7 @@ static void octree_fill_rayface(Octree *oc, RayFace *face)
d2dda(oc, 1,2,0,1,ocface+ocres2,rts,rtf);
d2dda(oc, 1,2,0,2,ocface,rts,rtf);
d2dda(oc, 1,2,1,2,ocface+2*ocres2,rts,rtf);
- if(!RE_rayface_isQuad(face)) {
+ if (!RE_rayface_isQuad(face)) {
d2dda(oc, 2,0,0,1,ocface+ocres2,rts,rtf);
d2dda(oc, 2,0,0,2,ocface,rts,rtf);
d2dda(oc, 2,0,1,2,ocface+2*ocres2,rts,rtf);
@@ -585,14 +585,14 @@ static void octree_fill_rayface(Octree *oc, RayFace *face)
/* init static vars here */
face_in_node(face, 0,0,0, rtf);
- for(x=ocmin[0];x<=ocmax[0];x++) {
+ for (x=ocmin[0];x<=ocmax[0];x++) {
a= oc->ocres*x;
- for(y=ocmin[1];y<=ocmax[1];y++) {
- if(ocface[a+y+ocres2]) {
+ for (y=ocmin[1];y<=ocmax[1];y++) {
+ if (ocface[a+y+ocres2]) {
b= oc->ocres*y+2*ocres2;
- for(z=ocmin[2];z<=ocmax[2];z++) {
- if(ocface[b+z] && ocface[a+z]) {
- if(face_in_node(NULL, x, y, z, rtf))
+ for (z=ocmin[2];z<=ocmax[2];z++) {
+ if (ocface[b+z] && ocface[a+z]) {
+ if (face_in_node(NULL, x, y, z, rtf))
ocwrite(oc, face, RE_rayface_isQuad(face), x,y,z, rtf);
}
}
@@ -601,14 +601,14 @@ static void octree_fill_rayface(Octree *oc, RayFace *face)
}
/* same loops to clear octree, doubt it can be done smarter */
- for(x=ocmin[0];x<=ocmax[0];x++) {
+ for (x=ocmin[0];x<=ocmax[0];x++) {
a= oc->ocres*x;
- for(y=ocmin[1];y<=ocmax[1];y++) {
+ for (y=ocmin[1];y<=ocmax[1];y++) {
/* x-y */
ocface[a+y+ocres2]= 0;
b= oc->ocres*y + 2*ocres2;
- for(z=ocmin[2];z<=ocmax[2];z++) {
+ for (z=ocmin[2];z<=ocmax[2];z++) {
/* y-z */
ocface[b+z]= 0;
/* x-z */
@@ -629,7 +629,7 @@ static void RE_rayobject_octree_done(RayObject *tree)
INIT_MINMAX(oc->min, oc->max);
/* Calculate Bounding Box */
- for(c=0; c<oc->ro_nodes_used; c++)
+ for (c=0; c<oc->ro_nodes_used; c++)
RE_rayobject_merge_bb( RE_rayobject_unalignRayFace(oc->ro_nodes[c]), oc->min, oc->max);
/* Alloc memory */
@@ -642,7 +642,7 @@ static void RE_rayobject_octree_done(RayObject *tree)
oc->ocface= (char*)MEM_callocN( 3*ocres2 + 8, "ocface");
memset(oc->ocface, 0, 3*ocres2);
- for(c=0;c<3;c++) { /* octree enlarge, still needed? */
+ for (c=0;c<3;c++) { /* octree enlarge, still needed? */
oc->min[c]-= 0.01f;
oc->max[c]+= 0.01f;
}
@@ -658,7 +658,7 @@ static void RE_rayobject_octree_done(RayObject *tree)
oc->ocsize= sqrt(t00*t00+t01*t01+t02*t02); /* global, max size octree */
- for(c=0; c<oc->ro_nodes_used; c++)
+ for (c=0; c<oc->ro_nodes_used; c++)
{
octree_fill_rayface(oc, oc->ro_nodes[c]);
}
@@ -686,19 +686,19 @@ static int testnode(Octree *UNUSED(oc), Isect *is, Node *no, OcVal ocval)
short nr=0;
/* return on any first hit */
- if(is->mode==RE_RAY_SHADOW) {
+ if (is->mode==RE_RAY_SHADOW) {
- for(; no; no = no->next)
- for(nr=0; nr<8; nr++)
+ for (; no; no = no->next)
+ for (nr=0; nr<8; nr++)
{
RayFace *face = no->v[nr];
OcVal *ov = no->ov+nr;
- if(!face) break;
+ if (!face) break;
- if( (ov->ocx & ocval.ocx) && (ov->ocy & ocval.ocy) && (ov->ocz & ocval.ocz) )
+ if ( (ov->ocx & ocval.ocx) && (ov->ocy & ocval.ocy) && (ov->ocz & ocval.ocz) )
{
- if( RE_rayobject_intersect( RE_rayobject_unalignRayFace(face),is) )
+ if ( RE_rayobject_intersect( RE_rayobject_unalignRayFace(face),is) )
return 1;
}
}
@@ -707,17 +707,17 @@ static int testnode(Octree *UNUSED(oc), Isect *is, Node *no, OcVal ocval)
{ /* else mirror or glass or shadowtra, return closest face */
int found= 0;
- for(; no; no = no->next)
- for(nr=0; nr<8; nr++)
+ for (; no; no = no->next)
+ for (nr=0; nr<8; nr++)
{
RayFace *face = no->v[nr];
OcVal *ov = no->ov+nr;
- if(!face) break;
+ if (!face) break;
- if( (ov->ocx & ocval.ocx) && (ov->ocy & ocval.ocy) && (ov->ocz & ocval.ocz) )
+ if ( (ov->ocx & ocval.ocx) && (ov->ocy & ocval.ocy) && (ov->ocz & ocval.ocz) )
{
- if( RE_rayobject_intersect( RE_rayobject_unalignRayFace(face),is) )
+ if ( RE_rayobject_intersect( RE_rayobject_unalignRayFace(face),is) )
found= 1;
}
}
@@ -739,43 +739,43 @@ static Node *ocread(Octree *oc, int x, int y, int z)
br= oc->adrbranch[0];
- if(oc->ocres==512) {
+ if (oc->ocres==512) {
oc1= ((x & 1024)+(y & 512)+(z & 256))>>8;
br= br->b[oc1];
- if(br==NULL) {
+ if (br==NULL) {
return NULL;
}
}
- if(oc->ocres>=256) {
+ if (oc->ocres>=256) {
oc1= ((x & 512)+(y & 256)+(z & 128))>>7;
br= br->b[oc1];
- if(br==NULL) {
+ if (br==NULL) {
return NULL;
}
}
- if(oc->ocres>=128) {
+ if (oc->ocres>=128) {
oc1= ((x & 256)+(y & 128)+(z & 64))>>6;
br= br->b[oc1];
- if(br==NULL) {
+ if (br==NULL) {
return NULL;
}
}
oc1= ((x & 128)+(y & 64)+(z & 32))>>5;
br= br->b[oc1];
- if(br) {
+ if (br) {
oc1= ((x & 64)+(y & 32)+(z & 16))>>4;
br= br->b[oc1];
- if(br) {
+ if (br) {
oc1= ((x & 32)+(y & 16)+(z & 8))>>3;
br= br->b[oc1];
- if(br) {
+ if (br) {
oc1= ((x & 16)+(y & 8)+(z & 4))>>2;
br= br->b[oc1];
- if(br) {
+ if (br) {
oc1= ((x & 8)+(y & 4)+(z & 2))>>1;
br= br->b[oc1];
- if(br) {
+ if (br) {
oc1= ((x & 4)+(y & 2)+(z & 1));
return (Node *)br->b[oc1];
}
@@ -791,24 +791,24 @@ static int cliptest(float p, float q, float *u1, float *u2)
{
float r;
- if(p<0.0f) {
- if(q<p) return 0;
- else if(q<0.0f) {
+ if (p<0.0f) {
+ if (q<p) return 0;
+ else if (q<0.0f) {
r= q/p;
- if(r>*u2) return 0;
- else if(r>*u1) *u1=r;
+ if (r>*u2) return 0;
+ else if (r>*u1) *u1=r;
}
}
else {
- if(p>0.0f) {
- if(q<0.0f) return 0;
- else if(q<p) {
+ if (p>0.0f) {
+ if (q<0.0f) return 0;
+ else if (q<p) {
r= q/p;
- if(r<*u1) return 0;
- else if(r<*u2) *u2=r;
+ if (r<*u1) return 0;
+ else if (r<*u2) *u2=r;
}
}
- else if(q<0.0f) return 0;
+ else if (q<0.0f) return 0;
}
return 1;
}
@@ -836,7 +836,7 @@ static int do_coherence_test(int ocx1, int ocx2, int ocy1, int ocy2, int ocz1, i
short *sp;
sp= coh_nodes[ (ocx2 & 15) + 16*(ocy2 & 15) + 256*(ocz2 & 15) ];
- if(sp[0]==ocx1 && sp[1]==ocy1 && sp[2]==ocz1 &&
+ if (sp[0]==ocx1 && sp[1]==ocy1 && sp[2]==ocz1 &&
sp[3]==ocx2 && sp[4]==ocy2 && sp[5]==ocz2) return 1;
return 0;
}
@@ -859,7 +859,7 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
int ocx1,ocx2,ocy1, ocy2,ocz1,ocz2;
/* clip with octree */
- if(oc->branchcount==0) return 0;
+ if (oc->branchcount==0) return 0;
/* do this before intersect calls */
#if 0
@@ -877,22 +877,22 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
u2= 1.0f;
/* clip with octree cube */
- if(cliptest(-ldx, start[0]-oc->min[0], &u1,&u2)) {
- if(cliptest(ldx, oc->max[0]-start[0], &u1,&u2)) {
+ if (cliptest(-ldx, start[0]-oc->min[0], &u1,&u2)) {
+ if (cliptest(ldx, oc->max[0]-start[0], &u1,&u2)) {
ldy= is->dir[1]*is->dist;
- if(cliptest(-ldy, start[1]-oc->min[1], &u1,&u2)) {
- if(cliptest(ldy, oc->max[1]-start[1], &u1,&u2)) {
+ if (cliptest(-ldy, start[1]-oc->min[1], &u1,&u2)) {
+ if (cliptest(ldy, oc->max[1]-start[1], &u1,&u2)) {
ldz = is->dir[2]*is->dist;
- if(cliptest(-ldz, start[2]-oc->min[2], &u1,&u2)) {
- if(cliptest(ldz, oc->max[2]-start[2], &u1,&u2)) {
+ if (cliptest(-ldz, start[2]-oc->min[2], &u1,&u2)) {
+ if (cliptest(ldz, oc->max[2]-start[2], &u1,&u2)) {
c1=1;
- if(u2<1.0f) {
+ if (u2<1.0f) {
end[0] = start[0]+u2*ldx;
end[1] = start[1]+u2*ldy;
end[2] = start[2]+u2*ldz;
}
- if(u1>0.0f) {
+ if (u1>0.0f) {
start[0] += u1*ldx;
start[1] += u1*ldy;
start[2] += u1*ldz;
@@ -904,7 +904,7 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
}
}
- if(c1==0) return 0;
+ if (c1==0) return 0;
/* reset static variables in ocread */
//ocread(oc, oc->ocres, 0, 0);
@@ -924,14 +924,14 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
ocy2= (int)oy2;
ocz2= (int)oz2;
- if(ocx1==ocx2 && ocy1==ocy2 && ocz1==ocz2) {
+ if (ocx1==ocx2 && ocy1==ocy2 && ocz1==ocz2) {
no= ocread(oc, ocx1, ocy1, ocz1);
- if(no) {
+ if (no) {
/* exact intersection with node */
vec1[0]= ox1; vec1[1]= oy1; vec1[2]= oz1;
vec2[0]= ox2; vec2[1]= oy2; vec2[2]= oz2;
calc_ocval_ray(&ocval, (float)ocx1, (float)ocy1, (float)ocz1, vec1, vec2);
- if( testnode(oc, is, no, ocval) ) return 1;
+ if ( testnode(oc, is, no, ocval) ) return 1;
}
}
else {
@@ -945,12 +945,12 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
doy= oy1-oy2;
doz= oz1-oz2;
- if(dox<-FLT_EPSILON) {
+ if (dox<-FLT_EPSILON) {
ldx= -1.0f/dox;
labdax= (ocx1-ox1+1.0f)*ldx;
dx= 1;
}
- else if(dox>FLT_EPSILON) {
+ else if (dox>FLT_EPSILON) {
ldx= 1.0f/dox;
labdax= (ox1-ocx1)*ldx;
dx= -1;
@@ -961,12 +961,12 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
dx= 0;
}
- if(doy<-FLT_EPSILON) {
+ if (doy<-FLT_EPSILON) {
ldy= -1.0f/doy;
labday= (ocy1-oy1+1.0f)*ldy;
dy= 1;
}
- else if(doy>FLT_EPSILON) {
+ else if (doy>FLT_EPSILON) {
ldy= 1.0f/doy;
labday= (oy1-ocy1)*ldy;
dy= -1;
@@ -977,12 +977,12 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
dy= 0;
}
- if(doz<-FLT_EPSILON) {
+ if (doz<-FLT_EPSILON) {
ldz= -1.0f/doz;
labdaz= (ocz1-oz1+1.0f)*ldz;
dz= 1;
}
- else if(doz>FLT_EPSILON) {
+ else if (doz>FLT_EPSILON) {
ldz= 1.0f/doz;
labdaz= (oz1-ocz1)*ldz;
dz= -1;
@@ -1006,7 +1006,7 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
while(TRUE) {
no= ocread(oc, xo, yo, zo);
- if(no) {
+ if (no) {
/* calculate ray intersection with octree node */
copy_v3_v3(vec1, vec2);
@@ -1017,10 +1017,10 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
calc_ocval_ray(&ocval, (float)xo, (float)yo, (float)zo, vec1, vec2);
//is->dist = (u1+ddalabda*(u2-u1))*olabda;
- if( testnode(oc, is, no, ocval) )
+ if ( testnode(oc, is, no, ocval) )
found = 1;
- if(is->dist < (u1+ddalabda*(u2-u1))*olabda)
+ if (is->dist < (u1+ddalabda*(u2-u1))*olabda)
return found;
}
@@ -1030,17 +1030,17 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
/* traversing ocree nodes need careful detection of smallest values, with proper
* exceptions for equal labdas */
eqval= (labdax==labday);
- if(labday==labdaz) eqval += 2;
- if(labdax==labdaz) eqval += 4;
+ if (labday==labdaz) eqval += 2;
+ if (labdax==labdaz) eqval += 4;
- if(eqval) { // only 4 cases exist!
- if(eqval==7) { // x=y=z
+ if (eqval) { // only 4 cases exist!
+ if (eqval==7) { // x=y=z
xo+=dx; labdax+=ldx;
yo+=dy; labday+=ldy;
zo+=dz; labdaz+=ldz;
}
- else if(eqval==1) { // x=y
- if(labday < labdaz) {
+ else if (eqval==1) { // x=y
+ if (labday < labdaz) {
xo+=dx; labdax+=ldx;
yo+=dy; labday+=ldy;
}
@@ -1048,8 +1048,8 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
zo+=dz; labdaz+=ldz;
}
}
- else if(eqval==2) { // y=z
- if(labdax < labday) {
+ else if (eqval==2) { // y=z
+ if (labdax < labday) {
xo+=dx; labdax+=ldx;
}
else {
@@ -1058,7 +1058,7 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
}
}
else { // x=z
- if(labday < labdax) {
+ if (labday < labdax) {
yo+=dy; labday+=ldy;
}
else {
@@ -1069,13 +1069,13 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
}
else { // all three different, just three cases exist
eqval= (labdax<labday);
- if(labday<labdaz) eqval += 2;
- if(labdax<labdaz) eqval += 4;
+ if (labday<labdaz) eqval += 2;
+ if (labdax<labdaz) eqval += 4;
- if(eqval==7 || eqval==5) { // x smallest
+ if (eqval==7 || eqval==5) { // x smallest
xo+=dx; labdax+=ldx;
}
- else if(eqval==2 || eqval==6) { // y smallest
+ else if (eqval==2 || eqval==6) { // y smallest
yo+=dy; labday+=ldy;
}
else { // z smallest
@@ -1085,9 +1085,9 @@ static int RE_rayobject_octree_intersect(RayObject *tree, Isect *is)
}
ddalabda=MIN3(labdax,labday,labdaz);
- if(ddalabda==labdao) break;
+ if (ddalabda==labdao) break;
/* to make sure the last node is always checked */
- if(labdao>=1.0f) break;
+ if (labdao>=1.0f) break;
}
}