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

Comparing ray/src/rt/source.c (file contents):
Revision 1.37 by greg, Tue Jun 25 12:32:51 1991 UTC vs.
Revision 1.42 by greg, Mon Aug 12 08:20:49 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1990 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 86 | Line 86 | marksources()                  /* find and mark source objects */
86                          source[ns].sflags |= SSPOT;
87                          if ((source[ns].sl.s = makespot(m)) == NULL)
88                                  goto memerr;
89 +                        if (source[ns].sflags & SFLAT &&
90 +                                !checkspot(source[ns].sl.s,source[ns].snorm)) {
91 +                                objerror(o, WARNING,
92 +                                        "invalid spotlight direction");
93 +                                source[ns].sflags |= SSKIP;
94 +                        }
95                  }
96          }
97          if (nsources <= 0) {
# Line 122 | Line 128 | register int  sn;              /* source number */
128          sr->rsrc = sn;                          /* remember source */
129                                                  /* get source direction */
130          if (source[sn].sflags & SDISTANT) {
125                if (source[sn].sflags & SSPOT) {        /* check location */
126                        for (i = 0; i < 3; i++)
127                                vd[i] = sr->rorg[i] - source[sn].sl.s->aim[i];
128                        d = DOT(source[sn].sloc,vd);
129                        d = DOT(vd,vd) - d*d;
130                        if (PI*d > source[sn].sl.s->siz)
131                                return(0.0);
132                }
131                                                  /* constant direction */
132                  VCOPY(sr->rdir, source[sn].sloc);
133          } else {                                /* compute direction */
# Line 146 | Line 144 | register int  sn;              /* source number */
144                  for (i = 0; i < 3; i++) {
145                          dimlist[ndims] = i + 8831;
146                          vd[i] = dstrsrc * source[sn].ss *
147 <                (1.0 - 2.0*urand(ilhash(dimlist,ndims+1)+samplendx));
147 >                (1.0 - 2.0*urand(urind(ilhash(dimlist,ndims+1),samplendx)));
148                  }
149                  ndims--;
150                  if (source[sn].sflags & SFLAT) {        /* project offset */
# Line 156 | Line 154 | register int  sn;              /* source number */
154                  }
155                  for (i = 0; i < 3; i++)         /* offset source direction */
156                          sr->rdir[i] += vd[i];
157 +                                                /* normalize */
158 +                d = normalize(sr->rdir);
159  
160 <        } else if (source[sn].sflags & SDISTANT)
161 <                                                /* already normalized */
162 <                return(source[sn].ss2);
160 >        } else if (!(source[sn].sflags & SDISTANT))
161 >                                                /* normalize direction */
162 >                d = normalize(sr->rdir);
163  
164 <        if ((d = normalize(sr->rdir)) == 0.0)
165 <                                                /* at source! */
164 >        if (source[sn].sflags & SDISTANT) {
165 >                if (source[sn].sflags & SSPOT) {        /* check location */
166 >                        for (i = 0; i < 3; i++)
167 >                                vd[i] = source[sn].sl.s->aim[i] - sr->rorg[i];
168 >                        d = DOT(sr->rdir,vd);
169 >                        if (d <= FTINY)
170 >                                return(0.0);
171 >                        d = DOT(vd,vd) - d*d;
172 >                        if (PI*d > source[sn].sl.s->siz)
173 >                                return(0.0);
174 >                }
175 >                return(source[sn].ss2);         /* domega constant */
176 >        }
177 >                                                /* check direction */
178 >        if (d == 0.0)
179                  return(0.0);
167        
168        if (source[sn].sflags & SDISTANT)
169                                                /* domega constant */
170                return(source[sn].ss2);
171
180                                                  /* check proximity */
181          if (source[sn].sflags & SPROX &&
182                          d > source[sn].sl.prox)
# Line 239 | Line 247 | RAY  *r;                       /* ray that hit surface */
247   int  (*f)();                    /* direct component coefficient function */
248   char  *p;                       /* data for f */
249   {
250 +        extern int  (*trace)();
251          extern double  pow();
252          register int  sn;
253          int  nshadcheck, ncnts;
# Line 308 | Line 317 | char  *p;                      /* data for f */
317                                  source[cntord[sn].sno].sflags & SFOLLOW )) {
318                                                  /* follow entire path */
319                          raycont(&sr);
320 +                        if (trace != NULL)
321 +                                (*trace)(&sr);  /* trace execution */
322                          if (bright(sr.rcol) <= FTINY)
323                                  continue;       /* missed! */
324                          copycolor(srccnt[cntord[sn].sno].val, sr.rcol);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines