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 2.3 by greg, Tue Dec 20 20:18:43 1994 UTC vs.
Revision 2.4 by greg, Sat Aug 26 14:07:46 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1994 Regents of the University of California */
1 > /* Copyright (c) 1995 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 301 | Line 301 | register int  sn;      /* target source number */
301          FVECT  offsdir;
302          SRCINDEX  si;
303          double  or, d;
304        int  infront;
304          int  stestlim, ssn;
305          int  nhit, nok;
306          register int  i, n;
# Line 314 | Line 313 | register int  sn;      /* target source number */
313          if (source[sn].sflags & SDISTANT) {
314                                          /* 32. == heuristic constant */
315                  n = 32.*or2/(thescene.cusize*thescene.cusize)*vspretest + .5;
317                infront = DOT(onorm, source[sn].sloc) > 0.;
316          } else {
317                  for (i = 0; i < 3; i++)
318                          offsdir[i] = source[sn].sloc[i] - oc[i];
# Line 323 | Line 321 | register int  sn;      /* target source number */
321                          n = 2.*PI * vspretest + .5;
322                  else
323                          n = 2.*PI * (1.-sqrt(1./(1.+or2/d)))*vspretest + .5;
326                infront = DOT(onorm, offsdir) > 0.;
324          }
325          if (n < MINSAMPLES) n = MINSAMPLES;
326   #ifdef DEBUG
# Line 335 | Line 332 | register int  sn;      /* target source number */
332          stestlim = n*STESTMAX;
333          ssn = 0;
334          nhit = nok = 0;
335 +        initsrcindex(&si);
336          while (n-- > 0) {
337                                          /* get sample point */
338                  do {
# Line 348 | Line 346 | register int  sn;      /* target source number */
346                          for (i = 0; i < 3; i++)
347                                  offsdir[i] = or*(1. - 2.*offsdir[i]);
348                          ssn++;
349 <                        for (i = 0; i < 3; i++)
350 <                                sr.rorg[i] = oc[i] + offsdir[i];
351 <                        d = DOT(offsdir,onorm);
349 >                        d = 1. - DOT(offsdir, onorm);
350 >                        for (i = 0; i < 3; i++) {
351 >                                sr.rorg[i] = oc[i] + offsdir[i] + d*onorm[i];
352 >                                sr.rdir[i] = -onorm[i];
353 >                        }
354                          sr.rmax = 0.0;
355                        if (infront)
356                                for (i = 0; i < 3; i++) {
357                                        sr.rorg[i] -= (d-.0001)*onorm[i];
358                                        sr.rdir[i] = -onorm[i];
359                                }
360                        else
361                                for (i = 0; i < 3; i++) {
362                                        sr.rorg[i] -= (d+.0001)*onorm[i];
363                                        sr.rdir[i] = onorm[i];
364                                }
355                          rayorigin(&sr, NULL, PRIMARY, 1.0);
356                  } while (!(*ofun[o->otype].funp)(o, &sr));
357                                          /* check against source */
358 <                initsrcindex(&si);
369 <                si.sn = sn;
370 <                nopart(&si, &sr);
358 >                VCOPY(sr.rorg, sr.rop); /* starting from intersection */
359                  samplendx++;
360 <                if (!srcray(&sr, NULL, &si) || sr.rsrc != sn)
361 <                        continue;
360 >                if (si.sp >= si.np-1 ||
361 >                                !srcray(&sr, NULL, &si) || sr.rsrc != sn) {
362 >                        si.sn = sn-1;           /* reset index to our source */
363 >                        si.np = 0;
364 >                        if (!srcray(&sr, NULL, &si) || sr.rsrc != sn)
365 >                                continue;       /* can't get there from here */
366 >                }
367                  sr.revf = srcvalue;
368 <                rayvalue(&sr);
368 >                rayvalue(&sr);                  /* check sample validity */
369                  if (bright(sr.rcol) <= FTINY)
370                          continue;
371 <                nok++;
379 <                                        /* check against obstructions */
371 >                nok++;                  /* got sample; check obstructions */
372                  rayclear(&sr);
373                  sr.revf = raytrace;
374                  rayvalue(&sr);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines