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.20 by greg, Fri Aug 2 10:30:27 1991 UTC vs.
Revision 1.28 by greg, Mon Oct 21 12:58:18 1991 UTC

# Line 19 | Line 19 | static char SCCSid[] = "$SunId$ LBL";
19  
20   #include  "random.h"
21  
22 < #define  MINSAMPLES     5               /* minimum number of pretest samples */
23 < #define  STESTMAX       30              /* maximum seeks per sample */
22 > #define  MINSAMPLES     16              /* minimum number of pretest samples */
23 > #define  STESTMAX       32              /* maximum seeks per sample */
24  
25  
26   double  getdisk();
# Line 44 | Line 44 | markvirtuals()                 /* find and mark virtual sources */
44                  if (!isvlight(objptr(o->omod)->otype))
45                          continue;
46                  if (sfun[o->otype].of == NULL ||
47 <                                sfun[o->otype].of->getpleq == NULL)
48 <                        objerror(o, USER, "illegal material");
47 >                                sfun[o->otype].of->getpleq == NULL) {
48 >                        objerror(o,WARNING,"secondary sources not supported");
49 >                        continue;
50 >                }
51                  if (nvobjects == 0)
52                          vobject = (OBJECT *)malloc(sizeof(OBJECT));
53                  else
# Line 142 | Line 144 | MAT4  pm;
144                  if (source[sn].sflags & SSPOT) {
145                          multp3(theirspot.aim, source[sn].sl.s->aim, pm);
146                          d = sqrt(dist2(ourspot.aim, theirspot.aim));
147 <                        d = sqrt(source[sn].sl.s->siz/PI) + d*source[sn].ss;
147 >                        d = sqrt(source[sn].sl.s->siz/PI) + d*source[sn].srad;
148                          theirspot.siz = PI*d*d;
149                          ourspot.flen = theirspot.flen = source[sn].sl.s->flen;
150                          d = ourspot.siz;
# Line 167 | Line 169 | MAT4  pm;
169                  if (source[sn].sflags & SPROX && d > source[sn].sl.prox)
170                          return(-1);             /* too far away */
171                  ourspot.flen = 0.;
172 <                d = (sqrt(maxrad2) + source[sn].ss) / d;
172 >                d = (sqrt(maxrad2) + source[sn].srad) / d;
173                  if (d < 1.-FTINY)
174                          ourspot.siz = 2.*PI*(1. - sqrt(1.-d*d));
175                  else
# Line 212 | Line 214 | MAT4  pm;
214                  goto memerr;
215          source[i].sflags = nsflags;
216          VCOPY(source[i].sloc, nsloc);
217 +        multv3(source[i].ss[SU], source[sn].ss[SU], pm);
218 +        multv3(source[i].ss[SV], source[sn].ss[SV], pm);
219          if (nsflags & SFLAT)
220                  VCOPY(source[i].snorm, nsnorm);
221 <        source[i].ss = source[sn].ss; source[i].ss2 = source[sn].ss2;
221 >        else
222 >                multv3(source[i].ss[SW], source[sn].ss[SW], pm);
223 >        source[i].ss2 = source[sn].ss2;
224          if (nsflags & SSPOT) {
225                  if ((source[i].sl.s = (SPOT *)malloc(sizeof(SPOT))) == NULL)
226                          goto memerr;
# Line 273 | Line 279 | register int  sn;      /* target source number */
279          RAY  sr;
280          FVECT  onorm;
281          FVECT  offsdir;
282 +        SRCINDEX  si;
283          double  or, d;
284          int  infront;
285          int  stestlim, ssn;
# Line 285 | Line 292 | register int  sn;      /* target source number */
292          getplaneq(onorm, o);
293                                  /* set number of rays to sample */
294          if (source[sn].sflags & SDISTANT) {
295 <                n = (2./3.*PI*PI)*or2/(thescene.cusize*thescene.cusize)*
296 <                                vspretest + .5;
295 >                                        /* 32. == heuristic constant */
296 >                n = 32.*or2/(thescene.cusize*thescene.cusize)*vspretest + .5;
297                  infront = DOT(onorm, source[sn].sloc) > 0.;
298          } else {
299                  for (i = 0; i < 3; i++)
# Line 317 | Line 324 | register int  sn;      /* target source number */
324   #endif
325                                  return(f);      /* too small a target! */
326                          }
327 +                        multisamp(offsdir, 3, urand(sn*931+5827+ssn));
328                          for (i = 0; i < 3; i++)
329 <                                offsdir[i] = or*(1. -
322 <                                        2.*urand(urind(931*i+5827,ssn)));
329 >                                offsdir[i] = or*(1. - 2.*offsdir[i]);
330                          ssn++;
331                          for (i = 0; i < 3; i++)
332                                  sr.rorg[i] = oc[i] + offsdir[i];
# Line 337 | Line 344 | register int  sn;      /* target source number */
344                          rayorigin(&sr, NULL, PRIMARY, 1.0);
345                  } while (!(*ofun[o->otype].funp)(o, &sr));
346                                          /* check against source */
347 +                initsrcindex(&si);
348 +                si.sn = sn;
349 +                nopart(&si, sr.rorg);
350                  samplendx++;
351 <                if (srcray(&sr, NULL, sn) == 0.)
351 >                if (!srcray(&sr, NULL, &si) || sr.rsrc != sn)
352                          continue;
353                  sr.revf = srcvalue;
354                  rayvalue(&sr);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines