ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rfluxmtx.c
(Generate patch)

Comparing ray/src/util/rfluxmtx.c (file contents):
Revision 2.39 by greg, Fri Aug 19 18:31:26 2016 UTC vs.
Revision 2.41 by greg, Sat Aug 20 03:43:24 2016 UTC

# Line 64 | Line 64 | typedef struct {
64          FVECT   uva[2];                 /* tangent axes */
65          int     ntris;                  /* number of triangles */
66          struct ptri {
67 <                float   afrac;                  /* fraction of total area */
67 >                double  afrac;                  /* fraction of total area */
68                  short   vndx[3];                /* vertex indices */
69          }       tri[1];                 /* triangle array (extends struct) */
70   } POLYTRIS;                     /* triangulated polygon */
# Line 558 | Line 558 | ssamp_poly(FVECT orig, SURF *sp, double x)
558  
559          if (ptp == NULL) {              /* need to triangulate */
560                  ptp = (POLYTRIS *)malloc(sizeof(POLYTRIS) +
561 <                                sizeof(struct ptri)*(sp->nfargs/3 - 1));
561 >                                sizeof(struct ptri)*(sp->nfargs/3 - 3));
562                  if (ptp == NULL)
563                          goto memerr;
564                  if (sp->nfargs == 3) {  /* simple case */
# Line 602 | Line 602 | ssamp_poly(FVECT orig, SURF *sp, double x)
602                  sp->priv = (void *)ptp;
603          }
604                                          /* pick triangle by partial area */
605 <        for (i = 0; i < ptp->ntris && x > ptp->tri[i].afrac; i++)
605 >        for (i = 0; i < ptp->ntris-1 && x > ptp->tri[i].afrac; i++)
606                  x -= ptp->tri[i].afrac;
607          SDmultiSamp(samp2, 2, x/ptp->tri[i].afrac);
608          samp2[0] *= samp2[1] = sqrt(samp2[1]);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines