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.6 by greg, Wed Oct 23 13:43:52 1991 UTC vs.
Revision 2.4 by greg, Tue Sep 22 11:28:48 1992 UTC

# Line 24 | Line 24 | register SRCINDEX  *si;                /* source index (modified to
24          FVECT  vpos;
25          double  d;
26          register int  i;
27 <
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 | register SRCINDEX  *si;                /* source index (modified to
76                          r->rdir[i] -= r->rorg[i];
77                                          /* compute distance */
78          if ((d = normalize(r->rdir)) == 0.0)
79 <                return(nextssamp(r, si));       /* 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);
85 <                si->dom *= (double)(size[SU]*size[SV])/(MAXSPART*MAXSPART);
85 >                si->dom *= size[SU]*size[SV]/(MAXSPART*(double)MAXSPART);
86          } else if (source[si->sn].sflags & SCYL) {
87                  si->dom *= scylform(si->sn, r->rdir);
88 <                si->dom *= (double)size[SU]/MAXSPART;
88 >                si->dom *= size[SU]/(double)MAXSPART;
89          } else {
90 <                si->dom *= (double)(size[SU]*size[SV]*size[SW]) /
91 <                                (MAXSPART*MAXSPART*MAXSPART) ;
90 >                si->dom *= size[SU]*size[SV]*(double)size[SW] /
91 >                                (MAXSPART*MAXSPART*(double)MAXSPART) ;
92          }
93          if (source[si->sn].sflags & SDISTANT)
94                  return(FHUGE);
95 +        if (si->dom <= 1e-4)
96 +                goto nextsample;                /* behind source? */
97          si->dom /= d*d;
98          return(d);              /* sample OK, return distance */
99   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines