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

Comparing ray/src/rt/source.h (file contents):
Revision 1.12 by greg, Tue Jul 16 15:56:44 1991 UTC vs.
Revision 2.10 by schorsch, Mon Jun 30 14:59:13 2003 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
2 <
3 < /* SCCSid "$SunId$ LBL" */
4 <
1 > /* RCSid $Id$ */
2   /*
3   *  source.h - header file for ray tracing sources.
4   *
5 < *     8/20/85
5 > *  Include after ray.h
6   */
7 + #ifndef _RAD_SOURCE_H_
8 + #define _RAD_SOURCE_H_
9 + #ifdef __cplusplus
10 + extern "C" {
11 + #endif
12  
13 + #include <string.h>
14 +
15   #define  AIMREQT        100             /* required aim success/failure */
16  
17   #define  SDISTANT       01              /* source distant flag */
# Line 16 | Line 20
20   #define  SSPOT          010             /* source spotlight flag */
21   #define  SVIRTUAL       020             /* source virtual flag */
22   #define  SFLAT          040             /* source flat flag */
23 < #define  SFOLLOW        0100            /* source follow path flag */
23 > #define  SCYL           0100            /* source cylindrical flag */
24 > #define  SFOLLOW        0200            /* source follow path flag */
25  
26   typedef struct {
27          FVECT  aim;             /* aim direction or center */
28          float  siz;             /* output solid angle or area */
29 <        float  flen;            /* focal length */
29 >        float  flen;            /* focal length (negative if distant source) */
30   } SPOT;                 /* spotlight */
31  
32   typedef struct {
33          int  sflags;            /* source flags */
34          FVECT  sloc;            /* direction or position of source */
35 <        FVECT  snorm;           /* surface normal of flat source */
36 <        float  ss;              /* tangent or disk radius */
37 <        float  ss2;             /* domega or projected area */
35 >        FVECT  ss[3];           /* source dimension vectors, U, V, and W */
36 >        float  srad;            /* maximum source radius */
37 >        float  ss2;             /* solid angle or projected area */
38          struct {
39                  float  prox;            /* proximity */
40                  SPOT  *s;               /* spot */
41          } sl;                   /* localized source information */
42          union {
43 <                int  success;           /* successes - AIMREQT*failures */
43 >                long  success;          /* successes - AIMREQT*failures */
44                  struct {
45                          short  pn;              /* projection number */
46 <                        short  sn;              /* next source to aim for */
46 >                        int  sn;                /* next source to aim for */
47                  }  sv;                  /* virtual source */
48          } sa;                   /* source aiming information */
49 <        long  ntests, nhits;    /* shadow tests and hits */
49 >        unsigned long
50 >                ntests, nhits;  /* shadow tests and hits */
51          OBJREC  *so;            /* source destination object */
52   }  SRCREC;              /* light source */
53  
54 + #define MAXSPART        64              /* maximum partitions per source */
55 +
56 + #define SU              0               /* U vector or partition */
57 + #define SV              1               /* V vector or partition */
58 + #define SW              2               /* W vector or partition */
59 + #define S0              3               /* leaf partition */
60 +
61 + #define snorm           ss[SW]          /* normal vector for flat source */
62 +
63 + typedef struct {
64 +        int  sn;                                /* source number */
65 +        short  np;                              /* number of partitions */
66 +        short  sp;                              /* this partition number */
67 +        double  dom;                            /* solid angle of partition */
68 +        unsigned char  spt[MAXSPART/2];         /* source partitioning */
69 + }  SRCINDEX;            /* source index structure */
70 +
71 + #define initsrcindex(s) ((s)->sn = (s)->sp = -1, (s)->np = 0)
72 +
73 + #define clrpart(pt)     memset((char *)(pt), '\0', MAXSPART/2)
74 + #define setpart(pt,i,v) ((pt)[(i)>>2] |= (v)<<(((i)&3)<<1))
75 + #define spart(pt,pi)    ((pt)[(pi)>>2] >> (((pi)&3)<<1) & 3)
76 +
77   /*
78   * Special support functions for sources
79   */
# Line 67 | Line 96 | typedef struct {
96   } VSMATERIAL;           /* virtual source material functions */
97  
98   typedef struct {
99 <        int     (*setsrc)();    /* set light source for object */
99 >        void    (*setsrc)();    /* set light source for object */
100 >        void    (*partit)();    /* partition light source object */
101          double  (*getpleq)();   /* plane equation for surface */
102          double  (*getdisk)();   /* maximum disk for surface */
103   } SOBJECT;              /* source object functions */
# Line 82 | Line 112 | extern SRCFUNC  sfun[];                        /* source dispatch table */
112   extern SRCREC  *source;                 /* our source list */
113   extern int  nsources;                   /* the number of sources */
114  
115 < extern double  srcray();                /* ray to source */
86 < extern int  srcvalue();                 /* compute source value w/o shadows */
115 > #define  sflatform(sn,dir)      -DOT(source[sn].snorm, dir)
116  
88 extern double  intercircle();           /* intersect two circles */
89 extern double  spotdisk();              /* intersecting disk for spot */
90 extern double  beamdisk();              /* intersecting disk for beam */
91
92 extern SPOT  *makespot();               /* make spotlight */
93
94 extern double  dstrsrc;                 /* source distribution amount */
95 extern double  shadthresh;              /* relative shadow threshold */
96 extern double  shadcert;                /* shadow testing certainty */
97 extern int  directrelay;                /* maximum number of source relays */
98 extern int  vspretest;                  /* virtual source pretest density */
99
117   #define  getplaneq(c,o)         (*sfun[(o)->otype].of->getpleq)(c,o)
118   #define  getmaxdisk(c,o)        (*sfun[(o)->otype].of->getdisk)(c,o)
119   #define  setsource(s,o)         (*sfun[(o)->otype].of->setsrc)(s,o)
120 +
121 +                                        /* defined in source.c */
122 + extern void     marksources(void);
123 + extern void     freesources(void);
124 + extern int      srcray(RAY *sr, RAY *r, SRCINDEX *si);
125 + extern void     srcvalue(RAY *r);
126 + extern int      sourcehit(RAY *r);
127 + extern void     direct(RAY *r, void (*f)(), char *p);
128 + extern void     srcscatter(RAY *r);
129 + extern int      m_light(OBJREC *m, RAY *r);
130 +                                        /* defined in srcsamp.c */
131 + extern double   nextssamp(RAY *r, SRCINDEX *si);
132 + extern int      skipparts(int ct[3], int sz[3], int pp[2], unsigned char *pt);
133 + extern void     nopart(SRCINDEX *si, RAY *r);
134 + extern void     cylpart(SRCINDEX *si, RAY *r);
135 + extern void     flatpart(SRCINDEX *si, RAY *r);
136 + extern double   scylform(int sn, FVECT dir);
137 +                                        /* defined in srcsupp.c */
138 + extern void     initstypes(void);
139 + extern int      newsource(void);
140 + extern void     setflatss(SRCREC *src);
141 + extern void     fsetsrc(SRCREC *src, OBJREC *so);
142 + extern void     ssetsrc(SRCREC *src, OBJREC *so);
143 + extern void     sphsetsrc(SRCREC *src, OBJREC *so);
144 + extern void     rsetsrc(SRCREC *src, OBJREC *so);
145 + extern void     cylsetsrc(SRCREC *src, OBJREC *so);
146 + extern SPOT     *makespot(OBJREC *m);
147 + extern int      spotout(RAY *r, SPOT *s);
148 + extern double   fgetmaxdisk(FVECT ocent, OBJREC *op);
149 + extern double   rgetmaxdisk(FVECT ocent, OBJREC *op);
150 + extern double   fgetplaneq(FVECT nvec, OBJREC *op);
151 + extern double   rgetplaneq(FVECT nvec, OBJREC *op);
152 + extern int      commonspot(SPOT *sp1, SPOT *sp2, FVECT org);
153 + extern int      commonbeam(SPOT *sp1, SPOT *sp2, FVECT org);
154 + extern int      checkspot(SPOT *sp, FVECT nrm);
155 + extern double   spotdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT pos);
156 + extern double   beamdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT dir);
157 + extern double   intercircle(FVECT cc, FVECT c1, FVECT c2,
158 +                        double r1s, double r2s);
159 +                                        /* defined in virtuals.c */
160 + extern void     markvirtuals(void);
161 + extern void     addvirtuals(int sn, int nr);
162 + extern void     vproject(OBJREC *o, int sn, int n);
163 + extern OBJREC   *vsmaterial(OBJREC *o);
164 + extern int      makevsrc(OBJREC *op, int sn, MAT4 pm);
165 + extern double   getdisk(FVECT oc, OBJREC *op, int sn);
166 + extern int      vstestvis(int f, OBJREC *o, FVECT oc, double or2, int sn);
167 + extern void     virtverb(int sn, FILE *fp);
168 +
169 +
170 + #ifdef __cplusplus
171 + }
172 + #endif
173 + #endif /* _RAD_SOURCE_H_ */
174 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines