code cleanup: use array size and const for vector args

This commit is contained in:
Campbell Barton 2012-05-26 16:04:31 +00:00
parent ae919658d4
commit de6af75d4d
18 changed files with 56 additions and 56 deletions

View File

@ -114,7 +114,7 @@ LIBIMPORT void IMB_rectcpy(struct ImBuf *dbuf, struct ImBuf *sbuf,
int destx, int desty, int srcx, int srcy, int width, int height);
LIBIMPORT void IMB_rectfill(struct ImBuf *drect, const float col[4]);
LIBIMPORT void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2);
LIBIMPORT void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2);
LIBIMPORT void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], int x1, int y1, int x2, int y2);
LIBIMPORT void IMB_rectfill_alpha(struct ImBuf *drect, const float value);

View File

@ -380,7 +380,7 @@ static BMFace *edge_ray_cast(BMBVHTree *tree, float *co, float *dir, float *hito
return f;
}
static void scale_point(float *c1, float *p, float s)
static void scale_point(float c1[3], const float p[3], const float s)
{
sub_v3_v3(c1, p);
mul_v3_fl(c1, s);

View File

@ -146,7 +146,7 @@ static int intersect_edges(float *points, float a, float b, float c, float d, fl
return numpoints;
}
static int convex(float *p0, float *up, float *a, float *b)
static int convex(const float p0[3], const float up[3], const float a[3], const float b[3])
{
// Vec3 va = a-p0, vb = b-p0;
float va[3], vb[3], tmp[3];

View File

@ -3596,7 +3596,7 @@ typedef struct SmoothNode {
int axis, ntri;
} SmoothNode;
static void p_barycentric_2d(float *v1, float *v2, float *v3, float *p, float *b)
static void p_barycentric_2d(const float v1[2], const float v2[2], const float v3[2], float p[2], float b[2])
{
float a[2], c[2], h[2], div;

View File

@ -480,7 +480,7 @@ void IMB_freezbuffloatImBuf(struct ImBuf *ibuf);
* \attention Defined in rectop.c
*/
void IMB_rectfill(struct ImBuf *drect, const float col[4]);
void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2);
void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2);
void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value);
/* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */

View File

@ -566,7 +566,7 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height,
}
}
void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2)
void IMB_rectfill_area(struct ImBuf *ibuf, const float col[4], int x1, int y1, int x2, int y2)
{
if (!ibuf) return;
buf_rectfill_area((unsigned char *) ibuf->rect, ibuf->rect_float, ibuf->x, ibuf->y, col, x1, y1, x2, y2);

View File

@ -36,30 +36,30 @@
* add 1 pixel to into filtered three lines
* (float vecs to float vec)
*/
void add_filt_fmask(unsigned int mask, float *col, float *rowbuf, int row_w);
void add_filt_fmask(unsigned int mask, const float col[4], float *rowbuf, int row_w);
void add_filt_fmask_pixsize(unsigned int mask, float *in, float *rowbuf, int row_w, int pixsize);
void add_filt_fmask_coord(float filt[][3], float *col, float *rowbuf, int row_w, int col_h, int x, int y);
void add_filt_fmask_coord(float filt[][3], const float col[4], float *rowbuf, int row_w, int col_h, int x, int y);
void mask_array(unsigned int mask, float filt[][3]);
/**
* Alpha-over blending for floats.
*/
void addAlphaOverFloat(float *dest, float *source);
void addAlphaOverFloat(float dest[4], const float source[4]);
/**
* Alpha-under blending for floats.
*/
void addAlphaUnderFloat(float *dest, float *source);
void addAlphaUnderFloat(float dest[4], const float source[4]);
/**
* Same for floats
*/
void addalphaAddfacFloat(float *dest, float *source, char addfac);
void addalphaAddfacFloat(float dest[4], const float source[4], char addfac);
/**
* dest = dest + source
*/
void addalphaAddFloat(float *dest, float *source);
void addalphaAddFloat(float dest[4], const float source[4]);
#endif /* __PIXELBLENDING_H__ */

View File

@ -96,7 +96,7 @@ ListBase *get_lights(struct ShadeInput *shi);
float lamp_get_visibility(struct LampRen *lar, const float co[3], float lv[3], float *dist);
void lamp_get_shadow(struct LampRen *lar, ShadeInput *shi, float inp, float shadfac[4], int do_real);
float fresnel_fac(float *view, float *vn, float fresnel, float fac);
float fresnel_fac(const float view[3], const float vn[3], float fresnel, float fac);
/* rayshade.c */
extern void shade_ray(struct Isect *is, struct ShadeInput *shi, struct ShadeResult *shr);

View File

@ -42,13 +42,13 @@ struct ScatterTree;
typedef struct ScatterTree ScatterTree;
ScatterSettings *scatter_settings_new(float refl, float radius, float ior,
float reflfac, float frontweight, float backweight);
float reflfac, float frontweight, float backweight);
void scatter_settings_free(ScatterSettings *ss);
ScatterTree *scatter_tree_new(ScatterSettings *ss[3], float scale, float error,
float (*co)[3], float (*color)[3], float *area, int totpoint);
float (*co)[3], float (*color)[3], float *area, int totpoint);
void scatter_tree_build(ScatterTree *tree);
void scatter_tree_sample(ScatterTree *tree, float *co, float *color);
void scatter_tree_sample(ScatterTree *tree, const float co[3], float color[3]);
void scatter_tree_free(ScatterTree *tree);
/* Internal renderer API */
@ -61,7 +61,7 @@ void make_sss_tree(struct Render *re);
void sss_add_points(Render *re, float (*co)[3], float (*color)[3], float *area, int totpoint);
void free_sss(struct Render *re);
int sample_sss(struct Render *re, struct Material *mat, float *co, float *col);
int sample_sss(struct Render *re, struct Material *mat, const float co[3], float color[3]);
int sss_pass_done(struct Render *re, struct Material *mat);
#endif /*__SSS_H__*/

View File

@ -67,7 +67,7 @@ void do_halo_tex(struct HaloRen *har, float xn, float yn, float col_r[4]);
void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float hor[3], float zen[3], float *blend, int skyflag, short thread);
void do_material_tex(struct ShadeInput *shi, struct Render *re);
void do_lamp_tex(LampRen *la, const float lavec[3], struct ShadeInput *shi, float col_r[3], int effect);
void do_volume_tex(struct ShadeInput *shi, const float xyz[3], int mapto_flag, float col[3], float *val, struct Render *re);
void do_volume_tex(struct ShadeInput *shi, const float xyz[3], int mapto_flag, float col_r[3], float *val, struct Render *re);
void init_render_textures(Render *re);
void end_render_textures(Render *re);

View File

@ -76,7 +76,7 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max
/* x and y have to be checked for image size */
static void ibuf_get_color(float *col, struct ImBuf *ibuf, int x, int y)
static void ibuf_get_color(float col[4], struct ImBuf *ibuf, int x, int y)
{
int ofs = y * ibuf->x + x;
@ -637,7 +637,7 @@ enum {TXC_XMIR=1, TXC_YMIR, TXC_REPT, TXC_EXTD};
// similar to ibuf_get_color() but clips/wraps coords according to repeat/extend flags
// returns true if out of range in clipmode
static int ibuf_get_color_clip(float *col, ImBuf *ibuf, int x, int y, int extflag)
static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extflag)
{
int clip = 0;
switch (extflag) {
@ -695,7 +695,7 @@ static int ibuf_get_color_clip(float *col, ImBuf *ibuf, int x, int y, int extfla
}
// as above + bilerp
static int ibuf_get_color_clip_bilerp(float *col, ImBuf *ibuf, float u, float v, int intpol, int extflag)
static int ibuf_get_color_clip_bilerp(float col[4], ImBuf *ibuf, float u, float v, int intpol, int extflag)
{
if (intpol) {
float c00[4], c01[4], c10[4], c11[4];

View File

@ -73,7 +73,7 @@ extern struct Render R;
/* ------------------------------------------------------------------------- */
void addAlphaOverFloat(float *dest, float *source)
void addAlphaOverFloat(float dest[4], const float source[4])
{
/* d = s + (1-alpha_s)d*/
float mul;
@ -90,7 +90,7 @@ void addAlphaOverFloat(float *dest, float *source)
/* ------------------------------------------------------------------------- */
void addAlphaUnderFloat(float *dest, float *source)
void addAlphaUnderFloat(float dest[4], const float source[4])
{
float mul;
@ -104,7 +104,7 @@ void addAlphaUnderFloat(float *dest, float *source)
/* ------------------------------------------------------------------------- */
void addalphaAddfacFloat(float *dest, float *source, char addfac)
void addalphaAddfacFloat(float dest[4], const float source[4], char addfac)
{
float m; /* weiging factor of destination */
float c; /* intermediate color */
@ -148,7 +148,7 @@ void addalphaAddfacFloat(float *dest, float *source, char addfac)
/* ------------------------------------------------------------------------- */
/* filtered adding to scanlines */
void add_filt_fmask(unsigned int mask, float *col, float *rowbuf, int row_w)
void add_filt_fmask(unsigned int mask, const float col[4], float *rowbuf, int row_w)
{
/* calc the value of mask */
float **fmask1= R.samples->fmask1, **fmask2=R.samples->fmask2;
@ -242,7 +242,7 @@ void mask_array(unsigned int mask, float filt[][3])
* --- --- ---
*/
void add_filt_fmask_coord(float filt[][3], float *col, float *rowbuf, int row_w, int col_h, int x, int y)
void add_filt_fmask_coord(float filt[][3], const float col[4], float *rowbuf, int row_w, int col_h, int x, int y)
{
float *fpoin[3][3];
float val, r, g, b, al, lfilt[3][3];
@ -366,7 +366,7 @@ void add_filt_fmask_pixsize(unsigned int mask, float *in, float *rowbuf, int row
}
/* ------------------------------------------------------------------------- */
void addalphaAddFloat(float *dest, float *source)
void addalphaAddFloat(float dest[4], const float source[4])
{
/* Makes me wonder whether this is required... */

View File

@ -280,8 +280,8 @@ static float haloZtoDist(int z)
* \param xn The x coordinate of the pixel relaticve to the center of the halo. given in pixels
* \param yn The y coordinate of the pixel relaticve to the center of the halo. given in pixels
*/
int shadeHaloFloat(HaloRen *har, float *col, int zz,
float dist, float xn, float yn, short flarec)
int shadeHaloFloat(HaloRen *har, float col[4], int zz,
float dist, float xn, float yn, short flarec)
{
/* fill in col */
float t, zn, radist, ringf=0.0f, linef=0.0f, alpha, si, co;

View File

@ -604,7 +604,7 @@ static void reflection(float ref[3], float n[3], const float view[3], const floa
}
#if 0
static void color_combine(float *result, float fac1, float fac2, float *col1, float *col2)
static void color_combine(float *result, float fac1, float fac2, float col1[3], float col2[3])
{
float col1t[3], col2t[3];

View File

@ -814,7 +814,7 @@ static int plugintex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex
}
static int cubemap_glob(float *n, float x, float y, float z, float *adr1, float *adr2)
static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1, float *adr2)
{
float x1, y1, z1, nor[3];
int ret;
@ -852,7 +852,7 @@ static int cubemap_glob(float *n, float x, float y, float z, float *adr1, float
/* ------------------------------------------------------------------------- */
/* mtex argument only for projection switches */
static int cubemap(MTex *mtex, VlakRen *vlr, float *n, float x, float y, float z, float *adr1, float *adr2)
static int cubemap(MTex *mtex, VlakRen *vlr, const float n[3], float x, float y, float z, float *adr1, float *adr2)
{
int proj[4]={0, ME_PROJXY, ME_PROJXZ, ME_PROJYZ}, ret= 0;
@ -910,7 +910,7 @@ static int cubemap(MTex *mtex, VlakRen *vlr, float *n, float x, float y, float z
/* ------------------------------------------------------------------------- */
static int cubemap_ob(Object *ob, float *n, float x, float y, float z, float *adr1, float *adr2)
static int cubemap_ob(Object *ob, const float n[3], float x, float y, float z, float *adr1, float *adr2)
{
float x1, y1, z1, nor[3];
int ret;
@ -944,7 +944,7 @@ static int cubemap_ob(Object *ob, float *n, float x, float y, float z, float *ad
/* ------------------------------------------------------------------------- */
static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *n, float *dxt, float *dyt)
static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3], float *dxt, float *dyt)
{
Tex *tex;
Object *ob= NULL;
@ -2690,7 +2690,7 @@ void do_material_tex(ShadeInput *shi, Render *re)
}
void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float *col, float *val, Render *re)
void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_r[3], float *val, Render *re)
{
MTex *mtex;
Tex *tex;
@ -2811,17 +2811,17 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float *col
/* used for emit */
if ((mapto_flag & MAP_EMISSION_COL) && (mtex->mapto & MAP_EMISSION_COL)) {
float colemitfac= mtex->colemitfac*stencilTin;
texture_rgb_blend(col, tcol, col, texres.tin, colemitfac, mtex->blendtype);
texture_rgb_blend(col_r, tcol, col_r, texres.tin, colemitfac, mtex->blendtype);
}
if ((mapto_flag & MAP_REFLECTION_COL) && (mtex->mapto & MAP_REFLECTION_COL)) {
float colreflfac= mtex->colreflfac*stencilTin;
texture_rgb_blend(col, tcol, col, texres.tin, colreflfac, mtex->blendtype);
texture_rgb_blend(col_r, tcol, col_r, texres.tin, colreflfac, mtex->blendtype);
}
if ((mapto_flag & MAP_TRANSMISSION_COL) && (mtex->mapto & MAP_TRANSMISSION_COL)) {
float coltransfac= mtex->coltransfac*stencilTin;
texture_rgb_blend(col, tcol, col, texres.tin, coltransfac, mtex->blendtype);
texture_rgb_blend(col_r, tcol, col_r, texres.tin, coltransfac, mtex->blendtype);
}
}
@ -3508,7 +3508,7 @@ void render_realtime_texture(ShadeInput *shi, Image *ima)
/* A modified part of shadeinput.c -> shade_input_set_uv()
* Used for sampling UV mapped texture color */
static void textured_face_generate_uv(float *uv, float *normal, float *hit, float *v1, float *v2, float *v3)
static void textured_face_generate_uv(float *uv, const float normal[3], float *hit, float *v1, float *v2, float *v3)
{
float detsh, t00, t10, t01, t11;

View File

@ -1509,7 +1509,7 @@ static void addps_sss(void *cb_handle, int obi, int facenr, int x, int y, int z)
}
}
static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRen *obi, VlakRen *vlr, int quad, float x, float y, float z, float *co, float *color, float *area)
static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRen *obi, VlakRen *vlr, int quad, float x, float y, float z, float *co, float color[3], float *area)
{
ShadeInput *shi= ssamp->shi;
ShadeResult shr;

View File

@ -77,7 +77,7 @@ ListBase *get_lights(ShadeInput *shi)
}
#if 0
static void fogcolor(float *colf, float *rco, float *view)
static void fogcolor(const float colf[3], float *rco, float *view)
{
float alpha, stepsize, startdist, dist, hor[4], zen[3], vec[3], dview[3];
float div=0.0f, distfac;
@ -408,13 +408,13 @@ static double Normalize_d(double *n)
}
/* mix of 'real' fresnel and allowing control. grad defines blending gradient */
float fresnel_fac(float *view, float *vn, float grad, float fac)
float fresnel_fac(const float view[3], const float vn[3], float grad, float fac)
{
float t1, t2;
if (fac==0.0f) return 1.0f;
t1= (view[0]*vn[0] + view[1]*vn[1] + view[2]*vn[2]);
t1 = dot_v3v3(view, vn);
if (t1>0.0f) t2= 1.0f+t1;
else t2= 1.0f-t1;
@ -433,7 +433,7 @@ static double saacos_d(double fac)
}
/* Stoke's form factor. Need doubles here for extreme small area sizes */
static float area_lamp_energy(float (*area)[3], float *co, float *vn)
static float area_lamp_energy(float (*area)[3], const float co[3], const float vn[3])
{
double fac;
double vec[4][3]; /* vectors of rendered co to vertices lamp */
@ -482,7 +482,7 @@ static float area_lamp_energy(float (*area)[3], float *co, float *vn)
return fac;
}
static float area_lamp_energy_multisample(LampRen *lar, float *co, float *vn)
static float area_lamp_energy_multisample(LampRen *lar, const float co[3], float *vn)
{
/* corner vectors are moved around according lamp jitter */
float *jitlamp= lar->jitter, vec[3];
@ -554,7 +554,7 @@ static float spec(float inp, int hard)
return inp;
}
static float Phong_Spec(float *n, float *l, float *v, int hard, int tangent )
static float Phong_Spec(const float n[3], const float l[3], const float v[3], int hard, int tangent )
{
float h[3];
float rslt;
@ -575,7 +575,7 @@ static float Phong_Spec(float *n, float *l, float *v, int hard, int tangent )
/* reduced cook torrance spec (for off-specular peak) */
static float CookTorr_Spec(float *n, float *l, float *v, int hard, int tangent)
static float CookTorr_Spec(const float n[3], const float l[3], const float v[3], int hard, int tangent)
{
float i, nh, nv, h[3];
@ -599,7 +599,7 @@ static float CookTorr_Spec(float *n, float *l, float *v, int hard, int tangent)
}
/* Blinn spec */
static float Blinn_Spec(float *n, float *l, float *v, float refrac, float spec_power, int tangent)
static float Blinn_Spec(const float n[3], const float l[3], const float v[3], float refrac, float spec_power, int tangent)
{
float i, nh, nv, nl, vh, h[3];
float a, b, c, g=0.0f, p, f, ang;
@ -653,7 +653,7 @@ static float Blinn_Spec(float *n, float *l, float *v, float refrac, float spec_p
}
/* cartoon render spec */
static float Toon_Spec(float *n, float *l, float *v, float size, float smooth, int tangent)
static float Toon_Spec(const float n[3], const float l[3], const float v[3], float size, float smooth, int tangent)
{
float h[3];
float ang;
@ -677,7 +677,7 @@ static float Toon_Spec(float *n, float *l, float *v, float size, float smooth, i
}
/* Ward isotropic gaussian spec */
static float WardIso_Spec(float *n, float *l, float *v, float rms, int tangent)
static float WardIso_Spec(const float n[3], const float l[3], const float v[3], float rms, int tangent)
{
float i, nh, nv, nl, h[3], angle, alpha;
@ -709,7 +709,7 @@ static float WardIso_Spec(float *n, float *l, float *v, float rms, int tangent)
}
/* cartoon render diffuse */
static float Toon_Diff(float *n, float *l, float *UNUSED(v), float size, float smooth)
static float Toon_Diff(const float n[3], const float l[3], const float UNUSED(v[3]), float size, float smooth)
{
float rslt, ang;
@ -728,7 +728,7 @@ static float Toon_Diff(float *n, float *l, float *UNUSED(v), float size, float s
/* 'nl' is either dot product, or return value of area light */
/* in latter case, only last multiplication uses 'nl' */
static float OrenNayar_Diff(float nl, float *n, float *l, float *v, float rough )
static float OrenNayar_Diff(float nl, const float n[3], const float l[3], const float v[3], float rough )
{
float i/*, nh*/, nv /*, vh */, realnl, h[3];
float a, b, t, A, B;
@ -788,7 +788,7 @@ static float OrenNayar_Diff(float nl, float *n, float *l, float *v, float rough
}
/* Minnaert diffuse */
static float Minnaert_Diff(float nl, float *n, float *v, float darkness)
static float Minnaert_Diff(float nl, const float n[3], const float v[3], float darkness)
{
float i, nv;

View File

@ -810,12 +810,12 @@ void scatter_tree_build(ScatterTree *tree)
sum_radiance(tree, tree->root);
}
void scatter_tree_sample(ScatterTree *tree, float *co, float *color)
void scatter_tree_sample(ScatterTree *tree, const float co[3], float color[3])
{
float sco[3];
copy_v3_v3(sco, co);
mul_v3_fl(sco, 1.0f/tree->scale);
mul_v3_fl(sco, 1.0f / tree->scale);
compute_radiance(tree, sco, color);
}
@ -1025,7 +1025,7 @@ void free_sss(Render *re)
}
}
int sample_sss(Render *re, Material *mat, float *co, float *color)
int sample_sss(Render *re, Material *mat, const float co[3], float color[3])
{
if (re->sss_hash) {
SSSData *sss= BLI_ghash_lookup(re->sss_hash, mat);