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 2.4 by greg, Tue Sep 22 11:28:48 1992 UTC vs.
Revision 2.9 by schorsch, Thu Jun 26 00:58:10 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Source sampling routines
6 + *
7 + *  External symbols declared in source.h
8   */
9  
10 + #include "copyright.h"
11 +
12   #include  "ray.h"
13  
14   #include  "source.h"
# Line 15 | Line 16 | static char SCCSid[] = "$SunId$ LBL";
16   #include  "random.h"
17  
18  
19 + static int  cyl_partit(), flt_partit();
20 +
21 +
22   double
23   nextssamp(r, si)                /* compute sample for source, rtn. distance */
24   register RAY  *r;               /* origin is read, direction is set */
# Line 79 | Line 83 | nextsample:
83                  goto nextsample;                /* at source! */
84  
85                                          /* compute sample size */
82        si->dom  = source[si->sn].ss2;
86          if (source[si->sn].sflags & SFLAT) {
87 <                si->dom *= sflatform(si->sn, r->rdir);
87 >                si->dom = sflatform(si->sn, r->rdir);
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);
90 >                si->dom = scylform(si->sn, r->rdir);
91                  si->dom *= size[SU]/(double)MAXSPART;
92          } else {
93 <                si->dom *= size[SU]*size[SV]*(double)size[SW] /
93 >                si->dom = size[SU]*size[SV]*(double)size[SW] /
94                                  (MAXSPART*MAXSPART*(double)MAXSPART) ;
95          }
96 <        if (source[si->sn].sflags & SDISTANT)
96 >        if (source[si->sn].sflags & SDISTANT) {
97 >                si->dom *= source[si->sn].ss2;
98                  return(FHUGE);
99 +        }
100          if (si->dom <= 1e-4)
101                  goto nextsample;                /* behind source? */
102 <        si->dom /= d*d;
102 >        si->dom *= source[si->sn].ss2/(d*d);
103          return(d);              /* sample OK, return distance */
104   }
105  
106  
107 + int
108   skipparts(ct, sz, pp, pt)               /* skip to requested partition */
109   int  ct[3], sz[3];              /* center and size of partition (returned) */
110   register int  pp[2];            /* current index, number to skip (modified) */
# Line 130 | Line 136 | unsigned char  *pt;            /* partition array */
136   }
137  
138  
139 + void
140   nopart(si, r)                   /* single source partition */
141   register SRCINDEX  *si;
142   RAY  *r;
# Line 140 | Line 147 | RAY  *r;
147   }
148  
149  
150 + void
151   cylpart(si, r)                  /* partition a cylinder */
152   SRCINDEX  *si;
153   register RAY  *r;
# Line 216 | Line 224 | double  d2;
224   }
225  
226  
227 + void
228   flatpart(si, r)                         /* partition a flat source */
229   register SRCINDEX  *si;
230   register RAY  *r;
231   {
232 <        register FLOAT  *vp;
232 >        register RREAL  *vp;
233          FVECT  v;
234          double  du2, dv2;
235          int  pi;
# Line 304 | Line 313 | scylform(sn, dir)              /* compute cosine for cylinder's pr
313   int  sn;
314   register FVECT  dir;            /* assume normalized */
315   {
316 <        register FLOAT  *dv;
316 >        register RREAL  *dv;
317          double  d;
318  
319          dv = source[sn].ss[SU];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines