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.87 by greg, Fri May 9 16:40:01 2014 UTC vs.
Revision 2.92 by greg, Fri Nov 21 00:30:11 2014 UTC

# Line 109 | Line 109 | setambres(                             /* set ambient resolution */
109                                                  /* set min & max radii */
110          if (ar <= 0) {
111                  minarad = 0;
112 <                maxarad = thescene.cusize*0.5;
112 >                maxarad = thescene.cusize*0.2;
113          } else {
114                  minarad = thescene.cusize / ar;
115                  maxarad = 64.0 * minarad;               /* heuristic */
116 <                if (maxarad > thescene.cusize*0.5)
117 <                        maxarad = thescene.cusize*0.5;
116 >                if (maxarad > thescene.cusize*0.2)
117 >                        maxarad = thescene.cusize*0.2;
118          }
119          if (minarad <= FTINY)
120                  minarad = 10.0*FTINY;
# Line 165 | Line 165 | setambient(void)                               /* initialize calculation */
165                  initambfile(0);                 /* file exists */
166                  lastpos = ftell(ambfp);
167                  while (readambval(&amb, ambfp))
168 <                        avinsert(avstore(&amb));
168 >                        avstore(&amb);
169                  nambshare = nambvals;           /* share loaded values */
170                  if (readonly) {
171                          sprintf(errmsg,
# Line 263 | Line 263 | ambnotify(                     /* record new modifier */
263  
264   /************ THE FOLLOWING ROUTINES DIFFER BETWEEN NEW & OLD ***************/
265  
266 < #ifdef NEWAMB
266 > #ifndef OLDAMB
267  
268   #define tfunc(lwr, x, upr)      (((x)-(lwr))/((upr)-(lwr)))
269  
# Line 271 | Line 271 | static int     plugaleak(RAY *r, AMBVAL *ap, FVECT anorm,
271   static double   sumambient(COLOR acol, RAY *r, FVECT rn, int al,
272                                  AMBTREE *at, FVECT c0, double s);
273   static int      makeambient(COLOR acol, RAY *r, FVECT rn, int al);
274 < static void     extambient(COLOR cr, AMBVAL *ap, FVECT pv, FVECT nv,
274 > static int      extambient(COLOR cr, AMBVAL *ap, FVECT pv, FVECT nv,
275                                  FVECT uvw[3]);
276  
277   void
# Line 486 | Line 486 | sumambient(            /* get interpolated ambient value */
486                  /*
487                   *  Extrapolate value and compute final weight (hat function)
488                   */
489 <                extambient(ct, av, r->rop, rn, uvw);
489 >                if (!extambient(ct, av, r->rop, rn, uvw))
490 >                        continue;
491                  d = tfunc(maxangle, sqrt(delta_r2), 0.0) *
492                          tfunc(ambacc, sqrt(delta_t2), 0.0);
493                  scalecolor(ct, d);
# Line 537 | Line 538 | makeambient(           /* make a new ambient value for storage
538   }
539  
540  
541 < static void
541 > static int
542   extambient(             /* extrapolate value at pv, nv */
543          COLOR  cr,
544          AMBVAL   *ap,
# Line 567 | Line 568 | extambient(            /* extrapolate value at pv, nv */
568          
569          if (d <= 0.0) {
570                  setcolor(cr, 0.0, 0.0, 0.0);
571 <                return;
571 >                return(0);              /* should not use if we can avoid it */
572          }
573          copycolor(cr, ap->val);
574          scalecolor(cr, d);
575 +        return(1);
576   }
577  
578  
# Line 960 | Line 962 | avsave(                                /* insert and save an ambient value */
962          AMBVAL  *av
963   )
964   {
965 <        avinsert(avstore(av));
965 >        avstore(av);
966          if (ambfp == NULL)
967                  return;
968          if (writambval(av, ambfp) < 0)
# Line 975 | Line 977 | writerr:
977  
978  
979   static AMBVAL *
980 < avstore(                                /* allocate memory and store aval */
980 > avstore(                                /* allocate memory and save aval */
981          AMBVAL  *aval
982   )
983   {
# Line 993 | Line 995 | avstore(                               /* allocate memory and store aval */
995                  avsum += log(d);
996                  navsum++;
997          }
998 +        avinsert(av);                   /* insert in our cache tree */
999          return(av);
1000   }
1001  
# Line 1193 | Line 1196 | sortambvals(                   /* resort ambient values */
1196                  if (i_avlist < nambvals)
1197                          error(CONSISTENCY, "missing ambient values in sortambvals");
1198   #endif
1199 <                qsort((char *)avlist1, nambvals, sizeof(struct avl), &alatcmp);
1200 <                qsort((char *)avlist2, nambvals, sizeof(AMBVAL *), &aposcmp);
1199 >                qsort((char *)avlist1, nambvals, sizeof(struct avl), alatcmp);
1200 >                qsort((char *)avlist2, nambvals, sizeof(AMBVAL *), aposcmp);
1201                  for (i = 0; i < nambvals; i++) {
1202                          if (avlist1[i].p == NULL)
1203                                  continue;
# Line 1275 | Line 1278 | ambsync(void)                  /* synchronize ambient file */
1278                                  error(WARNING, errmsg);
1279                                  break;
1280                          }
1281 <                        avinsert(avstore(&avs));
1281 >                        avstore(&avs);
1282                          n -= AMBVALSIZ;
1283                  }
1284                  lastpos = flen - n;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines