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.39 by greg, Thu Jul 11 16:39:03 1991 UTC vs.
Revision 1.44 by greg, Thu Aug 22 11:56:55 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 128 | Line 128 | register int  sn;              /* source number */
128          sr->rsrc = sn;                          /* remember source */
129                                                  /* get source direction */
130          if (source[sn].sflags & SDISTANT) {
131                if (source[sn].sflags & SSPOT) {        /* check location */
132                        for (i = 0; i < 3; i++)
133                                vd[i] = sr->rorg[i] - source[sn].sl.s->aim[i];
134                        d = DOT(source[sn].sloc,vd);
135                        d = DOT(vd,vd) - d*d;
136                        if (PI*d > source[sn].sl.s->siz)
137                                return(0.0);
138                }
131                                                  /* constant direction */
132                  VCOPY(sr->rdir, source[sn].sloc);
133          } else {                                /* compute direction */
# Line 148 | Line 140 | register int  sn;              /* source number */
140          }
141          if (dstrsrc > FTINY) {
142                                          /* distribute source direction */
143 <                dimlist[ndims++] = sn;
144 <                for (i = 0; i < 3; i++) {
145 <                        dimlist[ndims] = i + 8831;
146 <                        vd[i] = dstrsrc * source[sn].ss *
155 <                (1.0 - 2.0*urand(urind(ilhash(dimlist,ndims+1),samplendx)));
156 <                }
157 <                ndims--;
143 >                dimlist[ndims] = sn + 8831;
144 >                multisamp(vd, 3, urand(ilhash(dimlist,ndims+1)+samplendx));
145 >                for (i = 0; i < 3; i++)
146 >                        vd[i] = dstrsrc * source[sn].ss * (1. - 2.*vd[i]);
147                  if (source[sn].sflags & SFLAT) {        /* project offset */
148                          d = DOT(vd, source[sn].snorm);
149                          for (i = 0; i < 3; i++)
# Line 162 | Line 151 | register int  sn;              /* source number */
151                  }
152                  for (i = 0; i < 3; i++)         /* offset source direction */
153                          sr->rdir[i] += vd[i];
154 +                                                /* normalize */
155 +                d = normalize(sr->rdir);
156  
157 <        } else if (source[sn].sflags & SDISTANT)
158 <                                                /* already normalized */
159 <                return(source[sn].ss2);
157 >        } else if (!(source[sn].sflags & SDISTANT))
158 >                                                /* normalize direction */
159 >                d = normalize(sr->rdir);
160  
161 <        if ((d = normalize(sr->rdir)) == 0.0)
162 <                                                /* at source! */
161 >        if (source[sn].sflags & SDISTANT) {
162 >                if (source[sn].sflags & SSPOT) {        /* check location */
163 >                        for (i = 0; i < 3; i++)
164 >                                vd[i] = source[sn].sl.s->aim[i] - sr->rorg[i];
165 >                        d = DOT(sr->rdir,vd);
166 >                        if (d <= FTINY)
167 >                                return(0.0);
168 >                        d = DOT(vd,vd) - d*d;
169 >                        if (PI*d > source[sn].sl.s->siz)
170 >                                return(0.0);
171 >                }
172 >                return(source[sn].ss2);         /* domega constant */
173 >        }
174 >                                                /* check direction */
175 >        if (d == 0.0)
176                  return(0.0);
173        
174        if (source[sn].sflags & SDISTANT)
175                                                /* domega constant */
176                return(source[sn].ss2);
177
177                                                  /* check proximity */
178          if (source[sn].sflags & SPROX &&
179                          d > source[sn].sl.prox)
# Line 245 | Line 244 | RAY  *r;                       /* ray that hit surface */
244   int  (*f)();                    /* direct component coefficient function */
245   char  *p;                       /* data for f */
246   {
247 +        extern int  (*trace)();
248          extern double  pow();
249          register int  sn;
250          int  nshadcheck, ncnts;
# Line 314 | Line 314 | char  *p;                      /* data for f */
314                                  source[cntord[sn].sno].sflags & SFOLLOW )) {
315                                                  /* follow entire path */
316                          raycont(&sr);
317 +                        if (trace != NULL)
318 +                                (*trace)(&sr);  /* trace execution */
319                          if (bright(sr.rcol) <= FTINY)
320                                  continue;       /* missed! */
321                          copycolor(srccnt[cntord[sn].sno].val, sr.rcol);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines