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.15 by greg, Mon Oct 21 14:27:34 1991 UTC vs.
Revision 2.18 by greg, Sat Dec 6 01:08:53 2008 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  
23   #define  SDISTANT       01              /* source distant flag */
24   #define  SSKIP          02              /* source skip flag */
# Line 16 | Line 26
26   #define  SSPOT          010             /* source spotlight flag */
27   #define  SVIRTUAL       020             /* source virtual flag */
28   #define  SFLAT          040             /* source flat flag */
29 < #define  SCYL           0100            /* source cylindrical flag */
30 < #define  SFOLLOW        0200            /* source follow path flag */
29 > #define  SCIR           0100            /* source circular flag */
30 > #define  SCYL           0200            /* source cylindrical flag */
31 > #define  SFOLLOW        0400            /* source follow path flag */
32  
33   typedef struct {
34          FVECT  aim;             /* aim direction or center */
35          float  siz;             /* output solid angle or area */
36 <        float  flen;            /* focal length */
36 >        float  flen;            /* focal length (negative if distant source) */
37   } SPOT;                 /* spotlight */
38  
39   typedef struct {
40 <        int  sflags;            /* source flags */
40 >        union {
41 >                struct {
42 >                        FVECT   u, v;           /* unit vectors */
43 >                }  f;                   /* flat source indexing */
44 >                struct {
45 >                        FVECT   o;              /* origin position */
46 >                        RREAL   e1, e2;         /* 1/extent */
47 >                        int     ax;             /* major direction */
48 >                }  d;                   /* distant source indexing */
49 >        }  p;                   /* indexing parameters */
50 >        OBJECT  obs[1];         /* cache obstructors (extends struct) */
51 > }  OBSCACHE;            /* obstructor cache */
52 >
53 > typedef struct {
54          FVECT  sloc;            /* direction or position of source */
55          FVECT  ss[3];           /* source dimension vectors, U, V, and W */
56          float  srad;            /* maximum source radius */
57          float  ss2;             /* solid angle or projected area */
58 +        OBJREC  *so;            /* source destination object */
59          struct {
60                  float  prox;            /* proximity */
61                  SPOT  *s;               /* spot */
62          } sl;                   /* localized source information */
63          union {
64 <                int  success;           /* successes - AIMREQT*failures */
64 >                long  success;          /* successes - AIMREQT*failures */
65                  struct {
66                          short  pn;              /* projection number */
67 <                        short  sn;              /* next source to aim for */
67 >                        int  sn;                /* next source to aim for */
68                  }  sv;                  /* virtual source */
69          } sa;                   /* source aiming information */
70 <        long  ntests, nhits;    /* shadow tests and hits */
71 <        OBJREC  *so;            /* source destination object */
70 >        unsigned long
71 >                ntests, nhits;  /* shadow tests and hits */
72 > #ifdef  SHADCACHE
73 >        OBSCACHE  *obscache;    /* obstructor cache */
74 > #endif
75 >        int  sflags;            /* source flags */
76   }  SRCREC;              /* light source */
77  
78   #define MAXSPART        64              /* maximum partitions per source */
# Line 56 | Line 85 | typedef struct {
85   #define snorm           ss[SW]          /* normal vector for flat source */
86  
87   typedef struct {
88 +        double  dom;                            /* solid angle of partition */
89          int  sn;                                /* source number */
90          short  np;                              /* number of partitions */
91          short  sp;                              /* this partition number */
62        double  dom;                            /* solid angle of partition */
92          unsigned char  spt[MAXSPART/2];         /* source partitioning */
93   }  SRCINDEX;            /* source index structure */
94  
95   #define initsrcindex(s) ((s)->sn = (s)->sp = -1, (s)->np = 0)
96  
97 < #define clrpart(pt)     bzero((char *)(pt), MAXSPART/2)
97 > #define clrpart(pt)     memset((char *)(pt), '\0', MAXSPART/2)
98   #define setpart(pt,i,v) ((pt)[(i)>>2] |= (v)<<(((i)&3)<<1))
99   #define spart(pt,pi)    ((pt)[(pi)>>2] >> (((pi)&3)<<1) & 3)
100  
# Line 91 | Line 120 | typedef struct {
120   } VSMATERIAL;           /* virtual source material functions */
121  
122   typedef struct {
123 <        int     (*setsrc)();    /* set light source for object */
124 <        int     (*partit)();    /* partition light source object */
123 >        void    (*setsrc)();    /* set light source for object */
124 >        void    (*partit)();    /* partition light source object */
125          double  (*getpleq)();   /* plane equation for surface */
126          double  (*getdisk)();   /* maximum disk for surface */
127   } SOBJECT;              /* source object functions */
# Line 107 | Line 136 | extern SRCFUNC  sfun[];                        /* source dispatch table */
136   extern SRCREC  *source;                 /* our source list */
137   extern int  nsources;                   /* the number of sources */
138  
110 extern int  srcvalue();                 /* compute source value w/o shadows */
111 extern double  nextssamp();             /* get next source sample location */
112 extern double  scylform();              /* cosine to axis of cylinder */
113
139   #define  sflatform(sn,dir)      -DOT(source[sn].snorm, dir)
140  
116 extern double  intercircle();           /* intersect two circles */
117 extern double  spotdisk();              /* intersecting disk for spot */
118 extern double  beamdisk();              /* intersecting disk for beam */
119
120 extern SPOT  *makespot();               /* make spotlight */
121
122 extern double  dstrsrc;                 /* source distribution amount */
123 extern double  shadthresh;              /* relative shadow threshold */
124 extern double  shadcert;                /* shadow testing certainty */
125 extern double  srcsizerat;              /* max. ratio of source size/dist. */
126 extern int  directrelay;                /* maximum number of source relays */
127 extern int  vspretest;                  /* virtual source pretest density */
128 extern int  directinvis;                /* sources invisible? */
129
141   #define  getplaneq(c,o)         (*sfun[(o)->otype].of->getpleq)(c,o)
142   #define  getmaxdisk(c,o)        (*sfun[(o)->otype].of->getdisk)(c,o)
143   #define  setsource(s,o)         (*sfun[(o)->otype].of->setsrc)(s,o)
144 +
145 +                                        /* defined in source.c */
146 + extern OBJREC   *findmaterial(OBJREC *o);
147 + extern void     marksources(void);
148 + extern void     freesources(void);
149 + extern int      srcray(RAY *sr, RAY *r, SRCINDEX *si);
150 + extern void     srcvalue(RAY *r);
151 + extern int      sourcehit(RAY *r);
152 + typedef void srcdirf_t(COLOR cv, void *np, FVECT ldir, double omega);
153 + extern void     direct(RAY *r, srcdirf_t *f, void *p);
154 + extern void     srcscatter(RAY *r);
155 + extern int      m_light(OBJREC *m, RAY *r);
156 +                                        /* defined in srcobstr.c */
157 + extern void     initobscache(int sn);
158 + extern int      srcblocker(RAY *r);
159 + extern int      srcblocked(RAY *r);
160 + extern void     freeobscache(SRCREC *s);
161 + extern void     markclip(OBJREC *m);
162 +                                        /* defined in srcsamp.c */
163 + extern double   nextssamp(RAY *r, SRCINDEX *si);
164 + extern int      skipparts(int ct[3], int sz[3], int pp[2], unsigned char *pt);
165 + extern void     nopart(SRCINDEX *si, RAY *r);
166 + extern void     cylpart(SRCINDEX *si, RAY *r);
167 + extern void     flatpart(SRCINDEX *si, RAY *r);
168 + extern double   scylform(int sn, FVECT dir);
169 +                                        /* defined in srcsupp.c */
170 + extern void     initstypes(void);
171 + extern int      newsource(void);
172 + extern void     setflatss(SRCREC *src);
173 + extern void     fsetsrc(SRCREC *src, OBJREC *so);
174 + extern void     ssetsrc(SRCREC *src, OBJREC *so);
175 + extern void     sphsetsrc(SRCREC *src, OBJREC *so);
176 + extern void     rsetsrc(SRCREC *src, OBJREC *so);
177 + extern void     cylsetsrc(SRCREC *src, OBJREC *so);
178 + extern SPOT     *makespot(OBJREC *m);
179 + extern int      spotout(RAY *r, SPOT *s);
180 + extern double   fgetmaxdisk(FVECT ocent, OBJREC *op);
181 + extern double   rgetmaxdisk(FVECT ocent, OBJREC *op);
182 + extern double   fgetplaneq(FVECT nvec, OBJREC *op);
183 + extern double   rgetplaneq(FVECT nvec, OBJREC *op);
184 + extern int      commonspot(SPOT *sp1, SPOT *sp2, FVECT org);
185 + extern int      commonbeam(SPOT *sp1, SPOT *sp2, FVECT org);
186 + extern int      checkspot(SPOT *sp, FVECT nrm);
187 + extern double   spotdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT pos);
188 + extern double   beamdisk(FVECT oc, OBJREC *op, SPOT *sp, FVECT dir);
189 + extern double   intercircle(FVECT cc, FVECT c1, FVECT c2,
190 +                        double r1s, double r2s);
191 +                                        /* defined in virtuals.c */
192 + extern void     markvirtuals(void);
193 + extern void     addvirtuals(int sn, int nr);
194 + extern void     vproject(OBJREC *o, int sn, int n);
195 + extern OBJREC   *vsmaterial(OBJREC *o);
196 + extern int      makevsrc(OBJREC *op, int sn, MAT4 pm);
197 + extern double   getdisk(FVECT oc, OBJREC *op, int sn);
198 + extern int      vstestvis(int f, OBJREC *o, FVECT oc, double or2, int sn);
199 + extern void     virtverb(int sn, FILE *fp);
200 +
201 +
202 + #ifdef __cplusplus
203 + }
204 + #endif
205 + #endif /* _RAD_SOURCE_H_ */
206 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines