code cleanup:

- define array sizes for functions that take vectors.
- quiet some -Wshadow warnings.
- some copy/paste error in readfile.c made it set the same particle recalc flag twice.
This commit is contained in:
2012-10-20 08:02:18 +00:00
parent 08dd8a6849
commit 9f8070d047
21 changed files with 105 additions and 82 deletions

View File

@@ -104,7 +104,7 @@ RayObject *RE_vlakprimitive_from_vlak(VlakPrimitive *face, struct ObjectInstance
void RE_rayobject_merge_bb(RayObject *ob, float *min, float *max);
/* initializes an hint for optimizing raycast where it is know that a ray will pass by the given BB often the origin point */
void RE_rayobject_hint_bb(RayObject *r, struct RayHint *hint, float *min, float *max);
void RE_rayobject_hint_bb(RayObject *r, struct RayHint *hint, float min[3], float max[3]);
/* initializes an hint for optimizing raycast where it is know that a ray will be contained inside the given cone*/
/* void RE_rayobject_hint_cone(RayObject *r, struct RayHint *hint, float *); */

View File

@@ -62,7 +62,7 @@ typedef struct PixStrMain {
/* ------------------------------------------------------------------------- */
void calc_view_vector(float *view, float x, float y);
void calc_view_vector(float view[3], float x, float y);
float mistfactor(float zcor, const float co[3]); /* dist and height, return alpha */
void renderspothalo(struct ShadeInput *shi, float col[4], float alpha);
@@ -95,5 +95,4 @@ extern void init_ao_sphere(struct World *wrld);
extern void init_render_qmcsampler(Render *re);
extern void free_render_qmcsampler(Render *re);
#endif /* RENDER_EXT_H */
#endif /* __RENDERCORE_H__ */

View File

@@ -88,7 +88,7 @@ void free_renderdata_vertnodes(struct VertTableNode *vertnodes);
void free_renderdata_vlaknodes(struct VlakTableNode *vlaknodes);
void project_renderdata(struct Render *re, void (*projectfunc)(const float *, float mat[][4], float *), int do_pano, float xoffs, int do_buckets);
int clip_render_object(float boundbox[][3], float *bounds, float mat[][4]);
int clip_render_object(float boundbox[][3], float bounds[4], float mat[][4]);
/* functions are not exported... so wrong names */

View File

@@ -467,7 +467,7 @@ float RE_rayobject_cost(RayObject *r)
/* Bounding Boxes */
void RE_rayobject_merge_bb(RayObject *r, float *min, float *max)
void RE_rayobject_merge_bb(RayObject *r, float min[3], float max[3])
{
if (RE_rayobject_isRayFace(r)) {
RayFace *face = (RayFace *) RE_rayobject_align(r);

View File

@@ -124,9 +124,9 @@ typedef int (*RE_rayobject_raycast_callback)(RayObject *, struct Isect *);
typedef void (*RE_rayobject_add_callback)(RayObject *raytree, RayObject *rayobject);
typedef void (*RE_rayobject_done_callback)(RayObject *);
typedef void (*RE_rayobject_free_callback)(RayObject *);
typedef void (*RE_rayobject_merge_bb_callback)(RayObject *, float *min, float *max);
typedef void (*RE_rayobject_merge_bb_callback)(RayObject *, float min[3], float max[3]);
typedef float (*RE_rayobject_cost_callback)(RayObject *);
typedef void (*RE_rayobject_hint_bb_callback)(RayObject *, struct RayHint *, float *, float *);
typedef void (*RE_rayobject_hint_bb_callback)(RayObject *, struct RayHint *, float min[3], float max[3]);
typedef struct RayObjectAPI {
RE_rayobject_raycast_callback raycast;
@@ -154,5 +154,4 @@ int RE_rayobject_intersect(RayObject *r, struct Isect *i);
}
#endif
#endif
#endif /* __RAYOBJECT_INTERNAL_H__ */

View File

@@ -193,7 +193,7 @@ static void rtbuild_calc_bb(RTBuilder *b)
}
}
void rtbuild_merge_bb(RTBuilder *b, float *min, float *max)
void rtbuild_merge_bb(RTBuilder *b, float min[3], float max[3])
{
rtbuild_calc_bb(b);
DO_MIN(b->bb, min);
@@ -457,26 +457,26 @@ static void split_leafs(RTBuilder *b, int *nth, int partitions, int split_axis)
/*
* Bounding Box utils
*/
float bb_volume(float *min, float *max)
float bb_volume(const float min[3], const float max[3])
{
return (max[0] - min[0]) * (max[1] - min[1]) * (max[2] - min[2]);
}
float bb_area(float *min, float *max)
float bb_area(const float min[3], const float max[3])
{
float sub[3], a;
sub[0] = max[0] - min[0];
sub[1] = max[1] - min[1];
sub[2] = max[2] - min[2];
a = (sub[0] * sub[1] + sub[0] * sub[2] + sub[1] * sub[2]) * 2;
a = (sub[0] * sub[1] + sub[0] * sub[2] + sub[1] * sub[2]) * 2.0f;
/* used to have an assert() here on negative results
* however, in this case its likely some overflow or ffast math error.
* so just return 0.0f instead. */
return a < 0.0f ? 0.0f : a;
}
int bb_largest_axis(float *min, float *max)
int bb_largest_axis(const float min[3], const float max[3])
{
float sub[3];
@@ -497,7 +497,9 @@ int bb_largest_axis(float *min, float *max)
}
}
int bb_fits_inside(float *outer_min, float *outer_max, float *inner_min, float *inner_max)
/* only returns 0 if merging inner and outerbox would create a box larger than outer box */
int bb_fits_inside(const float outer_min[3], const float outer_max[3],
const float inner_min[3], const float inner_max[3])
{
int i;
for (i = 0; i < 3; i++)

View File

@@ -86,7 +86,7 @@ RTBuilder *rtbuild_create(int size);
void rtbuild_free(RTBuilder *b);
void rtbuild_add(RTBuilder *b, RayObject *o);
void rtbuild_done(RTBuilder *b, RayObjectControl *c);
void rtbuild_merge_bb(RTBuilder *b, float *min, float *max);
void rtbuild_merge_bb(RTBuilder *b, float min[3], float max[3]);
int rtbuild_size(RTBuilder *b);
RayObject *rtbuild_get_primitive(RTBuilder *b, int offset);
@@ -109,13 +109,14 @@ int rtbuild_median_split_largest_axis(RTBuilder *b, int nchilds);
/* bb utils */
float bb_area(float *min, float *max);
float bb_volume(float *min, float *max);
int bb_largest_axis(float *min, float *max);
int bb_fits_inside(float *outer_min, float *outer_max, float *inner_min, float *inner_max); /* only returns 0 if merging inner and outerbox would create a box larger than outer box */
float bb_area(const float min[3], const float max[3]);
float bb_volume(const float min[3], const float max[3]);
int bb_largest_axis(const float min[3], const float max[3]);
int bb_fits_inside(const float outer_min[3], const float outer_max[3],
const float inner_min[3], const float inner_max[3]);
#ifdef __cplusplus
}
#endif
#endif
#endif /* __RAYOBJECT_RTBUILD_H__ */

View File

@@ -2532,7 +2532,7 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float shadfac[4])
#if 0
/* only when face points away from lamp, in direction of lamp, trace ray and find first exit point */
static void ray_translucent(ShadeInput *shi, LampRen *lar, float *distfac, float *co)
static void ray_translucent(ShadeInput *shi, LampRen *lar, float *distfac, float co[3])
{
Isect isec;
float lampco[3];

View File

@@ -1843,7 +1843,9 @@ static void ntap_bump_init(NTapBump *ntap_bump)
memset(ntap_bump, 0, sizeof(*ntap_bump));
}
static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres, float Tnor, float *co, float *dx, float *dy, float texvec[3], float dxt[3], float dyt[3])
static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres,
float Tnor, const float co[3], const float dx[3], const float dy[3],
float texvec[3], float dxt[3], float dyt[3])
{
TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; /* temp TexResult */
@@ -2269,11 +2271,11 @@ void do_material_tex(ShadeInput *shi, Render *re)
if (texres.nor && !((tex->type==TEX_IMAGE) && (tex->imaflag & TEX_NORMALMAP))) {
if (use_compat_bump) {
rgbnor = compatible_bump_compute(&compat_bump, shi, mtex, tex,
&texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt);
&texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt);
}
else if (use_ntap_bump) {
rgbnor = ntap_bump_compute(&ntap_bump, shi, mtex, tex,
&texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt);
&texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt);
}
else {
texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt);

View File

@@ -94,7 +94,7 @@ extern struct Render R;
/* x and y are current pixels in rect to be rendered */
/* do not normalize! */
void calc_view_vector(float *view, float x, float y)
void calc_view_vector(float view[3], float x, float y)
{
view[2]= -ABS(R.clipsta);

View File

@@ -1356,40 +1356,42 @@ void RE_makeRenderInstances(Render *re)
re->instancetable= newlist;
}
int clip_render_object(float boundbox[][3], float *bounds, float winmat[][4])
int clip_render_object(float boundbox[][3], float bounds[4], float winmat[][4])
{
float mat[4][4], vec[4];
int a, fl, flag= -1;
int a, fl, flag = -1;
copy_m4_m4(mat, winmat);
for (a=0; a<8; a++) {
for (a=0; a < 8; a++) {
vec[0]= (a & 1)? boundbox[0][0]: boundbox[1][0];
vec[1]= (a & 2)? boundbox[0][1]: boundbox[1][1];
vec[2]= (a & 4)? boundbox[0][2]: boundbox[1][2];
vec[3]= 1.0;
mul_m4_v4(mat, vec);
fl= 0;
fl = 0;
if (bounds) {
if (vec[0] < bounds[0]*vec[3]) fl |= 1;
else if (vec[0] > bounds[1]*vec[3]) fl |= 2;
if (vec[0] < bounds[0] * vec[3]) fl |= 1;
else if (vec[0] > bounds[1] * vec[3]) fl |= 2;
if (vec[1] > bounds[3]*vec[3]) fl |= 4;
else if (vec[1]< bounds[2]*vec[3]) fl |= 8;
if (vec[1] > bounds[3] * vec[3]) fl |= 4;
else if (vec[1] < bounds[2] * vec[3]) fl |= 8;
}
else {
if (vec[0] < -vec[3]) fl |= 1;
else if (vec[0] > vec[3]) fl |= 2;
if (vec[0] < -vec[3]) fl |= 1;
else if (vec[0] > vec[3]) fl |= 2;
if (vec[1] > vec[3]) fl |= 4;
if (vec[1] > vec[3]) fl |= 4;
else if (vec[1] < -vec[3]) fl |= 8;
}
if (vec[2] < -vec[3]) fl |= 16;
else if (vec[2] > vec[3]) fl |= 32;
if (vec[2] < -vec[3]) fl |= 16;
else if (vec[2] > vec[3]) fl |= 32;
flag &= fl;
if (flag==0) return 0;
if (flag == 0) {
return 0;
}
}
return flag;

View File

@@ -381,7 +381,7 @@ static void add_radiance(ScatterTree *tree, float *frontrad, float *backrad, flo
}
}
static void traverse_octree(ScatterTree *tree, ScatterNode *node, float *co, int self, ScatterResult *result)
static void traverse_octree(ScatterTree *tree, ScatterNode *node, const float co[3], int self, ScatterResult *result)
{
float sub[3], dist;
int i, index = 0;
@@ -432,7 +432,7 @@ static void traverse_octree(ScatterTree *tree, ScatterNode *node, float *co, int
}
}
static void compute_radiance(ScatterTree *tree, float *co, float *rad)
static void compute_radiance(ScatterTree *tree, const float co[3], float *rad)
{
ScatterResult result;
float rdsum[3], backrad[3], backrdsum[3];