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.26 by greg, Mon Aug 26 10:10:43 1991 UTC vs.
Revision 1.31 by greg, Fri Nov 8 16:34:27 1991 UTC

# Line 41 | Line 41 | markvirtuals()                 /* find and mark virtual sources */
41                  o = objptr(i);
42                  if (!issurface(o->otype) || o->omod == OVOID)
43                          continue;
44 <                if (!isvlight(objptr(o->omod)->otype))
44 >                if (!isvlight(vsmaterial(o)->otype))
45                          continue;
46                  if (sfun[o->otype].of == NULL ||
47                                  sfun[o->otype].of->getpleq == NULL) {
# Line 101 | Line 101 | int  n;
101          if (o == source[sn].so) /* objects cannot project themselves */
102                  return;
103                                  /* get virtual source material */
104 <        vsmat = sfun[objptr(o->omod)->otype].mf;
104 >        vsmat = sfun[vsmaterial(o)->otype].mf;
105                                  /* project virtual sources */
106          for (i = 0; i < vsmat->nproj; i++)
107                  if ((*vsmat->vproj)(proj, o, &source[sn], i))
# Line 115 | Line 115 | int  n;
115   }
116  
117  
118 + OBJREC *
119 + vsmaterial(o)                   /* get virtual source material pointer */
120 + OBJREC  *o;
121 + {
122 +        register int  i;
123 +        register OBJREC  *m;
124 +
125 +        i = o->omod;
126 +        m = objptr(i);
127 +        if (m->otype != MAT_ILLUM || m->oargs.nsargs < 1 ||
128 +                        !strcmp(m->oargs.sarg[0], VOIDID) ||
129 +                        (i = modifier(m->oargs.sarg[0])) < 0)
130 +                return(m);              /* direct modifier */
131 +        return(objptr(i));              /* illum alternate */
132 + }
133 +
134 +
135   int
136   makevsrc(op, sn, pm)            /* make virtual source if reasonable */
137   OBJREC  *op;
# Line 143 | Line 160 | MAT4  pm;
160                  ourspot.flen = 0.;
161                  if (source[sn].sflags & SSPOT) {
162                          multp3(theirspot.aim, source[sn].sl.s->aim, pm);
163 +                                                /* adjust for source size */
164                          d = sqrt(dist2(ourspot.aim, theirspot.aim));
165 <                        d = sqrt(source[sn].sl.s->siz/PI) + d*source[sn].ss;
165 >                        d = sqrt(source[sn].sl.s->siz/PI) + d*source[sn].srad;
166                          theirspot.siz = PI*d*d;
167                          ourspot.flen = theirspot.flen = source[sn].sl.s->flen;
168                          d = ourspot.siz;
# Line 169 | Line 187 | MAT4  pm;
187                  if (source[sn].sflags & SPROX && d > source[sn].sl.prox)
188                          return(-1);             /* too far away */
189                  ourspot.flen = 0.;
190 <                d = (sqrt(maxrad2) + source[sn].ss) / d;
190 >                                                /* adjust for source size */
191 >                d = (sqrt(maxrad2) + source[sn].srad) / d;
192                  if (d < 1.-FTINY)
193                          ourspot.siz = 2.*PI*(1. - sqrt(1.-d*d));
194                  else
# Line 214 | Line 233 | MAT4  pm;
233                  goto memerr;
234          source[i].sflags = nsflags;
235          VCOPY(source[i].sloc, nsloc);
236 +        multv3(source[i].ss[SU], source[sn].ss[SU], pm);
237 +        multv3(source[i].ss[SV], source[sn].ss[SV], pm);
238          if (nsflags & SFLAT)
239                  VCOPY(source[i].snorm, nsnorm);
240 <        source[i].ss = source[sn].ss; source[i].ss2 = source[sn].ss2;
240 >        else
241 >                multv3(source[i].ss[SW], source[sn].ss[SW], pm);
242 >        source[i].srad = source[sn].srad;
243 >        source[i].ss2 = source[sn].ss2;
244          if (nsflags & SSPOT) {
245                  if ((source[i].sl.s = (SPOT *)malloc(sizeof(SPOT))) == NULL)
246                          goto memerr;
# Line 275 | Line 299 | register int  sn;      /* target source number */
299          RAY  sr;
300          FVECT  onorm;
301          FVECT  offsdir;
302 +        SRCINDEX  si;
303          double  or, d;
304          int  infront;
305          int  stestlim, ssn;
# Line 339 | Line 364 | register int  sn;      /* target source number */
364                          rayorigin(&sr, NULL, PRIMARY, 1.0);
365                  } while (!(*ofun[o->otype].funp)(o, &sr));
366                                          /* check against source */
367 +                initsrcindex(&si);
368 +                si.sn = sn;
369 +                nopart(&si, &sr);
370                  samplendx++;
371 <                if (srcray(&sr, NULL, sn) == 0.)
371 >                if (!srcray(&sr, NULL, &si) || sr.rsrc != sn)
372                          continue;
373                  sr.revf = srcvalue;
374                  rayvalue(&sr);
# Line 349 | Line 377 | register int  sn;      /* target source number */
377                  nok++;
378                                          /* check against obstructions */
379                  rayclear(&sr);
380 <                if (!localhit(&sr, &thescene) || sr.ro == source[sn].so)
380 >                sr.revf = raytrace;
381 >                rayvalue(&sr);
382 >                if (bright(sr.rcol) > FTINY)
383                          nhit++;
384                  if (nhit > 0 && nhit < nok) {
385   #ifdef DEBUG

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines