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.7 by greg, Mon Oct 28 08:07:44 1991 UTC vs.
Revision 2.5 by greg, Mon Mar 8 12:37:39 1993 UTC

# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #include  "random.h"
16  
17  
18 + static int  cyl_partit(), flt_partit();
19 +
20 +
21   double
22   nextssamp(r, si)                /* compute sample for source, rtn. distance */
23   register RAY  *r;               /* origin is read, direction is set */
# Line 24 | Line 27 | register SRCINDEX  *si;                /* source index (modified to
27          FVECT  vpos;
28          double  d;
29          register int  i;
30 <
30 > nextsample:
31          while (++si->sp >= si->np) {    /* get next sample */
32                  if (++si->sn >= nsources)
33                          return(0.0);    /* no more */
# Line 76 | Line 79 | register SRCINDEX  *si;                /* source index (modified to
79                          r->rdir[i] -= r->rorg[i];
80                                          /* compute distance */
81          if ((d = normalize(r->rdir)) == 0.0)
82 <                return(nextssamp(r, si));       /* at source! */
82 >                goto nextsample;                /* at source! */
83  
84                                          /* compute sample size */
85          si->dom  = source[si->sn].ss2;
86          if (source[si->sn].sflags & SFLAT) {
87                  si->dom *= sflatform(si->sn, r->rdir);
88 <                si->dom *= (double)(size[SU]*size[SV])/(MAXSPART*MAXSPART);
88 >                si->dom *= size[SU]*size[SV]/(MAXSPART*(double)MAXSPART);
89          } else if (source[si->sn].sflags & SCYL) {
90                  si->dom *= scylform(si->sn, r->rdir);
91 <                si->dom *= (double)size[SU]/MAXSPART;
91 >                si->dom *= size[SU]/(double)MAXSPART;
92          } else {
93 <                si->dom *= (double)(size[SU]*size[SV]*size[SW]) /
94 <                                (MAXSPART*MAXSPART*MAXSPART) ;
93 >                si->dom *= size[SU]*size[SV]*(double)size[SW] /
94 >                                (MAXSPART*MAXSPART*(double)MAXSPART) ;
95          }
96          if (source[si->sn].sflags & SDISTANT)
97                  return(FHUGE);
98 +        if (si->dom <= 1e-4)
99 +                goto nextsample;                /* behind source? */
100          si->dom /= d*d;
101          return(d);              /* sample OK, return distance */
102   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines