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.1 by greg, Thu Feb 2 10:41:15 1989 UTC vs.
Revision 2.20 by greg, Thu Nov 8 00:54:07 2018 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  
10 + #include <string.h>
11 +
12 + #ifdef __cplusplus
13 + extern "C" {
14 + #endif
15 +
16 + #ifndef  AIMREQT
17 + #define  AIMREQT        100             /* required aim success/failure */
18 + #endif
19 + #ifndef  SHADCACHE
20 + #define  SHADCACHE      20              /* shadow cache resolution */
21 + #endif
22 + #ifndef  MINSHADCNT
23 + #define  MINSHADCNT     4               /* test all sources if this few */
24 + #endif
25 +
26   #define  SDISTANT       01              /* source distant flag */
27   #define  SSKIP          02              /* source skip flag */
28   #define  SPROX          04              /* source proximity flag */
29   #define  SSPOT          010             /* source spotlight flag */
30 + #define  SVIRTUAL       020             /* source virtual flag */
31 + #define  SFLAT          040             /* source flat flag */
32 + #define  SCIR           0100            /* source circular flag */
33 + #define  SCYL           0200            /* source cylindrical flag */
34 + #define  SFOLLOW        0400            /* source follow path flag */
35  
36   typedef struct {
37 <        float  siz;             /* output solid angle */
38 <        float  flen;            /* focal length */
39 <        FVECT  aim;             /* aim direction */
37 >        FVECT  aim;             /* aim direction or center */
38 >        float  siz;             /* output solid angle or area */
39 >        float  flen;            /* focal length (negative if distant source) */
40   } SPOT;                 /* spotlight */
41  
42   typedef struct {
23        short  sflags;          /* source flags */
24        FVECT  sloc;            /* direction or position of source */
25        float  ss;              /* tangent or disk radius */
26        float  ss2;             /* domega or projected area */
43          union {
44 +                struct {
45 +                        FVECT   u, v;           /* unit vectors */
46 +                }  f;                   /* flat source indexing */
47 +                struct {
48 +                        FVECT   o;              /* origin position */
49 +                        RREAL   e1, e2;         /* 1/extent */
50 +                        int     ax;             /* major direction */
51 +                }  d;                   /* distant source indexing */
52 +        }  p;                   /* indexing parameters */
53 +        OBJECT  obs[1];         /* cache obstructors (extends struct) */
54 + }  OBSCACHE;            /* obstructor cache */
55 +
56 + typedef struct {
57 +        FVECT  sloc;            /* direction or position of source */
58 +        FVECT  ss[3];           /* source dimension vectors, U, V, and W */
59 +        float  srad;            /* maximum source radius */
60 +        float  ss2;             /* solid angle or projected area */
61 +        OBJREC  *so;            /* source destination object */
62 +        struct {
63                  float  prox;            /* proximity */
64                  SPOT  *s;               /* spot */
65          } sl;                   /* localized source information */
66 <        OBJREC  *so;            /* source object */
67 < }  SOURCE;              /* light source */
66 >        union {
67 >                long  success;          /* successes - AIMREQT*failures */
68 >                struct {
69 >                        short  pn;              /* projection number */
70 >                        int  sn;                /* next source to aim for */
71 >                }  sv;                  /* virtual source */
72 >        } sa;                   /* source aiming information */
73 >        unsigned long
74 >                ntests, nhits;  /* shadow tests and hits */
75 > #ifdef  SHADCACHE
76 >        OBSCACHE  *obscache;    /* obstructor cache */
77 > #endif
78 >        int  sflags;            /* source flags */
79 > }  SRCREC;              /* light source */
80  
81 < #define  MAXSOURCE      512             /* maximum # of sources */
81 > #define MAXSPART        64              /* maximum partitions per source */
82  
83 < extern SOURCE  srcval[MAXSOURCE];       /* our source list */
83 > #define SU              0               /* U vector or partition */
84 > #define SV              1               /* V vector or partition */
85 > #define SW              2               /* W vector or partition */
86 > #define S0              3               /* leaf partition */
87 >
88 > #define snorm           ss[SW]          /* normal vector for flat source */
89 >
90 > typedef struct {
91 >        double  dom;                            /* solid angle of partition */
92 >        int  sn;                                /* source number */
93 >        short  np;                              /* number of partitions */
94 >        short  sp;                              /* this partition number */
95 >        unsigned char  spt[MAXSPART/2];         /* source partitioning */
96 > }  SRCINDEX;            /* source index structure */
97 >
98 > #define initsrcindex(s) ((s)->sn = (s)->sp = -1, (s)->np = 0)
99 >
100 > #define clrpart(pt)     memset((char *)(pt), '\0', MAXSPART/2)
101 > #define setpart(pt,i,v) ((pt)[(i)>>2] |= (v)<<(((i)&3)<<1))
102 > #define spart(pt,pi)    ((pt)[(pi)>>2] >> (((pi)&3)<<1) & 3)
103 >
104 > /*
105 > * Special support functions for sources
106 > */
107 >
108 > /*
109 > * Virtual source materials must define the following.
110 > *
111 > *      vproj(pm, op, sp, i)    Compute i'th virtual projection
112 > *                              of source sp in object op and assign
113 > *                              the 4x4 transformation matrix pm.
114 > *                              Return 1 on success, 0 if no i'th projection.
115 > *
116 > *      nproj                   The number of projections.  The value of
117 > *                              i passed to vproj runs from 0 to nproj-1.
118 > */
119 >
120 > typedef struct {
121 >        int  (*vproj)();        /* project virtual sources */
122 >        int  nproj;             /* number of possible projections */
123 > } VSMATERIAL;           /* virtual source material functions */
124 >
125 > typedef struct {
126 >        void    (*setsrc)();    /* set light source for object */
127 >        void    (*partit)();    /* partition light source object */
128 >        double  (*getpleq)();   /* plane equation for surface */
129 >        double  (*getdisk)();   /* maximum disk for surface */
130 > } SOBJECT;              /* source object functions */
131 >
132 > typedef union {
133 >        VSMATERIAL  *mf;        /* material functions */
134 >        SOBJECT  *of;           /* object functions */
135 > } SRCFUNC;              /* source functions */
136 >
137 > extern SRCFUNC  sfun[];                 /* source dispatch table */
138 >
139 > extern SRCREC  *source;                 /* our source list */
140   extern int  nsources;                   /* the number of sources */
141  
142 < extern double  srcray();                /* ray to source */
142 > #define  sflatform(sn,dir)      -DOT(source[sn].snorm, dir)
143  
144 < extern SPOT  *makespot();               /* make spotlight */
144 > #define  getplaneq(c,o)         (*sfun[(o)->otype].of->getpleq)(c,o)
145 > #define  getmaxdisk(c,o)        (*sfun[(o)->otype].of->getdisk)(c,o)
146 > #define  setsource(s,o)         (*sfun[(o)->otype].of->setsrc)(s,o)
147 >
148 >                                        /* defined in source.c */
149 > extern void     marksources(void);
150 > extern void     freesources(void);
151 > extern int      srcray(RAY *sr, RAY *r, SRCINDEX *si);
152 > extern void     srcvalue(RAY *r);
153 > extern int      sourcehit(RAY *r);
154 > typedef void srcdirf_t(COLOR cv, void *np, FVECT ldir, double omega);
155 > extern void     direct(RAY *r, srcdirf_t *f, void *p);
156 > extern void     srcscatter(RAY *r);
157 > extern int      m_light(OBJREC *m, RAY *r);
158 >                                        /* defined in srcobstr.c */
159 > extern void     initobscache(int sn);
160 > extern int      srcblocker(RAY *r);
161 > extern int      srcblocked(RAY *r);
162 > extern void     freeobscache(SRCREC *s);
163 > extern void     markclip(OBJREC *m);
164 >                                        /* defined in srcsamp.c */
165 > extern double   nextssamp(RAY *r, SRCINDEX *si);
166 > extern int      skipparts(int ct[3], int sz[3], int pp[2], unsigned char *pt);
167 > extern void     nopart(SRCINDEX *si, RAY *r);
168 > extern void     cylpart(SRCINDEX *si, RAY *r);
169 > extern void     flatpart(SRCINDEX *si, RAY *r);
170 > extern double   scylform(int sn, FVECT dir);
171 >                                        /* defined in srcsupp.c */
172 > extern void     initstypes(void);
173 > extern int      newsource(void);
174 > extern void     setflatss(SRCREC *src);
175 > extern void     fsetsrc(SRCREC *src, OBJREC *so);
176 > extern void     ssetsrc(SRCREC *src, OBJREC *so);
177 > extern void     sphsetsrc(SRCREC *src, OBJREC *so);
178 > extern void     rsetsrc(SRCREC *src, OBJREC *so);
179 > extern void     cylsetsrc(SRCREC *src, OBJREC *so);
180 > extern SPOT     *makespot(OBJREC *m);
181 > extern int      spotout(RAY *r, SPOT *s);
182 > extern double   fgetmaxdisk(FVECT ocent, OBJREC *op);
183 > extern double   rgetmaxdisk(FVECT ocent, OBJREC *op);
184 > extern double   fgetplaneq(FVECT nvec, OBJREC *op);
185 > extern double   rgetplaneq(FVECT nvec, OBJREC *op);
186 > extern int      commonspot(SPOT *sp1, SPOT *sp2, FVECT org);
187 > extern int      commonbeam(SPOT *sp1, SPOT *sp2, FVECT org);
188 > extern int      checkspot(SPOT *sp, FVECT nrm);
189 > extern double   spotdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT pos);
190 > extern double   beamdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT dir);
191 > extern double   intercircle(FVECT cc, FVECT c1, FVECT c2,
192 >                        double r1s, double r2s);
193 >                                        /* defined in virtuals.c */
194 > extern void     markvirtuals(void);
195 > extern void     addvirtuals(int sn, int nr);
196 > extern void     vproject(OBJREC *o, int sn, int n);
197 > extern OBJREC   *vsmaterial(OBJREC *o);
198 > extern int      makevsrc(OBJREC *op, int sn, MAT4 pm);
199 > extern double   getdisk(FVECT oc, OBJREC *op, int sn);
200 > extern int      vstestvis(int f, OBJREC *o, FVECT oc, double or2, int sn);
201 > extern void     virtverb(int sn, FILE *fp);
202 >
203 >
204 > #ifdef __cplusplus
205 > }
206 > #endif
207 > #endif /* _RAD_SOURCE_H_ */
208 >

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines