minor edits / cleanup - no functional changes.

- use 'const float *' and array size in some function declarations.
- replace macros for BLI_math functions INPF, VECCOPY, VECADD etc.
- remove unused VertRen.clip struct member.
- remove static squared_dist() from 2 files, replace with BLI_math function len_squared_v3v3().
- use vertex arrays for drawing clipping background in the 3D viewport.
This commit is contained in:
Campbell Barton 2011-09-11 02:50:01 +00:00
parent 3a5f2272ad
commit 599cd56f53
29 changed files with 228 additions and 257 deletions

@ -55,7 +55,7 @@ void floatbuf_to_byte(float *rectf, unsigned char *rectc, int x1, int x2, int
struct CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, float maxy);
void curvemapping_free(struct CurveMapping *cumap);
struct CurveMapping *curvemapping_copy(struct CurveMapping *cumap);
void curvemapping_set_black_white(struct CurveMapping *cumap, float *black, float *white);
void curvemapping_set_black_white(struct CurveMapping *cumap, const float black[3], const float white[3]);
#define CURVEMAP_SLOPE_NEGATIVE 0
#define CURVEMAP_SLOPE_POSITIVE 1
@ -70,9 +70,9 @@ void curvemapping_changed(struct CurveMapping *cumap, int rem_doubles);
float curvemap_evaluateF(struct CurveMap *cuma, float value);
/* single curve, with table check */
float curvemapping_evaluateF(struct CurveMapping *cumap, int cur, float value);
void curvemapping_evaluate3F(struct CurveMapping *cumap, float *vecout, const float *vecin);
void curvemapping_evaluateRGBF(struct CurveMapping *cumap, float *vecout, const float *vecin);
void curvemapping_evaluate_premulRGBF(struct CurveMapping *cumap, float *vecout, const float *vecin);
void curvemapping_evaluate3F(struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
void curvemapping_evaluateRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
void curvemapping_evaluate_premulRGBF(struct CurveMapping *cumap, float vecout[3], const float vecin[3]);
void curvemapping_do_ibuf(struct CurveMapping *cumap, struct ImBuf *ibuf);
void curvemapping_premultiply(struct CurveMapping *cumap, int restore);
int curvemapping_RGBA_does_something(struct CurveMapping *cumap);

@ -555,7 +555,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf
if (texfall == 0) {
dist = sqrt(xy[0]*xy[0] + xy[1]*xy[1]);
VECCOPY(dstf, brush_rgb);
copy_v3_v3(dstf, brush_rgb);
dstf[3]= alpha*brush_curve_strength_clamp(brush, dist, radius);
}
else if (texfall == 1) {
@ -754,7 +754,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i
for (x=origx; x < w; x++, bf+=4, mf+=4, tf+=4) {
if (dotexold) {
VECCOPY(tf, otf);
copy_v3_v3(tf, otf);
tf[3] = otf[3];
otf += 4;
}
@ -926,7 +926,7 @@ static void brush_apply_pressure(BrushPainter *painter, Brush *brush, float pres
brush->spacing = MAX2(1.0f, painter->startspacing*(1.5f-pressure));
}
void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos)
void brush_jitter_pos(Brush *brush, float pos[2], float jitterpos[2])
{
int use_jitter= brush->jitter != 0;
@ -949,7 +949,7 @@ void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos)
jitterpos[1] = pos[1] + 2*rand_pos[1]*diameter*brush->jitter;
}
else {
VECCOPY2D(jitterpos, pos);
copy_v2_v2(jitterpos, pos);
}
}

@ -167,14 +167,14 @@ CurveMapping *curvemapping_copy(CurveMapping *cumap)
return NULL;
}
void curvemapping_set_black_white(CurveMapping *cumap, float *black, float *white)
void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], const float white[3])
{
int a;
if(white)
VECCOPY(cumap->white, white);
copy_v3_v3(cumap->white, white);
if(black)
VECCOPY(cumap->black, black);
copy_v3_v3(cumap->black, black);
for(a=0; a<3; a++) {
if(cumap->white[a]==cumap->black[a])
@ -432,7 +432,7 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex
/* in X, out Y.
X is presumed to be outside first or last */
static float curvemap_calc_extend(CurveMap *cuma, float x, float *first, float *last)
static float curvemap_calc_extend(CurveMap *cuma, float x, const float first[2], const float last[2])
{
if(x <= first[0]) {
if((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) {
@ -753,7 +753,7 @@ float curvemapping_evaluateF(CurveMapping *cumap, int cur, float value)
}
/* vector case */
void curvemapping_evaluate3F(CurveMapping *cumap, float *vecout, const float *vecin)
void curvemapping_evaluate3F(CurveMapping *cumap, float vecout[3], const float vecin[3])
{
vecout[0]= curvemapping_evaluateF(cumap, 0, vecin[0]);
vecout[1]= curvemapping_evaluateF(cumap, 1, vecin[1]);
@ -761,7 +761,7 @@ void curvemapping_evaluate3F(CurveMapping *cumap, float *vecout, const float *ve
}
/* RGB case, no black/white points, no premult */
void curvemapping_evaluateRGBF(CurveMapping *cumap, float *vecout, const float *vecin)
void curvemapping_evaluateRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3])
{
vecout[0]= curvemapping_evaluateF(cumap, 0, curvemapping_evaluateF(cumap, 3, vecin[0]));
vecout[1]= curvemapping_evaluateF(cumap, 1, curvemapping_evaluateF(cumap, 3, vecin[1]));
@ -770,7 +770,7 @@ void curvemapping_evaluateRGBF(CurveMapping *cumap, float *vecout, const float *
/* RGB with black/white points and premult. tables are checked */
void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float *vecout, const float *vecin)
void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3])
{
float fac;

@ -2547,9 +2547,9 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode)
sub_v3_v3v3(h2, p2, p2+3);
len1= normalize_v3(h1);
len2= normalize_v3(h2);
vz= INPR(h1, h2);
vz= dot_v3v3(h1, h2);
if(leftviolate) {
*(p2+3)= *(p2) - vz*len2*h1[0];
*(p2+4)= *(p2+1) - vz*len2*h1[1];

@ -133,16 +133,6 @@ static void space_transform_invert_normal(const SpaceTransform *data, float *no)
normalize_v3(no); // TODO: could we just determine de scale value from the matrix?
}
/*
* Returns the squared distance between two given points
*/
static float squared_dist(const float *a, const float *b)
{
float tmp[3];
VECSUB(tmp, a, b);
return INPR(tmp, tmp);
}
/*
* Shrinkwrap to the nearest vertex
*
@ -195,7 +185,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc)
//so we can initiate the "nearest.dist" with the expected value to that last hit.
//This will lead in prunning of the search tree.
if(nearest.index != -1)
nearest.dist = squared_dist(tmp_co, nearest.co);
nearest.dist = len_squared_v3v3(tmp_co, nearest.co);
else
nearest.dist = FLT_MAX;
@ -328,7 +318,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc)
normalize_v3(proj_axis);
//Invalid projection direction
if(INPR(proj_axis, proj_axis) < FLT_EPSILON)
if(dot_v3v3(proj_axis, proj_axis) < FLT_EPSILON)
return;
}
@ -469,7 +459,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc)
//so we can initiate the "nearest.dist" with the expected value to that last hit.
//This will lead in prunning of the search tree.
if(nearest.index != -1)
nearest.dist = squared_dist(tmp_co, nearest.co);
nearest.dist = len_squared_v3v3(tmp_co, nearest.co);
else
nearest.dist = FLT_MAX;

@ -408,7 +408,7 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, float *co, int numpoi
// for all Axes.
for (i = tree->start_axis; i < tree->stop_axis; i++)
{
newminmax = INPR(&co[k * 3], KDOP_AXES[i]);
newminmax = dot_v3v3(&co[k * 3], KDOP_AXES[i]);
if (newminmax < bv[2 * i])
bv[2 * i] = newminmax;
if (newminmax > bv[(2 * i) + 1])
@ -1193,17 +1193,6 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int
return overlap;
}
/*
* Nearest neighbour - BLI_bvhtree_find_nearest
*/
static float squared_dist(const float *a, const float *b)
{
float tmp[3];
VECSUB(tmp, a, b);
return INPR(tmp, tmp);
}
//Determines the nearest point of the given node BV. Returns the squared distance to that point.
static float calc_nearest_point(const float *proj, BVHNode *node, float *nearest)
{
@ -1226,7 +1215,7 @@ static float calc_nearest_point(const float *proj, BVHNode *node, float *nearest
VECCOPY(nearest, data->co);
for(i = data->tree->start_axis; i != data->tree->stop_axis; i++, bv+=2)
{
float proj = INPR( nearest, KDOP_AXES[i]);
float proj = dot_v3v3( nearest, KDOP_AXES[i]);
float dl = bv[0] - proj;
float du = bv[1] - proj;
@ -1240,7 +1229,7 @@ static float calc_nearest_point(const float *proj, BVHNode *node, float *nearest
}
}
*/
return squared_dist(proj, nearest);
return len_squared_v3v3(proj, nearest);
}
@ -1404,7 +1393,7 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float *co, BVHTreeNearest *nea
for(i = data.tree->start_axis; i != data.tree->stop_axis; i++)
{
data.proj[i] = INPR(data.co, KDOP_AXES[i]);
data.proj[i] = dot_v3v3(data.co, KDOP_AXES[i]);
}
if(nearest)
@ -1596,7 +1585,7 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float
for(i=0; i<3; i++)
{
data.ray_dot_axis[i] = INPR( data.ray.direction, KDOP_AXES[i]);
data.ray_dot_axis[i] = dot_v3v3(data.ray.direction, KDOP_AXES[i]);
data.idot_axis[i] = 1.0f / data.ray_dot_axis[i];
if(fabsf(data.ray_dot_axis[i]) < FLT_EPSILON)

@ -518,7 +518,7 @@ static float heat_source_distance(LaplacianSystem *sys, int vertex, int source)
dist= normalize_v3(d);
/* if the vertex normal does not point along the bone, increase distance */
cosine= INPR(d, sys->heat.vnors[vertex]);
cosine= dot_v3v3(d, sys->heat.vnors[vertex]);
return dist/(0.5f*(cosine + 1.001f));
}
@ -1120,7 +1120,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3],
cross_v3_v3v3(pvec, dir, edge2);
/* if determinant is near zero, ray lies in plane of triangle */
det = INPR(edge1, pvec);
det = dot_v3v3(edge1, pvec);
if (det == 0.0f)
return 0;
@ -1130,7 +1130,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3],
sub_v3_v3v3(tvec, orig, vert0);
/* calculate U parameter and test bounds */
u = INPR(tvec, pvec) * inv_det;
u = dot_v3v3(tvec, pvec) * inv_det;
if (u < -EPSILON || u > 1.0f+EPSILON)
return 0;
@ -1138,7 +1138,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3],
cross_v3_v3v3(qvec, tvec, edge1);
/* calculate V parameter and test bounds */
v = INPR(dir, qvec) * inv_det;
v = dot_v3v3(dir, qvec) * inv_det;
if (v < -EPSILON || u + v > 1.0f+EPSILON)
return 0;
@ -1153,10 +1153,10 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3],
/* check if it is within the length of the line segment */
sub_v3_v3v3(isectdir, isectco, orig);
if(INPR(dir, isectdir) < -EPSILON)
if(dot_v3v3(dir, isectdir) < -EPSILON)
return 0;
if(INPR(dir, dir) + EPSILON < INPR(isectdir, isectdir))
if(dot_v3v3(dir, dir) + EPSILON < dot_v3v3(isectdir, isectdir))
return 0;
return 1;
@ -1202,7 +1202,7 @@ static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec)
if(len < isec->labda) {
isec->labda= len;
isec->face = mface;
isec->isect= (INPR(isec->vec, nor) <= 0.0f);
isec->isect= (dot_v3v3(isec->vec, nor) <= 0.0f);
is= 1;
}
}

@ -210,7 +210,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event)
copy_v3_v3(vec, min);
normalize_v3(vec);
dot= INPR(vec, nor);
dot= dot_v3v3(vec, nor);
if( fabs(dot)<0.999) {
float cross[3], si, q1[4];

@ -1002,7 +1002,7 @@ void EM_free_data_layer(EditMesh *em, CustomData *data, int type)
static void add_normal_aligned(float *nor, float *add)
{
if( INPR(nor, add) < -0.9999f)
if(dot_v3v3(nor, add) < -0.9999f)
sub_v3_v3(nor, add);
else
add_v3_v3(nor, add);

@ -305,7 +305,7 @@ static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA
if(_sample_col) {
cumap->flag |= CUMA_DRAW_SAMPLE;
VECCOPY(cumap->sample, _sample_col);
copy_v3_v3(cumap->sample, _sample_col);
}
else
cumap->flag &= ~CUMA_DRAW_SAMPLE;

@ -827,7 +827,7 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4], int armflag,
if (0.0f != normalize_v3(dirvec)) {
float norvech[3], norvect[3], vec[3];
VECCOPY(vec, dirvec);
copy_v3_v3(vec, dirvec);
mul_v3_fl(dirvec, head);
cross_v3_v3v3(norvech, dirvec, imat[2]);
@ -1544,7 +1544,7 @@ static void draw_pose_dofs(Object *ob)
/* in parent-bone pose, but own restspace */
glPushMatrix();
VECCOPY(posetrans, pchan->pose_mat[3]);
copy_v3_v3(posetrans, pchan->pose_mat[3]);
glTranslatef(posetrans[0], posetrans[1], posetrans[2]);
if (pchan->parent) {
@ -1642,7 +1642,7 @@ static void bone_matrix_translate_y(float mat[][4], float y)
{
float trans[3];
VECCOPY(trans, mat[1]);
copy_v3_v3(trans, mat[1]);
mul_v3_fl(trans, y);
add_v3_v3(mat[3], trans);
}

@ -139,7 +139,7 @@ static int check_ob_drawface_dot(Scene *sce, View3D *vd, char dt)
/* ************* only use while object drawing **************
* or after running ED_view3d_init_mats_rv3d
* */
static void view3d_project_short_clip(ARegion *ar, float *vec, short *adr, int local)
static void view3d_project_short_clip(ARegion *ar, const float vec[3], short *adr, int local)
{
RegionView3D *rv3d= ar->regiondata;
float fx, fy, vec4[4];
@ -174,7 +174,7 @@ static void view3d_project_short_clip(ARegion *ar, float *vec, short *adr, int l
}
/* only use while object drawing */
static void view3d_project_short_noclip(ARegion *ar, float *vec, short *adr)
static void view3d_project_short_noclip(ARegion *ar, const float vec[3], short *adr)
{
RegionView3D *rv3d= ar->regiondata;
float fx, fy, vec4[4];
@ -837,7 +837,7 @@ static void drawcube_size(float size)
/* this is an unused (old) cube-drawing function based on a given size */
#if 0
static void drawcube_size(float *size)
static void drawcube_size(const float size[3])
{
glPushMatrix();
@ -891,7 +891,7 @@ static void drawshadbuflimits(Lamp *la, float mat[][4])
static void spotvolume(float *lvec, float *vvec, float inp)
static void spotvolume(float lvec[3], float vvec[3], const float inp)
{
/* camera is at 0,0,0 */
float temp[3],plane[3],mat1[3][3],mat2[3][3],mat3[3][3],mat4[3][3],q[4],co,si,angle;
@ -920,8 +920,8 @@ static void spotvolume(float *lvec, float *vvec, float inp)
normalize_v3(&q[1]);
angle = saacos(plane[2])/2.0f;
co = cos(angle);
si = sqrt(1-co*co);
co = cosf(angle);
si = sqrtf(1-co*co);
q[0] = co;
q[1] *= si;
@ -935,7 +935,7 @@ static void spotvolume(float *lvec, float *vvec, float inp)
unit_m3(mat2);
co = inp;
si = sqrt(1-inp*inp);
si = sqrtf(1.0f-inp*inp);
mat2[0][0] = co;
mat2[1][0] = -si;
@ -5035,7 +5035,7 @@ static void draw_textcurs(float textcurs[][2])
set_inverted_drawing(0);
}
static void drawspiral(float *cent, float rad, float tmat[][4], int start)
static void drawspiral(const float cent[3], float rad, float tmat[][4], int start)
{
float vec[3], vx[3], vy[3];
int a, tot=32;
@ -5106,7 +5106,7 @@ static void drawcircle_size(float size)
}
/* needs fixing if non-identity matrice used */
static void drawtube(float *vec, float radius, float height, float tmat[][4])
static void drawtube(const float vec[3], float radius, float height, float tmat[][4])
{
float cur[3];
drawcircball(GL_LINE_LOOP, vec, radius, tmat);
@ -5128,7 +5128,7 @@ static void drawtube(float *vec, float radius, float height, float tmat[][4])
glEnd();
}
/* needs fixing if non-identity matrice used */
static void drawcone(float *vec, float radius, float height, float tmat[][4])
static void drawcone(const float vec[3], float radius, float height, float tmat[][4])
{
float cur[3];
@ -5404,7 +5404,7 @@ static void draw_box(float vec[8][3])
/* uses boundbox, function used by Ketsji */
#if 0
static void get_local_bounds(Object *ob, float *center, float *size)
static void get_local_bounds(Object *ob, float center[3], float size[3])
{
BoundBox *bb= object_get_boundbox(ob);

@ -154,10 +154,10 @@ static int convex(float *p0, float *up, float *a, float *b)
{
// Vec3 va = a-p0, vb = b-p0;
float va[3], vb[3], tmp[3];
VECSUB(va, a, p0);
VECSUB(vb, b, p0);
sub_v3_v3v3(va, a, p0);
sub_v3_v3v3(vb, b, p0);
cross_v3_v3v3(tmp, va, vb);
return INPR(up, tmp) >= 0;
return dot_v3v3(up, tmp) >= 0;
}
// copied from gpu_extension.c
@ -280,20 +280,20 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3
cv[7][1] = min[1];
cv[7][2] = min[2];
VECCOPY(edges[0][0], cv[4]); // maxx, maxy, minz
VECCOPY(edges[1][0], cv[5]); // minx, maxy, minz
VECCOPY(edges[2][0], cv[6]); // minx, miny, minz
VECCOPY(edges[3][0], cv[7]); // maxx, miny, minz
copy_v3_v3(edges[0][0], cv[4]); // maxx, maxy, minz
copy_v3_v3(edges[1][0], cv[5]); // minx, maxy, minz
copy_v3_v3(edges[2][0], cv[6]); // minx, miny, minz
copy_v3_v3(edges[3][0], cv[7]); // maxx, miny, minz
VECCOPY(edges[4][0], cv[3]); // maxx, miny, maxz
VECCOPY(edges[5][0], cv[2]); // minx, miny, maxz
VECCOPY(edges[6][0], cv[6]); // minx, miny, minz
VECCOPY(edges[7][0], cv[7]); // maxx, miny, minz
copy_v3_v3(edges[4][0], cv[3]); // maxx, miny, maxz
copy_v3_v3(edges[5][0], cv[2]); // minx, miny, maxz
copy_v3_v3(edges[6][0], cv[6]); // minx, miny, minz
copy_v3_v3(edges[7][0], cv[7]); // maxx, miny, minz
VECCOPY(edges[8][0], cv[1]); // minx, maxy, maxz
VECCOPY(edges[9][0], cv[2]); // minx, miny, maxz
VECCOPY(edges[10][0], cv[6]); // minx, miny, minz
VECCOPY(edges[11][0], cv[5]); // minx, maxy, minz
copy_v3_v3(edges[8][0], cv[1]); // minx, maxy, maxz
copy_v3_v3(edges[9][0], cv[2]); // minx, miny, maxz
copy_v3_v3(edges[10][0], cv[6]); // minx, miny, minz
copy_v3_v3(edges[11][0], cv[5]); // minx, maxy, minz
// printf("size x: %f, y: %f, z: %f\n", size[0], size[1], size[2]);
// printf("min[2]: %f, max[2]: %f\n", min[2], max[2]);
@ -332,7 +332,7 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3
*/
// get view vector
VECCOPY(viewnormal, rv3d->viewinv[2]);
copy_v3_v3(viewnormal, rv3d->viewinv[2]);
normalize_v3(viewnormal);
// find cube vertex that is closest to the viewer
@ -407,10 +407,10 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3
if(dd*(float)n > ds)
break;
VECCOPY(tmp_point, viewnormal);
copy_v3_v3(tmp_point, viewnormal);
mul_v3_fl(tmp_point, -dd*((ds/dd)-(float)n));
VECADD(tmp_point2, cv[good_index], tmp_point);
d = INPR(tmp_point2, viewnormal);
add_v3_v3v3(tmp_point2, cv[good_index], tmp_point);
d = dot_v3v3(tmp_point2, viewnormal);
// printf("my d: %f\n", d);
@ -421,7 +421,7 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3
// printf("points: %d\n", numpoints);
if (numpoints > 2) {
VECCOPY(p0, points);
copy_v3_v3(p0, points);
// sort points to get a convex polygon
for(i = 1; i < numpoints - 1; i++)
@ -431,9 +431,9 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3
if(!convex(p0, viewnormal, &points[j * 3], &points[i * 3]))
{
float tmp2[3];
VECCOPY(tmp2, &points[j * 3]);
VECCOPY(&points[j * 3], &points[i * 3]);
VECCOPY(&points[i * 3], tmp2);
copy_v3_v3(tmp2, &points[j * 3]);
copy_v3_v3(&points[j * 3], &points[i * 3]);
copy_v3_v3(&points[i * 3], tmp2);
}
}
}

@ -150,20 +150,22 @@ void circ(float x, float y, float rad)
static void view3d_draw_clipping(RegionView3D *rv3d)
{
BoundBox *bb= rv3d->clipbb;
if(bb) {
static unsigned int clipping_index[6][4]= {{0, 1, 2, 3},
{0, 4, 5, 1},
{4, 7, 6, 5},
{7, 3, 2, 6},
{1, 5, 6, 2},
{7, 4, 0, 3}};
UI_ThemeColorShade(TH_BACK, -8);
glBegin(GL_QUADS);
glVertex3fv(bb->vec[0]); glVertex3fv(bb->vec[1]); glVertex3fv(bb->vec[2]); glVertex3fv(bb->vec[3]);
glVertex3fv(bb->vec[0]); glVertex3fv(bb->vec[4]); glVertex3fv(bb->vec[5]); glVertex3fv(bb->vec[1]);
glVertex3fv(bb->vec[4]); glVertex3fv(bb->vec[7]); glVertex3fv(bb->vec[6]); glVertex3fv(bb->vec[5]);
glVertex3fv(bb->vec[7]); glVertex3fv(bb->vec[3]); glVertex3fv(bb->vec[2]); glVertex3fv(bb->vec[6]);
glVertex3fv(bb->vec[1]); glVertex3fv(bb->vec[5]); glVertex3fv(bb->vec[6]); glVertex3fv(bb->vec[2]);
glVertex3fv(bb->vec[7]); glVertex3fv(bb->vec[4]); glVertex3fv(bb->vec[0]); glVertex3fv(bb->vec[3]);
glEnd();
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, bb->vec);
glDrawElements(GL_QUADS, sizeof(clipping_index)/sizeof(unsigned int), GL_UNSIGNED_INT, clipping_index);
glDisableClientState(GL_VERTEX_ARRAY);
}
}
@ -194,11 +196,11 @@ static int test_clipping(const float vec[3], float clip[][4])
{
float view[3];
copy_v3_v3(view, vec);
if(0.0f < clip[0][3] + INPR(view, clip[0]))
if(0.0f < clip[1][3] + INPR(view, clip[1]))
if(0.0f < clip[2][3] + INPR(view, clip[2]))
if(0.0f < clip[3][3] + INPR(view, clip[3]))
if(0.0f < clip[0][3] + dot_v3v3(view, clip[0]))
if(0.0f < clip[1][3] + dot_v3v3(view, clip[1]))
if(0.0f < clip[2][3] + dot_v3v3(view, clip[2]))
if(0.0f < clip[3][3] + dot_v3v3(view, clip[3]))
return 0;
return 1;

@ -62,16 +62,6 @@
/* Util macro. */
#define OUT_OF_MEMORY() ((void)printf("WeightVGProximity: Out of memory.\n"))
/**
* Returns the squared distance between two given points.
*/
static float squared_dist(const float *a, const float *b)
{
float tmp[3];
VECSUB(tmp, a, b);
return INPR(tmp, tmp);
}
/**
* Find nearest vertex and/or edge and/or face, for each vertex (adapted from shrinkwrap.c).
*/
@ -137,19 +127,19 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3],
* This will lead in prunning of the search tree.
*/
if (dist_v) {
nearest_v.dist = nearest_v.index != -1 ? squared_dist(tmp_co, nearest_v.co) : FLT_MAX;
nearest_v.dist = nearest_v.index != -1 ? len_squared_v3v3(tmp_co, nearest_v.co) : FLT_MAX;
/* Compute and store result. If invalid (-1 idx), keep FLT_MAX dist. */
BLI_bvhtree_find_nearest(treeData_v.tree, tmp_co, &nearest_v, treeData_v.nearest_callback, &treeData_v);
dist_v[i] = sqrtf(nearest_v.dist);
}
if (dist_e) {
nearest_e.dist = nearest_e.index != -1 ? squared_dist(tmp_co, nearest_e.co) : FLT_MAX;
nearest_e.dist = nearest_e.index != -1 ? len_squared_v3v3(tmp_co, nearest_e.co) : FLT_MAX;
/* Compute and store result. If invalid (-1 idx), keep FLT_MAX dist. */
BLI_bvhtree_find_nearest(treeData_e.tree, tmp_co, &nearest_e, treeData_e.nearest_callback, &treeData_e);
dist_e[i] = sqrtf(nearest_e.dist);
}
if (dist_f) {
nearest_f.dist = nearest_f.index != -1 ? squared_dist(tmp_co, nearest_f.co) : FLT_MAX;
nearest_f.dist = nearest_f.index != -1 ? len_squared_v3v3(tmp_co, nearest_f.co) : FLT_MAX;
/* Compute and store result. If invalid (-1 idx), keep FLT_MAX dist. */
BLI_bvhtree_find_nearest(treeData_f.tree, tmp_co, &nearest_f, treeData_f.nearest_callback, &treeData_f);
dist_f[i] = sqrtf(nearest_f.dist);

@ -338,7 +338,7 @@ typedef struct ObjectInstanceRen {
struct VolumePrecache *volume_precache;
float *vectors;
float *vectors; /* (RE_WINSPEED_ELEMS * VertRen.index) */
int totvector;
/* used on makeraytree */
@ -354,8 +354,8 @@ typedef struct VertRen
float co[3];
float n[3];
float *orco;
short clip;
unsigned short flag; /* in use for clipping zbuffer parts, temp setting stuff in convertblender.c */
unsigned int flag; /* in use for clipping zbuffer parts, temp setting stuff in convertblender.c
* only an 'int' because of alignment, could be a char too */
float accum; /* accum for radio weighting, and for strand texco static particles */
int index; /* index allows extending vertren with any property */
} VertRen;

@ -81,8 +81,8 @@ float mistfactor(float zcor, float *co); /* dist and height, return alpha */
void renderspothalo(struct ShadeInput *shi, float *col, float alpha);
void add_halo_flare(Render *re);
void calc_renderco_zbuf(float *co, float *view, int z);
void calc_renderco_ortho(float *co, float x, float y, int z);
void calc_renderco_zbuf(float co[3], float *view, int z);
void calc_renderco_ortho(float co[3], float x, float y, int z);
int count_mask(unsigned short mask);

@ -91,7 +91,7 @@ void free_renderdata_vertnodes(struct VertTableNode *vertnodes);
void free_renderdata_vlaknodes(struct VlakTableNode *vlaknodes);
void set_normalflags(struct Render *re, struct ObjectRen *obr);
void project_renderdata(struct Render *re, void (*projectfunc)(float *, float mat[][4], float *), int do_pano, float xoffs, int do_buckets);
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]);
/* functions are not exported... so wrong names */

@ -63,7 +63,7 @@ void shade_volume_loop(struct ShadeInput *shi, struct ShadeResult *shr);
void shade_input_set_triangle_i(struct ShadeInput *shi, struct ObjectInstanceRen *obi, struct VlakRen *vlr, short i1, short i2, short i3);
void shade_input_set_triangle(struct ShadeInput *shi, volatile int obi, volatile int facenr, int normal_flip);
void shade_input_copy_triangle(struct ShadeInput *shi, struct ShadeInput *from);
void shade_input_calc_viewco(struct ShadeInput *shi, float x, float y, float z, float *view, float *dxyview, float *co, float *dxco, float *dyco);
void shade_input_calc_viewco(struct ShadeInput *shi, float x, float y, float z, float view[3], float *dxyview, float *co, float *dxco, float *dyco);
void shade_input_set_viewco(struct ShadeInput *shi, float x, float y, float sx, float sy, float z);
void shade_input_set_uv(struct ShadeInput *shi);
void shade_input_set_normals(struct ShadeInput *shi);

@ -51,9 +51,9 @@ void fillrect(int *rect, int x, int y, int val);
* Converts a world coordinate into a homogenous coordinate in view
* coordinates.
*/
void projectvert(float *v1, float winmat[][4], float *adr);
void projectverto(float *v1, float winmat[][4], float *adr);
int testclip(float *v);
void projectvert(const float v1[3], float winmat[][4], float adr[4]);
void projectverto(const float v1[3], float winmat[][4], float adr[4]);
int testclip(const float v[3]);
void zbuffer_shadow(struct Render *re, float winmat[][4], struct LampRen *lar, int *rectz, int size, float jitx, float jity);
void zbuffer_abuf_shadow(struct Render *re, struct LampRen *lar, float winmat[][4], struct APixstr *APixbuf, struct APixstrand *apixbuf, struct ListBase *apsmbase, int size, int samples, float (*jit)[2]);

@ -142,7 +142,7 @@ static HaloRen *initstar(Render *re, ObjectRen *obr, float *vec, float hasize)
har= RE_findOrAddHalo(obr, obr->tothalo++);
/* projectvert is done in function zbufvlaggen again, because of parts */
VECCOPY(har->co, vec);
copy_v3_v3(har->co, vec);
har->hasize= hasize;
har->zd= 0.0;
@ -547,7 +547,7 @@ static void GetPosition(const SMikkTSpaceContext * pContext, float fPos[], const
SRenderMeshToTangent * pMesh = (SRenderMeshToTangent *) pContext->m_pUserData;
VlakRen *vlr= RE_findOrAddVlak(pMesh->obr, face_num);
const float *co= (&vlr->v1)[vert_index]->co;
VECCOPY(fPos, co);
copy_v3_v3(fPos, co);
}
static void GetTextureCoordinate(const SMikkTSpaceContext * pContext, float fUV[], const int face_num, const int vert_index)
@ -576,7 +576,7 @@ static void GetNormal(const SMikkTSpaceContext * pContext, float fNorm[], const
SRenderMeshToTangent * pMesh = (SRenderMeshToTangent *) pContext->m_pUserData;
VlakRen *vlr= RE_findOrAddVlak(pMesh->obr, face_num);
const float *n= (&vlr->v1)[vert_index]->n;
VECCOPY(fNorm, n);
copy_v3_v3(fNorm, n);
}
static void SetTSpace(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int face_num, const int iVert)
{
@ -585,7 +585,7 @@ static void SetTSpace(const SMikkTSpaceContext * pContext, const float fvTangent
VlakRen *vlr= RE_findOrAddVlak(pMesh->obr, face_num);
float * ftang= RE_vlakren_get_nmap_tangent(pMesh->obr, vlr, 1);
if(ftang!=NULL) {
VECCOPY(&ftang[iVert*4+0], fvTangent);
copy_v3_v3(&ftang[iVert*4+0], fvTangent);
ftang[iVert*4+3]=fSign;
}
}
@ -632,10 +632,10 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen
VlakRen *vlr= RE_findOrAddVlak(obr, a);
if((vlr->flag & ME_SMOOTH)==0) {
if(is_zero_v3(vlr->v1->n)) VECCOPY(vlr->v1->n, vlr->n);
if(is_zero_v3(vlr->v2->n)) VECCOPY(vlr->v2->n, vlr->n);
if(is_zero_v3(vlr->v3->n)) VECCOPY(vlr->v3->n, vlr->n);
if(vlr->v4 && is_zero_v3(vlr->v4->n)) VECCOPY(vlr->v4->n, vlr->n);
if(is_zero_v3(vlr->v1->n)) copy_v3_v3(vlr->v1->n, vlr->n);
if(is_zero_v3(vlr->v2->n)) copy_v3_v3(vlr->v2->n, vlr->n);
if(is_zero_v3(vlr->v3->n)) copy_v3_v3(vlr->v3->n, vlr->n);
if(vlr->v4 && is_zero_v3(vlr->v4->n)) copy_v3_v3(vlr->v4->n, vlr->n);
}
if(do_nmap_tangent) {
@ -647,17 +647,17 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen
float *vtang, *ftang= RE_vlakren_get_nmap_tangent(obr, vlr, 1);
vtang= find_vertex_tangent(vtangents[v1->index], tface->uv[0]);
VECCOPY(ftang, vtang);
copy_v3_v3(ftang, vtang);
normalize_v3(ftang);
vtang= find_vertex_tangent(vtangents[v2->index], tface->uv[1]);
VECCOPY(ftang+4, vtang);
copy_v3_v3(ftang+4, vtang);
normalize_v3(ftang+4);
vtang= find_vertex_tangent(vtangents[v3->index], tface->uv[2]);
VECCOPY(ftang+8, vtang);
copy_v3_v3(ftang+8, vtang);
normalize_v3(ftang+8);
if(v4) {
vtang= find_vertex_tangent(vtangents[v4->index], tface->uv[3]);
VECCOPY(ftang+12, vtang);
copy_v3_v3(ftang+12, vtang);
normalize_v3(ftang+12);
}
for(k=0; k<4; k++) ftang[4*k+3]=1;
@ -1023,7 +1023,7 @@ typedef struct ParticleStrandData
}
ParticleStrandData;
/* future thread problem... */
static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, ParticleStrandData *sd, float *vec, float *vec1)
static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, ParticleStrandData *sd, const float vec[3], const float vec1[3])
{
static VertRen *v1= NULL, *v2= NULL;
VlakRen *vlr= NULL;
@ -1090,27 +1090,27 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
vlr->v3= RE_findOrAddVert(obr, obr->totvert++);
vlr->v4= RE_findOrAddVert(obr, obr->totvert++);
VECCOPY(vlr->v1->co, vec);
copy_v3_v3(vlr->v1->co, vec);
add_v3_v3(vlr->v1->co, cross);
VECCOPY(vlr->v1->n, nor);
copy_v3_v3(vlr->v1->n, nor);
vlr->v1->orco= sd->orco;
vlr->v1->accum= -1.0f; // accum abuse for strand texco
VECCOPY(vlr->v2->co, vec);
copy_v3_v3(vlr->v2->co, vec);
sub_v3_v3v3(vlr->v2->co, vlr->v2->co, cross);
VECCOPY(vlr->v2->n, nor);
copy_v3_v3(vlr->v2->n, nor);
vlr->v2->orco= sd->orco;
vlr->v2->accum= vlr->v1->accum;
VECCOPY(vlr->v4->co, vec1);
copy_v3_v3(vlr->v4->co, vec1);
add_v3_v3(vlr->v4->co, cross);
VECCOPY(vlr->v4->n, nor);
copy_v3_v3(vlr->v4->n, nor);
vlr->v4->orco= sd->orco;
vlr->v4->accum= 1.0f; // accum abuse for strand texco
VECCOPY(vlr->v3->co, vec1);
copy_v3_v3(vlr->v3->co, vec1);
sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross);
VECCOPY(vlr->v3->n, nor);
copy_v3_v3(vlr->v3->n, nor);
vlr->v3->orco= sd->orco;
vlr->v3->accum= vlr->v4->accum;
@ -1121,7 +1121,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
if(sd->surfnor) {
float *snor= RE_vlakren_get_surfnor(obr, vlr, 1);
VECCOPY(snor, sd->surfnor);
copy_v3_v3(snor, sd->surfnor);
}
if(sd->uvco){
@ -1156,23 +1156,23 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
/* first two vertices of a strand */
else if(sd->first) {
if(sd->adapt){
VECCOPY(anor, nor);
VECCOPY(avec, vec);
copy_v3_v3(anor, nor);
copy_v3_v3(avec, vec);
second=1;
}
v1= RE_findOrAddVert(obr, obr->totvert++);
v2= RE_findOrAddVert(obr, obr->totvert++);
VECCOPY(v1->co, vec);
copy_v3_v3(v1->co, vec);
add_v3_v3(v1->co, cross);
VECCOPY(v1->n, nor);
copy_v3_v3(v1->n, nor);
v1->orco= sd->orco;
v1->accum= -1.0f; // accum abuse for strand texco
VECCOPY(v2->co, vec);
copy_v3_v3(v2->co, vec);
sub_v3_v3v3(v2->co, v2->co, cross);
VECCOPY(v2->n, nor);
copy_v3_v3(v2->n, nor);
v2->orco= sd->orco;
v2->accum= v1->accum;
}
@ -1192,8 +1192,8 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
if(sd->adapt){
second=0;
VECCOPY(anor,nor);
VECCOPY(avec,vec);
copy_v3_v3(anor,nor);
copy_v3_v3(avec,vec);
}
}
@ -1218,23 +1218,23 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
v1= vlr->v4; // cycle
v2= vlr->v3; // cycle
VECCOPY(anor,nor);
VECCOPY(avec,vec);
copy_v3_v3(anor,nor);
copy_v3_v3(avec,vec);
}
else{
vlr= RE_findOrAddVlak(obr, obr->totvlak-1);
}
}
VECCOPY(vlr->v4->co, vec);
copy_v3_v3(vlr->v4->co, vec);
add_v3_v3(vlr->v4->co, cross);
VECCOPY(vlr->v4->n, nor);
copy_v3_v3(vlr->v4->n, nor);
vlr->v4->orco= sd->orco;
vlr->v4->accum= -1.0f + 2.0f*sd->time; // accum abuse for strand texco
VECCOPY(vlr->v3->co, vec);
copy_v3_v3(vlr->v3->co, vec);
sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross);
VECCOPY(vlr->v3->n, nor);
copy_v3_v3(vlr->v3->n, nor);
vlr->v3->orco= sd->orco;
vlr->v3->accum= vlr->v4->accum;
@ -1245,7 +1245,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
if(sd->surfnor) {
float *snor= RE_vlakren_get_surfnor(obr, vlr, 1);
VECCOPY(snor, sd->surfnor);
copy_v3_v3(snor, sd->surfnor);
}
if(sd->uvco){
@ -1279,7 +1279,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
}
}
static void static_particle_wire(ObjectRen *obr, Material *ma, float *vec, float *vec1, int first, int line)
static void static_particle_wire(ObjectRen *obr, Material *ma, const float vec[3], const float vec1[3], int first, int line)
{
VlakRen *vlr;
static VertRen *v1;
@ -1291,13 +1291,13 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, float *vec, float
vlr->v3= vlr->v2;
vlr->v4= NULL;
VECCOPY(vlr->v1->co, vec);
VECCOPY(vlr->v2->co, vec1);
copy_v3_v3(vlr->v1->co, vec);
copy_v3_v3(vlr->v2->co, vec1);
sub_v3_v3v3(vlr->n, vec, vec1);
normalize_v3(vlr->n);
VECCOPY(vlr->v1->n, vlr->n);
VECCOPY(vlr->v2->n, vlr->n);
copy_v3_v3(vlr->v1->n, vlr->n);
copy_v3_v3(vlr->v2->n, vlr->n);
vlr->mat= ma;
vlr->ec= ME_V1V2;
@ -1305,7 +1305,7 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, float *vec, float
}
else if(first) {
v1= RE_findOrAddVert(obr, obr->totvert++);
VECCOPY(v1->co, vec);
copy_v3_v3(v1->co, vec);
}
else {
vlr= RE_findOrAddVlak(obr, obr->totvlak++);
@ -1315,11 +1315,11 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, float *vec, float
vlr->v4= NULL;
v1= vlr->v2; // cycle
VECCOPY(v1->co, vec);
copy_v3_v3(v1->co, vec);
sub_v3_v3v3(vlr->n, vec, vec1);
normalize_v3(vlr->n);
VECCOPY(v1->n, vlr->n);
copy_v3_v3(v1->n, vlr->n);
vlr->mat= ma;
vlr->ec= ME_V1V2;
@ -1376,10 +1376,10 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl
mul_m4_v3(re->viewmat, vlr->v4->co);
normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
VECCOPY(vlr->v1->n,vlr->n);
VECCOPY(vlr->v2->n,vlr->n);
VECCOPY(vlr->v3->n,vlr->n);
VECCOPY(vlr->v4->n,vlr->n);
copy_v3_v3(vlr->v1->n,vlr->n);
copy_v3_v3(vlr->v2->n,vlr->n);
copy_v3_v3(vlr->v3->n,vlr->n);
copy_v3_v3(vlr->v4->n,vlr->n);
vlr->mat= ma;
vlr->ec= ME_V2V3;
@ -1470,7 +1470,7 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re
{
float loc[3], loc0[3], loc1[3], vel[3];
VECCOPY(loc, state->co);
copy_v3_v3(loc, state->co);
if(ren_as != PART_DRAW_BB)
mul_m4_v3(re->viewmat, loc);
@ -1481,7 +1481,7 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re
sd->time = 0.0f;
sd->size = hasize;
VECCOPY(vel, state->vel);
copy_v3_v3(vel, state->vel);
mul_mat3_m4_v3(re->viewmat, vel);
normalize_v3(vel);
@ -1497,8 +1497,8 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re
case PART_DRAW_BB:
VECCOPY(bb->vec, loc);
VECCOPY(bb->vel, state->vel);
copy_v3_v3(bb->vec, loc);
copy_v3_v3(bb->vel, state->vel);
particle_billboard(re, obr, ma, bb);
@ -1892,7 +1892,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
strand= RE_findOrAddStrand(obr, obr->totstrand++);
strand->buffer= strandbuf;
strand->vert= svert;
VECCOPY(strand->orco, sd.orco);
copy_v3_v3(strand->orco, sd.orco);
if(dosimplify) {
float *ssimplify= RE_strandren_get_simplify(obr, strand, 1);
@ -1902,7 +1902,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if(sd.surfnor) {
float *snor= RE_strandren_get_surfnor(obr, strand, 1);
VECCOPY(snor, sd.surfnor);
copy_v3_v3(snor, sd.surfnor);
}
if(dosurfacecache && num >= 0) {
@ -1945,8 +1945,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
float time;
if(k<=max_k){
VECCOPY(state.co,(cache+k)->co);
VECCOPY(state.vel,(cache+k)->vel);
copy_v3_v3(state.co,(cache+k)->co);
copy_v3_v3(state.vel,(cache+k)->vel);
}
else
continue;
@ -1955,11 +1955,11 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
curlen += len_v3v3((cache+k-1)->co, (cache+k)->co);
time= curlen/strandlen;
VECCOPY(loc,state.co);
copy_v3_v3(loc,state.co);
mul_m4_v3(re->viewmat,loc);
if(strandbuf) {
VECCOPY(svert->co, loc);
copy_v3_v3(svert->co, loc);
svert->strandco= -1.0f + 2.0f*time;
svert++;
strand->totvert++;
@ -1982,7 +1982,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
if(k)
particle_curve(re, obr, psmd->dm, ma, &sd, loc, loc1, seed, pa_co);
VECCOPY(loc1,loc);
copy_v3_v3(loc1,loc);
}
}
@ -2147,7 +2147,7 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int
if(ok) {
hasize= ma->hasize;
VECCOPY(vec, mvert->co);
copy_v3_v3(vec, mvert->co);
mul_m4_v3(mat, vec);
if(ma->mode & MA_HALOPUNO) {
@ -2161,7 +2161,7 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int
nor[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
normalize_v3(nor);
VECCOPY(view, vec);
copy_v3_v3(view, vec);
normalize_v3(view);
zn= nor[0]*view[0]+nor[1]*view[1]+nor[2]*view[2];
@ -2238,9 +2238,9 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve
int i;
/* shi->co is current render coord, just make sure at least some vector is here */
VECCOPY(shi->co, vr->co);
copy_v3_v3(shi->co, vr->co);
/* vertex normal is used for textures type 'col' and 'var' */
VECCOPY(shi->vn, vr->n);
copy_v3_v3(shi->vn, vr->n);
if(mat)
mul_m4_v3(mat, shi->co);
@ -2269,7 +2269,7 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve
/* set all rendercoords, 'texco' is an ORed value for all textures needed */
if ((texco & TEXCO_ORCO) && (vr->orco)) {
VECCOPY(shi->lo, vr->orco);
copy_v3_v3(shi->lo, vr->orco);
}
if (texco & TEXCO_STICKY) {
float *sticky= RE_vertren_get_sticky(obr, vr, 0);
@ -2280,11 +2280,11 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve
}
}
if (texco & TEXCO_GLOB) {
VECCOPY(shi->gl, shi->co);
copy_v3_v3(shi->gl, shi->co);
mul_m4_v3(re->viewinv, shi->gl);
}
if (texco & TEXCO_NORM) {
VECCOPY(shi->orn, shi->vn);
copy_v3_v3(shi->orn, shi->vn);
}
if(texco & TEXCO_REFL) {
/* not (yet?) */
@ -2461,7 +2461,7 @@ static void init_render_mball(Render *re, ObjectRen *obr)
for(a=0; a<dl->nr; a++, data+=3, nors+=3) {
ver= RE_findOrAddVert(obr, obr->totvert++);
VECCOPY(ver->co, data);
copy_v3_v3(ver->co, data);
mul_m4_v3(mat, ver->co);
/* render normals are inverted */
@ -2540,7 +2540,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
data= dl->verts;
for (u = 0; u < sizeu; u++) {
v1 = RE_findOrAddVert(obr, obr->totvert++); /* save this for possible V wrapping */
VECCOPY(v1->co, data); data += 3;
copy_v3_v3(v1->co, data); data += 3;
if(orco) {
v1->orco= orco; orco+= 3; orcoret++;
}
@ -2548,7 +2548,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
for (v = 1; v < sizev; v++) {
ver= RE_findOrAddVert(obr, obr->totvert++);
VECCOPY(ver->co, data); data += 3;
copy_v3_v3(ver->co, data); data += 3;
if(orco) {
ver->orco= orco; orco+= 3; orcoret++;
}
@ -2557,7 +2557,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
/* if V-cyclic, add extra vertices at end of the row */
if (dl->flag & DL_CYCL_U) {
ver= RE_findOrAddVert(obr, obr->totvert++);
VECCOPY(ver->co, v1->co);
copy_v3_v3(ver->co, v1->co);
if(orco) {
ver->orco= orco; orco+=3; orcoret++; //orcobase + 3*(u*sizev + 0);
}
@ -2573,7 +2573,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
for (v = 0; v < nsizev; v++) {
v1= RE_findOrAddVert(obr, startvert + v);
ver= RE_findOrAddVert(obr, obr->totvert++);
VECCOPY(ver->co, v1->co);
copy_v3_v3(ver->co, v1->co);
if(orco) {
ver->orco= orco; orco+=3; orcoret++; //ver->orco= orcobase + 3*(0*sizev + v);
}
@ -2602,7 +2602,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
normal_quad_v3( n1,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
VECCOPY(vlr->n, n1);
copy_v3_v3(vlr->n, n1);
vlr->mat= matar[ dl->col];
vlr->ec= ME_V1V2+ME_V2V3;
@ -2670,10 +2670,10 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
add_v3_v3(n1, vlr2->n);
vlr3= RE_findOrAddVlak(obr, UVTOINDEX(sizeu-1, 0)); /* (m,0) */
add_v3_v3(n1, vlr3->n);
VECCOPY(vlr->v3->n, n1);
VECCOPY(vlr1->v1->n, n1);
VECCOPY(vlr2->v2->n, n1);
VECCOPY(vlr3->v4->n, n1);
copy_v3_v3(vlr->v3->n, n1);
copy_v3_v3(vlr1->v1->n, n1);
copy_v3_v3(vlr2->v2->n, n1);
copy_v3_v3(vlr3->v4->n, n1);
}
for(a = startvert; a < obr->totvert; a++) {
ver= RE_findOrAddVert(obr, a);
@ -2701,7 +2701,7 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr,
for(a=0; a<totvert; a++, mvert++) {
ver= RE_findOrAddVert(obr, obr->totvert++);
VECCOPY(ver->co, mvert->co);
copy_v3_v3(ver->co, mvert->co);
mul_m4_v3(mat, ver->co);
if(orco) {
@ -2913,7 +2913,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
for(a=0; a<dl->nr; a++, data+=3) {
ver= RE_findOrAddVert(obr, obr->totvert++);
VECCOPY(ver->co, data);
copy_v3_v3(ver->co, data);
mul_m4_v3(mat, ver->co);
@ -2979,7 +2979,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
while(nr--) {
ver= RE_findOrAddVert(obr, obr->totvert++);
VECCOPY(ver->co, fp);
copy_v3_v3(ver->co, fp);
mul_m4_v3(mat, ver->co);
fp+= 3;
@ -3340,7 +3340,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
for(a=0; a<totvert; a++, mvert++) {
ver= RE_findOrAddVert(obr, obr->totvert++);
VECCOPY(ver->co, mvert->co);
copy_v3_v3(ver->co, mvert->co);
if(do_autosmooth==0) { /* autosmooth on original unrotated data to prevent differences between frames */
normal_short_to_float_v3(ver->n, mvert->no);
mul_m4_v3(mat, ver->co);
@ -3782,7 +3782,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
lar->sunsky = (struct SunSky*)MEM_callocN(sizeof(struct SunSky), "sunskyren");
lar->sunsky->effect_type = la->sun_effect_type;
VECCOPY(vec,ob->obmat[2]);
copy_v3_v3(vec,ob->obmat[2]);
normalize_v3(vec);
InitSunSky(lar->sunsky, la->atm_turbidity, vec, la->horizon_brightness,
@ -4001,7 +4001,7 @@ void init_render_world(Render *re)
cp[2]= 255.0f*re->wrld.horb;
cp[3]= 1;
VECCOPY(re->grvec, re->viewmat[2]);
copy_v3_v3(re->grvec, re->viewmat[2]);
normalize_v3(re->grvec);
copy_m3_m4(re->imat, re->viewinv);
@ -4051,25 +4051,25 @@ static void set_phong_threshold(ObjectRen *obr)
for(i=0; i<obr->totvlak; i++) {
vlr= RE_findOrAddVlak(obr, i);
if(vlr->flag & R_SMOOTH) {
dot= INPR(vlr->n, vlr->v1->n);
dot= dot_v3v3(vlr->n, vlr->v1->n);
dot= ABS(dot);
if(dot>0.9f) {
thresh+= dot; tot++;
}
dot= INPR(vlr->n, vlr->v2->n);
dot= dot_v3v3(vlr->n, vlr->v2->n);
dot= ABS(dot);
if(dot>0.9f) {
thresh+= dot; tot++;
}
dot= INPR(vlr->n, vlr->v3->n);
dot= dot_v3v3(vlr->n, vlr->v3->n);
dot= ABS(dot);
if(dot>0.9f) {
thresh+= dot; tot++;
}
if(vlr->v4) {
dot= INPR(vlr->n, vlr->v4->n);
dot= dot_v3v3(vlr->n, vlr->v4->n);
dot= ABS(dot);
if(dot>0.9f) {
thresh+= dot; tot++;
@ -4340,16 +4340,16 @@ static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset)
strand_minmax(strand, smin, smax, width);
}
VECCOPY(sbound->boundbox[0], smin);
VECCOPY(sbound->boundbox[1], smax);
copy_v3_v3(sbound->boundbox[0], smin);
copy_v3_v3(sbound->boundbox[1], smax);
DO_MINMAX(smin, min, max);
DO_MINMAX(smax, min, max);
}
}
VECCOPY(obr->boundbox[0], min);
VECCOPY(obr->boundbox[1], max);
copy_v3_v3(obr->boundbox[0], min);
copy_v3_v3(obr->boundbox[1], max);
}
}
}
@ -4932,7 +4932,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
/* fill in instance variables for texturing */
set_dupli_tex_mat(re, obi, dob);
if(dob->type != OB_DUPLIGROUP) {
VECCOPY(obi->dupliorco, dob->orco);
copy_v3_v3(obi->dupliorco, dob->orco);
obi->dupliuv[0]= dob->uv[0];
obi->dupliuv[1]= dob->uv[1];
}
@ -4958,7 +4958,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
set_dupli_tex_mat(re, obi, dob);
if(dob->type != OB_DUPLIGROUP) {
VECCOPY(obi->dupliorco, dob->orco);
copy_v3_v3(obi->dupliorco, dob->orco);
obi->dupliuv[0]= dob->uv[0];
obi->dupliuv[1]= dob->uv[1];
}
@ -5064,7 +5064,7 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l
/* still bad... doing all */
init_render_textures(re);
VECCOPY(amb, &re->wrld.ambr);
copy_v3_v3(amb, &re->wrld.ambr);
init_render_materials(re->main, re->r.mode, amb);
set_node_shader_lamp_loop(shade_material_loop);
@ -5216,7 +5216,7 @@ static void database_fromscene_vectors(Render *re, Scene *scene, unsigned int la
}
/* choose to use static, to prevent giving too many args to this call */
static void speedvector_project(Render *re, float *zco, float *co, float *ho)
static void speedvector_project(Render *re, float zco[2], const float co[3], const float ho[4])
{
static float pixelphix=0.0f, pixelphiy=0.0f, zmulx=0.0f, zmuly=0.0f;
static int pano= 0;
@ -5251,7 +5251,7 @@ static void speedvector_project(Render *re, float *zco, float *co, float *ho)
if(pano) {
float vec[3], ang;
/* angle between (0,0,-1) and (co) */
VECCOPY(vec, co);
copy_v3_v3(vec, co);
ang= saacos(-vec[2]/sqrt(vec[0]*vec[0] + vec[2]*vec[2]));
if(vec[0]<0.0f) ang= -ang;
@ -5267,7 +5267,7 @@ static void speedvector_project(Render *re, float *zco, float *co, float *ho)
}
}
static void calculate_speedvector(float *vectors, int step, float winsq, float winroot, float *co, float *ho, float *speed)
static void calculate_speedvector(const float vectors[2], int step, float winsq, float winroot, const float co[3], const float ho[4], float speed[4])
{
float zco[2], len;
@ -5764,7 +5764,7 @@ void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, unsigned int lay,
/* still bad... doing all */
init_render_textures(re);
VECCOPY(amb, &re->wrld.ambr);
copy_v3_v3(amb, &re->wrld.ambr);
init_render_materials(re->main, re->r.mode, amb);
set_node_shader_lamp_loop(shade_material_loop);
@ -5860,7 +5860,7 @@ void RE_make_sticky(Scene *scene, View3D *v3d)
ms= me->msticky;
for(a=0; a<me->totvert; a++, ms++, mvert++) {
VECCOPY(ho, mvert->co);
copy_v3_v3(ho, mvert->co);
mul_m4_v3(mat, ho);
projectverto(ho, re->winmat, ho);
ms->co[0]= ho[0]/ho[3];

@ -2526,7 +2526,7 @@ void do_material_tex(ShadeInput *shi)
nor[1]= Tnor*norfac*texres.nor[1];
nor[2]= Tnor*norfac*texres.nor[2];
dot= 0.5f + 0.5f*INPR(nor, shi->vn);
dot= 0.5f + 0.5f * dot_v3v3(nor, shi->vn);
shi->vn[0]+= dot*nor[0];
shi->vn[1]+= dot*nor[1];

@ -128,7 +128,7 @@ void calc_view_vector(float *view, float x, float y)
}
}
void calc_renderco_ortho(float *co, float x, float y, int z)
void calc_renderco_ortho(float co[3], float x, float y, int z)
{
/* x and y 3d coordinate can be derived from pixel coord and winmat */
float fx= 2.0f/(R.winx*R.winmat[0][0]);
@ -142,7 +142,7 @@ void calc_renderco_ortho(float *co, float x, float y, int z)
co[2]= R.winmat[3][2]/( R.winmat[2][3]*zco - R.winmat[2][2] );
}
void calc_renderco_zbuf(float *co, float *view, int z)
void calc_renderco_zbuf(float co[3], float *view, int z)
{
float fac, zco;

@ -1238,7 +1238,7 @@ static int panotestclip(Render *re, int do_pano, float *v)
- shadow buffering (shadbuf.c)
*/
void project_renderdata(Render *re, void (*projectfunc)(float *, float mat[][4], float *), int do_pano, float xoffs, int UNUSED(do_buckets))
void project_renderdata(Render *re, void (*projectfunc)(const float *, float mat[][4], float *), int do_pano, float xoffs, int UNUSED(do_buckets))
{
ObjectRen *obr;
HaloRen *har = NULL;

@ -369,7 +369,7 @@ void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spo
cross_v3_v3v3(shi->vn, cross, spoint->tan);
normalize_v3(shi->vn);
if(INPR(shi->vn, shi->view) < 0.0f)
if(dot_v3v3(shi->vn, shi->view) < 0.0f)
negate_v3(shi->vn);
}
@ -586,7 +586,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert
}
/* from scanline pixel coordinates to 3d coordinates, requires set_triangle */
void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float *view, float *dxyview, float *co, float *dxco, float *dyco)
void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float view[3], float dxyview[2], float co[3], float dxco[3], float dyco[3])
{
/* returns not normalized, so is in viewplane coords */
calc_view_vector(view, x, y);

@ -486,8 +486,8 @@ static float area_lamp_energy_multisample(LampRen *lar, float *co, float *vn)
int a= lar->ray_totsamp;
/* test if co is behind lamp */
VECSUB(vec, co, lar->co);
if(INPR(vec, lar->vec) < 0.0f)
sub_v3_v3v3(vec, co, lar->co);
if(dot_v3v3(vec, lar->vec) < 0.0f)
return 0.0f;
while(a--) {
@ -1125,15 +1125,15 @@ float lamp_get_visibility(LampRen *lar, float *co, float *lv, float *dist)
else {
float visifac= 1.0f, t;
VECSUB(lv, co, lar->co);
*dist= sqrt( INPR(lv, lv));
sub_v3_v3v3(lv, co, lar->co);
*dist= len_v3v3(lv, lv);
t= 1.0f/dist[0];
VECMUL(lv, t);
mul_v3_fl(lv, t);
/* area type has no quad or sphere option */
if(lar->type==LA_AREA) {
/* area is single sided */
//if(INPR(lv, lar->vec) > 0.0f)
//if(dot_v3v3(lv, lar->vec) > 0.0f)
// visifac= 1.0f;
//else
// visifac= 0.0f;
@ -1279,7 +1279,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int
cross_v3_v3v3(cross, shi->surfnor, vn);
cross_v3_v3v3(nstrand, vn, cross);
blend= INPR(nstrand, shi->surfnor);
blend= dot_v3v3(nstrand, shi->surfnor);
blend= 1.0f - blend;
CLAMP(blend, 0.0f, 1.0f);
@ -1383,7 +1383,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int
if(lar->shb || (lar->mode & LA_SHAD_RAY)) {
if(vn==vnor) /* tangent trigger */
lamp_get_shadow(lar, shi, INPR(shi->vn, lv), shadfac, shi->depth);
lamp_get_shadow(lar, shi, dot_v3v3(shi->vn, lv), shadfac, shi->depth);
else
lamp_get_shadow(lar, shi, inp, shadfac, shi->depth);
@ -1531,7 +1531,7 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr)
continue;
}
inpr= INPR(shi->vn, lv);
inpr= dot_v3v3(shi->vn, lv);
if(inpr <= 0.0f) {
if (shi->mat->shadowonly_flag == MA_SO_OLD)
accum+= 1.0f;
@ -1864,7 +1864,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
result[2]= shi->mirb*shi->refcol[3] + (1.0f - shi->mirb*shi->refcol[0])*shr->combined[2];
if(passflag & SCE_PASS_REFLECT)
VECSUB(shr->refl, result, shr->combined);
sub_v3_v3v3(shr->refl, result, shr->combined);
if(shi->combinedflag & SCE_PASS_REFLECT)
VECCOPY(shr->combined, result);

@ -394,8 +394,8 @@ static void traverse_octree(ScatterTree *tree, ScatterNode *node, float *co, int
for(i=0; i<node->totpoint; i++) {
ScatterPoint *p= &node->points[i];
VECSUB(sub, co, p->co);
dist= INPR(sub, sub);
sub_v3_v3v3(sub, co, p->co);
dist= dot_v3v3(sub, sub);
if(p->back)
add_radiance(tree, NULL, p->rad, 0.0f, p->area, dist, result);
@ -418,8 +418,8 @@ static void traverse_octree(ScatterTree *tree, ScatterNode *node, float *co, int
}
else {
/* decide subnode traversal based on maximum solid angle */
VECSUB(sub, co, subnode->co);
dist= INPR(sub, sub);
sub_v3_v3v3(sub, co, subnode->co);
dist= dot_v3v3(sub, sub);
/* actually area/dist > error, but this avoids division */
if(subnode->area+subnode->backarea>tree->error*dist) {

@ -95,7 +95,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, float *co)
is.dir[2] = -lar->vec[2];
is.dist = R.maxdist;
} else {
VECSUB( is.dir, lar->co, is.start );
sub_v3_v3v3(is.dir, lar->co, is.start);
is.dist = normalize_v3( is.dir );
}

@ -239,7 +239,7 @@ static short cliptestf(float p, float q, float *u1, float *u2)
return 1;
}
int testclip(float *v)
int testclip(const float v[3])
{
float abs4; /* WATCH IT: this function should do the same as cliptestf, otherwise troubles in zbufclip()*/
short c=0;
@ -1692,7 +1692,7 @@ static void makevertpyra(float *vez, float *labda, float **trias, float *v1, flo
/* ------------------------------------------------------------------------- */
void projectverto(float *v1, float winmat[][4], float *adr)
void projectverto(const float v1[3], float winmat[][4], float adr[4])
{
/* calcs homogenic coord of vertex v1 */
float x,y,z;
@ -1710,7 +1710,7 @@ void projectverto(float *v1, float winmat[][4], float *adr)
/* ------------------------------------------------------------------------- */
void projectvert(float *v1, float winmat[][4], float *adr)
void projectvert(const float v1[3], float winmat[][4], float adr[4])
{
/* calcs homogenic coord of vertex v1 */
float x,y,z;