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 1.14 by greg, Mon Oct 21 12:58:16 1991 UTC vs.
Revision 2.5 by greg, Fri Aug 28 14:07:45 1992 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 174 | Line 174 | register OBJREC  *so;
174          for (i = 0; i < 3; i++)
175                  src->ss[SU][i] = src->ss[SV][i] = src->ss[SW][i] = 0.0;
176          for (i = 0; i < 3; i++)
177 <                src->ss[i][i] = .886227 * so->oargs.farg[3];
177 >                src->ss[i][i] = .7236 * so->oargs.farg[3];
178   }
179  
180  
# Line 212 | Line 212 | OBJREC  *so;
212          co = getcone(so, 0);
213          if (CO_R0(co) > .2*co->al)              /* heuristic constraint */
214                  objerror(so, WARNING, "source aspect too small");
215 +        src->sflags |= SCYL;
216          for (i = 0; i < 3; i++)
217                  src->sloc[i] = .5 * (CO_P1(co)[i] + CO_P0(co)[i]);
218 <        src->srad = co->al;
218 >        src->srad = .5*co->al;
219          src->ss2 = 2.*CO_R0(co)*co->al;
220                                                  /* set sampling vectors */
221          for (i = 0; i < 3; i++)
# Line 227 | Line 228 | OBJREC  *so;
228          fcross(src->ss[SW], src->ss[SV], co->ad);
229          normalize(src->ss[SW]);
230          for (i = 0; i < 3; i++)
231 <                src->ss[SW][i] *= .886227 * CO_R0(co);
231 >                src->ss[SW][i] *= .8559 * CO_R0(co);
232          fcross(src->ss[SV], src->ss[SW], co->ad);
233   }
234  
# Line 238 | Line 239 | register OBJREC  *m;
239   {
240          register SPOT  *ns;
241  
242 +        if ((ns = (SPOT *)m->os) != NULL)
243 +                return(ns);
244          if ((ns = (SPOT *)malloc(sizeof(SPOT))) == NULL)
245                  return(NULL);
246          ns->siz = 2.0*PI * (1.0 - cos(PI/180.0/2.0 * m->oargs.farg[3]));
247          VCOPY(ns->aim, m->oargs.farg+4);
248          if ((ns->flen = normalize(ns->aim)) == 0.0)
249                  objerror(m, USER, "zero focus vector");
250 +        m->os = (char *)ns;
251          return(ns);
252   }
253  
254  
255 + spotout(r, s, dist)             /* check if we're outside spot region */
256 + register RAY  *r;
257 + register SPOT  *s;
258 + int  dist;
259 + {
260 +        double  d;
261 +        FVECT  vd;
262 +        
263 +        if (s == NULL)
264 +                return(0);
265 +        if (dist) {                     /* distant source */
266 +                vd[0] = s->aim[0] - r->rorg[0];
267 +                vd[1] = s->aim[1] - r->rorg[1];
268 +                vd[2] = s->aim[2] - r->rorg[2];
269 +                d = DOT(r->rdir,vd);
270 +                /*                      wrong side?
271 +                if (d <= FTINY)
272 +                        return(1);      */
273 +                d = DOT(vd,vd) - d*d;
274 +                if (PI*d > s->siz)
275 +                        return(1);      /* out */
276 +                return(0);      /* OK */
277 +        }
278 +                                        /* local source */
279 +        if (s->siz < 2.0*PI * (1.0 + DOT(s->aim,r->rdir)))
280 +                return(1);      /* out */
281 +        return(0);      /* OK */
282 + }
283 +
284 +
285   double
286   fgetmaxdisk(ocent, op)          /* get center and squared radius of face */
287   FVECT  ocent;
# Line 496 | Line 530 | register RAY  *r;
530                  return(1);
531          }
532          return(0);
499 }
500
501
502 #define  wrongsource(m, r)      (r->rsrc>=0 && \
503                                source[r->rsrc].so!=r->ro && \
504                                (m->otype!=MAT_ILLUM || \
505                        objptr(source[r->rsrc].so->omod)->otype==MAT_ILLUM))
506
507 #define  distglow(m, r)         (m->otype==MAT_GLOW && \
508                                r->rot > m->oargs.farg[3])
509
510 #define  badambient(m, r)       ((r->crtype&(AMBIENT|SHADOW))==AMBIENT && \
511                                !distglow(m, r))
512
513 #define  passillum(m, r)        (m->otype==MAT_ILLUM && \
514                                !(r->rsrc>=0&&source[r->rsrc].so==r->ro))
515
516 #define  srcignore(m, r)        (directinvis && !(r->crtype&SHADOW) && \
517                                !distglow(m, r))
518
519
520 m_light(m, r)                   /* ray hit a light source */
521 register OBJREC  *m;
522 register RAY  *r;
523 {
524                                                /* check for over-counting */
525        if (wrongsource(m, r) || badambient(m, r))
526                return;
527                                                /* check for passed illum */
528        if (passillum(m, r)) {
529                if (m->oargs.nsargs < 1 || !strcmp(m->oargs.sarg[0], VOIDID))
530                        raytrans(r);
531                else
532                        rayshade(r, modifier(m->oargs.sarg[0]));
533                return;
534        }
535                                        /* otherwise treat as source */
536                                                /* check for behind */
537        if (r->rod < 0.0)
538                return;
539                                                /* check for invisibility */
540        if (srcignore(m, r))
541                return;
542                                                /* get distribution pattern */
543        raytexture(r, m->omod);
544                                                /* get source color */
545        setcolor(r->rcol, m->oargs.farg[0],
546                          m->oargs.farg[1],
547                          m->oargs.farg[2]);
548                                                /* modify value */
549        multcolor(r->rcol, r->pcol);
533   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines