| 76 |
|
int main (int argc, char** argv) |
| 77 |
|
{ |
| 78 |
|
char format [128]; |
| 79 |
< |
RREAL rad, radScale = RADSCALE, vol, dumpRatio; |
| 80 |
< |
unsigned arg, j, ptype; |
| 79 |
> |
RREAL rad, radScale = RADSCALE, extent, dumpRatio; |
| 80 |
> |
unsigned arg, j, ptype, dim; |
| 81 |
|
long numSpheres = NSPHERES; |
| 82 |
|
FILE *pmapFile; |
| 83 |
|
PhotonMap pm; |
| 172 |
|
for (j = 0; j < 4; j++) |
| 173 |
|
getflt(pmapFile); |
| 174 |
|
|
| 175 |
< |
/* Sphere radius based on avg intersphere dist |
| 176 |
< |
(= sphere distrib density ^-1/3) */ |
| 177 |
< |
vol = (pm.maxPos [0] - pm.minPos [0]) * (pm.maxPos [1] - pm.minPos [1]) * |
| 178 |
< |
(pm.maxPos [2] - pm.minPos [2]); |
| 179 |
< |
rad = radScale * RADCOEFF * pow(vol / numSpheres, 1./3.); |
| 175 |
> |
/* Sphere radius based on avg intersphere dist depending on |
| 176 |
> |
whether the distribution occupies a 1D line (!), a 2D plane, |
| 177 |
> |
or 3D volume (= sphere distrib density ^-1/d, where d is the |
| 178 |
> |
dimensionality of the distribution) */ |
| 179 |
> |
for (j = 0, extent = 1.0, dim = 0; j < 3; j++) { |
| 180 |
> |
rad = pm.maxPos [j] - pm.minPos [j]; |
| 181 |
> |
|
| 182 |
> |
if (rad > FTINY) { |
| 183 |
> |
dim++; |
| 184 |
> |
extent *= rad; |
| 185 |
> |
} |
| 186 |
> |
} |
| 187 |
> |
|
| 188 |
> |
rad = radScale * RADCOEFF * pow(extent / numSpheres, 1./dim); |
| 189 |
|
|
| 190 |
|
/* Photon dump probability to satisfy target sphere count */ |
| 191 |
|
dumpRatio = numSpheres < pm.numPhotons |
| 194 |
|
/* Skip primary rays */ |
| 195 |
|
pm.numPrimary = getint(sizeof(pm.numPrimary), pmapFile); |
| 196 |
|
while (pm.numPrimary-- > 0) { |
| 197 |
< |
getint(sizeof(pri.srcIdx) + sizeof(pri.dir), pmapFile); |
| 197 |
> |
/* Skip source index & incident dir */ |
| 198 |
> |
getint(sizeof(pri.srcIdx), pmapFile); |
| 199 |
> |
#ifdef PMAP_PRIMARYDIR |
| 200 |
> |
/* Skip primary incident dir */ |
| 201 |
> |
getint(sizeof(pri.dir), pmapFile); |
| 202 |
> |
#endif |
| 203 |
> |
#ifdef PMAP_PRIMARYPOS |
| 204 |
> |
/* Skip primary hitpoint */ |
| 205 |
|
for (j = 0; j < 3; j++) |
| 206 |
|
getflt(pmapFile); |
| 207 |
+ |
#endif |
| 208 |
|
} |
| 209 |
|
|
| 210 |
|
#ifdef PMAP_OOC |