| 56 |
|
struct stat octstat, pmstat; |
| 57 |
|
PhotonMap *pm; |
| 58 |
|
PhotonMapType type; |
| 59 |
< |
|
| 59 |
> |
|
| 60 |
|
for (t = 0; t < NUM_PMAP_TYPES; t++) |
| 61 |
< |
if (setPmapParam(&pm, parm + t)) { |
| 61 |
> |
if (setPmapParam(&pm, parm + t)) { |
| 62 |
|
/* Check if photon map newer than octree */ |
| 63 |
|
if (pm -> fileName && octname && |
| 64 |
|
!stat(pm -> fileName, &pmstat) && !stat(octname, &octstat) && |
| 67 |
|
pm -> fileName); |
| 68 |
|
error(USER, errmsg); |
| 69 |
|
} |
| 70 |
< |
|
| 70 |
> |
|
| 71 |
|
/* Load photon map from file and get its type */ |
| 72 |
|
if ((type = loadPhotonMap(pm, pm -> fileName)) == PMAP_TYPE_NONE) |
| 73 |
|
error(USER, "failed loading photon map"); |
| 82 |
|
free(pmaps [type]); |
| 83 |
|
} |
| 84 |
|
pmaps [type] = pm; |
| 85 |
< |
|
| 85 |
> |
|
| 86 |
|
/* Check for valid density estimate bandwidths */ |
| 87 |
|
if ((pm -> minGather > 1 || pm -> maxGather > 1) && |
| 88 |
|
(type == PMAP_TYPE_PRECOMP)) { |
| 90 |
|
error(WARNING, "ignoring bandwidth for precomp photon map"); |
| 91 |
|
pm -> minGather = pm -> maxGather = 1; |
| 92 |
|
} |
| 93 |
< |
|
| 93 |
> |
|
| 94 |
|
if ((pm -> maxGather > pm -> minGather) && |
| 95 |
|
(type == PMAP_TYPE_VOLUME)) { |
| 96 |
|
/* Biascomp for volume pmaps (see volumePhotonDensity() below) |
| 102 |
|
pmapName [type]); |
| 103 |
|
error(USER, errmsg); |
| 104 |
|
} |
| 105 |
< |
|
| 105 |
> |
|
| 106 |
|
if (pm -> maxGather > pm -> numPhotons) { |
| 107 |
< |
error(WARNING, "adjusting density estimate bandwidth"); |
| 108 |
< |
pm -> minGather = pm -> maxGather = pm -> numPhotons; |
| 109 |
< |
} |
| 107 |
> |
/* Clamp lookup bandwidth to total number of photons (minus one, |
| 108 |
> |
since density estimate gets extra photon to obtain averaged |
| 109 |
> |
radius) */ |
| 110 |
> |
sprintf( |
| 111 |
> |
errmsg, "clamping density estimate bandwidth to %ld", |
| 112 |
> |
pm -> numPhotons |
| 113 |
> |
); |
| 114 |
> |
error(WARNING, errmsg); |
| 115 |
> |
pm -> minGather = pm -> maxGather = pm -> numPhotons - 1; |
| 116 |
> |
} |
| 117 |
|
} |
| 118 |
|
} |
| 119 |
|
|
| 127 |
|
if (pmaps [t]) { |
| 128 |
|
deletePhotons(pmaps [t]); |
| 129 |
|
free(pmaps [t]); |
| 130 |
+ |
pmaps [t] = NULL; |
| 131 |
|
} |
| 132 |
|
} |
| 133 |
|
} |
| 211 |
|
if (r -> ro && islight(objptr(r -> ro -> omod) -> otype)) |
| 212 |
|
return; |
| 213 |
|
|
| 214 |
< |
find1Photon(preCompPmap, r, &p); |
| 215 |
< |
getPhotonFlux(&p, irrad); |
| 214 |
> |
if (find1Photon(preCompPmap, r, &p)) |
| 215 |
> |
/* p contains a found photon, so get its irradiance, otherwise it |
| 216 |
> |
* remains zero under the assumption all photons are too distant |
| 217 |
> |
* to contribute significantly */ |
| 218 |
> |
getPhotonFlux(&p, irrad); |
| 219 |
|
} |
| 220 |
|
|
| 221 |
|
|