code cleanup: minor improvements to float/vector usage.
This commit is contained in:
parent
a88f910b9a
commit
145289ad95
|
@ -777,7 +777,7 @@ static float *_face_getIFNoEdge(CCGFace *f, CCGEdge *e, int f_ed_idx, int lvl, i
|
|||
{
|
||||
return (float *) ((byte *) _face_getIFCoEdge(f, e, f_ed_idx, lvl, eX, eY, levels, dataSize) + normalDataOffset);
|
||||
}
|
||||
static void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no, int levels, int dataSize)
|
||||
static void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float no[3], int levels, int dataSize)
|
||||
{
|
||||
float *a = _face_getIFCo(f, lvl, S, x + 0, y + 0, levels, dataSize);
|
||||
float *b = _face_getIFCo(f, lvl, S, x + 1, y + 0, levels, dataSize);
|
||||
|
|
|
@ -2541,7 +2541,7 @@ int get_selected_defgroups(Object *ob, char *dg_selection, int defbase_tot)
|
|||
}
|
||||
|
||||
/************** Bounding box ********************/
|
||||
int minmax_armature(Object *ob, float min[3], float max[3])
|
||||
static int minmax_armature(Object *ob, float min[3], float max[3])
|
||||
{
|
||||
bPoseChannel *pchan;
|
||||
|
||||
|
@ -2554,7 +2554,7 @@ int minmax_armature(Object *ob, float min[3], float max[3])
|
|||
return (ob->pose->chanbase.first != NULL);
|
||||
}
|
||||
|
||||
void boundbox_armature(Object *ob, float *loc, float *size)
|
||||
static void boundbox_armature(Object *ob, float loc[3], float size[3])
|
||||
{
|
||||
BoundBox *bb;
|
||||
float min[3], max[3];
|
||||
|
|
|
@ -961,7 +961,7 @@ static int basis_cross(int n, int m)
|
|||
}
|
||||
}
|
||||
|
||||
static void vectomat(float *vec, float *target_up, short axis, short upflag, short flags, float m[][3])
|
||||
static void vectomat(const float vec[3], const float target_up[3], short axis, short upflag, short flags, float m[][3])
|
||||
{
|
||||
float n[3];
|
||||
float u[3]; /* vector specifying the up axis */
|
||||
|
|
|
@ -588,7 +588,7 @@ void BKE_nurb_test2D(Nurb *nu)
|
|||
}
|
||||
}
|
||||
|
||||
void BKE_nurb_minmax(Nurb *nu, float *min, float *max)
|
||||
void BKE_nurb_minmax(Nurb *nu, float min[3], float max[3])
|
||||
{
|
||||
BezTriple *bezt;
|
||||
BPoint *bp;
|
||||
|
@ -1166,19 +1166,23 @@ void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float
|
|||
}
|
||||
}
|
||||
|
||||
static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float *p3, float *p, int it, int stride)
|
||||
static void forward_diff_bezier_cotangent(const float p0[3], const float p1[3], const float p2[3], const float p3[3],
|
||||
float p[3], int it, int stride)
|
||||
{
|
||||
/* note that these are not purpendicular to the curve
|
||||
* they need to be rotated for this,
|
||||
*
|
||||
* This could also be optimized like forward_diff_bezier */
|
||||
* This could also be optimized like BKE_curve_forward_diff_bezier */
|
||||
int a;
|
||||
for (a = 0; a <= it; a++) {
|
||||
float t = (float)a / (float)it;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 3; i++) {
|
||||
p[i] = (-6 * t + 6) * p0[i] + (18 * t - 12) * p1[i] + (-18 * t + 6) * p2[i] + (6 * t) * p3[i];
|
||||
p[i] = (-6.0f * t + 6.0f) * p0[i] +
|
||||
( 18.0f * t - 12.0f) * p1[i] +
|
||||
(-18.0f * t + 6.0f) * p2[i] +
|
||||
( 6.0f * t) * p3[i];
|
||||
}
|
||||
normalize_v3(p);
|
||||
p = (float *)(((char *)p) + stride);
|
||||
|
|
|
@ -424,7 +424,7 @@ static int surface_totalSamples(DynamicPaintSurface *surface)
|
|||
return surface->data->total_points;
|
||||
}
|
||||
|
||||
static void blendColors(float t_color[3], float t_alpha, float s_color[3], float s_alpha, float result[4])
|
||||
static void blendColors(const float t_color[3], float t_alpha, const float s_color[3], float s_alpha, float result[4])
|
||||
{
|
||||
int i;
|
||||
float i_alpha = 1.0f - s_alpha;
|
||||
|
@ -2842,7 +2842,8 @@ static void mesh_faces_nearest_point_dp(void *userdata, int index, const float c
|
|||
* timescale : value used to adjust time dependand
|
||||
* operations when using substeps
|
||||
*/
|
||||
static void dynamicPaint_mixPaintColors(DynamicPaintSurface *surface, int index, int paintFlags, float *paintColor, float *paintAlpha, float *paintWetness, float *timescale)
|
||||
static void dynamicPaint_mixPaintColors(DynamicPaintSurface *surface, int index, int paintFlags,
|
||||
const float paintColor[3], float *paintAlpha, float *paintWetness, float *timescale)
|
||||
{
|
||||
PaintPoint *pPoint = &((PaintPoint *)surface->data->type_data)[index];
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ void BLI_calcGraphLength(BGraph *graph);
|
|||
void BLI_replaceNode(BGraph *graph, BNode *node_src, BNode *node_replaced);
|
||||
void BLI_replaceNodeInArc(BGraph *graph, BArc *arc, BNode *node_src, BNode *node_replaced);
|
||||
void BLI_removeDoubleNodes(BGraph *graph, float limit);
|
||||
BNode *BLI_FindNodeByPosition(BGraph *graph, float *p, float limit);
|
||||
BNode *BLI_FindNodeByPosition(BGraph *graph, const float p[3], const float limit);
|
||||
|
||||
BArc *BLI_findConnectedArc(BGraph *graph, BArc *arc, BNode *v);
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ void BLI_removeDoubleNodes(BGraph *graph, float limit)
|
|||
|
||||
}
|
||||
|
||||
BNode *BLI_FindNodeByPosition(BGraph *graph, float *p, float limit)
|
||||
BNode *BLI_FindNodeByPosition(BGraph *graph, const float p[3], const float limit)
|
||||
{
|
||||
BNode *closest_node = NULL, *node;
|
||||
float min_distance = 0.0f;
|
||||
|
|
|
@ -195,7 +195,7 @@ static int BME_bevel_is_split_vert(BMesh *bm, BMLoop *l)
|
|||
* the bevel operation as a whole based on the relationship between v1 and v2
|
||||
* (won't necessarily be a vec from v1->co to v2->co, though it probably will be);
|
||||
* the return value is -1 for failure, 0 if we used vert co's, and 1 if we used transform origins */
|
||||
static int BME_bevel_get_vec(float *vec, BMVert *v1, BMVert *v2, BME_TransData_Head *td)
|
||||
static int BME_bevel_get_vec(float vec[3], BMVert *v1, BMVert *v2, BME_TransData_Head *td)
|
||||
{
|
||||
BME_TransData *vtd1, *vtd2;
|
||||
|
||||
|
|
|
@ -201,12 +201,13 @@ void BMBVH_FreeBVH(BMBVHTree *tree)
|
|||
}
|
||||
|
||||
/* taken from bvhutils.c */
|
||||
static float ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_dist), float *v0,
|
||||
float *v1, float *v2, float *uv, float UNUSED(e))
|
||||
static float ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_dist),
|
||||
const float v0[3], const float v1[3], const float v2[3],
|
||||
float r_uv[2], float UNUSED(e))
|
||||
{
|
||||
float dist;
|
||||
|
||||
if (isect_ray_tri_v3((float *)ray->origin, (float *)ray->direction, v0, v1, v2, &dist, uv)) {
|
||||
if (isect_ray_tri_v3((float *)ray->origin, (float *)ray->direction, v0, v1, v2, &dist, r_uv)) {
|
||||
return dist;
|
||||
}
|
||||
|
||||
|
@ -343,7 +344,7 @@ BMVert *BMBVH_FindClosestVert(BMBVHTree *tree, float *co, float maxdist)
|
|||
|
||||
/* UNUSED */
|
||||
#if 0
|
||||
static short winding(float *v1, float *v2, float *v3)
|
||||
static short winding(const float v1[3], const float v2[3], const float v3[3])
|
||||
/* is v3 to the right of (v1 - v2) ? With exception: v3 == v1 || v3 == v2 */
|
||||
{
|
||||
double inp;
|
||||
|
|
|
@ -3769,7 +3769,7 @@ static void do_projectpaint_smear_f(ProjPaintState *ps, ProjPixel *projPixel, fl
|
|||
BLI_linklist_prepend_arena(smearPixels_f, (void *)projPixel, smearArena);
|
||||
}
|
||||
|
||||
static void do_projectpaint_draw(ProjPaintState *ps, ProjPixel *projPixel, float *rgba, float alpha, float mask)
|
||||
static void do_projectpaint_draw(ProjPaintState *ps, ProjPixel *projPixel, const float rgba[4], float alpha, float mask)
|
||||
{
|
||||
unsigned char rgba_ub[4];
|
||||
|
||||
|
@ -3793,7 +3793,7 @@ static void do_projectpaint_draw(ProjPaintState *ps, ProjPixel *projPixel, float
|
|||
}
|
||||
}
|
||||
|
||||
static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, float *rgba, float alpha, float mask, int use_color_correction)
|
||||
static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, float rgba[4], float alpha, float mask, int use_color_correction)
|
||||
{
|
||||
if (ps->is_texbrush) {
|
||||
/* rgba already holds a texture result here from higher level function */
|
||||
|
@ -4190,9 +4190,10 @@ static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, s
|
|||
|
||||
/* Image Paint Operations */
|
||||
|
||||
static void imapaint_ibuf_get_set_rgb(ImBuf *ibuf, int x, int y, short torus, short set, float *rgb)
|
||||
/* keep these functions in sync */
|
||||
static void imapaint_ibuf_rgb_get(ImBuf *ibuf, int x, int y, const short is_torus, float r_rgb[3])
|
||||
{
|
||||
if (torus) {
|
||||
if (is_torus) {
|
||||
x %= ibuf->x;
|
||||
if (x < 0) x += ibuf->x;
|
||||
y %= ibuf->y;
|
||||
|
@ -4201,23 +4202,29 @@ static void imapaint_ibuf_get_set_rgb(ImBuf *ibuf, int x, int y, short torus, sh
|
|||
|
||||
if (ibuf->rect_float) {
|
||||
float *rrgbf = ibuf->rect_float + (ibuf->x * y + x) * 4;
|
||||
|
||||
if (set) {
|
||||
IMAPAINT_FLOAT_RGB_COPY(rrgbf, rgb);
|
||||
}
|
||||
else {
|
||||
IMAPAINT_FLOAT_RGB_COPY(rgb, rrgbf);
|
||||
}
|
||||
IMAPAINT_FLOAT_RGB_COPY(r_rgb, rrgbf);
|
||||
}
|
||||
else {
|
||||
char *rrgb = (char *)ibuf->rect + (ibuf->x * y + x) * 4;
|
||||
IMAPAINT_CHAR_RGB_TO_FLOAT(r_rgb, rrgb)
|
||||
}
|
||||
}
|
||||
static void imapaint_ibuf_rgb_set(ImBuf *ibuf, int x, int y, const short is_torus, const float rgb[3])
|
||||
{
|
||||
if (is_torus) {
|
||||
x %= ibuf->x;
|
||||
if (x < 0) x += ibuf->x;
|
||||
y %= ibuf->y;
|
||||
if (y < 0) y += ibuf->y;
|
||||
}
|
||||
|
||||
if (set) {
|
||||
IMAPAINT_FLOAT_RGB_TO_CHAR(rrgb, rgb)
|
||||
}
|
||||
else {
|
||||
IMAPAINT_CHAR_RGB_TO_FLOAT(rgb, rrgb)
|
||||
}
|
||||
if (ibuf->rect_float) {
|
||||
float *rrgbf = ibuf->rect_float + (ibuf->x * y + x) * 4;
|
||||
IMAPAINT_FLOAT_RGB_COPY(rrgbf, rgb);
|
||||
}
|
||||
else {
|
||||
char *rrgb = (char *)ibuf->rect + (ibuf->x * y + x) * 4;
|
||||
IMAPAINT_FLOAT_RGB_TO_CHAR(rrgb, rgb)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4227,10 +4234,10 @@ static int imapaint_ibuf_add_if(ImBuf *ibuf, unsigned int x, unsigned int y, flo
|
|||
|
||||
// XXX: signed unsigned mismatch
|
||||
if ((x >= (unsigned int)(ibuf->x)) || (y >= (unsigned int)(ibuf->y))) {
|
||||
if (torus) imapaint_ibuf_get_set_rgb(ibuf, x, y, 1, 0, inrgb);
|
||||
if (torus) imapaint_ibuf_rgb_get(ibuf, x, y, 1, inrgb);
|
||||
else return 0;
|
||||
}
|
||||
else imapaint_ibuf_get_set_rgb(ibuf, x, y, 0, 0, inrgb);
|
||||
else imapaint_ibuf_rgb_get(ibuf, x, y, 0, inrgb);
|
||||
|
||||
outrgb[0] += inrgb[0];
|
||||
outrgb[1] += inrgb[1];
|
||||
|
@ -4239,7 +4246,7 @@ static int imapaint_ibuf_add_if(ImBuf *ibuf, unsigned int x, unsigned int y, flo
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void imapaint_lift_soften(ImBuf *ibuf, ImBuf *ibufb, int *pos, short torus)
|
||||
static void imapaint_lift_soften(ImBuf *ibuf, ImBuf *ibufb, int *pos, const short is_torus)
|
||||
{
|
||||
int x, y, count, xi, yi, xo, yo;
|
||||
int out_off[2], in_off[2], dim[2];
|
||||
|
@ -4251,7 +4258,7 @@ static void imapaint_lift_soften(ImBuf *ibuf, ImBuf *ibufb, int *pos, short toru
|
|||
in_off[1] = pos[1];
|
||||
out_off[0] = out_off[1] = 0;
|
||||
|
||||
if (!torus) {
|
||||
if (!is_torus) {
|
||||
IMB_rectclip(ibuf, ibufb, &in_off[0], &in_off[1], &out_off[0],
|
||||
&out_off[1], &dim[0], &dim[1]);
|
||||
|
||||
|
@ -4266,27 +4273,25 @@ static void imapaint_lift_soften(ImBuf *ibuf, ImBuf *ibufb, int *pos, short toru
|
|||
yi = in_off[1] + y;
|
||||
|
||||
count = 1;
|
||||
imapaint_ibuf_get_set_rgb(ibuf, xi, yi, torus, 0, outrgb);
|
||||
imapaint_ibuf_rgb_get(ibuf, xi, yi, is_torus, outrgb);
|
||||
|
||||
count += imapaint_ibuf_add_if(ibuf, xi - 1, yi - 1, outrgb, torus);
|
||||
count += imapaint_ibuf_add_if(ibuf, xi - 1, yi, outrgb, torus);
|
||||
count += imapaint_ibuf_add_if(ibuf, xi - 1, yi + 1, outrgb, torus);
|
||||
count += imapaint_ibuf_add_if(ibuf, xi - 1, yi - 1, outrgb, is_torus);
|
||||
count += imapaint_ibuf_add_if(ibuf, xi - 1, yi, outrgb, is_torus);
|
||||
count += imapaint_ibuf_add_if(ibuf, xi - 1, yi + 1, outrgb, is_torus);
|
||||
|
||||
count += imapaint_ibuf_add_if(ibuf, xi, yi - 1, outrgb, torus);
|
||||
count += imapaint_ibuf_add_if(ibuf, xi, yi + 1, outrgb, torus);
|
||||
count += imapaint_ibuf_add_if(ibuf, xi, yi - 1, outrgb, is_torus);
|
||||
count += imapaint_ibuf_add_if(ibuf, xi, yi + 1, outrgb, is_torus);
|
||||
|
||||
count += imapaint_ibuf_add_if(ibuf, xi + 1, yi - 1, outrgb, torus);
|
||||
count += imapaint_ibuf_add_if(ibuf, xi + 1, yi, outrgb, torus);
|
||||
count += imapaint_ibuf_add_if(ibuf, xi + 1, yi + 1, outrgb, torus);
|
||||
count += imapaint_ibuf_add_if(ibuf, xi + 1, yi - 1, outrgb, is_torus);
|
||||
count += imapaint_ibuf_add_if(ibuf, xi + 1, yi, outrgb, is_torus);
|
||||
count += imapaint_ibuf_add_if(ibuf, xi + 1, yi + 1, outrgb, is_torus);
|
||||
|
||||
outrgb[0] /= count;
|
||||
outrgb[1] /= count;
|
||||
outrgb[2] /= count;
|
||||
mul_v3_fl(outrgb, 1.0f / (float)count);
|
||||
|
||||
/* write into brush buffer */
|
||||
xo = out_off[0] + x;
|
||||
yo = out_off[1] + y;
|
||||
imapaint_ibuf_get_set_rgb(ibufb, xo, yo, 0, 1, outrgb);
|
||||
imapaint_ibuf_rgb_set(ibufb, xo, yo, 0, outrgb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -844,7 +844,7 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x
|
|||
}
|
||||
|
||||
/* whats _dl mean? */
|
||||
static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float *vert_nor,
|
||||
static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float vert_nor[3],
|
||||
const float mval[2], const float brush_size_pressure)
|
||||
{
|
||||
Brush *brush = paint_brush(&vp->paint);
|
||||
|
|
|
@ -260,7 +260,7 @@ void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
|
|||
zero_v2(adr);
|
||||
}
|
||||
|
||||
void applyAspectRatio(TransInfo *t, float *vec)
|
||||
void applyAspectRatio(TransInfo *t, float vec[2])
|
||||
{
|
||||
if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) {
|
||||
SpaceImage *sima= t->sa->spacedata.first;
|
||||
|
@ -293,7 +293,7 @@ void applyAspectRatio(TransInfo *t, float *vec)
|
|||
}
|
||||
}
|
||||
|
||||
void removeAspectRatio(TransInfo *t, float *vec)
|
||||
void removeAspectRatio(TransInfo *t, float vec[2])
|
||||
{
|
||||
if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) {
|
||||
SpaceImage *sima= t->sa->spacedata.first;
|
||||
|
|
|
@ -3853,13 +3853,6 @@ static int shade_tra_samples(ShadeSample *ssamp, StrandShadeCache *cache, int x,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void addvecmul(float *v1, float *v2, float fac)
|
||||
{
|
||||
v1[0]= v1[0]+fac*v2[0];
|
||||
v1[1]= v1[1]+fac*v2[1];
|
||||
v1[2]= v1[2]+fac*v2[2];
|
||||
}
|
||||
|
||||
static int addtosamp_shr(ShadeResult *samp_shr, ShadeSample *ssamp, int addpassflag)
|
||||
{
|
||||
int a, sample, osa = (R.osa? R.osa: 1), retval = osa;
|
||||
|
@ -3887,34 +3880,34 @@ static int addtosamp_shr(ShadeResult *samp_shr, ShadeSample *ssamp, int addpassf
|
|||
addAlphaUnderFloat(samp_shr->col, shr->col);
|
||||
|
||||
if (addpassflag & SCE_PASS_NORMAL)
|
||||
addvecmul(samp_shr->nor, shr->nor, fac);
|
||||
madd_v3_v3fl(samp_shr->nor, shr->nor, fac);
|
||||
|
||||
if (addpassflag & SCE_PASS_EMIT)
|
||||
addvecmul(samp_shr->emit, shr->emit, fac);
|
||||
madd_v3_v3fl(samp_shr->emit, shr->emit, fac);
|
||||
|
||||
if (addpassflag & SCE_PASS_DIFFUSE)
|
||||
addvecmul(samp_shr->diff, shr->diff, fac);
|
||||
madd_v3_v3fl(samp_shr->diff, shr->diff, fac);
|
||||
|
||||
if (addpassflag & SCE_PASS_SPEC)
|
||||
addvecmul(samp_shr->spec, shr->spec, fac);
|
||||
madd_v3_v3fl(samp_shr->spec, shr->spec, fac);
|
||||
|
||||
if (addpassflag & SCE_PASS_SHADOW)
|
||||
addvecmul(samp_shr->shad, shr->shad, fac);
|
||||
madd_v3_v3fl(samp_shr->shad, shr->shad, fac);
|
||||
|
||||
if (addpassflag & SCE_PASS_AO)
|
||||
addvecmul(samp_shr->ao, shr->ao, fac);
|
||||
madd_v3_v3fl(samp_shr->ao, shr->ao, fac);
|
||||
|
||||
if (addpassflag & SCE_PASS_ENVIRONMENT)
|
||||
addvecmul(samp_shr->env, shr->env, fac);
|
||||
madd_v3_v3fl(samp_shr->env, shr->env, fac);
|
||||
|
||||
if (addpassflag & SCE_PASS_INDIRECT)
|
||||
addvecmul(samp_shr->indirect, shr->indirect, fac);
|
||||
madd_v3_v3fl(samp_shr->indirect, shr->indirect, fac);
|
||||
|
||||
if (addpassflag & SCE_PASS_REFLECT)
|
||||
addvecmul(samp_shr->refl, shr->refl, fac);
|
||||
madd_v3_v3fl(samp_shr->refl, shr->refl, fac);
|
||||
|
||||
if (addpassflag & SCE_PASS_REFRACT)
|
||||
addvecmul(samp_shr->refr, shr->refr, fac);
|
||||
madd_v3_v3fl(samp_shr->refr, shr->refr, fac);
|
||||
|
||||
if (addpassflag & SCE_PASS_MIST)
|
||||
samp_shr->mist= samp_shr->mist+fac*shr->mist;
|
||||
|
|
Loading…
Reference in New Issue