diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 11:52:14 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 11:52:14 +0400 |
commit | b8a71efeba70d6c3ebc579f5043daa4162da86e8 (patch) | |
tree | d2d89da2a59f8955583f4968a35e48c578fd4d4c /source/blender/render | |
parent | 81d8f17843f92c6d6abbacb652ca22917910f4bc (diff) |
style cleanup: follow style guide for/with/if spacing
Diffstat (limited to 'source/blender/render')
23 files changed, 324 insertions, 324 deletions
diff --git a/source/blender/render/intern/raytrace/rayobject.cpp b/source/blender/render/intern/raytrace/rayobject.cpp index 3f675a1b9ab..687498ba66e 100644 --- a/source/blender/render/intern/raytrace/rayobject.cpp +++ b/source/blender/render/intern/raytrace/rayobject.cpp @@ -60,7 +60,7 @@ MALWAYS_INLINE RayObject* rayface_from_coords(RayFace *rayface, void *ob, void * copy_v3_v3(rayface->v2, v2); copy_v3_v3(rayface->v3, v3); - if(v4) + if (v4) { copy_v3_v3(rayface->v4, v4); rayface->quad = 1; @@ -77,13 +77,13 @@ MALWAYS_INLINE void rayface_from_vlak(RayFace *rayface, ObjectInstanceRen *obi, { rayface_from_coords(rayface, obi, vlr, vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4 ? vlr->v4->co : 0); - if(obi->transform_primitives) + if (obi->transform_primitives) { mul_m4_v3(obi->mat, rayface->v1); mul_m4_v3(obi->mat, rayface->v2); mul_m4_v3(obi->mat, rayface->v3); - if(RE_rayface_isQuad(rayface)) + if (RE_rayface_isQuad(rayface)) mul_m4_v3(obi->mat, rayface->v4); } } @@ -109,11 +109,11 @@ MALWAYS_INLINE int vlr_check_intersect(Isect *is, ObjectInstanceRen *obi, VlakRe { /* for baking selected to active non-traceable materials might still * be in the raytree */ - if(!(vlr->flag & R_TRACEBLE)) + if (!(vlr->flag & R_TRACEBLE)) return 0; /* I know... cpu cycle waste, might do smarter once */ - if(is->mode==RE_RAY_MIRROR) + if (is->mode==RE_RAY_MIRROR) return !(vlr->mat->mode & MA_ONLYCAST); else return (is->lay & obi->lay); @@ -159,21 +159,21 @@ MALWAYS_INLINE int isec_tri_quad(float start[3], float dir[3], RayFace *face, fl sub_v3_v3v3(m, start, co3); det1= dot_v3v3(m, x); - if(divdet != 0.0f) { + if (divdet != 0.0f) { divdet= 1.0f/divdet; v= det1*divdet; - if(v < RE_RAYTRACE_EPSILON && v > -(1.0f+RE_RAYTRACE_EPSILON)) { + if (v < RE_RAYTRACE_EPSILON && v > -(1.0f+RE_RAYTRACE_EPSILON)) { float cros[3]; cross_v3_v3v3(cros, m, t0); u= divdet*dot_v3v3(cros, r); - if(u < RE_RAYTRACE_EPSILON && (v + u) > -(1.0f+RE_RAYTRACE_EPSILON)) { + if (u < RE_RAYTRACE_EPSILON && (v + u) > -(1.0f+RE_RAYTRACE_EPSILON)) { l= divdet*dot_v3v3(cros, t1); /* check if intersection is within ray length */ - if(l > -RE_RAYTRACE_EPSILON && l < *lambda) { + if (l > -RE_RAYTRACE_EPSILON && l < *lambda) { uv[0]= u; uv[1]= v; *lambda= l; @@ -184,25 +184,25 @@ MALWAYS_INLINE int isec_tri_quad(float start[3], float dir[3], RayFace *face, fl } /* intersect second triangle in quad */ - if(quad) { + if (quad) { copy_v3_v3(co4, face->v4); sub_v3_v3v3(t0, co3, co4); divdet= dot_v3v3(t0, x); - if(divdet != 0.0f) { + if (divdet != 0.0f) { divdet= 1.0f/divdet; v = det1*divdet; - if(v < RE_RAYTRACE_EPSILON && v > -(1.0f+RE_RAYTRACE_EPSILON)) { + if (v < RE_RAYTRACE_EPSILON && v > -(1.0f+RE_RAYTRACE_EPSILON)) { float cros[3]; cross_v3_v3v3(cros, m, t0); u= divdet*dot_v3v3(cros, r); - if(u < RE_RAYTRACE_EPSILON && (v + u) > -(1.0f+RE_RAYTRACE_EPSILON)) { + if (u < RE_RAYTRACE_EPSILON && (v + u) > -(1.0f+RE_RAYTRACE_EPSILON)) { l= divdet*dot_v3v3(cros, t1); - if(l >- RE_RAYTRACE_EPSILON && l < *lambda) { + if (l >- RE_RAYTRACE_EPSILON && l < *lambda) { uv[0]= u; uv[1]= -(1.0f + v + u); *lambda= l; @@ -242,38 +242,38 @@ MALWAYS_INLINE int isec_tri_quad_neighbour(float start[3], float dir[3], RayFace sub_v3_v3v3(m, start, co3); det1= dot_v3v3(m, x); - if(divdet != 0.0f) { + if (divdet != 0.0f) { divdet= 1.0f/divdet; v= det1*divdet; - if(v < RE_RAYTRACE_EPSILON && v > -(1.0f+RE_RAYTRACE_EPSILON)) { + if (v < RE_RAYTRACE_EPSILON && v > -(1.0f+RE_RAYTRACE_EPSILON)) { float cros[3]; cross_v3_v3v3(cros, m, t0); u= divdet*dot_v3v3(cros, r); - if(u < RE_RAYTRACE_EPSILON && (v + u) > -(1.0f+RE_RAYTRACE_EPSILON)) + if (u < RE_RAYTRACE_EPSILON && (v + u) > -(1.0f+RE_RAYTRACE_EPSILON)) return 1; } } /* intersect second triangle in quad */ - if(quad) { + if (quad) { copy_v3_v3(co4, face->v4); sub_v3_v3v3(t0, co3, co4); divdet= dot_v3v3(t0, x); - if(divdet != 0.0f) { + if (divdet != 0.0f) { divdet= 1.0f/divdet; v = det1*divdet; - if(v < RE_RAYTRACE_EPSILON && v > -(1.0f+RE_RAYTRACE_EPSILON)) { + if (v < RE_RAYTRACE_EPSILON && v > -(1.0f+RE_RAYTRACE_EPSILON)) { float cros[3]; cross_v3_v3v3(cros, m, t0); u= divdet*dot_v3v3(cros, r); - if(u < RE_RAYTRACE_EPSILON && (v + u) > -(1.0f+RE_RAYTRACE_EPSILON)) + if (u < RE_RAYTRACE_EPSILON && (v + u) > -(1.0f+RE_RAYTRACE_EPSILON)) return 2; } } @@ -291,24 +291,24 @@ MALWAYS_INLINE int intersect_rayface(RayObject *hit_obj, RayFace *face, Isect *i int ok= 0; /* avoid self-intersection */ - if(is->orig.ob == face->ob && is->orig.face == face->face) + if (is->orig.ob == face->ob && is->orig.face == face->face) return 0; /* check if we should intersect this face */ - if(is->check == RE_CHECK_VLR_RENDER) + if (is->check == RE_CHECK_VLR_RENDER) { - if(vlr_check_intersect(is, (ObjectInstanceRen*)face->ob, (VlakRen*)face->face) == 0) + if (vlr_check_intersect(is, (ObjectInstanceRen*)face->ob, (VlakRen*)face->face) == 0) return 0; } - else if(is->check == RE_CHECK_VLR_NON_SOLID_MATERIAL) + else if (is->check == RE_CHECK_VLR_NON_SOLID_MATERIAL) { - if(vlr_check_intersect(is, (ObjectInstanceRen*)face->ob, (VlakRen*)face->face) == 0) + if (vlr_check_intersect(is, (ObjectInstanceRen*)face->ob, (VlakRen*)face->face) == 0) return 0; - if(vlr_check_intersect_solid(is, (ObjectInstanceRen*)face->ob, (VlakRen*)face->face) == 0) + if (vlr_check_intersect_solid(is, (ObjectInstanceRen*)face->ob, (VlakRen*)face->face) == 0) return 0; } - else if(is->check == RE_CHECK_VLR_BAKE) { - if(vlr_check_bake(is, (ObjectInstanceRen*)face->ob, (VlakRen*)face->face) == 0) + else if (is->check == RE_CHECK_VLR_BAKE) { + if (vlr_check_bake(is, (ObjectInstanceRen*)face->ob, (VlakRen*)face->face) == 0) return 0; } @@ -318,13 +318,13 @@ MALWAYS_INLINE int intersect_rayface(RayObject *hit_obj, RayFace *face, Isect *i dist= is->dist; ok= isec_tri_quad(is->start, is->dir, face, uv, &dist); - if(ok) { + if (ok) { /* when a shadow ray leaves a face, it can be little outside the edges * of it, causing intersection to be detected in its neighbor face */ - if(is->skip & RE_SKIP_VLR_NEIGHBOUR) + if (is->skip & RE_SKIP_VLR_NEIGHBOUR) { - if(dist < 0.1f && is->orig.ob == face->ob) + if (dist < 0.1f && is->orig.ob == face->ob) { VlakRen * a = (VlakRen*)is->orig.face; VlakRen * b = (VlakRen*)face->face; @@ -332,7 +332,7 @@ MALWAYS_INLINE int intersect_rayface(RayObject *hit_obj, RayFace *face, Isect *i /* so there's a shared edge or vertex, let's intersect ray with * face itself, if that's true we can safely return 1, otherwise * we assume the intersection is invalid, 0 */ - if(a->v1==b->v1 || a->v2==b->v1 || a->v3==b->v1 || a->v4==b->v1 + if (a->v1==b->v1 || a->v2==b->v1 || a->v3==b->v1 || a->v4==b->v1 || a->v1==b->v2 || a->v2==b->v2 || a->v3==b->v2 || a->v4==b->v2 || a->v1==b->v3 || a->v2==b->v3 || a->v3==b->v3 || a->v4==b->v3 || (b->v4 && (a->v1==b->v4 || a->v2==b->v4 || a->v3==b->v4 || a->v4==b->v4))) { @@ -341,7 +341,7 @@ MALWAYS_INLINE int intersect_rayface(RayObject *hit_obj, RayFace *face, Isect *i ObjectInstanceRen *ob= (ObjectInstanceRen*)is->orig.ob; rayface_from_vlak(&origface, ob, (VlakRen*)is->orig.face); - if(!isec_tri_quad_neighbour(is->start, is->dir, &origface)) + if (!isec_tri_quad_neighbour(is->start, is->dir, &origface)) { return 0; } @@ -375,7 +375,7 @@ int RE_rayobject_raycast(RayObject *r, Isect *isec) RE_RC_COUNT(isec->raycounter->raycast.test); /* setup vars used on raycast */ - for(i=0; i<3; i++) + for (i=0; i<3; i++) { isec->idot_axis[i] = 1.0f / isec->dir[i]; @@ -388,11 +388,11 @@ int RE_rayobject_raycast(RayObject *r, Isect *isec) #ifdef RT_USE_LAST_HIT /* last hit heuristic */ - if(isec->mode==RE_RAY_SHADOW && isec->last_hit) + if (isec->mode==RE_RAY_SHADOW && isec->last_hit) { RE_RC_COUNT(isec->raycounter->rayshadow_last_hit.test); - if(RE_rayobject_intersect(isec->last_hit, isec)) + if (RE_rayobject_intersect(isec->last_hit, isec)) { RE_RC_COUNT(isec->raycounter->raycast.hit); RE_RC_COUNT(isec->raycounter->rayshadow_last_hit.hit); @@ -405,7 +405,7 @@ int RE_rayobject_raycast(RayObject *r, Isect *isec) isec->hit_hint = 0; #endif - if(RE_rayobject_intersect(r, isec)) + if (RE_rayobject_intersect(r, isec)) { RE_RC_COUNT(isec->raycounter->raycast.hit); @@ -420,11 +420,11 @@ int RE_rayobject_raycast(RayObject *r, Isect *isec) int RE_rayobject_intersect(RayObject *r, Isect *i) { - if(RE_rayobject_isRayFace(r)) + if (RE_rayobject_isRayFace(r)) { return intersect_rayface(r, (RayFace*) RE_rayobject_align(r), i); } - else if(RE_rayobject_isVlakPrimitive(r)) + else if (RE_rayobject_isVlakPrimitive(r)) { //TODO optimize (useless copy to RayFace to avoid duplicate code) VlakPrimitive *face = (VlakPrimitive*) RE_rayobject_align(r); @@ -433,7 +433,7 @@ int RE_rayobject_intersect(RayObject *r, Isect *i) return intersect_rayface(r, &nface, i); } - else if(RE_rayobject_isRayAPI(r)) + else if (RE_rayobject_isRayAPI(r)) { r = RE_rayobject_align(r); return r->api->raycast(r, i); @@ -466,11 +466,11 @@ void RE_rayobject_free(RayObject *r) float RE_rayobject_cost(RayObject *r) { - if(RE_rayobject_isRayFace(r) || RE_rayobject_isVlakPrimitive(r)) + if (RE_rayobject_isRayFace(r) || RE_rayobject_isVlakPrimitive(r)) { return 1.0f; } - else if(RE_rayobject_isRayAPI(r)) + else if (RE_rayobject_isRayAPI(r)) { r = RE_rayobject_align(r); return r->api->cost(r); @@ -485,16 +485,16 @@ float RE_rayobject_cost(RayObject *r) void RE_rayobject_merge_bb(RayObject *r, float *min, float *max) { - if(RE_rayobject_isRayFace(r)) + if (RE_rayobject_isRayFace(r)) { RayFace *face = (RayFace*) RE_rayobject_align(r); DO_MINMAX(face->v1, min, max); DO_MINMAX(face->v2, min, max); DO_MINMAX(face->v3, min, max); - if(RE_rayface_isQuad(face)) DO_MINMAX(face->v4, min, max); + if (RE_rayface_isQuad(face)) DO_MINMAX(face->v4, min, max); } - else if(RE_rayobject_isVlakPrimitive(r)) + else if (RE_rayobject_isVlakPrimitive(r)) { VlakPrimitive *face = (VlakPrimitive*) RE_rayobject_align(r); RayFace nface; @@ -503,9 +503,9 @@ void RE_rayobject_merge_bb(RayObject *r, float *min, float *max) DO_MINMAX(nface.v1, min, max); DO_MINMAX(nface.v2, min, max); DO_MINMAX(nface.v3, min, max); - if(RE_rayface_isQuad(&nface)) DO_MINMAX(nface.v4, min, max); + if (RE_rayface_isQuad(&nface)) DO_MINMAX(nface.v4, min, max); } - else if(RE_rayobject_isRayAPI(r)) + else if (RE_rayobject_isRayAPI(r)) { r = RE_rayobject_align(r); r->api->bb(r, min, max); @@ -518,11 +518,11 @@ void RE_rayobject_merge_bb(RayObject *r, float *min, float *max) void RE_rayobject_hint_bb(RayObject *r, RayHint *hint, float *min, float *max) { - if(RE_rayobject_isRayFace(r) || RE_rayobject_isVlakPrimitive(r)) + if (RE_rayobject_isRayFace(r) || RE_rayobject_isVlakPrimitive(r)) { return; } - else if(RE_rayobject_isRayAPI(r)) + else if (RE_rayobject_isRayAPI(r)) { r = RE_rayobject_align(r); return r->api->hint_bb(r, hint, min, max); @@ -535,7 +535,7 @@ void RE_rayobject_hint_bb(RayObject *r, RayHint *hint, float *min, float *max) int RE_rayobjectcontrol_test_break(RayObjectControl *control) { - if(control->test_break) + if (control->test_break) return control->test_break(control->data); return 0; @@ -543,7 +543,7 @@ int RE_rayobjectcontrol_test_break(RayObjectControl *control) void RE_rayobject_set_control(RayObject *r, void *data, RE_rayobjectcontrol_test_break_callback test_break) { - if(RE_rayobject_isRayAPI(r)) + if (RE_rayobject_isRayAPI(r)) { r = RE_rayobject_align(r); r->control.data = data; diff --git a/source/blender/render/intern/raytrace/rayobject_blibvh.cpp b/source/blender/render/intern/raytrace/rayobject_blibvh.cpp index f5a60308561..165b62cfbe4 100644 --- a/source/blender/render/intern/raytrace/rayobject_blibvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_blibvh.cpp @@ -102,11 +102,11 @@ static void bvh_callback(void *userdata, int index, const BVHTreeRay *UNUSED(ray Isect *isec = data->isec; RayObject *face = data->leafs[index]; - if(RE_rayobject_intersect(face,isec)) + if (RE_rayobject_intersect(face,isec)) { hit->index = index; - if(isec->mode == RE_RAY_SHADOW) + if (isec->mode == RE_RAY_SHADOW) hit->dist = 0; else hit->dist = isec->dist; @@ -154,10 +154,10 @@ static void RE_rayobject_blibvh_free(RayObject *o) { BVHObject *obj = (BVHObject*)o; - if(obj->bvh) + if (obj->bvh) BLI_bvhtree_free(obj->bvh); - if(obj->leafs) + if (obj->leafs) MEM_freeN(obj->leafs); MEM_freeN(obj); diff --git a/source/blender/render/intern/raytrace/rayobject_instance.cpp b/source/blender/render/intern/raytrace/rayobject_instance.cpp index c7af501a808..2e803ce0fd3 100644 --- a/source/blender/render/intern/raytrace/rayobject_instance.cpp +++ b/source/blender/render/intern/raytrace/rayobject_instance.cpp @@ -99,7 +99,7 @@ static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) int changed = 0, i, res; // TODO - this is disabling self intersection on instances - if(isec->orig.ob == obj->ob && obj->ob) + if (isec->orig.ob == obj->ob && obj->ob) { changed = 1; isec->orig.ob = obj->target_ob; @@ -117,7 +117,7 @@ static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) isec->dist *= normalize_v3(isec->dir); // update idot_axis and bv_index - for(i=0; i<3; i++) + for (i=0; i<3; i++) { isec->idot_axis[i] = 1.0f / isec->dir[i]; @@ -132,7 +132,7 @@ static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) res = RE_rayobject_intersect(obj->target, isec); // map dist into original coordinate space - if(res == 0) + if (res == 0) { isec->dist = dist; } @@ -161,11 +161,11 @@ static int RE_rayobject_instance_intersect(RayObject *o, Isect *isec) copy_v3_v3(isec->dir, dir); copy_v3_v3(isec->idot_axis, idot_axis); - if(changed) + if (changed) isec->orig.ob = obj->ob; // restore bv_index - for(i=0; i<3; i++) + for (i=0; i<3; i++) { isec->bv_index[2*i] = isec->idot_axis[i] < 0.0 ? 1 : 0; isec->bv_index[2*i+1] = 1 - isec->bv_index[2*i]; @@ -202,9 +202,9 @@ static void RE_rayobject_instance_bb(RayObject *o, float *min, float *max) RE_rayobject_merge_bb(obj->target, m, M); //There must be a faster way than rotating all the 8 vertexs of the BB - for(i=0; i<8; i++) + for (i=0; i<8; i++) { - for(j=0; j<3; j++) t[j] = i&(1<<j) ? M[j] : m[j]; + for (j=0; j<3; j++) t[j] = i&(1<<j) ? M[j] : m[j]; mul_m4_v3(obj->target2global, t); DO_MINMAX(t, min, max); } 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; } } diff --git a/source/blender/render/intern/raytrace/rayobject_qbvh.cpp b/source/blender/render/intern/raytrace/rayobject_qbvh.cpp index f7d38bf0fa3..437d7f433b5 100644 --- a/source/blender/render/intern/raytrace/rayobject_qbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_qbvh.cpp @@ -71,14 +71,14 @@ void bvh_done<QBVHTree>(QBVHTree *obj) //TODO do this in 1 pass (half memory usage during building) VBVHNode *root = BuildBinaryVBVH<VBVHNode>(arena1, &obj->rayobj.control).transform(obj->builder); - if(RE_rayobjectcontrol_test_break(&obj->rayobj.control)) + if (RE_rayobjectcontrol_test_break(&obj->rayobj.control)) { BLI_memarena_free(arena1); BLI_memarena_free(arena2); return; } - if(root) { + if (root) { pushup_simd<VBVHNode,4>(root); obj->root = Reorganize_SVBVH<VBVHNode>(arena2).transform(root); } @@ -99,8 +99,8 @@ template<int StackSize> int intersect(QBVHTree *obj, Isect* isec) { //TODO renable hint support - if(RE_rayobject_isAligned(obj->root)) { - if(isec->mode == RE_RAY_SHADOW) + if (RE_rayobject_isAligned(obj->root)) { + if (isec->mode == RE_RAY_SHADOW) return svbvh_node_stack_raycast<StackSize,true>(obj->root, isec); else return svbvh_node_stack_raycast<StackSize,false>(obj->root, isec); @@ -141,7 +141,7 @@ RayObjectAPI* bvh_get_api(int maxstacksize) { static RayObjectAPI bvh_api256 = make_api<Tree,1024>(); - if(maxstacksize <= 1024) return &bvh_api256; + if (maxstacksize <= 1024) return &bvh_api256; assert(maxstacksize <= 256); return 0; } diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp index 6988e3fcc38..54901db8bdd 100644 --- a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp +++ b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp @@ -54,10 +54,10 @@ static void rtbuild_init(RTBuilder *b) b->primitives.end = 0; b->primitives.maxsize = 0; - for(int i=0; i<RTBUILD_MAX_CHILDS; i++) + for (int i=0; i<RTBUILD_MAX_CHILDS; i++) b->child_offset[i] = 0; - for(int i=0; i<3; i++) + for (int i=0; i<3; i++) b->sorted_begin[i] = b->sorted_end[i] = 0; INIT_MINMAX(b->bb, b->bb+3); @@ -74,7 +74,7 @@ RTBuilder* rtbuild_create(int size) builder->primitives.begin = builder->primitives.end = memblock; builder->primitives.maxsize = size; - for(int i=0; i<3; i++) + for (int i=0; i<3; i++) { builder->sorted_begin[i] = (RTBuilder::Object**)MEM_mallocN( sizeof(RTBuilder::Object*)*size,"RTBuilder.sorted_objects"); builder->sorted_end[i] = builder->sorted_begin[i]; @@ -86,10 +86,10 @@ RTBuilder* rtbuild_create(int size) void rtbuild_free(RTBuilder *b) { - if(b->primitives.begin) MEM_freeN(b->primitives.begin); + if (b->primitives.begin) MEM_freeN(b->primitives.begin); - for(int i=0; i<3; i++) - if(b->sorted_begin[i]) + for (int i=0; i<3; i++) + if (b->sorted_begin[i]) MEM_freeN(b->sorted_begin[i]); MEM_freeN(b); @@ -107,16 +107,16 @@ void rtbuild_add(RTBuilder *b, RayObject *o) /* skip objects with invalid bounding boxes, nan causes DO_MINMAX * to do nothing, so we get these invalid values. this shouldn't * happen usually, but bugs earlier in the pipeline can cause it. */ - if(bb[0] > bb[3] || bb[1] > bb[4] || bb[2] > bb[5]) + if (bb[0] > bb[3] || bb[1] > bb[4] || bb[2] > bb[5]) return; /* skip objects with inf bounding boxes */ - if(!finite(bb[0]) || !finite(bb[1]) || !finite(bb[2])) + if (!finite(bb[0]) || !finite(bb[1]) || !finite(bb[2])) return; - if(!finite(bb[3]) || !finite(bb[4]) || !finite(bb[5])) + if (!finite(bb[3]) || !finite(bb[4]) || !finite(bb[5])) return; /* skip objects with zero bounding box, they are of no use, and * will give problems in rtbuild_heuristic_object_split later */ - if(bb[0] == bb[3] && bb[1] == bb[4] && bb[2] == bb[5]) + if (bb[0] == bb[3] && bb[1] == bb[4] && bb[2] == bb[5]) return; copy_v3_v3(b->primitives.end->bb, bb); @@ -124,7 +124,7 @@ void rtbuild_add(RTBuilder *b, RayObject *o) b->primitives.end->obj = o; b->primitives.end->cost = RE_rayobject_cost(o); - for(int i=0; i<3; i++) + for (int i=0; i<3; i++) { *(b->sorted_end[i]) = b->primitives.end; b->sorted_end[i]++; @@ -141,7 +141,7 @@ int rtbuild_size(RTBuilder *b) template<class Obj,int Axis> static bool obj_bb_compare(const Obj &a, const Obj &b) { - if(a->bb[Axis] != b->bb[Axis]) + if (a->bb[Axis] != b->bb[Axis]) return a->bb[Axis] < b->bb[Axis]; return a->obj < b->obj; } @@ -149,18 +149,18 @@ static bool obj_bb_compare(const Obj &a, const Obj &b) template<class Item> static void object_sort(Item *begin, Item *end, int axis) { - if(axis == 0) return std::sort(begin, end, obj_bb_compare<Item,0> ); - if(axis == 1) return std::sort(begin, end, obj_bb_compare<Item,1> ); - if(axis == 2) return std::sort(begin, end, obj_bb_compare<Item,2> ); + if (axis == 0) return std::sort(begin, end, obj_bb_compare<Item,0> ); + if (axis == 1) return std::sort(begin, end, obj_bb_compare<Item,1> ); + if (axis == 2) return std::sort(begin, end, obj_bb_compare<Item,2> ); assert(false); } void rtbuild_done(RTBuilder *b, RayObjectControl* ctrl) { - for(int i=0; i<3; i++) - if(b->sorted_begin[i]) + for (int i=0; i<3; i++) + if (b->sorted_begin[i]) { - if(RE_rayobjectcontrol_test_break(ctrl)) break; + if (RE_rayobjectcontrol_test_break(ctrl)) break; object_sort( b->sorted_begin[i], b->sorted_end[i], i ); } } @@ -174,8 +174,8 @@ RTBuilder* rtbuild_get_child(RTBuilder *b, int child, RTBuilder *tmp) { rtbuild_init( tmp ); - for(int i=0; i<3; i++) - if(b->sorted_begin[i]) + for (int i=0; i<3; i++) + if (b->sorted_begin[i]) { tmp->sorted_begin[i] = b->sorted_begin[i] + b->child_offset[child ]; tmp->sorted_end [i] = b->sorted_begin[i] + b->child_offset[child+1]; @@ -191,9 +191,9 @@ RTBuilder* rtbuild_get_child(RTBuilder *b, int child, RTBuilder *tmp) void rtbuild_calc_bb(RTBuilder *b) { - if(b->bb[0] == 1.0e30f) + if (b->bb[0] == 1.0e30f) { - for(RTBuilder::Object **index = b->sorted_begin[0]; index != b->sorted_end[0]; index++) + for (RTBuilder::Object **index = b->sorted_begin[0]; index != b->sorted_end[0]; index++) RE_rayobject_merge_bb( (*index)->obj , b->bb, b->bb+3); } } @@ -225,20 +225,20 @@ int rtbuild_mean_split(RTBuilder *b, int nchilds, int axis) assert(nchilds <= RTBUILD_MAX_CHILDS); //TODO optimize calc of leafs_per_child - for(s=nchilds; s<tot_leafs; s*=nchilds); + for (s=nchilds; s<tot_leafs; s*=nchilds); Mleafs_per_child = s/nchilds; mleafs_per_child = Mleafs_per_child/nchilds; //split min leafs per child b->child_offset[0] = 0; - for(i=1; i<=nchilds; i++) + for (i=1; i<=nchilds; i++) b->child_offset[i] = mleafs_per_child; //split remaining leafs missing_leafs = tot_leafs - mleafs_per_child*nchilds; - for(i=1; i<=nchilds; i++) + for (i=1; i<=nchilds; i++) { - if(missing_leafs > Mleafs_per_child - mleafs_per_child) + if (missing_leafs > Mleafs_per_child - mleafs_per_child) { b->child_offset[i] += Mleafs_per_child - mleafs_per_child; missing_leafs -= Mleafs_per_child - mleafs_per_child; @@ -252,11 +252,11 @@ int rtbuild_mean_split(RTBuilder *b, int nchilds, int axis) } //adjust for accumulative offsets - for(i=1; i<=nchilds; i++) + for (i=1; i<=nchilds; i++) b->child_offset[i] += b->child_offset[i-1]; //Count created childs - for(i=nchilds; b->child_offset[i] == b->child_offset[i-1]; i--); + for (i=nchilds; b->child_offset[i] == b->child_offset[i-1]; i--); split_leafs(b, b->child_offset, i, axis); assert( b->child_offset[0] == 0 && b->child_offset[i] == tot_leafs ); @@ -281,7 +281,7 @@ int rtbuild_median_split(RTBuilder *b, float *separators, int nchilds, int axis) int size = rtbuild_size(b); assert(nchilds <= RTBUILD_MAX_CHILDS); - if(size <= nchilds) + if (size <= nchilds) { return rtbuild_mean_split(b, nchilds, axis); } @@ -293,12 +293,12 @@ int rtbuild_median_split(RTBuilder *b, float *separators, int nchilds, int axis) //Calculate child offsets b->child_offset[0] = 0; - for(i=0; i<nchilds-1; i++) + for (i=0; i<nchilds-1; i++) b->child_offset[i+1] = split_leafs_by_plane(b, b->child_offset[i], size, separators[i]); b->child_offset[nchilds] = size; - for(i=0; i<nchilds; i++) - if(b->child_offset[i+1] - b->child_offset[i] == size) + for (i=0; i<nchilds; i++) + if (b->child_offset[i+1] - b->child_offset[i] == size) return rtbuild_mean_split(b, nchilds, axis); return nchilds; @@ -313,7 +313,7 @@ int rtbuild_median_split_largest_axis(RTBuilder *b, int nchilds) rtbuild_calc_bb(b); la = bb_largest_axis(b->bb,b->bb+3); - for(i=1; i<nchilds; i++) + for (i=1; i<nchilds; i++) separators[i-1] = (b->bb[la+3]-b->bb[la])*i / nchilds; return rtbuild_median_split(b, separators, nchilds, la); @@ -337,23 +337,23 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds) assert(size > 1); int baxis = -1, boffset = 0; - if(size > nchilds) + if (size > nchilds) { float bcost = FLT_MAX; baxis = -1, boffset = size/2; SweepCost *sweep = (SweepCost*)MEM_mallocN( sizeof(SweepCost)*size, "RTBuilder.HeuristicSweep" ); - for(int axis=0; axis<3; axis++) + for (int axis=0; axis<3; axis++) { SweepCost sweep_left; RTBuilder::Object **obj = b->sorted_begin[axis]; // float right_cost = 0; - for(int i=size-1; i>=0; i--) + for (int i=size-1; i>=0; i--) { - if(i == size-1) + if (i == size-1) { copy_v3_v3(sweep[i].bb, obj[i]->bb); copy_v3_v3(sweep[i].bb+3, obj[i]->bb+3); @@ -380,9 +380,9 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds) sweep_left.bb[5] = obj[0]->bb[5]; sweep_left.cost = obj[0]->cost; -// right_cost -= obj[0]->cost; if(right_cost < 0) right_cost = 0; +// right_cost -= obj[0]->cost; if (right_cost < 0) right_cost = 0; - for(int i=1; i<size; i++) + for (int i=1; i<size; i++) { //Worst case heuristic (cost of each child is linear) float hcost, left_side, right_side; @@ -398,10 +398,10 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds) assert(left_side >= 0); assert(right_side >= 0); - if(left_side > bcost) break; //No way we can find a better heuristic in this axis + if (left_side > bcost) break; //No way we can find a better heuristic in this axis assert(hcost >= 0); - if( hcost < bcost + if ( hcost < bcost || (hcost == bcost && axis < baxis)) //this makes sure the tree built is the same whatever is the order of the sorting axis { bcost = hcost; @@ -412,7 +412,7 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds) DO_MAX( obj[i]->bb+3, sweep_left.bb+3 ); sweep_left.cost += obj[i]->cost; -// right_cost -= obj[i]->cost; if(right_cost < 0) right_cost = 0; +// right_cost -= obj[i]->cost; if (right_cost < 0) right_cost = 0; } //assert(baxis >= 0 && baxis < 3); @@ -423,12 +423,12 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds) MEM_freeN(sweep); } - else if(size == 2) + else if (size == 2) { baxis = 0; boffset = 1; } - else if(size == 1) + else if (size == 1) { b->child_offset[0] = 0; b->child_offset[1] = 1; @@ -441,9 +441,9 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds) /* Adjust sorted arrays for childs */ - for(int i=0; i<boffset; i++) b->sorted_begin[baxis][i]->selected = true; - for(int i=boffset; i<size; i++) b->sorted_begin[baxis][i]->selected = false; - for(int i=0; i<3; i++) + for (int i=0; i<boffset; i++) b->sorted_begin[baxis][i]->selected = true; + for (int i=boffset; i<size; i++) b->sorted_begin[baxis][i]->selected = false; + for (int i=0; i<3; i++) std::stable_partition( b->sorted_begin[i], b->sorted_end[i], selected_node ); return nchilds; @@ -460,13 +460,13 @@ static void split_leafs(RTBuilder *b, int *nth, int partitions, int split_axis) int i; b->split_axis = split_axis; - for(i=0; i < partitions-1; i++) + for (i=0; i < partitions-1; i++) { assert(nth[i] < nth[i+1] && nth[i+1] < nth[partitions]); - if(split_axis == 0) std::nth_element(b, nth[i], nth[i+1], nth[partitions], obj_bb_compare<RTBuilder::Object,0>); - if(split_axis == 1) std::nth_element(b, nth[i], nth[i+1], nth[partitions], obj_bb_compare<RTBuilder::Object,1>); - if(split_axis == 2) std::nth_element(b, nth[i], nth[i+1], nth[partitions], obj_bb_compare<RTBuilder::Object,2>); + if (split_axis == 0) std::nth_element(b, nth[i], nth[i+1], nth[partitions], obj_bb_compare<RTBuilder::Object,0>); + if (split_axis == 1) std::nth_element(b, nth[i], nth[i+1], nth[partitions], obj_bb_compare<RTBuilder::Object,1>); + if (split_axis == 2) std::nth_element(b, nth[i], nth[i+1], nth[partitions], obj_bb_compare<RTBuilder::Object,2>); } } #endif @@ -500,16 +500,16 @@ int bb_largest_axis(float *min, float *max) sub[0] = max[0]-min[0]; sub[1] = max[1]-min[1]; sub[2] = max[2]-min[2]; - if(sub[0] > sub[1]) + if (sub[0] > sub[1]) { - if(sub[0] > sub[2]) + if (sub[0] > sub[2]) return 0; else return 2; } else { - if(sub[1] > sub[2]) + if (sub[1] > sub[2]) return 1; else return 2; @@ -519,11 +519,11 @@ int bb_largest_axis(float *min, float *max) int bb_fits_inside(float *outer_min, float *outer_max, float *inner_min, float *inner_max) { int i; - for(i=0; i<3; i++) - if(outer_min[i] > inner_min[i]) return 0; + for (i=0; i<3; i++) + if (outer_min[i] > inner_min[i]) return 0; - for(i=0; i<3; i++) - if(outer_max[i] < inner_max[i]) return 0; + for (i=0; i<3; i++) + if (outer_max[i] < inner_max[i]) return 0; return 1; } diff --git a/source/blender/render/intern/raytrace/rayobject_svbvh.cpp b/source/blender/render/intern/raytrace/rayobject_svbvh.cpp index 7ce444a2e99..02821d45c50 100644 --- a/source/blender/render/intern/raytrace/rayobject_svbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_svbvh.cpp @@ -79,11 +79,11 @@ void bvh_done<SVBVHTree>(SVBVHTree *obj) BLI_memarena_use_align(arena2, 16); //Build and optimize the tree - if(0) + if (0) { VBVHNode *root = BuildBinaryVBVH<VBVHNode>(arena1, &obj->rayobj.control).transform(obj->builder); - if(RE_rayobjectcontrol_test_break(&obj->rayobj.control)) + if (RE_rayobjectcontrol_test_break(&obj->rayobj.control)) { BLI_memarena_free(arena1); BLI_memarena_free(arena2); @@ -106,14 +106,14 @@ void bvh_done<SVBVHTree>(SVBVHTree *obj) //TODO this uses quite a lot of memory, find ways to reduce memory usage during building OVBVHNode *root = BuildBinaryVBVH<OVBVHNode>(arena1,&obj->rayobj.control).transform(obj->builder); - if(RE_rayobjectcontrol_test_break(&obj->rayobj.control)) + if (RE_rayobjectcontrol_test_break(&obj->rayobj.control)) { BLI_memarena_free(arena1); BLI_memarena_free(arena2); return; } - if(root) { + if (root) { VBVH_optimalPackSIMD<OVBVHNode,PackCost>(PackCost()).transform(root); obj->root = Reorganize_SVBVH<OVBVHNode>(arena2).transform(root); } @@ -135,8 +135,8 @@ template<int StackSize> int intersect(SVBVHTree *obj, Isect* isec) { //TODO renable hint support - if(RE_rayobject_isAligned(obj->root)) { - if(isec->mode == RE_RAY_SHADOW) + if (RE_rayobject_isAligned(obj->root)) { + if (isec->mode == RE_RAY_SHADOW) return svbvh_node_stack_raycast<StackSize,true>(obj->root, isec); else return svbvh_node_stack_raycast<StackSize,false>(obj->root, isec); @@ -177,7 +177,7 @@ RayObjectAPI* bvh_get_api(int maxstacksize) { static RayObjectAPI bvh_api256 = make_api<Tree,1024>(); - if(maxstacksize <= 1024) return &bvh_api256; + if (maxstacksize <= 1024) return &bvh_api256; assert(maxstacksize <= 256); return 0; } diff --git a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp index 75323cfe56a..84395a9ad50 100644 --- a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp @@ -87,16 +87,16 @@ void bvh_done<VBVHTree>(VBVHTree *obj) BLI_memarena_use_malloc(arena1); //Build and optimize the tree - if(1) + if (1) { VBVHNode *root = BuildBinaryVBVH<VBVHNode>(arena1,&obj->rayobj.control).transform(obj->builder); - if(RE_rayobjectcontrol_test_break(&obj->rayobj.control)) + if (RE_rayobjectcontrol_test_break(&obj->rayobj.control)) { BLI_memarena_free(arena1); return; } - if(root) { + if (root) { reorganize(root); remove_useless(root, &root); bvh_refit(root); @@ -137,8 +137,8 @@ template<int StackSize> int intersect(VBVHTree *obj, Isect* isec) { //TODO renable hint support - if(RE_rayobject_isAligned(obj->root)) { - if(isec->mode == RE_RAY_SHADOW) + if (RE_rayobject_isAligned(obj->root)) { + if (isec->mode == RE_RAY_SHADOW) return bvh_node_stack_raycast<VBVHNode,StackSize,false,true>( obj->root, isec); else return bvh_node_stack_raycast<VBVHNode,StackSize,false,false>( obj->root, isec); @@ -159,9 +159,9 @@ void bvh_hint_bb(Tree *tree, LCTSHint *hint, float *UNUSED(min), float *UNUSED(m void bfree(VBVHTree *tree) { - if(tot_pushup + tot_pushdown + tot_hints + tot_moves) + if (tot_pushup + tot_pushdown + tot_hints + tot_moves) { - if(G.f & G_DEBUG) { + if (G.f & G_DEBUG) { printf("tot pushups: %d\n", tot_pushup); printf("tot pushdowns: %d\n", tot_pushdown); printf("tot moves: %d\n", tot_moves); @@ -199,7 +199,7 @@ RayObjectAPI* bvh_get_api(int maxstacksize) { static RayObjectAPI bvh_api256 = make_api<Tree,1024>(); - if(maxstacksize <= 1024) return &bvh_api256; + if (maxstacksize <= 1024) return &bvh_api256; assert(maxstacksize <= 256); return 0; } diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 7dd11dd1fe0..b6a25985d33 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -766,7 +766,7 @@ static int as_testvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, float if (vlr==0) return 0; asf= asv->faces.first; - while(asf) { + while (asf) { for (a=0; a<4; a++) { if (asf->vlr[a] && asf->vlr[a]!=vlr) { inp = fabsf(dot_v3v3(vlr->n, asf->vlr[a]->n)); @@ -787,7 +787,7 @@ static VertRen *as_findvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, f int a; asf= asv->faces.first; - while(asf) { + while (asf) { for (a=0; a<4; a++) { if (asf->vlr[a] && asf->vlr[a]!=vlr) { /* this face already made a copy for this vertex! */ @@ -844,7 +844,7 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[][4], int d ver= RE_findOrAddVert(obr, a); asf= asv->faces.first; - while(asf) { + while (asf) { for (b=0; b<4; b++) { /* is there a reason to make a new vertex? */ @@ -2400,7 +2400,7 @@ static void do_displacement(Render *re, ObjectRen *obr, float mat[][4], float im /* Object Size with parenting */ obt=obr->ob; - while(obt) { + while (obt) { mul_v3_v3v3(temp, obt->size, obt->dscale); scale[0]*=temp[0]; scale[1]*=temp[1]; scale[2]*=temp[2]; obt=obt->parent; @@ -2913,7 +2913,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) orco= get_object_orco(re, ob); } - while(dl) { + while (dl) { if (dl->col > ob->totcol) { /* pass */ } @@ -2988,7 +2988,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) startvert= obr->totvert; nr= dl->nr*dl->parts; - while(nr--) { + while (nr--) { ver= RE_findOrAddVert(obr, obr->totvert++); copy_v3_v3(ver->co, fp); @@ -3583,7 +3583,7 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4]) struct ShadBuf *shb; float viewinv[4][4]; - /* if(la->spsi<16) return; */ + /* if (la->spsi<16) return; */ /* memory alloc */ shb= (struct ShadBuf *)MEM_callocN( sizeof(struct ShadBuf),"initshadbuf"); @@ -4025,7 +4025,7 @@ void init_render_world(Render *re) /* AO samples should be OSA minimum */ if (re->osa) - while(re->wrld.aosamp*re->wrld.aosamp < re->osa) + while (re->wrld.aosamp*re->wrld.aosamp < re->osa) re->wrld.aosamp++; if (!(re->r.mode & R_RAYTRACE) && (re->wrld.ao_gather_method == WO_AOGATHER_RAYTRACE)) re->wrld.mode &= ~(WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT); diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 59f8782e816..fa7b9cb7ea1 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -399,7 +399,7 @@ static void env_set_imats(Render *re) float mat[4][4]; base= re->scene->base.first; - while(base) { + while (base) { mult_m4_m4m4(mat, re->viewmat, base->object->obmat); invert_m4_m4(base->object->imat, mat); @@ -519,9 +519,9 @@ void make_envmaps(Render *re) re->stats_draw(re->sdh, &re->i); /* 5 = hardcoded max recursion level */ - while(depth<5) { + while (depth<5) { tex= re->main->tex.first; - while(tex) { + while (tex) { if (tex->id.us && tex->type==TEX_ENVMAP) { if (tex->env && tex->env->object) { EnvMap *env= tex->env; diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 6d8ae20985c..260a2de4858 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -591,7 +591,7 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max if (count>1) { tot= texres->tr= texres->tb= texres->tg= texres->ta= 0.0; - while(count--) { + while (count--) { boxsampleclip(ibuf, rf, &texr); opp= square_rctf(rf); @@ -1639,7 +1639,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const curmap= 0; previbuf= curibuf= ibuf; - while(curmap<IB_MIPMAP_LEVELS && ibuf->mipmap[curmap]) { + while (curmap<IB_MIPMAP_LEVELS && ibuf->mipmap[curmap]) { if (maxd < pixsize) break; previbuf= curibuf; curibuf= ibuf->mipmap[curmap]; diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index 532d384ec26..436eaefd155 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -466,7 +466,7 @@ static void occ_build_split(OcclusionTree *tree, int begin, int end, int *split) a= begin; enda= end; - while(a<enda) { + while (a<enda) { if (tree->co[a][axis] > mid) { enda--; SWAP(OccFace, tree->face[a], tree->face[enda]); @@ -1226,7 +1226,7 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, float stack[0]= tree->root; totstack= 1; - while(totstack) { + while (totstack) { /* pop point off the stack */ node= stack[--totstack]; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index aa475e8aef0..5db59fcdcc0 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -405,7 +405,7 @@ void RE_FreeRender(Render *re) /* exit blender */ void RE_FreeAllRender(void) { - while(RenderGlobal.renderlist.first) { + while (RenderGlobal.renderlist.first) { RE_FreeRender(RenderGlobal.renderlist.first); } } @@ -811,7 +811,7 @@ static void threaded_tile_processor(Render *re) else nextpa= find_next_part(re, 0); - while(rendering) { + while (rendering) { if (re->test_break(re->tbh)) PIL_sleep_ms(50); @@ -1030,7 +1030,7 @@ static void do_render_blur_3d(Render *re) rres= render_result_new(re, &re->disprect, 0, RR_USE_MEM); /* do the blur steps */ - while(blur--) { + while (blur--) { re->mblur_offs = re->r.blurfac*((float)(re->r.mblur_samples-blur))/(float)re->r.mblur_samples; re->i.curblur= re->r.mblur_samples-blur; /* stats */ @@ -1743,7 +1743,7 @@ static int check_valid_camera(Scene *scene, Object *camera_override) check_comp= 0; - while(seq) { + while (seq) { if (seq->type == SEQ_SCENE && seq->scene) { if (!seq->scene_camera) { if (!seq->scene->camera && !scene_find_camera(seq->scene)) { @@ -1768,7 +1768,7 @@ static int check_valid_camera(Scene *scene, Object *camera_override) if (scene->r.scemode&R_DOCOMP && scene->use_nodes) { bNode *node= scene->nodetree->nodes.first; - while(node) { + while (node) { if (node->type == CMP_NODE_R_LAYERS) { Scene *sce= node->id ? (Scene*)node->id : scene; diff --git a/source/blender/render/intern/source/pixelblending.c b/source/blender/render/intern/source/pixelblending.c index 41b12171b2c..48ce611fed7 100644 --- a/source/blender/render/intern/source/pixelblending.c +++ b/source/blender/render/intern/source/pixelblending.c @@ -309,7 +309,7 @@ void add_filt_fmask_coord(float filt[][3], float *col, float *rowbuf, int row_w, /* loop unroll */ -#define MASKFILT(i, j) val= lfilt[i][j]; if(val!=0.0f) {float *fp= fpoin[i][j]; fp[0]+= val*r; fp[1]+= val*g; fp[2]+= val*b; fp[3]+= val*al; } +#define MASKFILT(i, j) val= lfilt[i][j]; if (val!=0.0f) {float *fp= fpoin[i][j]; fp[0]+= val*r; fp[1]+= val*g; fp[2]+= val*b; fp[3]+= val*al; } MASKFILT(0, 0) MASKFILT(0, 1) diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index 98578c8dc70..826a31e17a8 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -93,7 +93,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) lar= go->lampren; /* test for lamplayer */ - if (lar->mode & LA_LAYER) if((lar->lay & har->lay)==0) continue; + if (lar->mode & LA_LAYER) if ((lar->lay & har->lay)==0) continue; /* lampdist cacluation */ if (lar->type==LA_SUN || lar->type==LA_HEMI) { @@ -186,7 +186,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) inpr*= soft; } if (lar->mode & LA_ONLYSHADOW) { - /* if(ma->mode & MA_SHADOW) { */ + /* if (ma->mode & MA_SHADOW) { */ /* dot product positive: front side face! */ inp= vn[0]*lv[0] + vn[1]*lv[1] + vn[2]*lv[2]; if (inp>0.0f) { diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 7e1ff53d4e7..3346cf3c261 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -140,7 +140,7 @@ void init_render_textures(Render *re) Tex *tex; tex= re->main->tex.first; - while(tex) { + while (tex) { if (tex->id.us) init_render_texture(re, tex); tex= tex->id.next; } @@ -733,7 +733,7 @@ static int texnoise(Tex *tex, TexResult *texres) val= (ran & 3); loop= tex->noisedepth; - while(loop--) { + while (loop--) { ran= (ran>>2); val*= (ran & 3); div*= 3.0f; @@ -3038,7 +3038,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h tex= mtex->tex; if (tex==0) continue; - /* if(mtex->mapto==0) continue; */ + /* if (mtex->mapto==0) continue; */ /* which coords */ co= lo; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 6f0ffcb8470..f5e36125299 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -869,7 +869,7 @@ static void shadeDA_tile(RenderPart *pa, RenderLayer *rl) rectdaps+= pa->rectx; offs+= pa->rectx; - if (y&1) if(R.test_break(R.tbh)) break; + if (y&1) if (R.test_break(R.tbh)) break; } /* disable scanline updating */ @@ -1328,7 +1328,7 @@ void zbufshade_tile(RenderPart *pa) zbuffer_solid(pa, rl, NULL, NULL); - if (!R.test_break(R.tbh)) { /* NOTE: this if() is not consistent */ + if (!R.test_break(R.tbh)) { /* NOTE: this if () is not consistent */ /* edges only for solid part, ztransp doesn't support it yet anti-aliased */ if (rl->layflag & SCE_LAY_EDGE) { diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index f28931f7b16..d238087cfb1 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -1210,7 +1210,7 @@ static int panotestclip(Render *re, int do_pano, float *v) abs4= fabs(v[3]); - if (v[2]< -abs4) c=16; /* this used to be " if(v[2]<0) ", see clippz() */ + if (v[2]< -abs4) c=16; /* this used to be " if (v[2]<0) ", see clippz() */ else if (v[2]> abs4) c+= 32; if ( v[1]>abs4) c+=4; diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index 25705a9fc99..742d28d89b7 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -1042,8 +1042,8 @@ static float readshadowbuf(ShadBuf *shb, ShadSampleBuf *shsample, int bias, int char *ct, *cz; /* simpleclip */ - /* if(xs<0 || ys<0) return 1.0; */ - /* if(xs>=shb->size || ys>=shb->size) return 1.0; */ + /* if (xs<0 || ys<0) return 1.0; */ + /* if (xs>=shb->size || ys>=shb->size) return 1.0; */ /* always test borders of shadowbuffer */ if (xs<0) xs= 0; else if (xs>=shb->size) xs= shb->size-1; diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index ece6e464bdf..5951006c7b5 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -331,7 +331,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) /* soft area */ /* not needed because t0 has been used for p1/p2 as well */ - /* if(doclip && t0<t2) { */ + /* if (doclip && t0<t2) { */ /* *intens *= (t0-t1)/(t2-t1); */ /* } */ @@ -736,7 +736,7 @@ static float OrenNayar_Diff(float nl, float *n, float *l, float *v, float rough normalize_v3(h); /* nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; */ /* Dot product between surface normal and half-way vector */ - /* if(nh<0.0f) nh = 0.0f; */ + /* if (nh<0.0f) nh = 0.0f; */ nv= n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; /* Dot product between surface normal and view vector */ if (nv<=0.0f) nv= 0.0f; @@ -746,7 +746,7 @@ static float OrenNayar_Diff(float nl, float *n, float *l, float *v, float rough if (nl<0.0f) return 0.0f; /* value from area light */ /* vh= v[0]*h[0]+v[1]*h[1]+v[2]*h[2]; */ /* Dot product between view vector and halfway vector */ - /* if(vh<=0.0f) vh= 0.0f; */ + /* if (vh<=0.0f) vh= 0.0f; */ Lit_A = saacos(realnl); View_A = saacos( nv ); @@ -1537,7 +1537,7 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr) /* yafray: ignore shading by photonlights, not used in Blender */ if (lar->type==LA_YF_PHOTON) continue; - if (lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) continue; + if (lar->mode & LA_LAYER) if ((lar->lay & shi->obi->lay)==0) continue; if ((lar->lay & shi->lay)==0) continue; if (lar->shb || (lar->mode & LA_SHAD_RAY)) { @@ -1759,7 +1759,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) if (lar->type==LA_YF_PHOTON) continue; /* test for lamp layer */ - if (lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) continue; + if (lar->mode & LA_LAYER) if ((lar->lay & shi->obi->lay)==0) continue; if ((lar->lay & shi->lay)==0) continue; /* accumulates in shr->diff and shr->spec and shr->shad (diffuse with shadow!) */ diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index 9a24e1dbe75..e29623aee22 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -551,7 +551,7 @@ static void do_strand_fillac(void *handle, int x, int y, float u, float v, float #define CHECK_ADD(n) \ if (apn->p[n]==strnr && apn->obi[n]==obi && apn->seg[n]==seg) \ - { if(!(apn->mask[n] & mask)) { apn->mask[n] |= mask; apn->v[n] += t; apn->u[n] += s; } break; } + { if (!(apn->mask[n] & mask)) { apn->mask[n] |= mask; apn->v[n] += t; apn->u[n] += s; } break; } #define CHECK_ASSIGN(n) \ if (apn->p[n]==0) \ {apn->obi[n]= obi; apn->p[n]= strnr; apn->z[n]= zverg; apn->mask[n]= mask; apn->v[n]= t; apn->u[n]= s; apn->seg[n]= seg; break; } diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index 9c4afaea0fe..02dcc72f525 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -475,7 +475,7 @@ static void vol_shade_one_lamp(struct ShadeInput *shi, const float co[3], const float hitco[3], *atten_co; float p, ref_col[3]; - if (lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) return; + if (lar->mode & LA_LAYER) if ((lar->lay & shi->obi->lay)==0) return; if ((lar->lay & shi->lay)==0) return; if (lar->energy == 0.0f) return; diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index e3068d12265..74c4bf19faf 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -140,7 +140,7 @@ static void zbuf_add_to_span(ZSpan *zspan, float *v1, float *v2) if (my0<0) my0= 0; if (my0>my2) return; - /* if(my0>my2) should still fill in, that way we get spans that skip nicely */ + /* if (my0>my2) should still fill in, that way we get spans that skip nicely */ xx1= maxv[1]-minv[1]; if (xx1>FLT_EPSILON) { @@ -253,7 +253,7 @@ int testclip(const float v[4]) if ( v[1] > abs4) c+=4; else if ( v[1] < -abs4) c+=8; - if (v[2] < -abs4) c+=16; /* this used to be " if(v[2]<0) ", see clippz() */ + if (v[2] < -abs4) c+=16; /* this used to be " if (v[2]<0) ", see clippz() */ else if (v[2]> abs4) c+= 32; return c; @@ -1882,7 +1882,7 @@ void zbufclip(ZSpan *zspan, int obi, int zvlnr, float *f1, float *f2, float *f3, clippyra(labda[2], vlzp[v][2],vlzp[v][0], &b2,&b3, arg, zspan->clipcrop); if (b2==0 && b3==1) { - /* completely 'in', but we copy because of last for() loop in this section */; + /* completely 'in', but we copy because of last for () loop in this section */; vlzp[clvl][0]= vlzp[v][0]; vlzp[clvl][1]= vlzp[v][1]; vlzp[clvl][2]= vlzp[v][2]; |