28 |
|
#ifndef PMAPDATA_H |
29 |
|
#define PMAPDATA_H |
30 |
|
|
31 |
< |
#ifndef NIX |
32 |
< |
#if defined(_WIN32) || defined(_WIN64) |
33 |
< |
#define NIX 0 |
34 |
< |
#else |
35 |
< |
#define NIX 1 |
36 |
< |
#endif |
37 |
< |
#endif |
31 |
> |
#ifndef NIX |
32 |
> |
#if defined(_WIN32) || defined(_WIN64) |
33 |
> |
#define NIX 0 |
34 |
> |
#else |
35 |
> |
#define NIX 1 |
36 |
> |
#endif |
37 |
> |
#endif |
38 |
|
|
39 |
|
#if (defined(PMAP_OOC) && !NIX) |
40 |
|
#error "OOC currently only supported on NIX -- tuff luck." |
41 |
|
#endif |
42 |
|
|
43 |
+ |
#ifdef PMAP_CBDM |
44 |
+ |
/* Enable photon primary hitpoints and incident directions (see struct |
45 |
+ |
* PhotonPrimary below). Note this will increase the size of photon |
46 |
+ |
* primaries 9-fold (10-fold after alignment)!!! */ |
47 |
+ |
#define PMAP_PRIMARYPOS |
48 |
+ |
#define PMAP_PRIMARYDIR |
49 |
+ |
#endif |
50 |
|
|
51 |
< |
#include "ray.h" |
51 |
> |
#include "ray.h" |
52 |
|
#include "pmaptype.h" |
53 |
|
#include "paths.h" |
54 |
|
#include "lookup.h" |
55 |
|
#include <stdint.h> |
56 |
|
|
50 |
– |
|
51 |
– |
|
57 |
|
/* Primary photon ray for light source contributions */ |
58 |
|
typedef struct { |
59 |
|
int16 srcIdx; /* Index of emitting light source */ |
60 |
|
/* !!! REDUCED FROM 32 BITS !!! */ |
61 |
+ |
#ifdef PMAP_PRIMARYDIR |
62 |
|
int32 dir; /* Encoded ray direction */ |
63 |
< |
#ifdef PMAP_PRIMARYPOS |
63 |
> |
#endif |
64 |
> |
#ifdef PMAP_PRIMARYPOS |
65 |
|
float pos [3]; /* Hit point */ |
66 |
< |
#endif |
66 |
> |
#endif |
67 |
|
} PhotonPrimary; |
68 |
|
|
69 |
|
#define photonSrcIdx(pm, p) ((pm)->primaries[(p)->primary].srcIdx) |
71 |
|
|
72 |
|
|
73 |
|
/* Photon primary ray index type and limit */ |
74 |
< |
typedef uint32 PhotonPrimaryIdx; |
74 |
> |
typedef uint32 PhotonPrimaryIdx; |
75 |
|
#define PMAP_MAXPRIMARY UINT32_MAX |
76 |
|
|
77 |
|
/* Macros for photon's generating subprocess field */ |
78 |
|
#ifdef PMAP_OOC |
79 |
|
#define PMAP_PROCBITS 7 |
80 |
< |
#else |
81 |
< |
#define PMAP_PROCBITS 5 |
80 |
> |
#else |
81 |
> |
#define PMAP_PROCBITS 5 |
82 |
|
#endif |
83 |
|
#define PMAP_MAXPROC (1 << PMAP_PROCBITS) |
84 |
|
#define PMAP_GETRAYPROC(r) ((r) -> crtype >> 8) |
110 |
|
}; |
111 |
|
|
112 |
|
#ifdef PMAP_FLOAT_FLUX |
113 |
< |
COLOR flux; |
113 |
> |
COLOR flux; |
114 |
|
#else |
115 |
< |
COLR flux; |
115 |
> |
COLR flux; |
116 |
|
#endif |
117 |
|
PhotonPrimaryIdx primary; /* Index to primary ray */ |
118 |
|
} Photon; |
119 |
|
|
120 |
+ |
/* Define search queue and underlying data struct types */ |
121 |
+ |
#ifdef PMAP_OOC |
122 |
+ |
#include "pmapooc.h" |
123 |
+ |
#else |
124 |
+ |
#include "pmapkdt.h" |
125 |
+ |
#endif |
126 |
|
|
127 |
|
|
128 |
|
/* Define PMAP_FLOAT_FLUX to store photon flux as floats instead of |
138 |
|
|
139 |
|
|
140 |
|
/* Bias compensation history node */ |
141 |
< |
typedef struct { |
141 |
> |
typedef struct { |
142 |
|
COLOR irrad; |
143 |
|
float weight; |
144 |
|
} PhotonBiasCompNode; |
146 |
|
|
147 |
|
/* Forward declaration */ |
148 |
|
struct PhotonMap; |
136 |
– |
|
137 |
– |
|
138 |
– |
/* Define search queue and underlying data struct types */ |
139 |
– |
#ifdef PMAP_OOC |
140 |
– |
#include "pmapooc.h" |
141 |
– |
#else |
142 |
– |
#include "pmapkdt.h" |
143 |
– |
#endif |
149 |
|
|
150 |
|
|
151 |
|
/* Mean size of heapfile write buffer, in number of photons */ |
174 |
|
unsigned long heapBufLen, /* Current & max size of heapBuf */ |
175 |
|
heapBufSize; |
176 |
|
PhotonStorage store; /* Photon storage in space |
177 |
< |
subdividing data struct */ |
177 |
> |
subdividing data struct */ |
178 |
|
|
179 |
|
/* ================================================================ |
180 |
|
* PHOTON DISTRIBUTION STUFF |
211 |
|
|
212 |
|
/* ================================================================ |
213 |
|
* BIAS COMPENSATION STUFF |
214 |
< |
* ================================================================ */ |
214 |
> |
* ================================================================ */ |
215 |
|
PhotonBiasCompNode *biasCompHist; /* Bias compensation history */ |
216 |
|
|
217 |
|
|
218 |
|
/* ================================================================ |
219 |
|
* STATISTIX |
220 |
< |
* ================================================================ */ |
220 |
> |
* ================================================================ */ |
221 |
|
unsigned long totalGathered, /* Total photons gathered */ |
222 |
|
numDensity, /* Num density estimates */ |
223 |
|
numLookups, /* Counters for short photon lookups */ |
265 |
|
#define isContribPmap(p) ((p) -> type == PMAP_TYPE_CONTRIB) |
266 |
|
#define isVolumePmap(p) ((p) -> type == PMAP_TYPE_VOLUME) |
267 |
|
|
268 |
+ |
#ifdef __cplusplus |
269 |
+ |
extern "C" { |
270 |
+ |
#endif |
271 |
|
|
264 |
– |
|
272 |
|
void initPhotonMap (PhotonMap *pmap, PhotonMapType t); |
273 |
|
/* Initialise empty photon map of specified type */ |
274 |
|
|
315 |
|
are placed search queue starting with the furthest photon at pmap -> |
316 |
|
squeue.node, and pmap -> squeue.tail being the number actually found. */ |
317 |
|
|
318 |
< |
void find1Photon (PhotonMap *pmap, const RAY *ray, Photon *photon); |
319 |
< |
/* Finds single closest photon to ray -> rop with similar normal. |
320 |
< |
Returns NULL if none found. */ |
318 |
> |
Photon *find1Photon (PhotonMap *pmap, const RAY *ray, Photon *photon); |
319 |
> |
/* Find single closest photon to ray -> rop with similar normal. |
320 |
> |
Return NULL if none found, else the supplied Photon* buffer, |
321 |
> |
indicating that it contains a valid photon. */ |
322 |
|
|
323 |
|
void getPhoton (PhotonMap *pmap, PhotonIdx idx, Photon *photon); |
324 |
|
/* Retrieve photon referenced by idx from pmap -> store */ |
332 |
|
|
333 |
|
void deletePhotons (PhotonMap*); |
334 |
|
/* Free dem mammaries... */ |
335 |
+ |
|
336 |
+ |
#ifdef __cplusplus |
337 |
+ |
} |
338 |
+ |
#endif |
339 |
|
|
340 |
|
#endif |