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

Comparing ray/src/rt/srcsamp.c (file contents):
Revision 1.4 by greg, Tue Oct 22 15:45:21 1991 UTC vs.
Revision 2.2 by greg, Mon Nov 25 09:52:49 1991 UTC

# Line 24 | Line 24 | register SRCINDEX  *si;                /* source index (modified to
24          FVECT  vpos;
25          double  d;
26          register int  i;
27 < tryagain:
27 > nextsample:
28          while (++si->sp >= si->np) {    /* get next sample */
29                  if (++si->sn >= nsources)
30                          return(0.0);    /* no more */
31 <                if (srcsizerat <= FTINY)
31 >                if (source[si->sn].sflags & SSKIP)
32 >                        si->np = 0;
33 >                else if (srcsizerat <= FTINY)
34                          nopart(si, r);
35                  else {
36                          for (i = si->sn; source[i].sflags & SVIRTUAL;
# Line 74 | Line 76 | tryagain:
76                          r->rdir[i] -= r->rorg[i];
77                                          /* compute distance */
78          if ((d = normalize(r->rdir)) == 0.0)
79 <                goto tryagain;  /* at source! */
79 >                goto nextsample;                /* at source! */
80  
81                                          /* compute sample size */
82          si->dom  = source[si->sn].ss2;
83          if (source[si->sn].sflags & SFLAT) {
84                  si->dom *= sflatform(si->sn, r->rdir);
83                if (si->dom <= FTINY) {         /* behind source */
84                        si->np = 0;
85                        goto tryagain;
86                }
85                  si->dom *= (double)(size[SU]*size[SV])/(MAXSPART*MAXSPART);
86          } else if (source[si->sn].sflags & SCYL) {
87                  si->dom *= scylform(si->sn, r->rdir);
# Line 94 | Line 92 | tryagain:
92          }
93          if (source[si->sn].sflags & SDISTANT)
94                  return(FHUGE);
95 +        if (si->dom <= FTINY)
96 +                goto nextsample;                /* behind source? */
97          si->dom /= d*d;
98          return(d);              /* sample OK, return distance */
99   }
# Line 165 | Line 165 | register RAY  *r;
165                  return;
166          }
167          safedist2 *= 4.*r->rweight*r->rweight/(srcsizerat*srcsizerat);
168 <        if (dist2 <= 4.*rad2 ||         /* point too close to subdivide? */
169 <                        dist2cent >= safedist2) {       /* too far? */
168 >        if (dist2 <= 4.*rad2 ||         /* point too close to subdivide */
169 >                        dist2cent >= safedist2) {       /* or too far */
170                  setpart(si->spt, 0, S0);
171                  si->np = 1;
172                  return;
# Line 218 | Line 218 | double  d2;
218  
219   flatpart(si, r)                         /* partition a flat source */
220   register SRCINDEX  *si;
221 < RAY  *r;
221 > register RAY  *r;
222   {
223 <        register double  *vp;
223 >        register FLOAT  *vp;
224 >        FVECT  v;
225          double  du2, dv2;
226          int  pi;
227  
228 +        clrpart(si->spt);
229 +        vp = source[si->sn].sloc;
230 +        v[0] = r->rorg[0] - vp[0];
231 +        v[1] = r->rorg[1] - vp[1];
232 +        v[2] = r->rorg[2] - vp[2];
233 +        vp = source[si->sn].snorm;
234 +        if (DOT(v,vp) <= FTINY) {       /* behind source */
235 +                si->np = 0;
236 +                return;
237 +        }
238          dv2 = 2.*r->rweight/srcsizerat;
239          dv2 *= dv2;
240          vp = source[si->sn].ss[SU];
241          du2 = dv2 * DOT(vp,vp);
242          vp = source[si->sn].ss[SV];
243          dv2 *= DOT(vp,vp);
233        clrpart(si->spt);
244          pi = 0;
245          si->np = flt_partit(r->rorg, si->spt, &pi, MAXSPART,
246                  source[si->sn].sloc,
# Line 294 | Line 304 | scylform(sn, dir)              /* compute cosine for cylinder's pr
304   int  sn;
305   register FVECT  dir;            /* assume normalized */
306   {
307 <        register double  *dv;
307 >        register FLOAT  *dv;
308          double  d;
309  
310          dv = source[sn].ss[SU];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines