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 1.12 by greg, Wed May 22 12:44:39 1991 UTC vs.
Revision 1.13 by greg, Thu Jun 6 10:48:50 1991 UTC

# Line 40 | Line 40 | OBJECT  ambset[MAXASET+1]={0}; /* ambient include/excl
40   double  maxarad;                /* maximum ambient radius */
41   double  minarad;                /* minimum ambient radius */
42  
43 + /*
44 + * Since we've defined our vectors as float below to save space,
45 + * watch out for changes in the definitions of VCOPY() and DOT().
46 + */
47   typedef struct ambval {
48 <        FVECT  pos;             /* position in space */
49 <        FVECT  dir;             /* normal direction */
48 >        float  pos[3];          /* position in space */
49 >        float  dir[3];          /* normal direction */
50          int  lvl;               /* recursion level of parent ray */
51          float  weight;          /* weight of parent ray */
52          COLOR  val;             /* computed ambient value */
# Line 209 | Line 213 | double  s;
213                  for (j = 0; j < 3; j++)
214                          d += (r->rop[j] - av->pos[j]) *
215                                          (av->dir[j] + r->ron[j]);
216 <                if (d < -minarad)
216 >                if (d*0.5 < -minarad*ambacc)
217                          continue;
218                  /*
219                   *  Jittering final test reduces image artifacts.
# Line 303 | Line 307 | register RAY  *r;
307                  div = (AMBSAMP *)malloc(ndivs*sizeof(AMBSAMP));
308                  if (div == NULL)
309                          error(SYSTEM, "out of memory in doambient");
310 <        }
310 >        } else
311 >                div = NULL;
312                                          /* make axes */
313          uy[0] = uy[1] = uy[2] = 0.0;
314          for (k = 0; k < 3; k++)
# Line 337 | Line 342 | register RAY  *r;
342                          ndims--;
343                          if (ar.rot < FHUGE)
344                                  arad += 1.0 / ar.rot;
345 <                        if (ns > 0) {                   /* save division */
345 >                        if (div != NULL) {              /* save division */
346                                  div[ne].k = 0.0;
347                                  copycolor(div[ne].v, ar.rcol);
348                                  div[ne].n = 0;
# Line 420 | Line 425 | register RAY  *r;
425  
426                  if (ne >= i) {          /* extract darkest division */
427                          ne--;
428 <                        if (div[ne].n > 1)
429 <                                scalecolor(div[ne].v, 1.0/div[ne].n);
428 >                        if (div[ne].n > 1) {
429 >                                b = 1.0/div[ne].n;
430 >                                scalecolor(div[ne].v, b);
431 >                                div[ne].n = 1;
432 >                        }
433                          addcolor(acol, div[ne].v);
434                  }
435          }
# Line 434 | Line 442 | register RAY  *r;
442                  arad = maxarad;
443          else if (arad < minarad)
444                  arad = minarad;
445 <        if (ns > 0)
445 >        if (div != NULL)
446                  free((char *)div);
447          return(arad);
448   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines