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.3 by greg, Thu Jun 20 13:43:38 1991 UTC vs.
Revision 2.2 by greg, Sat May 23 08:03:19 1992 UTC

# Line 11 | Line 11 | static char SCCSid[] = "$SunId$ LBL";
11  
12   #include  "ray.h"
13  
14 + #include  "octree.h"
15 +
16   #include  "otypes.h"
17  
18   #include  "source.h"
19  
20 < #include  "cone.h"
20 > #include  "random.h"
21  
22 < #include  "face.h"
22 > #define  MINSAMPLES     16              /* minimum number of pretest samples */
23 > #define  STESTMAX       32              /* maximum seeks per sample */
24  
25  
26 < double  intercircle();
24 < SRCREC  *makevsrc();
26 > double  getdisk();
27  
28   static OBJECT  *vobject;                /* virtual source objects */
29   static int  nvobjects = 0;              /* number of virtual source objects */
# Line 39 | 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)
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 55 | Line 59 | markvirtuals()                 /* find and mark virtual sources */
59          }
60          if (nvobjects == 0)
61                  return;
62 + #ifdef DEBUG
63 +        fprintf(stderr, "found %d virtual source objects\n", nvobjects);
64 + #endif
65                                          /* append virtual sources */
66          for (i = nsources; i-- > 0; )
67 <                if (!(source[i].sflags & SSKIP))
61 <                        addvirtuals(&source[i], directrelay);
67 >                addvirtuals(i, directrelay);
68                                          /* done with our object list */
69          free((char *)vobject);
70          nvobjects = 0;
71   }
72  
73  
74 < addvirtuals(sr, nr)             /* add virtual sources associated with sr */
75 < SRCREC  *sr;
74 > addvirtuals(sn, nr)             /* add virtuals associated with source */
75 > int  sn;
76   int  nr;
77   {
78          register int  i;
79                                  /* check relay limit first */
80          if (nr <= 0)
81                  return;
82 +        if (source[sn].sflags & SSKIP)
83 +                return;
84                                  /* check each virtual object for projection */
85          for (i = 0; i < nvobjects; i++)
86                                          /* vproject() calls us recursively */
87 <                vproject(objptr(i), sr, nr-1);
87 >                vproject(objptr(vobject[i]), sn, nr-1);
88   }
89  
90  
91 < vproject(o, s, n)               /* create projected source(s) if they exist */
91 > vproject(o, sn, n)              /* create projected source(s) if they exist */
92   OBJREC  *o;
93 < SRCREC  *s;
93 > int  sn;
94   int  n;
95   {
96          register int  i;
97          register VSMATERIAL  *vsmat;
98          MAT4  proj;
99 <        SRCREC  *ns;
99 >        int  ns;
100 >
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, s, i))
108 <                        if ((ns = makevsrc(o, s, proj)) != NULL)
107 >                if ((*vsmat->vproj)(proj, o, &source[sn], i))
108 >                        if ((ns = makevsrc(o, sn, proj)) >= 0) {
109 >                                source[ns].sa.sv.pn = i;
110 > #ifdef DEBUG
111 >                                virtverb(ns, stderr);
112 > #endif
113                                  addvirtuals(ns, n);
114 +                        }
115   }
116  
117  
118 < SRCREC *
119 < makevsrc(op, sp, pm)            /* make virtual source if reasonable */
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])) == OVOID)
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;
138 < register SRCREC  *sp;
138 > register int  sn;
139   MAT4  pm;
140   {
141 <        register SRCREC  *newsrc;
142 <        FVECT  nsloc, ocent, nsnorm;
141 >        FVECT  nsloc, nsnorm, ocent, v;
142 >        double  maxrad2, d;
143          int  nsflags;
111        double  maxrad2;
112        double  d1;
144          SPOT  theirspot, ourspot;
145          register int  i;
146  
147 <        nsflags = (sp->sflags|(SVIRTUAL|SFOLLOW)) & ~SSPOT;
147 >        nsflags = source[sn].sflags | (SVIRTUAL|SSPOT|SFOLLOW);
148                                          /* get object center and max. radius */
149 <        if (sfun[op->otype].of->getdisk != NULL) {
150 <                maxrad2 = (*sfun[op->otype].of->getdisk)(ocent, op);
151 <                if (maxrad2 <= FTINY)                   /* too small? */
121 <                        return(NULL);
122 <                nsflags |= SSPOT;
123 <        }
149 >        maxrad2 = getdisk(ocent, op, sn);
150 >        if (maxrad2 <= FTINY)                   /* too small? */
151 >                return(-1);
152                                          /* get location and spot */
153 <        if (sp->sflags & SDISTANT) {            /* distant source */
154 <                if (sp->sflags & SPROX)
155 <                        return(NULL);           /* should never get here! */
156 <                multv3(nsloc, sp->sloc, pm);
157 <                if (nsflags & SSPOT) {
158 <                        VCOPY(ourspot.aim, ocent);
159 <                        ourspot.siz = PI*maxrad2;
160 <                        ourspot.flen = 0.;
153 >        if (source[sn].sflags & SDISTANT) {             /* distant source */
154 >                if (source[sn].sflags & SPROX)
155 >                        return(-1);             /* should never get here! */
156 >                multv3(nsloc, source[sn].sloc, pm);
157 >                normalize(nsloc);
158 >                VCOPY(ourspot.aim, ocent);
159 >                ourspot.siz = PI*maxrad2;
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].srad;
166 >                        theirspot.siz = PI*d*d;
167 >                        ourspot.flen = theirspot.flen = source[sn].sl.s->flen;
168 >                        d = ourspot.siz;
169 >                        if (!commonbeam(&ourspot, &theirspot, nsloc))
170 >                                return(-1);     /* no overlap */
171 >                        if (ourspot.siz < d-FTINY) {    /* it shrunk */
172 >                                d = beamdisk(v, op, &ourspot, nsloc);
173 >                                if (d <= FTINY)
174 >                                        return(-1);
175 >                                if (d < maxrad2) {
176 >                                        maxrad2 = d;
177 >                                        VCOPY(ocent, v);
178 >                                }
179 >                        }
180                  }
134                if (sp->sflags & SSPOT) {
135                        copystruct(&theirspot, sp->sl.s);
136                        multp3(theirspot.aim, sp->sl.s->aim, pm);
137                        if (nsflags & SSPOT &&
138                                !commonbeam(&ourspot, &theirspot, nsloc))
139                                return(NULL);           /* no overlap */
140                }
181          } else {                                /* local source */
182 <                multp3(nsloc, sp->sloc, pm);
183 <                if (nsflags & SSPOT) {
184 <                        for (i = 0; i < 3; i++)
185 <                                ourspot.aim[i] = ocent[i] - nsloc[i];
186 <                        if ((d1 = normalize(ourspot.aim)) == 0.)
187 <                                return(NULL);           /* at source!! */
188 <                        if (sp->sflags & SPROX && d1 > sp->sl.prox)
189 <                                return(NULL);           /* too far away */
190 <                        ourspot.siz = 2.*PI*(1. - d1/sqrt(d1*d1+maxrad2));
191 <                        ourspot.flen = 0.;
192 <                } else if (sp->sflags & SPROX) {
193 <                        FVECT  norm;
194 <                        double  offs;
195 <                                                /* use distance from plane */
196 <                        offs = (*sfun[op->otype].of->getpleq)(norm, op);
197 <                        d1 = DOT(norm, nsloc) - offs;
198 <                        if (d1 > sp->sl.prox || d1 < -sp->sl.prox)
199 <                                return(NULL);           /* too far away */
160 <                }
161 <                if (sp->sflags & SSPOT) {
162 <                        copystruct(&theirspot, sp->sl.s);
163 <                        multv3(theirspot.aim, sp->sl.s->aim, pm);
182 >                multp3(nsloc, source[sn].sloc, pm);
183 >                for (i = 0; i < 3; i++)
184 >                        ourspot.aim[i] = ocent[i] - nsloc[i];
185 >                if ((d = normalize(ourspot.aim)) == 0.)
186 >                        return(-1);             /* at source!! */
187 >                if (source[sn].sflags & SPROX && d > source[sn].sl.prox)
188 >                        return(-1);             /* too far away */
189 >                ourspot.flen = 0.;
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
195 >                        nsflags &= ~SSPOT;
196 >                if (source[sn].sflags & SSPOT) {
197 >                        copystruct(&theirspot, source[sn].sl.s);
198 >                        multv3(theirspot.aim, source[sn].sl.s->aim, pm);
199 >                        normalize(theirspot.aim);
200                          if (nsflags & SSPOT) {
165                                if (!commonspot(&ourspot, &theirspot, nsloc))
166                                        return(NULL);   /* no overlap */
201                                  ourspot.flen = theirspot.flen;
202 +                                d = ourspot.siz;
203 +                                if (!commonspot(&ourspot, &theirspot, nsloc))
204 +                                        return(-1);     /* no overlap */
205 +                        } else {
206 +                                nsflags |= SSPOT;
207 +                                copystruct(&ourspot, &theirspot);
208 +                                d = 2.*ourspot.siz;
209                          }
210 +                        if (ourspot.siz < d-FTINY) {    /* it shrunk */
211 +                                d = spotdisk(v, op, &ourspot, nsloc);
212 +                                if (d <= FTINY)
213 +                                        return(-1);
214 +                                if (d < maxrad2) {
215 +                                        maxrad2 = d;
216 +                                        VCOPY(ocent, v);
217 +                                }
218 +                        }
219                  }
220 <                if (sp->sflags & SFLAT) {       /* check for behind source */
221 <                        multv3(nsnorm, sp->snorm, pm);
222 <                        if (nsflags & SSPOT && checkspot(&ourspot, nsnorm) < 0)
223 <                                return(NULL);
220 >                if (source[sn].sflags & SFLAT) {        /* behind source? */
221 >                        multv3(nsnorm, source[sn].snorm, pm);
222 >                        normalize(nsnorm);
223 >                        if (nsflags & SSPOT && !checkspot(&ourspot, nsnorm))
224 >                                return(-1);
225                  }
226          }
227 <                                        /* everything is OK, make source */
228 <        if ((newsrc = newsource()) == NULL)
227 >                                        /* pretest visibility */
228 >        nsflags = vstestvis(nsflags, op, ocent, maxrad2, sn);
229 >        if (nsflags & SSKIP)
230 >                return(-1);     /* obstructed */
231 >                                        /* it all checks out, so make it */
232 >        if ((i = newsource()) < 0)
233                  goto memerr;
234 <        newsrc->sflags = nsflags;
235 <        VCOPY(newsrc->sloc, nsloc);
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(newsrc->snorm, nsnorm);
240 <        newsrc->ss = sp->ss; newsrc->ss2 = sp->ss2;
241 <        if ((nsflags | sp->sflags) & SSPOT) {
242 <                if ((newsrc->sl.s = (SPOT *)malloc(sizeof(SPOT))) == NULL)
239 >                VCOPY(source[i].snorm, nsnorm);
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;
247 <                if (nsflags & SSPOT)
188 <                        copystruct(newsrc->sl.s, &ourspot);
189 <                else
190 <                        copystruct(newsrc->sl.s, &theirspot);
191 <                newsrc->sflags |= SSPOT;
247 >                copystruct(source[i].sl.s, &ourspot);
248          }
249          if (nsflags & SPROX)
250 <                newsrc->sl.prox = sp->sl.prox;
251 <        newsrc->sa.svnext = sp - source;
252 <        return(newsrc);
250 >                source[i].sl.prox = source[sn].sl.prox;
251 >        source[i].sa.sv.sn = sn;
252 >        source[i].so = op;
253 >        return(i);
254   memerr:
255          error(SYSTEM, "out of memory in makevsrc");
256   }
257  
258  
259 < commonspot(sp1, sp2, org)       /* set sp1 to intersection of sp1 and sp2 */
260 < register SPOT  *sp1, *sp2;
261 < FVECT  org;
259 > double
260 > getdisk(oc, op, sn)             /* get visible object disk */
261 > FVECT  oc;
262 > OBJREC  *op;
263 > register int  sn;
264   {
265 <        FVECT  cent;
266 <        double  rad2, cos1, cos2;
267 <
268 <        cos1 = 1. - sp1->siz/(2.*PI);
269 <        cos2 = 1. - sp2->siz/(2.*PI);
270 <        if (sp2->siz >= 2.*PI-FTINY)            /* BIG, just check overlap */
271 <                return(DOT(sp1->aim,sp2->aim) >= cos1*cos2 -
272 <                                        sqrt((1.-cos1*cos1)*(1.-cos2*cos2)));
273 <                                /* compute and check disks */
274 <        rad2 = intercircle(cent, sp1->aim, sp2->aim,
275 <                        1./(cos1*cos1) - 1.,  1./(cos2*cos2) - 1.);
276 <        if (rad2 <= FTINY || normalize(cent) == 0.)
277 <                return(0);
278 <        VCOPY(sp1->aim, cent);
279 <        sp1->siz = 2.*PI*(1. - 1./sqrt(1.+rad2));
280 <        return(1);
265 >        double  rad2, roffs, offs, d, rd, rdoto;
266 >        FVECT  rnrm, nrm;
267 >                                /* first, use object getdisk function */
268 >        rad2 = getmaxdisk(oc, op);
269 >        if (!(source[sn].sflags & SVIRTUAL))
270 >                return(rad2);           /* all done for normal source */
271 >                                /* check for correct side of relay surface */
272 >        roffs = getplaneq(rnrm, source[sn].so);
273 >        rd = DOT(rnrm, source[sn].sloc);        /* source projection */
274 >        if (!(source[sn].sflags & SDISTANT))
275 >                rd -= roffs;
276 >        d = DOT(rnrm, oc) - roffs;      /* disk distance to relay plane */
277 >        if ((d > 0.) ^ (rd > 0.))
278 >                return(rad2);           /* OK if opposite sides */
279 >        if (d*d >= rad2)
280 >                return(0.);             /* no relay is possible */
281 >                                /* we need a closer look */
282 >        offs = getplaneq(nrm, op);
283 >        rdoto = DOT(rnrm, nrm);
284 >        if (d*d >= rad2*(1.-rdoto*rdoto))
285 >                return(0.);             /* disk entirely on projection side */
286 >                                /* should shrink disk but I'm lazy */
287 >        return(rad2);
288   }
289  
290  
291 < commonbeam(sp1, sp2, dir)       /* set sp1 to intersection of sp1 and sp2 */
292 < register SPOT  *sp1, *sp2;
293 < FVECT  dir;
291 > int
292 > vstestvis(f, o, oc, or2, sn)            /* pretest source visibility */
293 > int  f;                 /* virtual source flags */
294 > OBJREC  *o;             /* relay object */
295 > FVECT  oc;              /* relay object center */
296 > double  or2;            /* relay object radius squared */
297 > register int  sn;       /* target source number */
298   {
299 <        FVECT  cent, c1, c2;
300 <        double  rad2, d;
301 <        register int  i;
302 <                                        /* move centers to common plane */
303 <        d = DOT(sp1->aim, dir);
304 <        for (i = 0; i < 3; i++)
305 <                c1[i] = sp1->aim[i] - d*dir[i];
306 <        d = DOT(sp2->aim, dir);
307 <        for (i = 0; i < 3; i++)
308 <                c2[i] = sp2->aim[i] - d*dir[i];
309 <                                        /* compute overlap */
310 <        rad2 = intercircle(cent, c1, c2, sp1->siz/PI, sp2->siz/PI);
311 <        if (rad2 <= FTINY)
312 <                return(0);
313 <        VCOPY(sp1->aim, cent);
314 <        sp1->siz = PI*rad2;
315 <        return(1);
299 >        RAY  sr;
300 >        FVECT  onorm;
301 >        FVECT  offsdir;
302 >        SRCINDEX  si;
303 >        double  or, d;
304 >        int  infront;
305 >        int  stestlim, ssn;
306 >        int  nhit, nok;
307 >        register int  i, n;
308 >                                /* return if pretesting disabled */
309 >        if (vspretest <= 0)
310 >                return(f);
311 >                                /* get surface normal */
312 >        getplaneq(onorm, o);
313 >                                /* set number of rays to sample */
314 >        if (source[sn].sflags & SDISTANT) {
315 >                                        /* 32. == heuristic constant */
316 >                n = 32.*or2/(thescene.cusize*thescene.cusize)*vspretest + .5;
317 >                infront = DOT(onorm, source[sn].sloc) > 0.;
318 >        } else {
319 >                for (i = 0; i < 3; i++)
320 >                        offsdir[i] = source[sn].sloc[i] - oc[i];
321 >                d = DOT(offsdir,offsdir);
322 >                if (d <= FTINY)
323 >                        n = 2.*PI * vspretest + .5;
324 >                else
325 >                        n = 2.*PI * (1.-sqrt(1./(1.+or2/d)))*vspretest + .5;
326 >                infront = DOT(onorm, offsdir) > 0.;
327 >        }
328 >        if (n < MINSAMPLES) n = MINSAMPLES;
329 > #ifdef DEBUG
330 >        fprintf(stderr, "pretesting source %d in object %s with %d rays\n",
331 >                        sn, o->oname, n);
332 > #endif
333 >                                /* sample */
334 >        or = sqrt(or2);
335 >        stestlim = n*STESTMAX;
336 >        ssn = 0;
337 >        nhit = nok = 0;
338 >        while (n-- > 0) {
339 >                                        /* get sample point */
340 >                do {
341 >                        if (ssn >= stestlim) {
342 > #ifdef DEBUG
343 >                                fprintf(stderr, "\ttoo hard to hit\n");
344 > #endif
345 >                                return(f);      /* too small a target! */
346 >                        }
347 >                        multisamp(offsdir, 3, urand(sn*931+5827+ssn));
348 >                        for (i = 0; i < 3; i++)
349 >                                offsdir[i] = or*(1. - 2.*offsdir[i]);
350 >                        ssn++;
351 >                        for (i = 0; i < 3; i++)
352 >                                sr.rorg[i] = oc[i] + offsdir[i];
353 >                        d = DOT(offsdir,onorm);
354 >                        if (infront)
355 >                                for (i = 0; i < 3; i++) {
356 >                                        sr.rorg[i] -= (d-.0001)*onorm[i];
357 >                                        sr.rdir[i] = -onorm[i];
358 >                                }
359 >                        else
360 >                                for (i = 0; i < 3; i++) {
361 >                                        sr.rorg[i] -= (d+.0001)*onorm[i];
362 >                                        sr.rdir[i] = onorm[i];
363 >                                }
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, &si) || sr.rsrc != sn)
372 >                        continue;
373 >                sr.revf = srcvalue;
374 >                rayvalue(&sr);
375 >                if (bright(sr.rcol) <= FTINY)
376 >                        continue;
377 >                nok++;
378 >                                        /* check against obstructions */
379 >                rayclear(&sr);
380 >                sr.revf = raytrace;
381 >                rayvalue(&sr);
382 >                if (bright(sr.rcol) > FTINY)
383 >                        nhit++;
384 >                if (nhit > 0 && nhit < nok) {
385 > #ifdef DEBUG
386 >                        fprintf(stderr, "\tpartially occluded\n");
387 > #endif
388 >                        return(f);              /* need to shadow test */
389 >                }
390 >        }
391 >        if (nhit == 0) {
392 > #ifdef DEBUG
393 >                fprintf(stderr, "\t0%% hit rate\n");
394 > #endif
395 >                return(f | SSKIP);      /* 0% hit rate:  totally occluded */
396 >        }
397 > #ifdef DEBUG
398 >        fprintf(stderr, "\t100%% hit rate\n");
399 > #endif
400 >        return(f & ~SFOLLOW);           /* 100% hit rate:  no occlusion */
401   }
402 +        
403  
404 <
405 < checkspot(sp, nrm)              /* check spotlight for behind source */
406 < register SPOT  *sp;
407 < FVECT  nrm;
404 > #ifdef DEBUG
405 > virtverb(sn, fp)        /* print verbose description of virtual source */
406 > register int  sn;
407 > FILE  *fp;
408   {
253        double  d, d1;
254
255        d = DOT(sp->aim, nrm);
256        if (d > FTINY)                  /* center in front? */
257                return(0);
258                                        /* else check horizon */
259        d1 = 1. - sp->siz/(2.*PI);
260        return(1.-FTINY-d*d > d1*d1);
261 }
262
263
264 double
265 intercircle(cc, c1, c2, r1s, r2s)       /* intersect two circles */
266 FVECT  cc;                      /* midpoint (return value) */
267 FVECT  c1, c2;                  /* circle centers */
268 double  r1s, r2s;               /* radii squared */
269 {
270        double  a2, d2, l;
271        FVECT  disp;
409          register int  i;
410  
411 <        for (i = 0; i < 3; i++)
412 <                disp[i] = c2[i] - c1[i];
413 <        d2 = DOT(disp,disp);
414 <                                        /* circle within overlap? */
415 <        if (r1s < r2s) {
416 <                if (r2s >= r1s + d2) {
417 <                        VCOPY(cc, c1);
418 <                        return(r1s);
419 <                }
420 <        } else {
421 <                if (r1s >= r2s + d2) {
422 <                        VCOPY(cc, c2);
423 <                        return(r2s);
424 <                }
425 <        }
426 <        a2 = .25*(2.*(r1s+r2s) - d2 - (r2s-r1s)*(r2s-r1s)/d2);
427 <                                        /* no overlap? */
291 <        if (a2 <= 0.)
292 <                return(0.);
293 <                                        /* overlap, compute center */
294 <        l = sqrt((r1s - a2)/d2);
295 <        for (i = 0; i < 3; i++)
296 <                cc[i] = c1[i] + l*disp[i];
297 <        return(a2);
411 >        fprintf(fp, "%s virtual source %d in %s %s\n",
412 >                        source[sn].sflags & SDISTANT ? "distant" : "local",
413 >                        sn, ofun[source[sn].so->otype].funame,
414 >                        source[sn].so->oname);
415 >        fprintf(fp, "\tat (%f,%f,%f)\n",
416 >                source[sn].sloc[0], source[sn].sloc[1], source[sn].sloc[2]);
417 >        fprintf(fp, "\tlinked to source %d (%s)\n",
418 >                source[sn].sa.sv.sn, source[source[sn].sa.sv.sn].so->oname);
419 >        if (source[sn].sflags & SFOLLOW)
420 >                fprintf(fp, "\talways followed\n");
421 >        else
422 >                fprintf(fp, "\tnever followed\n");
423 >        if (!(source[sn].sflags & SSPOT))
424 >                return;
425 >        fprintf(fp, "\twith spot aim (%f,%f,%f) and size %f\n",
426 >                        source[sn].sl.s->aim[0], source[sn].sl.s->aim[1],
427 >                        source[sn].sl.s->aim[2], source[sn].sl.s->siz);
428   }
429 + #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines