diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-09-12 17:00:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-09-12 17:00:24 +0400 |
commit | e16ba13251701a9845adf702e60be3f2fad724bd (patch) | |
tree | 8ab57f007a995b4928410cfacda18a5c4538fc9d /source/blender/render/intern/source/shadbuf.c | |
parent | 4a9a0ec3e45c3870771e8dd44c62a05cf0d4d2d1 (diff) |
use vector size and const args where possible (no functional change)
Diffstat (limited to 'source/blender/render/intern/source/shadbuf.c')
-rw-r--r-- | source/blender/render/intern/source/shadbuf.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index 5860c395b07..e4b2a0cf1d1 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -1099,7 +1099,7 @@ static float readshadowbuf(ShadBuf *shb, ShadSampleBuf *shsample, int bias, int } } -static void shadowbuf_project_co(float *x, float *y, float *z, ShadBuf *shb, float co[3]) +static void shadowbuf_project_co(float *x, float *y, float *z, ShadBuf *shb, const float co[3]) { float hco[4], size= 0.5f*(float)shb->size; @@ -1115,7 +1115,7 @@ static void shadowbuf_project_co(float *x, float *y, float *z, ShadBuf *shb, flo /* the externally called shadow testing (reading) function */ /* return 1.0: no shadow at all */ -float testshadowbuf(Render *re, ShadBuf *shb, float *co, float *dxco, float *dyco, float inp, float mat_bias) +float testshadowbuf(Render *re, ShadBuf *shb, const float co[3], const float dxco[3], const float dyco[3], float inp, float mat_bias) { ShadSampleBuf *shsample; float fac, dco[3], dx[3], dy[3], shadfac=0.0f; @@ -1291,7 +1291,7 @@ static float readshadowbuf_halo(ShadBuf *shb, ShadSampleBuf *shsample, int xs, i } -float shadow_halo(LampRen *lar, float *p1, float *p2) +float shadow_halo(LampRen *lar, const float p1[3], const float p2[3]) { /* p1 p2 already are rotated in spot-space */ ShadBuf *shb= lar->shb; @@ -1469,7 +1469,7 @@ static void init_box(Boxf *box) } /* use v1 to calculate boundbox */ -static void bound_boxf(Boxf *box, float *v1) +static void bound_boxf(Boxf *box, const float v1[3]) { if(v1[0] < box->xmin) box->xmin= v1[0]; if(v1[0] > box->xmax) box->xmax= v1[0]; @@ -1480,7 +1480,7 @@ static void bound_boxf(Boxf *box, float *v1) } /* use v1 to calculate boundbox */ -static void bound_rectf(rctf *box, float *v1) +static void bound_rectf(rctf *box, const float v1[2]) { if(v1[0] < box->xmin) box->xmin= v1[0]; if(v1[0] > box->xmax) box->xmax= v1[0]; @@ -1639,24 +1639,17 @@ static int isb_bsp_insert(ISBBranch *root, MemArena *memarena, ISBSample *sample return 0; } -static float VecLen2f( float *v1, float *v2) -{ - float x= v1[0]-v2[0]; - float y= v1[1]-v2[1]; - return (float)sqrt(x*x+y*y); -} - /* initialize vars in face, for optimal point-in-face test */ static void bspface_init_strand(BSPFace *face) { - face->radline= 0.5f*VecLen2f(face->v1, face->v2); + face->radline= 0.5f* len_v2v2(face->v1, face->v2); mid_v3_v3v3(face->vec1, face->v1, face->v2); if(face->v4) mid_v3_v3v3(face->vec2, face->v3, face->v4); else - VECCOPY(face->vec2, face->v3); + copy_v3_v3(face->vec2, face->v3); face->rc[0]= face->vec2[0]-face->vec1[0]; face->rc[1]= face->vec2[1]-face->vec1[1]; @@ -1671,7 +1664,7 @@ static void bspface_init_strand(BSPFace *face) } /* brought back to a simple 2d case */ -static int point_behind_strand(float *p, BSPFace *face) +static int point_behind_strand(const float p[3], BSPFace *face) { /* v1 - v2 is radius, v1 - v3 length */ float dist, rc[2], pt[2]; @@ -1712,7 +1705,7 @@ static int point_behind_strand(float *p, BSPFace *face) /* return 1 if inside. code derived from src/parametrizer.c */ -static int point_behind_tria2d(float *p, float *v1, float *v2, float *v3) +static int point_behind_tria2d(const float p[3], const float v1[3], const float v2[3], const float v3[3]) { float a[2], c[2], h[2], div; float u, v; @@ -1751,7 +1744,7 @@ static int point_behind_tria2d(float *p, float *v1, float *v2, float *v3) /* tested these calls, but it gives inaccuracy, 'side' cannot be found reliably using v3 */ /* check if line v1-v2 has all rect points on other side of point v3 */ -static int rect_outside_line(rctf *rect, float *v1, float *v2, float *v3) +static int rect_outside_line(rctf *rect, const float v1[3], const float v2[3], const float v3[3]) { float a, b, c; int side; @@ -1772,7 +1765,7 @@ static int rect_outside_line(rctf *rect, float *v1, float *v2, float *v3) } /* check if one of the triangle edges separates all rect points on 1 side */ -static int rect_isect_tria(rctf *rect, float *v1, float *v2, float *v3) +static int rect_isect_tria(rctf *rect, const float v1[3], const float v2[3], const float v3[3]) { if(rect_outside_line(rect, v1, v2, v3)) return 0; @@ -1935,7 +1928,7 @@ static void isb_bsp_test_face(ZSpan *zspan, int obi, int zvlnr, float *v1, float isb_bsp_face_inside((ISBBranch *)zspan->rectz, &face); } -static int testclip_minmax(float *ho, float *minmax) +static int testclip_minmax(const float ho[4], const float minmax[4]) { float wco= ho[3]; int flag= 0; @@ -2064,7 +2057,7 @@ static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root) } /* returns 1 when the viewpixel is visible in lampbuffer */ -static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *vlr, float x, float y, float *co) +static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *vlr, float x, float y, float co_r[3]) { float hoco[4], v1[3], nor[3]; float dface, fac, siz; @@ -2123,12 +2116,12 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v return 0; siz= 0.5f*(float)shb->size; - co[0]= siz*(1.0f+hoco[0]/hoco[3]) -0.5f; - co[1]= siz*(1.0f+hoco[1]/hoco[3]) -0.5f; - co[2]= ((float)0x7FFFFFFF)*(hoco[2]/hoco[3]); + co_r[0]= siz*(1.0f+hoco[0]/hoco[3]) -0.5f; + co_r[1]= siz*(1.0f+hoco[1]/hoco[3]) -0.5f; + co_r[2]= ((float)0x7FFFFFFF)*(hoco[2]/hoco[3]); /* XXXX bias, much less than normal shadbuf, or do we need a constant? */ - co[2] -= 0.05f*shb->bias; + co_r[2] -= 0.05f*shb->bias; return 1; } |