--- ray/src/cv/bsdfrep.c 2012/11/09 02:16:29 2.8 +++ ray/src/cv/bsdfrep.c 2012/11/22 06:07:17 2.11 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: bsdfrep.c,v 2.8 2012/11/09 02:16:29 greg Exp $"; +static const char RCSid[] = "$Id: bsdfrep.c,v 2.11 2012/11/22 06:07:17 greg Exp $"; #endif /* * Support BSDF representation as radial basis functions. @@ -82,7 +82,7 @@ new_input_direction(double new_theta, double new_phi) int use_symmetry(FVECT vec) { - double phi = get_phi360(vec); + const double phi = get_phi360(vec); switch (inp_coverage) { case INP_QUAD1|INP_QUAD2|INP_QUAD3|INP_QUAD4: @@ -189,7 +189,7 @@ rotate_rbf(RBFNODE *rbf, const FVECT invec) int pos[2]; int n; - for (n = rbf->nrbf; n-- > 0; ) { + for (n = ((-.01 > phi) | (phi > .01))*rbf->nrbf; n-- > 0; ) { ovec_from_pos(outvec, rbf->rbfa[n].gx, rbf->rbfa[n].gy); spinvector(outvec, outvec, vnorm, phi); pos_from_vec(pos, outvec); @@ -485,6 +485,10 @@ load_bsdf_rep(FILE *ifp) rbfh.invec[0] = getflt(ifp); rbfh.invec[1] = getflt(ifp); rbfh.invec[2] = getflt(ifp); + if (normalize(rbfh.invec) == 0) { + fprintf(stderr, "%s: zero incident vector\n", progname); + return(0); + } rbfh.vtotal = getflt(ifp); rbfh.nrbf = getint(4, ifp); newrbf = (RBFNODE *)malloc(sizeof(RBFNODE) +