/* ====================================================================== Photon map filter callbacks for nearest neighbour search Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) (c) Lucerne University of Applied Sciences and Arts, supported by the Swiss National Science Foundation (SNSF #147053, "Daylight Redirecting Components", SNSF #179067, "Light Fields for Spatio-Temporal Glare Assessment") (c) Tokyo University of Science, supported by the JSPS Grants-in-Aid for Scientific Research (KAKENHI JP19KK0115, "Three-Dimensional Light Flow") ====================================================================== $Id$ */ #ifndef PMAP_FILT_H #define PMAP_FILT_H #include "standard.h" #include "lookup.h" #include "object.h" /* Tolerance for photon normal check during lookups */ #define PMAP_NORM_TOL 0.02 /* Forward declarations */ struct PhotonMap; /* Generic callback function container with context/state data to filter photons during k-NN search */ typedef struct { int (*filtFunc)(const void *rec, const void *state); void *state; } PhotonSearchFilterCallback; /* State data for PhotonSearchFilterCallback, used by filterPhoton() */ typedef struct { const struct PhotonMap *pmap; const float *norm; const OBJREC *srcMod; /* Emitting light source modifier for contrib photons, else NULL */ } PhotonSearchFilterState; #ifdef PMAP_OOC /* Interface to out-of-core photon map routines */ typedef PhotonSearchFilterCallback OOC_SearchFilterCallback; typedef PhotonSearchFilterState OOC_SearchFilterState; #else /* Interface to in-core kd-tree photon map routines */ typedef PhotonSearchFilterCallback kdT_SearchFilterCallback; typedef PhotonSearchFilterState kdT_SearchFilterState; #endif int filterPhoton (const void *rec, const void *state); /* Filter callback for photon kNN search */ #ifdef PMAP_PHOTONFLOW /* Generic callback function container with context/state data to maintain table of photon attributes and exclude possible duplicates during k-NN search */ typedef struct { void **(*findFunc)(const void *rec, const void *state); void (*addFunc)(const void *rec, void *data, void *state); void (*delFunc)(const void *rec, void *state); int (*checkFunc)(const void *state); void *state; } PhotonSearchAttribCallback; #ifdef PMAP_OOC /* Interface to out-of-core photon map routines */ typedef PhotonSearchAttribCallback OOC_SearchAttribCallback; #else /* Interface to in-core kd-tree photon map routines */ typedef PhotonSearchAttribCallback kdT_SearchAttribCallback; #endif void initPhotonPaths (void *state); /* Lazily allocate and initialise photon path ID lookup table and * associate key buffer */ int checkPhotonPaths (const void *state); /* Run sanity check on photon path ID lookup table */ void **findPhotonPath (const void *rec, const void *state); /* Photon path callback for k-NN search to map photon path IDs to * search queue nodes via a lookup table. State points to the * associated photon map containing the path lookup table. Returns * modifiable pointer to data field of found LUT entry, which in turn * points to the search queue node for the corresponding record. If * no entry exists for the path ID, NULL is returned. */ void addPhotonPath (const void *rec, void *data, void *state); /* Photon path callback for k-NN search to add photon path IDs to lookup table entries. State points to the associated photon map containing the path lookup table. The new lookup table entry is initialised with the specified data pointer */ void deletePhotonPath (const void *rec, void *state); /* Photon path callback for k-NN search to delete photon path IDs from lookup table. State points to the associated photon map containing the path ID lookup table. */ int clearPhotonPath (const LUENT *lutEntry, void *lut); /* Clear entry in photon path ID lookup table */ void resetPhotonPaths (void *state); /* Reset (clear) all entries in photon path ID lookup table */ #else #ifdef PMAP_OOC typedef void OOC_SearchAttribCallback; #else typedef void kdT_SearchAttribCallback; #endif #endif /* PMAP_PHOTONFLOW */ #endif