ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/srcsupp.c
(Generate patch)

Comparing ray/src/rt/srcsupp.c (file contents):
Revision 2.2 by greg, Sat Jan 4 19:54:20 1992 UTC vs.
Revision 2.23 by greg, Thu Apr 21 00:40:35 2016 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  Support routines for source objects and materials
6 + *
7 + *  External symbols declared in source.h
8   */
9  
10 + #include "copyright.h"
11 +
12   #include  "ray.h"
13  
14   #include  "otypes.h"
# Line 18 | Line 19 | static char SCCSid[] = "$SunId$ LBL";
19  
20   #include  "face.h"
21  
22 < #define SRCINC          4               /* realloc increment for array */
22 > #define SRCINC          32              /* realloc increment for array */
23  
24   SRCREC  *source = NULL;                 /* our list of sources */
25   int  nsources = 0;                      /* the number of sources */
# Line 26 | Line 27 | int  nsources = 0;                     /* the number of sources */
27   SRCFUNC  sfun[NUMOTYPE];                /* source dispatch table */
28  
29  
30 < initstypes()                    /* initialize source dispatch table */
30 > void
31 > initstypes(void)                        /* initialize source dispatch table */
32   {
33          extern VSMATERIAL  mirror_vs, direct1_vs, direct2_vs;
32        extern int  fsetsrc(), ssetsrc(), sphsetsrc(), cylsetsrc(), rsetsrc();
33        extern int  nopart(), flatpart(), cylpart();
34        extern double  fgetplaneq(), rgetplaneq();
35        extern double  fgetmaxdisk(), rgetmaxdisk();
34          static SOBJECT  fsobj = {fsetsrc, flatpart, fgetplaneq, fgetmaxdisk};
35          static SOBJECT  ssobj = {ssetsrc, nopart};
36          static SOBJECT  sphsobj = {sphsetsrc, nopart};
# Line 51 | Line 49 | initstypes()                   /* initialize source dispatch table */
49  
50  
51   int
52 < newsource()                     /* allocate new source in our array */
52 > newsource(void)                 /* allocate new source in our array */
53   {
54          if (nsources == 0)
55                  source = (SRCREC *)malloc(SRCINC*sizeof(SRCREC));
56          else if (nsources%SRCINC == 0)
57 <                source = (SRCREC *)realloc((char *)source,
57 >                source = (SRCREC *)realloc((void *)source,
58                                  (unsigned)(nsources+SRCINC)*sizeof(SRCREC));
59          if (source == NULL)
60                  return(-1);
61          source[nsources].sflags = 0;
62          source[nsources].nhits = 1;
63 <        source[nsources].ntests = 2;    /* initial hit probability = 1/2 */
63 >        source[nsources].ntests = 2;    /* initial hit probability = 50% */
64 > #if SHADCACHE
65 >        source[nsources].obscache = NULL;
66 > #endif
67          return(nsources++);
68   }
69  
70  
71 < setflatss(src)                          /* set sampling for a flat source */
72 < register SRCREC  *src;
71 > void
72 > setflatss(                              /* set sampling for a flat source */
73 >        SRCREC  *src
74 > )
75   {
76          double  mult;
77 <        register int  i;
77 >        int  i;
78  
79 <        src->ss[SV][0] = src->ss[SV][1] = src->ss[SV][2] = 0.0;
79 >        getperpendicular(src->ss[SU], src->snorm, rand_samp);
80 >        mult = .5 * sqrt( src->ss2 );
81          for (i = 0; i < 3; i++)
78                if (src->snorm[i] < 0.6 && src->snorm[i] > -0.6)
79                        break;
80        src->ss[SV][i] = 1.0;
81        fcross(src->ss[SU], src->ss[SV], src->snorm);
82        mult = .5 * sqrt( src->ss2 / DOT(src->ss[SU],src->ss[SU]) );
83        for (i = 0; i < 3; i++)
82                  src->ss[SU][i] *= mult;
83          fcross(src->ss[SV], src->snorm, src->ss[SU]);
84   }
85  
86  
87 < fsetsrc(src, so)                        /* set a face as a source */
88 < register SRCREC  *src;
89 < OBJREC  *so;
87 > void
88 > fsetsrc(                        /* set a face as a source */
89 >        SRCREC  *src,
90 >        OBJREC  *so
91 > )
92   {
93 <        register FACE  *f;
94 <        register int  i, j;
93 >        FACE  *f;
94 >        int  i, j;
95          double  d;
96          
97          src->sa.success = 2*AIMREQT-1;          /* bitch on second failure */
98          src->so = so;
99                                                  /* get the face */
100          f = getface(so);
101 +        if (f->area == 0.)
102 +                objerror(so, USER, "zero source area");
103                                                  /* find the center */
104          for (j = 0; j < 3; j++) {
105                  src->sloc[j] = 0.0;
# Line 106 | Line 108 | OBJREC  *so;
108                  src->sloc[j] /= (double)f->nv;
109          }
110          if (!inface(src->sloc, f))
111 <                objerror(so, USER, "cannot hit center");
111 >                objerror(so, USER, "cannot hit source center");
112          src->sflags |= SFLAT;
113          VCOPY(src->snorm, f->norm);
114          src->ss2 = f->area;
# Line 119 | Line 121 | OBJREC  *so;
121          }
122          src->srad = sqrt(src->srad);
123                                                  /* compute size vectors */
124 <        if (f->nv == 4 || (f->nv == 5 &&        /* parallelogram case */
123 <                        dist2(VERTEX(f,0),VERTEX(f,4)) <= FTINY*FTINY))
124 >        if (f->nv == 4)                         /* parallelogram case */
125                  for (j = 0; j < 3; j++) {
126                          src->ss[SU][j] = .5*(VERTEX(f,1)[j]-VERTEX(f,0)[j]);
127                          src->ss[SV][j] = .5*(VERTEX(f,3)[j]-VERTEX(f,0)[j]);
# Line 130 | Line 131 | OBJREC  *so;
131   }
132  
133  
134 < ssetsrc(src, so)                        /* set a source as a source */
135 < register SRCREC  *src;
136 < register OBJREC  *so;
134 > void
135 > ssetsrc(                        /* set a source as a source */
136 >        SRCREC  *src,
137 >        OBJREC  *so
138 > )
139   {
140          double  theta;
141          
# Line 140 | Line 143 | register OBJREC  *so;
143          src->so = so;
144          if (so->oargs.nfargs != 4)
145                  objerror(so, USER, "bad arguments");
146 <        src->sflags |= SDISTANT;
146 >        src->sflags |= (SDISTANT|SCIR);
147          VCOPY(src->sloc, so->oargs.farg);
148          if (normalize(src->sloc) == 0.0)
149                  objerror(so, USER, "zero direction");
# Line 156 | Line 159 | register OBJREC  *so;
159   }
160  
161  
162 < sphsetsrc(src, so)                      /* set a sphere as a source */
163 < register SRCREC  *src;
164 < register OBJREC  *so;
162 > void
163 > sphsetsrc(                      /* set a sphere as a source */
164 >        SRCREC  *src,
165 >        OBJREC  *so
166 > )
167   {
168 <        register int  i;
168 >        int  i;
169  
170          src->sa.success = 2*AIMREQT-1;          /* bitch on second failure */
171          src->so = so;
172          if (so->oargs.nfargs != 4)
173                  objerror(so, USER, "bad # arguments");
174          if (so->oargs.farg[3] <= FTINY)
175 <                objerror(so, USER, "illegal radius");
175 >                objerror(so, USER, "illegal source radius");
176 >        src->sflags |= SCIR;
177          VCOPY(src->sloc, so->oargs.farg);
178          src->srad = so->oargs.farg[3];
179          src->ss2 = PI * src->srad * src->srad;
180          for (i = 0; i < 3; i++)
181                  src->ss[SU][i] = src->ss[SV][i] = src->ss[SW][i] = 0.0;
182          for (i = 0; i < 3; i++)
183 <                src->ss[i][i] = .7236 * so->oargs.farg[3];
183 >                src->ss[i][i] = 0.7236 * so->oargs.farg[3];
184   }
185  
186  
187 < rsetsrc(src, so)                        /* set a ring (disk) as a source */
188 < register SRCREC  *src;
189 < OBJREC  *so;
187 > void
188 > rsetsrc(                        /* set a ring (disk) as a source */
189 >        SRCREC  *src,
190 >        OBJREC  *so
191 > )
192   {
193 <        register CONE  *co;
193 >        CONE  *co;
194          
195          src->sa.success = 2*AIMREQT-1;          /* bitch on second failure */
196          src->so = so;
197                                                  /* get the ring */
198          co = getcone(so, 0);
199 +        if (co == NULL)
200 +                objerror(so, USER, "illegal source");
201 +        if (CO_R1(co) <= FTINY)
202 +                objerror(so, USER, "illegal source radius");
203          VCOPY(src->sloc, CO_P0(co));
204          if (CO_R0(co) > 0.0)
205 <                objerror(so, USER, "cannot hit center");
206 <        src->sflags |= SFLAT;
205 >                objerror(so, USER, "cannot hit source center");
206 >        src->sflags |= (SFLAT|SCIR);
207          VCOPY(src->snorm, co->ad);
208          src->srad = CO_R1(co);
209          src->ss2 = PI * src->srad * src->srad;
# Line 199 | Line 211 | OBJREC  *so;
211   }
212  
213  
214 < cylsetsrc(src, so)                      /* set a cylinder as a source */
215 < register SRCREC  *src;
216 < OBJREC  *so;
214 > void
215 > cylsetsrc(                      /* set a cylinder as a source */
216 >        SRCREC  *src,
217 >        OBJREC  *so
218 > )
219   {
220 <        register CONE  *co;
221 <        register int  i;
220 >        CONE  *co;
221 >        int  i;
222          
223          src->sa.success = 4*AIMREQT-1;          /* bitch on fourth failure */
224          src->so = so;
225                                                  /* get the cylinder */
226          co = getcone(so, 0);
227 +        if (co == NULL)
228 +                objerror(so, USER, "illegal source");
229 +        if (CO_R0(co) <= FTINY)
230 +                objerror(so, USER, "illegal source radius");
231          if (CO_R0(co) > .2*co->al)              /* heuristic constraint */
232                  objerror(so, WARNING, "source aspect too small");
233          src->sflags |= SCYL;
# Line 220 | Line 238 | OBJREC  *so;
238                                                  /* set sampling vectors */
239          for (i = 0; i < 3; i++)
240                  src->ss[SU][i] = .5 * co->al * co->ad[i];
241 <        src->ss[SV][0] = src->ss[SV][1] = src->ss[SV][2] = 0.0;
241 >        getperpendicular(src->ss[SW], co->ad, rand_samp);
242          for (i = 0; i < 3; i++)
225                if (co->ad[i] < 0.6 && co->ad[i] > -0.6)
226                        break;
227        src->ss[SV][i] = 1.0;
228        fcross(src->ss[SW], src->ss[SV], co->ad);
229        normalize(src->ss[SW]);
230        for (i = 0; i < 3; i++)
243                  src->ss[SW][i] *= .8559 * CO_R0(co);
244          fcross(src->ss[SV], src->ss[SW], co->ad);
245   }
246  
247  
248   SPOT *
249 < makespot(m)                     /* make a spotlight */
250 < register OBJREC  *m;
249 > makespot(                       /* make a spotlight */
250 >        OBJREC  *m
251 > )
252   {
253 <        register SPOT  *ns;
253 >        SPOT  *ns;
254  
255 +        if ((ns = (SPOT *)m->os) != NULL)
256 +                return(ns);
257          if ((ns = (SPOT *)malloc(sizeof(SPOT))) == NULL)
258                  return(NULL);
259 +        if (m->oargs.farg[3] <= FTINY)
260 +                objerror(m, USER, "zero angle");
261          ns->siz = 2.0*PI * (1.0 - cos(PI/180.0/2.0 * m->oargs.farg[3]));
262          VCOPY(ns->aim, m->oargs.farg+4);
263          if ((ns->flen = normalize(ns->aim)) == 0.0)
264                  objerror(m, USER, "zero focus vector");
265 +        m->os = (char *)ns;
266          return(ns);
267   }
268  
269  
270 + int
271 + spotout(                        /* check if we're outside spot region */
272 +        RAY  *r,
273 +        SPOT  *s
274 + )
275 + {
276 +        double  d;
277 +        FVECT  vd;
278 +        
279 +        if (s == NULL)
280 +                return(0);
281 +        if (s->flen < -FTINY) {         /* distant source */
282 +                vd[0] = s->aim[0] - r->rorg[0];
283 +                vd[1] = s->aim[1] - r->rorg[1];
284 +                vd[2] = s->aim[2] - r->rorg[2];
285 +                d = DOT(r->rdir,vd);
286 +                /*                      wrong side?
287 +                if (d <= FTINY)
288 +                        return(1);      */
289 +                d = DOT(vd,vd) - d*d;
290 +                if (PI*d > s->siz)
291 +                        return(1);      /* out */
292 +                return(0);      /* OK */
293 +        }
294 +                                        /* local source */
295 +        if (s->siz < 2.0*PI * (1.0 + DOT(s->aim,r->rdir)))
296 +                return(1);      /* out */
297 +        return(0);      /* OK */
298 + }
299 +
300 +
301   double
302 < fgetmaxdisk(ocent, op)          /* get center and squared radius of face */
303 < FVECT  ocent;
304 < OBJREC  *op;
302 > fgetmaxdisk(            /* get center and squared radius of face */
303 >        FVECT  ocent,
304 >        OBJREC  *op
305 > )
306   {
307          double  maxrad2;
308          double  d;
309 <        register int  i, j;
310 <        register FACE  *f;
309 >        int  i, j;
310 >        FACE  *f;
311          
312          f = getface(op);
313          if (f->area == 0.)
# Line 282 | Line 332 | OBJREC  *op;
332  
333  
334   double
335 < rgetmaxdisk(ocent, op)          /* get center and squared radius of ring */
336 < FVECT  ocent;
337 < OBJREC  *op;
335 > rgetmaxdisk(            /* get center and squared radius of ring */
336 >        FVECT  ocent,
337 >        OBJREC  *op
338 > )
339   {
340 <        register CONE  *co;
340 >        CONE  *co;
341          
342          co = getcone(op, 0);
343 +        if (co == NULL)
344 +                return(0.);
345          VCOPY(ocent, CO_P0(co));
346          return(CO_R1(co)*CO_R1(co));
347   }
348  
349  
350   double
351 < fgetplaneq(nvec, op)                    /* get plane equation for face */
352 < FVECT  nvec;
353 < OBJREC  *op;
351 > fgetplaneq(                     /* get plane equation for face */
352 >        FVECT  nvec,
353 >        OBJREC  *op
354 > )
355   {
356 <        register FACE  *fo;
356 >        FACE  *fo;
357  
358          fo = getface(op);
359          VCOPY(nvec, fo->norm);
# Line 308 | Line 362 | OBJREC  *op;
362  
363  
364   double
365 < rgetplaneq(nvec, op)                    /* get plane equation for ring */
366 < FVECT  nvec;
367 < OBJREC  *op;
365 > rgetplaneq(                     /* get plane equation for ring */
366 >        FVECT  nvec,
367 >        OBJREC  *op
368 > )
369   {
370 <        register CONE  *co;
370 >        CONE  *co;
371  
372          co = getcone(op, 0);
373 +        if (co == NULL) {
374 +                memset(nvec, 0, sizeof(FVECT));
375 +                return(0.);
376 +        }
377          VCOPY(nvec, co->ad);
378          return(DOT(nvec, CO_P0(co)));
379   }
380  
381  
382 < commonspot(sp1, sp2, org)       /* set sp1 to intersection of sp1 and sp2 */
383 < register SPOT  *sp1, *sp2;
384 < FVECT  org;
382 > int
383 > commonspot(             /* set sp1 to intersection of sp1 and sp2 */
384 >        SPOT  *sp1,
385 >        SPOT  *sp2,
386 >        FVECT  org
387 > )
388   {
389          FVECT  cent;
390          double  rad2, cos1, cos2;
# Line 343 | Line 405 | FVECT  org;
405   }
406  
407  
408 < commonbeam(sp1, sp2, dir)       /* set sp1 to intersection of sp1 and sp2 */
409 < register SPOT  *sp1, *sp2;
410 < FVECT  dir;
408 > int
409 > commonbeam(             /* set sp1 to intersection of sp1 and sp2 */
410 >        SPOT  *sp1,
411 >        SPOT  *sp2,
412 >        FVECT  dir
413 > )
414   {
415          FVECT  cent, c1, c2;
416          double  rad2, d;
352        register int  i;
417                                          /* move centers to common plane */
418          d = DOT(sp1->aim, dir);
419 <        for (i = 0; i < 3; i++)
356 <                c1[i] = sp1->aim[i] - d*dir[i];
419 >        VSUM(c1, sp1->aim, dir, -d);
420          d = DOT(sp2->aim, dir);
421 <        for (i = 0; i < 3; i++)
359 <                c2[i] = sp2->aim[i] - d*dir[i];
421 >        VSUM(c2, sp2->aim, dir, -d);
422                                          /* compute overlap */
423          rad2 = intercircle(cent, c1, c2, sp1->siz/PI, sp2->siz/PI);
424          if (rad2 <= FTINY)
# Line 367 | Line 429 | FVECT  dir;
429   }
430  
431  
432 < checkspot(sp, nrm)              /* check spotlight for behind source */
433 < register SPOT  *sp;     /* spotlight */
434 < FVECT  nrm;             /* source surface normal */
432 > int
433 > checkspot(                      /* check spotlight for behind source */
434 >        SPOT  *sp,      /* spotlight */
435 >        FVECT  nrm      /* source surface normal */
436 > )
437   {
438          double  d, d1;
439  
# Line 383 | Line 447 | FVECT  nrm;            /* source surface normal */
447  
448  
449   double
450 < spotdisk(oc, op, sp, pos)       /* intersect spot with object op */
451 < FVECT  oc;
452 < OBJREC  *op;
453 < register SPOT  *sp;
454 < FVECT  pos;
450 > spotdisk(               /* intersect spot with object op */
451 >        FVECT  oc,
452 >        OBJREC  *op,
453 >        SPOT  *sp,
454 >        FVECT  pos
455 > )
456   {
457          FVECT  onorm;
458          double  offs, d, dist;
394        register int  i;
459  
460          offs = getplaneq(onorm, op);
461          d = -DOT(onorm, sp->aim);
# Line 400 | Line 464 | FVECT  pos;
464          dist = (DOT(pos, onorm) - offs)/d;
465          if (dist < 0.)
466                  return(0.);
467 <        for (i = 0; i < 3; i++)
404 <                oc[i] = pos[i] + dist*sp->aim[i];
467 >        VSUM(oc, pos, sp->aim, dist);
468          return(sp->siz*dist*dist/PI/(d*d));
469   }
470  
471  
472   double
473 < beamdisk(oc, op, sp, dir)       /* intersect beam with object op */
474 < FVECT  oc;
475 < OBJREC  *op;
476 < register SPOT  *sp;
477 < FVECT  dir;
473 > beamdisk(               /* intersect beam with object op */
474 >        FVECT  oc,
475 >        OBJREC  *op,
476 >        SPOT  *sp,
477 >        FVECT  dir
478 > )
479   {
480          FVECT  onorm;
481          double  offs, d, dist;
418        register int  i;
482  
483          offs = getplaneq(onorm, op);
484          d = -DOT(onorm, dir);
485          if (d >= -FTINY && d <= FTINY)
486                  return(0.);
487          dist = (DOT(sp->aim, onorm) - offs)/d;
488 <        for (i = 0; i < 3; i++)
426 <                oc[i] = sp->aim[i] + dist*dir[i];
488 >        VSUM(oc, sp->aim, dir, dist);
489          return(sp->siz/PI/(d*d));
490   }
491  
492  
493   double
494 < intercircle(cc, c1, c2, r1s, r2s)       /* intersect two circles */
495 < FVECT  cc;                      /* midpoint (return value) */
496 < FVECT  c1, c2;                  /* circle centers */
497 < double  r1s, r2s;               /* radii squared */
494 > intercircle(                            /* intersect two circles */
495 >        FVECT  cc,              /* midpoint (return value) */
496 >        FVECT  c1,              /* circle centers */
497 >        FVECT  c2,
498 >        double  r1s,            /* radii squared */
499 >        double  r2s
500 > )
501   {
502          double  a2, d2, l;
503          FVECT  disp;
439        register int  i;
504  
505 <        for (i = 0; i < 3; i++)
442 <                disp[i] = c2[i] - c1[i];
505 >        VSUB(disp, c2, c1);
506          d2 = DOT(disp,disp);
507                                          /* circle within overlap? */
508          if (r1s < r2s) {
# Line 459 | Line 522 | double  r1s, r2s;              /* radii squared */
522                  return(0.);
523                                          /* overlap, compute center */
524          l = sqrt((r1s - a2)/d2);
525 <        for (i = 0; i < 3; i++)
463 <                cc[i] = c1[i] + l*disp[i];
525 >        VSUM(cc, c1, disp, l);
526          return(a2);
465 }
466
467
468 sourcehit(r)                    /* check to see if ray hit distant source */
469 register RAY  *r;
470 {
471        int  first, last;
472        register int  i;
473
474        if (r->rsrc >= 0) {             /* check only one if aimed */
475                first = last = r->rsrc;
476        } else {                        /* otherwise check all */
477                first = 0; last = nsources-1;
478        }
479        for (i = first; i <= last; i++)
480                if ((source[i].sflags & (SDISTANT|SVIRTUAL)) == SDISTANT)
481                        /*
482                         * Check to see if ray is within
483                         * solid angle of source.
484                         */
485                        if (2.0*PI * (1.0 - DOT(source[i].sloc,r->rdir))
486                                        <= source[i].ss2) {
487                                r->ro = source[i].so;
488                                if (!(source[i].sflags & SSKIP))
489                                        break;
490                        }
491
492        if (r->ro != NULL) {
493                for (i = 0; i < 3; i++)
494                        r->ron[i] = -r->rdir[i];
495                r->rod = 1.0;
496                r->rox = NULL;
497                return(1);
498        }
499        return(0);
500 }
501
502
503 /****************************************************************
504 * The following macros were separated from the m_light() routine
505 * because they are very nasty and difficult to understand.
506 */
507
508 /* wrongillum *
509 *
510 * We cannot allow an illum to pass to another illum, because that
511 * would almost certainly constitute overcounting.
512 * However, we do allow an illum to pass to another illum
513 * that is actually going to relay to a virtual light source.
514 */
515
516 #define  wrongillum(m, r)       (!(source[r->rsrc].sflags&SVIRTUAL) && \
517                        objptr(source[r->rsrc].so->omod)->otype==MAT_ILLUM)
518
519 /* wrongsource *
520 *
521 * This source is the wrong source (ie. overcounted) if we are
522 * aimed to a different source than the one we hit and the one
523 * we hit is not an illum which should be passed.
524 */
525
526 #define  wrongsource(m, r)      (r->rsrc>=0 && source[r->rsrc].so!=r->ro && \
527                                (m->otype!=MAT_ILLUM || wrongillum(m,r)))
528
529 /* badspecular *
530 *
531 * Any undirected specular ray that hits a light source
532 * should be discarded.  This is because the source contribution to
533 * specular components is calculated separately to reduce variance.
534 */
535
536 #define  badspecular(m, r)      (r->rsrc<0 && r->crtype&SPECULAR)
537
538 /* distglow *
539 *
540 * A distant glow is an object that sometimes acts as a light source,
541 * but is too far away from the test point to be one in this case.
542 */
543
544 #define  distglow(m, r)         (m->otype==MAT_GLOW && \
545                                r->rot > m->oargs.farg[3])
546
547 /* badambient *
548 *
549 * We must avoid including counting light sources in the ambient calculation,
550 * since the direct component is handled separately.  Therefore, any
551 * ambient ray which hits an active light source must be discarded.
552 */
553
554 #define  badambient(m, r)       ((r->crtype&(AMBIENT|SHADOW))==AMBIENT && \
555                                !distglow(m, r))
556
557 /* overcount *
558 *
559 * All overcounting possibilities are contained here.
560 */
561
562 #define  overcount(m, r)        (badspecular(m,r) || wrongsource(m,r) || \
563                                badambient(m,r))
564
565 /* passillum *
566 *
567 * An illum passes to another material type when we didn't hit it
568 * on purpose (as part of a direct calculation), or it is relaying
569 * a virtual light source.
570 */
571
572 #define  passillum(m, r)        (m->otype==MAT_ILLUM && \
573                                (r->rsrc<0 || source[r->rsrc].so!=r->ro || \
574                                source[r->rsrc].sflags&SVIRTUAL))
575
576 /* srcignore *
577 *
578 * The -di flag renders light sources invisible, and here is the test.
579 */
580
581 #define  srcignore(m, r)        (directinvis && !(r->crtype&SHADOW) && \
582                                !distglow(m, r))
583
584
585 m_light(m, r)                   /* ray hit a light source */
586 register OBJREC  *m;
587 register RAY  *r;
588 {
589                                                /* check for over-counting */
590        if (overcount(m, r))
591                return;
592                                                /* check for passed illum */
593        if (passillum(m, r)) {
594                if (m->oargs.nsargs < 1 || !strcmp(m->oargs.sarg[0], VOIDID))
595                        raytrans(r);
596                else
597                        rayshade(r, modifier(m->oargs.sarg[0]));
598                return;
599        }
600                                        /* otherwise treat as source */
601                                                /* check for behind */
602        if (r->rod < 0.0)
603                return;
604                                                /* check for invisibility */
605        if (srcignore(m, r))
606                return;
607                                                /* get distribution pattern */
608        raytexture(r, m->omod);
609                                                /* get source color */
610        setcolor(r->rcol, m->oargs.farg[0],
611                          m->oargs.farg[1],
612                          m->oargs.farg[2]);
613                                                /* modify value */
614        multcolor(r->rcol, r->pcol);
527   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines