| 1 |
|
/* |
| 2 |
< |
================================================================== |
| 2 |
> |
====================================================================== |
| 3 |
|
Photon map interface to out-of-core octree |
| 4 |
|
|
| 5 |
|
Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) |
| 6 |
|
(c) Lucerne University of Applied Sciences and Arts, |
| 7 |
< |
supported by the Swiss National Science Foundation (SNSF, #147053) |
| 8 |
< |
================================================================== |
| 7 |
> |
supported by the Swiss National Science Foundation (SNSF, #147053) |
| 8 |
> |
====================================================================== |
| 9 |
|
|
| 10 |
|
$Id$ |
| 11 |
|
*/ |
| 12 |
|
|
| 13 |
|
|
| 14 |
< |
#ifndef PMAP_OOC |
| 15 |
< |
/* Checked in pmapdata.h */ |
| 16 |
< |
#define PMAP_OOC |
| 17 |
< |
#endif |
| 14 |
> |
|
| 15 |
|
#include "pmapdata.h" /* Includes pmapooc.h */ |
| 16 |
|
#include "source.h" |
| 17 |
|
#include "oocsort.h" |
| 214 |
|
DOT(filtData->norm, photon->norm) <= PMAP_NORM_TOL * 127 * frandom()) |
| 215 |
|
return 0; |
| 216 |
|
|
| 217 |
< |
if (isContribPmap(pmap) && pmap -> srcContrib) { |
| 218 |
< |
/* Lookup in contribution photon map */ |
| 219 |
< |
OBJREC *srcMod; |
| 220 |
< |
const int srcIdx = photonSrcIdx(pmap, photon); |
| 217 |
> |
if (isContribPmap(pmap)) { |
| 218 |
> |
/* Lookup in contribution photon map; filter according to emitting |
| 219 |
> |
* light source if contrib list set, else accept all */ |
| 220 |
> |
|
| 221 |
> |
if (pmap -> srcContrib) { |
| 222 |
> |
OBJREC *srcMod; |
| 223 |
> |
const int srcIdx = photonSrcIdx(pmap, photon); |
| 224 |
|
|
| 225 |
< |
if (srcIdx < 0 || srcIdx >= nsources) |
| 226 |
< |
error(INTERNAL, "invalid light source index in photon map"); |
| 225 |
> |
if (srcIdx < 0 || srcIdx >= nsources) |
| 226 |
> |
error(INTERNAL, "invalid light source index in photon map"); |
| 227 |
|
|
| 228 |
< |
srcMod = findmaterial(source [srcIdx].so); |
| 228 |
> |
srcMod = findmaterial(source [srcIdx].so); |
| 229 |
|
|
| 230 |
< |
/* Reject photon if contributions from light source which emitted it |
| 231 |
< |
* are not sought */ |
| 232 |
< |
if (!lu_find(pmap -> srcContrib, srcMod -> oname) -> data) |
| 233 |
< |
return 0; |
| 230 |
> |
/* Reject photon if contributions from light source which emitted |
| 231 |
> |
* it are not sought */ |
| 232 |
> |
if (!lu_find(pmap -> srcContrib, srcMod -> oname) -> data) |
| 233 |
> |
return 0; |
| 234 |
> |
} |
| 235 |
|
|
| 236 |
|
/* Reject non-caustic photon if lookup for caustic contribs */ |
| 237 |
|
if (pmap -> lookupCaustic && !photon -> caustic) |
| 256 |
|
|
| 257 |
|
/* Set up filter callback */ |
| 258 |
|
filtData.pmap = pmap; |
| 259 |
< |
VCOPY(n, norm); |
| 260 |
< |
filtData.norm = n; |
| 259 |
> |
if (norm) |
| 260 |
> |
VCOPY(n, norm); |
| 261 |
> |
filtData.norm = norm ? n : NULL; |
| 262 |
|
filt.data = &filtData; |
| 263 |
|
filt.func = OOC_FilterPhoton; |
| 264 |
|
|
| 287 |
|
|
| 288 |
|
/* Set up filter callback */ |
| 289 |
|
filtData.pmap = pmap; |
| 290 |
< |
VCOPY(n, norm); |
| 291 |
< |
filtData.norm = n; |
| 290 |
> |
if (norm) |
| 291 |
> |
VCOPY(n, norm); |
| 292 |
> |
filtData.norm = norm ? n : NULL; |
| 293 |
|
filt.data = &filtData; |
| 294 |
|
filt.func = OOC_FilterPhoton; |
| 295 |
|
|