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.89 by greg, Sun May 11 19:03:37 2014 UTC vs.
Revision 2.93 by greg, Fri Nov 21 00:53:52 2014 UTC

# 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 546 | Line 547 | extambient(            /* extrapolate value at pv, nv */
547          FVECT  uvw[3]
548   )
549   {
550 +        const double    min_d = 0.05;
551          static FVECT    my_uvw[3];
552          FVECT           v1;
553          int             i;
# Line 565 | Line 567 | extambient(            /* extrapolate value at pv, nv */
567          for (i = 3; i--; )
568                  d += v1[i] * (ap->gdir[0]*uvw[0][i] + ap->gdir[1]*uvw[1][i]);
569          
570 <        if (d <= 0.0) {
571 <                setcolor(cr, 0.0, 0.0, 0.0);
570 <                return;
571 <        }
570 >        if (d < min_d)                  /* should not use if we can avoid it */
571 >                d = min_d;
572          copycolor(cr, ap->val);
573          scalecolor(cr, d);
574 +        return(d > min_d);
575   }
576  
577  
# Line 1194 | Line 1195 | sortambvals(                   /* resort ambient values */
1195                  if (i_avlist < nambvals)
1196                          error(CONSISTENCY, "missing ambient values in sortambvals");
1197   #endif
1198 <                qsort((char *)avlist1, nambvals, sizeof(struct avl), &alatcmp);
1199 <                qsort((char *)avlist2, nambvals, sizeof(AMBVAL *), &aposcmp);
1198 >                qsort((char *)avlist1, nambvals, sizeof(struct avl), alatcmp);
1199 >                qsort((char *)avlist2, nambvals, sizeof(AMBVAL *), aposcmp);
1200                  for (i = 0; i < nambvals; i++) {
1201                          if (avlist1[i].p == NULL)
1202                                  continue;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines