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.17 by greg, Tue Jul 16 15:56:51 1991 UTC vs.
Revision 1.24 by greg, Fri Aug 16 09:23:15 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 140 | Line 142 | MAT4  pm;
142                  ourspot.siz = PI*maxrad2;
143                  ourspot.flen = 0.;
144                  if (source[sn].sflags & SSPOT) {
143                        copystruct(&theirspot, source[sn].sl.s);
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;
148 +                        theirspot.siz = PI*d*d;
149 +                        ourspot.flen = theirspot.flen = source[sn].sl.s->flen;
150                          d = ourspot.siz;
151                          if (!commonbeam(&ourspot, &theirspot, nsloc))
152                                  return(-1);     /* no overlap */
# Line 164 | 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 <                if (d*d > maxrad2)
173 <                        ourspot.siz = 2.*PI*(1. - sqrt(1.-maxrad2/(d*d)));
172 >                d = (sqrt(maxrad2) + source[sn].ss) / d;
173 >                if (d < 1.-FTINY)
174 >                        ourspot.siz = 2.*PI*(1. - sqrt(1.-d*d));
175                  else
176                          nsflags &= ~SSPOT;
177                  if (source[sn].sflags & SSPOT) {
# Line 195 | Line 201 | MAT4  pm;
201                  if (source[sn].sflags & SFLAT) {        /* behind source? */
202                          multv3(nsnorm, source[sn].snorm, pm);
203                          normalize(nsnorm);
204 <                        if (!checkspot(&ourspot, nsnorm))
204 >                        if (nsflags & SSPOT && !checkspot(&ourspot, nsnorm))
205                                  return(-1);
206                  }
207          }
# Line 281 | Line 287 | register int  sn;      /* target source number */
287          getplaneq(onorm, o);
288                                  /* set number of rays to sample */
289          if (source[sn].sflags & SDISTANT) {
290 <                n = (2./3.*PI*PI)*or2/(thescene.cusize*thescene.cusize)*
285 <                                vspretest + .5;
290 >                n = 4.*or2/(thescene.cusize*thescene.cusize)*vspretest + .5;
291                  infront = DOT(onorm, source[sn].sloc) > 0.;
292          } else {
293                  for (i = 0; i < 3; i++)
294                          offsdir[i] = source[sn].sloc[i] - oc[i];
295 <                n = or2/DOT(offsdir,offsdir)*vspretest + .5;
295 >                d = DOT(offsdir,offsdir);
296 >                if (d <= FTINY)
297 >                        n = 2.*PI * vspretest + .5;
298 >                else
299 >                        n = 2.*PI * (1.-sqrt(1./(1.+or2/d)))*vspretest + .5;
300                  infront = DOT(onorm, offsdir) > 0.;
301          }
302          if (n < MINSAMPLES) n = MINSAMPLES;
# Line 309 | Line 318 | register int  sn;      /* target source number */
318   #endif
319                                  return(f);      /* too small a target! */
320                          }
321 +                        peano(offsdir, 3, urand(sn*931+5827+ssn), .005);
322                          for (i = 0; i < 3; i++)
323 <                                offsdir[i] = or*(1. -
314 <                                        2.*urand(urind(931*i+5827,ssn)));
323 >                                offsdir[i] = or*(1. - 2.*offsdir[i]);
324                          ssn++;
325                          for (i = 0; i < 3; i++)
326                                  sr.rorg[i] = oc[i] + offsdir[i];
# Line 338 | Line 347 | register int  sn;      /* target source number */
347                          continue;
348                  nok++;
349                                          /* check against obstructions */
350 <                srcray(&sr, NULL, sn);
351 <                rayvalue(&sr);
343 <                if (bright(sr.rcol) > FTINY)
350 >                rayclear(&sr);
351 >                if (!localhit(&sr, &thescene) || sr.ro == source[sn].so)
352                          nhit++;
353                  if (nhit > 0 && nhit < nok) {
354   #ifdef DEBUG

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines