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

Comparing ray/src/rt/ambient.c (file contents):
Revision 2.81 by greg, Fri Apr 25 23:04:16 2014 UTC vs.
Revision 2.83 by greg, Sat Apr 26 05:15:17 2014 UTC

# Line 110 | Line 110 | setambres(                             /* set ambient resolution */
110                                                  /* set min & max radii */
111          if (ar <= 0) {
112                  minarad = 0;
113 <                maxarad = thescene.cusize / 2.0;
113 >                maxarad = thescene.cusize*0.5;
114          } else {
115                  minarad = thescene.cusize / ar;
116 <                maxarad = 64 * minarad;                 /* heuristic */
117 <                if (maxarad > thescene.cusize / 2.0)
118 <                        maxarad = thescene.cusize / 2.0;
116 >                maxarad = 64.0 * minarad;               /* heuristic */
117 >                if (maxarad > thescene.cusize*0.5)
118 >                        maxarad = thescene.cusize*0.5;
119          }
120          if (minarad <= FTINY)
121 <                minarad = 10*FTINY;
121 >                minarad = 10.0*FTINY;
122          if (maxarad <= minarad)
123 <                maxarad = 64 * minarad;
123 >                maxarad = 64.0 * minarad;
124   }
125  
126  
# Line 129 | Line 129 | setambacc(                             /* set ambient accuracy */
129          double  newa
130   )
131   {
132 <        double  ambdiff;
133 <
134 <        if (newa < 0.0)
135 <                newa = 0.0;
136 <        ambdiff = fabs(newa - ambacc);
137 <        if (ambdiff >= .01 && (ambacc = newa) > FTINY) {
138 <                qambacc = sqrt(sqrt(ambacc));
132 >        double  olda = qambacc*qambacc*qambacc*qambacc;
133 >        
134 >        newa *= (newa > 0);
135 >        if (fabs(newa - olda) >= .05*(newa + olda)) {
136 >                qambacc = sqrt(sqrt(ambacc = newa));
137                  if (nambvals > 0)
138                          sortambvals(1);         /* rebuild tree */
139          }
# Line 152 | Line 150 | setambient(void)                               /* initialize calculation */
150          ambdone();
151                                                  /* init ambient limits */
152          setambres(ambres);
153 <        qambacc = sqrt(sqrt(ambacc *= (ambacc > FTINY)));
153 >        setambacc(ambacc);
154          if (ambfile == NULL || !ambfile[0])
155                  return;
156          if (ambacc <= FTINY) {
# Line 365 | Line 363 | sumambient(            /* get interpolated ambient value */
363          FVECT           ck0;
364          int             i, j;
365          AMBVAL          *av;
366 +
367 +        if (at->kid != NULL) {          /* sum children first */                                
368 +                s *= 0.5;
369 +                for (i = 0; i < 8; i++) {
370 +                        for (j = 0; j < 3; j++) {
371 +                                ck0[j] = c0[j];
372 +                                if (1<<j & i)
373 +                                        ck0[j] += s;
374 +                                if (r->rop[j] < ck0[j] - OCTSCALE*s)
375 +                                        break;
376 +                                if (r->rop[j] > ck0[j] + (1.0+OCTSCALE)*s)
377 +                                        break;
378 +                        }
379 +                        if (j == 3)
380 +                                wsum += sumambient(acol, r, rn, al,
381 +                                                        at->kid+i, ck0, s);
382 +                }
383 +                                        /* good enough? */
384 +                if (wsum > 0.04 && s > (minarad*0.8+maxarad*0.2))
385 +                        return(wsum);
386 +        }
387                                          /* sum this node */
388          for (av = at->alist; av != NULL; av = av->next) {
389                  double  d, delta_r2, delta_t2;
# Line 421 | Line 440 | sumambient(            /* get interpolated ambient value */
440                  scalecolor(ct, d);
441                  addcolor(acol, ct);
442                  wsum += d;
424        }
425        if (at->kid == NULL)
426                return(wsum);
427                                        /* sum children */
428        s *= 0.5;
429        for (i = 0; i < 8; i++) {
430                for (j = 0; j < 3; j++) {
431                        ck0[j] = c0[j];
432                        if (1<<j & i)
433                                ck0[j] += s;
434                        if (r->rop[j] < ck0[j] - OCTSCALE*s)
435                                break;
436                        if (r->rop[j] > ck0[j] + (1.0+OCTSCALE)*s)
437                                break;
438                }
439                if (j == 3)
440                        wsum += sumambient(acol, r, rn, al,
441                                                at->kid+i, ck0, s);
443          }
444          return(wsum);
445   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines