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

Comparing ray/src/rt/source.c (file contents):
Revision 2.41 by greg, Fri Jan 9 05:37:11 2004 UTC vs.
Revision 2.44 by schorsch, Tue Mar 30 16:13:01 2004 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8   */
9  
10   #include  "ray.h"
11
11   #include  "otypes.h"
12 <
12 > #include  "rtotypes.h"
13   #include  "source.h"
15
14   #include  "random.h"
15  
16   extern double  ssampdist;               /* scatter sampling distance */
# Line 41 | Line 39 | static CONTRIB  *srccnt;               /* source contributions in d
39   static CNTPTR  *cntord;                 /* source ordering in direct() */
40   static int  maxcntr = 0;                /* size of contribution arrays */
41  
42 + static int cntcmp(const void *p1, const void *p2);
43  
44 < OBJREC *                        /* find an object's actual material */
44 >
45 > extern OBJREC *                 /* find an object's actual material */
46   findmaterial(register OBJREC *o)
47   {
48          while (!ismaterial(o->otype)) {
# Line 66 | Line 66 | findmaterial(register OBJREC *o)
66   }
67  
68  
69 < void
70 < marksources()                   /* find and mark source objects */
69 > extern void
70 > marksources(void)                       /* find and mark source objects */
71   {
72          int  foundsource = 0;
73          int  i;
# Line 83 | Line 83 | marksources()                  /* find and mark source objects */
83                  if (!issurface(o->otype) || o->omod == OVOID)
84                          continue;
85                                          /* find material */
86 <                m = findmaterial(o);
86 >                m = findmaterial(objptr(o->omod));
87                  if (m == NULL || !islight(m->otype))
88                          continue;       /* not source modifier */
89          
# Line 147 | Line 147 | memerr:
147   }
148  
149  
150 < void
151 < freesources()                   /* free all source structures */
150 > extern void
151 > freesources(void)                       /* free all source structures */
152   {
153          if (nsources > 0) {
154   #if SHADCACHE
# Line 169 | Line 169 | freesources()                  /* free all source structures */
169   }
170  
171  
172 < int
172 > extern int
173   srcray(                         /* send a ray to a source, return domega */
174 < register RAY  *sr,              /* returned source ray */
175 < RAY  *r,                        /* ray which hit object */
176 < SRCINDEX  *si                   /* source sample index */
174 >        register RAY  *sr,              /* returned source ray */
175 >        RAY  *r,                        /* ray which hit object */
176 >        SRCINDEX  *si                   /* source sample index */
177   )
178   {
179      double  d;                          /* distance to source */
# Line 208 | Line 208 | SRCINDEX  *si                  /* source sample index */
208   }
209  
210  
211 < void
211 > extern void
212   srcvalue(                       /* punch ray to source and compute value */
213 < register RAY  *r
213 >        register RAY  *r
214   )
215   {
216          register SRCREC  *sp;
# Line 250 | Line 250 | nomat:
250   }
251  
252  
253 < int
253 > extern int
254   sourcehit(                      /* check to see if ray hit distant source */
255 < register RAY  *r
255 >        register RAY  *r
256   )
257   {
258          int  first, last;
# Line 292 | Line 292 | register RAY  *r
292  
293   static int
294   cntcmp(                         /* contribution compare (descending) */
295 < const void *p1,
296 < const void *p2
295 >        const void *p1,
296 >        const void *p2
297   )
298   {
299          register const CNTPTR  *sc1 = (const CNTPTR *)p1;
# Line 307 | Line 307 | const void *p2
307   }
308  
309  
310 < void
310 > extern void
311   direct(                                 /* add direct component */
312 < RAY  *r,                        /* ray that hit surface */
313 < void  (*f)(),                   /* direct component coefficient function */
314 < char  *p                        /* data for f */
312 >        RAY  *r,                        /* ray that hit surface */
313 >        srcdirf_t *f,                   /* direct component coefficient function */
314 >        void  *p                        /* data for f */
315   )
316   {
317        extern void  (*trace)();
317          register int  sn;
318          register CONTRIB  *scp;
319          SRCINDEX  si;
# Line 452 | Line 451 | char  *p                       /* data for f */
451   }
452  
453  
454 < void
454 > extern void
455   srcscatter(                     /* compute source scattering into ray */
456 < register RAY  *r
456 >        register RAY  *r
457   )
458   {
459          int  oldsampndx;
# Line 544 | Line 543 | register RAY  *r
543   */
544  
545   static int
546 < weaksrcmat(int obj)             /* identify material */
546 > weaksrcmat(OBJECT obj)          /* identify material */
547   {
548 <        register OBJREC *o = objptr(obj);
548 >        OBJREC *o = findmaterial(objptr(obj));
549          
550 <        while (!ismaterial(o->otype))   /* find material */
552 <                o = objptr(o->omod);
550 >        if (o == NULL) return 0;
551          return((o->otype==MAT_ILLUM)|(o->otype==MAT_GLOW));
552   }
553  
# Line 611 | Line 609 | weaksrcmat(int obj)            /* identify material */
609                                  distglow(m, r, raydist(r,PRIMARY)))
610  
611  
612 < int
612 > extern int
613   m_light(                                /* ray hit a light source */
614 < register OBJREC  *m,
615 < register RAY  *r
614 >        register OBJREC  *m,
615 >        register RAY  *r
616   )
617   {
618                                                  /* check for over-counting */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines