--- ray/src/cv/bsdfrbf.c 2013/10/21 21:48:42 2.13 +++ ray/src/cv/bsdfrbf.c 2014/03/02 01:56:03 2.19 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: bsdfrbf.c,v 2.13 2013/10/21 21:48:42 greg Exp $"; +static const char RCSid[] = "$Id: bsdfrbf.c,v 2.19 2014/03/02 01:56:03 greg Exp $"; #endif /* * Radial basis function representation for BSDF data. @@ -35,7 +35,7 @@ static const char RCSid[] = "$Id: bsdfrbf.c,v 2.13 201 #define SMOOTH_MSE 5e-5 /* acceptable mean squared error */ #endif #ifndef SMOOTH_MSER -#define SMOOTH_MSER 0.07 /* acceptable relative MSE */ +#define SMOOTH_MSER 0.03 /* acceptable relative MSE */ #endif #define MAX_RAD (GRIDRES/8) /* maximum lobe radius */ @@ -91,8 +91,8 @@ add_bsdf_data(double theta_out, double phi_out, double static void comp_bsdf_min() { - int cnt; - int i, target; + unsigned long cnt, target; + int i; cnt = 0; for (i = HISTLEN; i--; ) @@ -147,10 +147,11 @@ smooth_region(int x0, int x1, int y0, int y1) xvec[2] += z; } rMtx[1][0] = rMtx[0][1]; + rMtx[2][0] = rMtx[0][2]; rMtx[2][1] = rMtx[1][2]; nvs = rMtx[2][2]; if (SDinvXform(rMtx, rMtx) != SDEnone) - return(0); + return(1); /* colinear values */ A = DOT(rMtx[0], xvec); B = DOT(rMtx[1], xvec); C = DOT(rMtx[2], xvec); @@ -223,7 +224,8 @@ build_rbfrep(RBFVAL **arp, int *np, int x0, int x1, in if (!nleaves) /* nothing but branches? */ return(nadded); /* combine 4 leaves into 1? */ - if (nleaves == 4 && x1-x0 < MAX_RAD && smooth_region(x0, x1, y0, y1)) + if ((nleaves == 4) & (x1-x0 <= MAX_RAD) && + smooth_region(x0, x1, y0, y1)) return(0); /* need more array space? */ if ((*np+nleaves-1)>>RBFALLOCB != (*np-1)>>RBFALLOCB) {