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

Comparing ray/src/rt/ambcomp.c (file contents):
Revision 2.61 by greg, Sun May 18 18:59:55 2014 UTC vs.
Revision 2.62 by greg, Mon May 19 20:23:48 2014 UTC

# Line 68 | Line 68 | ambsample(                             /* initial ambient division sample */
68                  setcolor(ar.rcoef, AVGREFL, AVGREFL, AVGREFL);
69          else
70                  copycolor(ar.rcoef, hp->acoef);
71 <        if (rayorigin(&ar, AMBIENT, hp->rp, ar.rcoef) < 0) {
72 <                if (!n) memset(ap, 0, sizeof(AMBSAMP));
71 >        if (rayorigin(&ar, AMBIENT, hp->rp, ar.rcoef) < 0)
72                  return(0);
74        }
73          if (ambacc > FTINY) {
74                  multcolor(ar.rcoef, hp->acoef);
75                  scalecolor(ar.rcoef, 1./AVGREFL);
# Line 99 | Line 97 | ambsample(                             /* initial ambient division sample */
97          if (ar.rt <= FTINY)
98                  return(0);              /* should never happen */
99          multcolor(ar.rcol, ar.rcoef);   /* apply coefficient */
100 <        if (!n || ar.rt*ap->d < 1.0)    /* new/closer distance? */
100 >        if (ar.rt*ap->d < 1.0)          /* new/closer distance? */
101                  ap->d = 1.0/ar.rt;
102          if (!n) {                       /* record first vertex & value */
103                  if (ar.rt > 10.0*thescene.cusize)
# Line 195 | Line 193 | ambsupersamp(AMBHEMI *hp, int cnt)
193                  if (e2rem <= FTINY)
194                          goto done;      /* nothing left to do */
195                  nss = *ep/e2rem*cnt + frandom();
196 <                for (n = 1; n <= nss; n++)
197 <                        cnt -= ambsample(hp, i, j, n);
196 >                for (n = 1; n <= nss && ambsample(hp,i,j,n); n++)
197 >                        --cnt;
198                  e2rem -= *ep++;         /* update remainder */
199          }
200   done:
# Line 229 | Line 227 | samp_hemi(                             /* sample indirect hemisphere */
227          hp->rp = r;
228          hp->ns = n;
229          hp->acol[RED] = hp->acol[GRN] = hp->acol[BLU] = 0.0;
230 +        memset(hp->sa, 0, sizeof(AMBSAMP)*n*n);
231          hp->sampOK = 0;
232                                          /* assign coefficient */
233          copycolor(hp->acoef, rcol);
# Line 614 | Line 613 | ambcorral(AMBHEMI *hp, FVECT uv[2], const double r0, c
613          double          avg_d = 0;
614          uint32          flgs = 0;
615          FVECT           vec;
616 <        double          d, u, v;
616 >        double          u, v;
617          double          ang, a1;
618          int             i, j;
619                                          /* don't bother for a few samples */
# Line 636 | Line 635 | ambcorral(AMBHEMI *hp, FVECT uv[2], const double r0, c
635                  if ((ap->d <= FTINY) | (ap->d >= max_d))
636                          continue;       /* too far or too near */
637                  VSUB(vec, ap->p, hp->rp->rop);
638 <                d = DOT(vec, hp->rp->ron);
639 <                d = 1.0/sqrt(DOT(vec,vec) - d*d);
640 <                u = DOT(vec, uv[0]) * d;
642 <                v = DOT(vec, uv[1]) * d;
643 <                if ((r0*r0*u*u + r1*r1*v*v) * ap->d*ap->d <= 1.0)
638 >                u = DOT(vec, uv[0]);
639 >                v = DOT(vec, uv[1]);
640 >                if ((r0*r0*u*u + r1*r1*v*v) * ap->d*ap->d <= u*u + v*v)
641                          continue;       /* occluder outside ellipse */
642                  ang = atan2a(v, u);     /* else set direction flags */
643                  for (a1 = ang-.5*ang_res; a1 <= ang+.5*ang_res; a1 += ang_step)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines