--- ray/src/util/rfluxmtx.c 2016/08/18 00:52:48 2.38 +++ ray/src/util/rfluxmtx.c 2016/08/20 03:43:24 2.41 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rfluxmtx.c,v 2.38 2016/08/18 00:52:48 greg Exp $"; +static const char RCSid[] = "$Id: rfluxmtx.c,v 2.41 2016/08/20 03:43:24 greg Exp $"; #endif /* * Calculate flux transfer matrix or matrices using rcontrib @@ -64,7 +64,7 @@ typedef struct { FVECT uva[2]; /* tangent axes */ int ntris; /* number of triangles */ struct ptri { - float afrac; /* fraction of total area */ + double afrac; /* fraction of total area */ short vndx[3]; /* vertex indices */ } tri[1]; /* triangle array (extends struct) */ } POLYTRIS; /* triangulated polygon */ @@ -602,7 +602,7 @@ ssamp_poly(FVECT orig, SURF *sp, double x) sp->priv = (void *)ptp; } /* pick triangle by partial area */ - for (i = 0; i < ptp->ntris && x > ptp->tri[i].afrac; i++) + for (i = 0; i < ptp->ntris-1 && x > ptp->tri[i].afrac; i++) x -= ptp->tri[i].afrac; SDmultiSamp(samp2, 2, x/ptp->tri[i].afrac); samp2[0] *= samp2[1] = sqrt(samp2[1]);