--- ray/src/rt/pmapdata.h 2018/02/08 19:55:02 2.12 +++ ray/src/rt/pmapdata.h 2024/09/17 16:36:05 2.15 @@ -1,4 +1,4 @@ -/* RCSid $Id: pmapdata.h,v 2.12 2018/02/08 19:55:02 rschregle Exp $ */ +/* RCSid $Id: pmapdata.h,v 2.15 2024/09/17 16:36:05 greg Exp $ */ /* ========================================================================= @@ -20,7 +20,7 @@ supported by the Swiss National Science Foundation (SNSF, #147053) ========================================================================= - $Id: pmapdata.h,v 2.12 2018/02/08 19:55:02 rschregle Exp $ + $Id: pmapdata.h,v 2.15 2024/09/17 16:36:05 greg Exp $ */ @@ -28,37 +28,42 @@ #ifndef PMAPDATA_H #define PMAPDATA_H - #ifndef NIX - #if defined(_WIN32) || defined(_WIN64) - #define NIX 0 - #else - #define NIX 1 - #endif - #endif + #ifndef NIX + #if defined(_WIN32) || defined(_WIN64) + #define NIX 0 + #else + #define NIX 1 + #endif + #endif #if (defined(PMAP_OOC) && !NIX) #error "OOC currently only supported on NIX -- tuff luck." #endif + #ifdef PMAP_CBDM + /* Enable photon primary hitpoints and incident directions (see struct + * PhotonPrimary below). Note this will increase the size of photon + * primaries 9-fold (10-fold after alignment)!!! */ + #define PMAP_PRIMARYPOS + #define PMAP_PRIMARYDIR + #endif - #include "ray.h" + #include "ray.h" #include "pmaptype.h" #include "paths.h" #include "lookup.h" #include - - /* Primary photon ray for light source contributions */ typedef struct { int16 srcIdx; /* Index of emitting light source */ /* !!! REDUCED FROM 32 BITS !!! */ -#ifdef PMAP_PRIMARYDIR +#ifdef PMAP_PRIMARYDIR int32 dir; /* Encoded ray direction */ -#endif -#ifdef PMAP_PRIMARYPOS +#endif +#ifdef PMAP_PRIMARYPOS float pos [3]; /* Hit point */ -#endif +#endif } PhotonPrimary; #define photonSrcIdx(pm, p) ((pm)->primaries[(p)->primary].srcIdx) @@ -66,14 +71,14 @@ /* Photon primary ray index type and limit */ - typedef uint32 PhotonPrimaryIdx; + typedef uint32 PhotonPrimaryIdx; #define PMAP_MAXPRIMARY UINT32_MAX /* Macros for photon's generating subprocess field */ #ifdef PMAP_OOC #define PMAP_PROCBITS 7 -#else - #define PMAP_PROCBITS 5 +#else + #define PMAP_PROCBITS 5 #endif #define PMAP_MAXPROC (1 << PMAP_PROCBITS) #define PMAP_GETRAYPROC(r) ((r) -> crtype >> 8) @@ -105,13 +110,19 @@ }; #ifdef PMAP_FLOAT_FLUX - COLOR flux; + COLOR flux; #else - COLR flux; + COLR flux; #endif PhotonPrimaryIdx primary; /* Index to primary ray */ } Photon; + /* Define search queue and underlying data struct types */ +#ifdef PMAP_OOC + #include "pmapooc.h" +#else + #include "pmapkdt.h" +#endif /* Define PMAP_FLOAT_FLUX to store photon flux as floats instead of @@ -127,7 +138,7 @@ /* Bias compensation history node */ - typedef struct { + typedef struct { COLOR irrad; float weight; } PhotonBiasCompNode; @@ -135,14 +146,6 @@ /* Forward declaration */ struct PhotonMap; - - - /* Define search queue and underlying data struct types */ -#ifdef PMAP_OOC - #include "pmapooc.h" -#else - #include "pmapkdt.h" -#endif /* Mean size of heapfile write buffer, in number of photons */ @@ -171,7 +174,7 @@ unsigned long heapBufLen, /* Current & max size of heapBuf */ heapBufSize; PhotonStorage store; /* Photon storage in space - subdividing data struct */ + subdividing data struct */ /* ================================================================ * PHOTON DISTRIBUTION STUFF @@ -208,13 +211,13 @@ /* ================================================================ * BIAS COMPENSATION STUFF - * ================================================================ */ + * ================================================================ */ PhotonBiasCompNode *biasCompHist; /* Bias compensation history */ /* ================================================================ * STATISTIX - * ================================================================ */ + * ================================================================ */ unsigned long totalGathered, /* Total photons gathered */ numDensity, /* Num density estimates */ numLookups, /* Counters for short photon lookups */ @@ -262,8 +265,10 @@ #define isContribPmap(p) ((p) -> type == PMAP_TYPE_CONTRIB) #define isVolumePmap(p) ((p) -> type == PMAP_TYPE_VOLUME) +#ifdef __cplusplus +extern "C" { +#endif - void initPhotonMap (PhotonMap *pmap, PhotonMapType t); /* Initialise empty photon map of specified type */ @@ -310,9 +315,10 @@ are placed search queue starting with the furthest photon at pmap -> squeue.node, and pmap -> squeue.tail being the number actually found. */ - void find1Photon (PhotonMap *pmap, const RAY *ray, Photon *photon); - /* Finds single closest photon to ray -> rop with similar normal. - Returns NULL if none found. */ + Photon *find1Photon (PhotonMap *pmap, const RAY *ray, Photon *photon); + /* Find single closest photon to ray -> rop with similar normal. + Return NULL if none found, else the supplied Photon* buffer, + indicating that it contains a valid photon. */ void getPhoton (PhotonMap *pmap, PhotonIdx idx, Photon *photon); /* Retrieve photon referenced by idx from pmap -> store */ @@ -326,5 +332,9 @@ void deletePhotons (PhotonMap*); /* Free dem mammaries... */ + +#ifdef __cplusplus +} +#endif #endif