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

Comparing ray/src/rt/virtuals.c (file contents):
Revision 1.9 by greg, Tue Jun 25 13:11:53 1991 UTC vs.
Revision 1.13 by greg, Wed Jun 26 08:55:10 1991 UTC

# Line 19 | Line 19 | static char SCCSid[] = "$SunId$ LBL";
19  
20   #include  "random.h"
21  
22 + #define  MINSAMPLES     3               /* minimum number of pretest samples */
23 + #define  STESTMAX       30              /* maximum seeks per sample */
24  
25 +
26   double  getdisk();
27  
28   static OBJECT  *vobject;                /* virtual source objects */
# Line 179 | Line 182 | MAT4  pm;
182                  }
183                  if (source[sn].sflags & SFLAT) {        /* behind source? */
184                          multv3(nsnorm, source[sn].snorm, pm);
185 <                        if (checkspot(&ourspot, nsnorm) < 0)
185 >                        if (!checkspot(&ourspot, nsnorm))
186                                  return(-1);
187                  }
188          }
# Line 254 | Line 257 | register int  sn;      /* target source number */
257          double  or, d;
258          int  infront;
259          int  ssn;
260 <        int  nhit;
260 >        int  nhit, nok;
261          register int  i, n;
262                                  /* return if pretesting disabled */
263          if (vspretest <= 0)
# Line 272 | Line 275 | register int  sn;      /* target source number */
275                  n = or2/DOT(offsdir,offsdir)*vspretest + .5;
276                  infront = DOT(onorm, offsdir) > 0.;
277          }
278 <        if (n < 1) n = 1;
278 >        if (n < MINSAMPLES) n = MINSAMPLES;
279   #ifdef DEBUG
280          fprintf(stderr, "pretesting source %d in object %s with %d rays\n",
281                          sn, o->oname, n);
282   #endif
283                                  /* sample */
284          or = sqrt(or2);
285 <        ssn = 25*n;
286 <        nhit = 0;
285 >        ssn = STESTMAX*n;
286 >        nhit = nok = 0;
287          while (n-- > 0) {
288                                          /* get sample point */
289                  do {
# Line 316 | Line 319 | register int  sn;      /* target source number */
319                  rayvalue(&sr);
320                  if (bright(sr.rcol) <= FTINY)
321                          continue;
322 +                nok++;
323                                          /* check against obstructions */
324                  srcray(&sr, NULL, sn);
325                  rayvalue(&sr);
326 <                if (bright(sr.rcol) <= FTINY) {
326 >                if (bright(sr.rcol) > FTINY)
327 >                        nhit++;
328 >                if (nhit > 0 && nhit < nok) {
329   #ifdef DEBUG
330 <                        fprintf(stderr, "\tfound an occlusion\n");
330 >                        fprintf(stderr, "\tpartially occluded\n");
331   #endif
332 <                        return(f);      /* need to shadow test */
332 >                        return(f);              /* need to shadow test */
333                  }
328                nhit++;
334          }
335          if (nhit == 0) {
336   #ifdef DEBUG

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines