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.14 by greg, Wed Jun 26 11:54:43 1991 UTC vs.
Revision 1.19 by greg, Tue Jul 30 18:23:45 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 */
22 > #define  MINSAMPLES     5               /* minimum number of pretest samples */
23   #define  STESTMAX       30              /* maximum seeks per sample */
24  
25  
# Line 104 | Line 104 | int  n;
104          for (i = 0; i < vsmat->nproj; i++)
105                  if ((*vsmat->vproj)(proj, o, &source[sn], i))
106                          if ((ns = makevsrc(o, sn, proj)) >= 0) {
107 +                                source[ns].sa.sv.pn = i;
108   #ifdef DEBUG
109                                  virtverb(ns, stderr);
110   #endif
# Line 134 | Line 135 | MAT4  pm;
135                  if (source[sn].sflags & SPROX)
136                          return(-1);             /* should never get here! */
137                  multv3(nsloc, source[sn].sloc, pm);
138 +                normalize(nsloc);
139                  VCOPY(ourspot.aim, ocent);
140                  ourspot.siz = PI*maxrad2;
141                  ourspot.flen = 0.;
142                  if (source[sn].sflags & SSPOT) {
141                        copystruct(&theirspot, source[sn].sl.s);
143                          multp3(theirspot.aim, source[sn].sl.s->aim, pm);
144 +                        d = sqrt(dist2(ourspot.aim, theirspot.aim));
145 +                        d = sqrt(source[sn].sl.s->siz/PI) + d*source[sn].ss;
146 +                        theirspot.siz = PI*d*d;
147 +                        ourspot.flen = theirspot.flen = source[sn].sl.s->flen;
148                          d = ourspot.siz;
149                          if (!commonbeam(&ourspot, &theirspot, nsloc))
150                                  return(-1);     /* no overlap */
# Line 162 | Line 167 | MAT4  pm;
167                  if (source[sn].sflags & SPROX && d > source[sn].sl.prox)
168                          return(-1);             /* too far away */
169                  ourspot.flen = 0.;
170 <                if (d*d > maxrad2)
171 <                        ourspot.siz = 2.*PI*(1. - sqrt(1.-maxrad2/(d*d)));
170 >                d = (sqrt(maxrad2) + source[sn].ss) / d;
171 >                if (d < 1.-FTINY)
172 >                        ourspot.siz = 2.*PI*(1. - sqrt(1.-d*d));
173                  else
174                          nsflags &= ~SSPOT;
175                  if (source[sn].sflags & SSPOT) {
176                          copystruct(&theirspot, source[sn].sl.s);
177                          multv3(theirspot.aim, source[sn].sl.s->aim, pm);
178 +                        normalize(theirspot.aim);
179                          if (nsflags & SSPOT) {
180                                  ourspot.flen = theirspot.flen;
181                                  d = ourspot.siz;
# Line 191 | Line 198 | MAT4  pm;
198                  }
199                  if (source[sn].sflags & SFLAT) {        /* behind source? */
200                          multv3(nsnorm, source[sn].snorm, pm);
201 +                        normalize(nsnorm);
202                          if (!checkspot(&ourspot, nsnorm))
203                                  return(-1);
204                  }
# Line 214 | Line 222 | MAT4  pm;
222          }
223          if (nsflags & SPROX)
224                  source[i].sl.prox = source[sn].sl.prox;
225 <        source[i].sa.svnext = sn;
225 >        source[i].sa.sv.sn = sn;
226          source[i].so = op;
227          return(i);
228   memerr:
# Line 267 | Line 275 | register int  sn;      /* target source number */
275          FVECT  offsdir;
276          double  or, d;
277          int  infront;
278 <        int  ssn;
278 >        int  stestlim, ssn;
279          int  nhit, nok;
280          register int  i, n;
281                                  /* return if pretesting disabled */
# Line 293 | Line 301 | register int  sn;      /* target source number */
301   #endif
302                                  /* sample */
303          or = sqrt(or2);
304 <        ssn = STESTMAX*n;
304 >        stestlim = n*STESTMAX;
305 >        ssn = 0;
306          nhit = nok = 0;
307          while (n-- > 0) {
308                                          /* get sample point */
309                  do {
310 <                        if (--ssn < 0) {
310 >                        if (ssn >= stestlim) {
311   #ifdef DEBUG
312                                  fprintf(stderr, "\ttoo hard to hit\n");
313   #endif
# Line 306 | Line 315 | register int  sn;      /* target source number */
315                          }
316                          for (i = 0; i < 3; i++)
317                                  offsdir[i] = or*(1. -
318 <                                                2.*urand(931*i+5827+ssn));
318 >                                        2.*urand(urind(931*i+5827,ssn)));
319 >                        ssn++;
320                          for (i = 0; i < 3; i++)
321                                  sr.rorg[i] = oc[i] + offsdir[i];
322                          d = DOT(offsdir,onorm);
# Line 332 | Line 342 | register int  sn;      /* target source number */
342                          continue;
343                  nok++;
344                                          /* check against obstructions */
345 <                srcray(&sr, NULL, sn);
345 >                rayclear(&sr);
346 >                sr.revf = raytrace;
347                  rayvalue(&sr);
348                  if (bright(sr.rcol) > FTINY)
349                          nhit++;
# Line 370 | Line 381 | FILE  *fp;
381          fprintf(fp, "\tat (%f,%f,%f)\n",
382                  source[sn].sloc[0], source[sn].sloc[1], source[sn].sloc[2]);
383          fprintf(fp, "\tlinked to source %d (%s)\n",
384 <                source[sn].sa.svnext, source[source[sn].sa.svnext].so->oname);
384 >                source[sn].sa.sv.sn, source[source[sn].sa.sv.sn].so->oname);
385          if (source[sn].sflags & SFOLLOW)
386                  fprintf(fp, "\talways followed\n");
387          else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines