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 1.5 by greg, Wed Oct 23 08:50:06 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 >
28          while (++si->sp >= si->np) {    /* get next sample */
29                  if (++si->sn >= nsources)
30                          return(0.0);    /* no more */
# Line 74 | Line 74 | tryagain:
74                          r->rdir[i] -= r->rorg[i];
75                                          /* compute distance */
76          if ((d = normalize(r->rdir)) == 0.0)
77 <                goto tryagain;  /* at source! */
77 >                return(nextssamp(r, si));       /* at source! */
78  
79                                          /* compute sample size */
80          si->dom  = source[si->sn].ss2;
81          if (source[si->sn].sflags & SFLAT) {
82                  si->dom *= sflatform(si->sn, r->rdir);
83                if (si->dom <= FTINY) {         /* behind source */
84                        si->np = 0;
85                        goto tryagain;
86                }
83                  si->dom *= (double)(size[SU]*size[SV])/(MAXSPART*MAXSPART);
84          } else if (source[si->sn].sflags & SCYL) {
85                  si->dom *= scylform(si->sn, r->rdir);
# Line 165 | Line 161 | register RAY  *r;
161                  return;
162          }
163          safedist2 *= 4.*r->rweight*r->rweight/(srcsizerat*srcsizerat);
164 <        if (dist2 <= 4.*rad2 ||         /* point too close to subdivide? */
165 <                        dist2cent >= safedist2) {       /* too far? */
164 >        if (dist2 <= 4.*rad2 ||         /* point too close to subdivide */
165 >                        dist2cent >= safedist2) {       /* or too far */
166                  setpart(si->spt, 0, S0);
167                  si->np = 1;
168                  return;
# Line 218 | Line 214 | double  d2;
214  
215   flatpart(si, r)                         /* partition a flat source */
216   register SRCINDEX  *si;
217 < RAY  *r;
217 > register RAY  *r;
218   {
219          register double  *vp;
220 +        FVECT  v;
221          double  du2, dv2;
222          int  pi;
223  
224 +        clrpart(si->spt);
225 +        vp = source[si->sn].sloc;
226 +        v[0] = r->rorg[0] - vp[0];
227 +        v[1] = r->rorg[1] - vp[1];
228 +        v[2] = r->rorg[2] - vp[2];
229 +        vp = source[si->sn].snorm;
230 +        if (DOT(v,vp) <= FTINY) {       /* behind source */
231 +                si->np = 0;
232 +                return;
233 +        }
234          dv2 = 2.*r->rweight/srcsizerat;
235          dv2 *= dv2;
236          vp = source[si->sn].ss[SU];
237          du2 = dv2 * DOT(vp,vp);
238          vp = source[si->sn].ss[SV];
239          dv2 *= DOT(vp,vp);
233        clrpart(si->spt);
240          pi = 0;
241          si->np = flt_partit(r->rorg, si->spt, &pi, MAXSPART,
242                  source[si->sn].sloc,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines