1 |
+ |
#ifndef lint |
2 |
+ |
static const char RCSid[] = "$Id$"; |
3 |
+ |
#endif |
4 |
|
/* |
5 |
|
================================================================== |
6 |
|
Photon map main module |
104 |
|
|
105 |
|
for (t = 0; t < NUM_PMAP_TYPES; t++) { |
106 |
|
if (pmaps [t]) |
107 |
< |
savePhotonMap(pmaps [t], pmaps [t] -> fileName, t, argc, argv); |
107 |
> |
savePhotonMap(pmaps [t], pmaps [t] -> fileName, argc, argv); |
108 |
|
} |
109 |
|
} |
110 |
|
|
327 |
|
double totalFlux = 0; |
328 |
|
PhotonMap *pm; |
329 |
|
|
330 |
< |
for (t = 0; t < NUM_PMAP_TYPES && !photonMaps [t]; t++); |
330 |
> |
for (t = 0; t < NUM_PMAP_TYPES && !pmaps [t]; t++); |
331 |
|
if (t >= NUM_PMAP_TYPES) |
332 |
|
error(USER, "no photon maps defined"); |
333 |
|
|
345 |
|
|
346 |
|
/* Initialise all defined photon maps */ |
347 |
|
for (t = 0; t < NUM_PMAP_TYPES; t++) |
348 |
< |
initPhotonMap(photonMaps [t], t); |
348 |
> |
initPhotonMap(pmaps [t], t); |
349 |
|
|
350 |
|
initPhotonEmissionFuncs(); |
351 |
|
initPhotonScatterFuncs(); |
437 |
|
sprintf(errmsg, "too many prepasses"); |
438 |
|
|
439 |
|
for (t = 0; t < NUM_PMAP_TYPES; t++) |
440 |
< |
if (photonMaps [t] && !photonMaps [t] -> heapEnd) { |
440 |
> |
if (pmaps [t] && !pmaps [t] -> heapEnd) { |
441 |
|
sprintf(errmsg2, ", no %s photons stored", pmapName [t]); |
442 |
|
strcat(errmsg, errmsg2); |
443 |
|
} |
450 |
|
numEmit = FHUGE; |
451 |
|
|
452 |
|
for (t = 0; t < NUM_PMAP_TYPES; t++) |
453 |
< |
if (photonMaps [t]) |
454 |
< |
numEmit = min(photonMaps [t] -> distribTarget, numEmit); |
453 |
> |
if (pmaps [t]) |
454 |
> |
numEmit = min(pmaps [t] -> distribTarget, numEmit); |
455 |
|
|
456 |
|
numEmit *= preDistrib; |
457 |
|
} |
472 |
|
* Since this biases the photon density, addPhoton() promotes the |
473 |
|
* flux of stored photons to compensate. */ |
474 |
|
for (t = 0; t < NUM_PMAP_TYPES; t++) |
475 |
< |
if ((pm = photonMaps [t])) { |
475 |
> |
if ((pm = pmaps [t])) { |
476 |
|
pm -> distribRatio = (double)pm -> distribTarget / |
477 |
|
pm -> heapEnd - 1; |
478 |
|
|
497 |
|
/* Normalise distribution ratios and calculate number of photons to |
498 |
|
* emit in main pass */ |
499 |
|
for (t = 0; t < NUM_PMAP_TYPES; t++) |
500 |
< |
if ((pm = photonMaps [t])) |
500 |
> |
if ((pm = pmaps [t])) |
501 |
|
pm -> distribRatio /= maxDistribRatio; |
502 |
|
|
503 |
|
if ((numEmit = repProgress * maxDistribRatio) < FTINY) |
512 |
|
for (srcIdx = 0; srcIdx < nsources; srcIdx++) { |
513 |
|
unsigned portCnt = 0; |
514 |
|
emap.src = source + srcIdx; |
515 |
< |
|
515 |
> |
|
516 |
|
do { |
517 |
|
emap.port = emap.src -> sflags & SDISTANT ? photonPorts + portCnt |
518 |
|
: NULL; |
584 |
|
} |
585 |
|
|
586 |
|
for (t = 0; t < NUM_PMAP_TYPES; t++) |
587 |
< |
if (photonMaps [t] && !photonMaps [t] -> heapEnd) { |
587 |
> |
if (pmaps [t] && !pmaps [t] -> heapEnd) { |
588 |
|
/* Double preDistrib in case a photon map is empty and redo |
589 |
|
* pass 1 --> possibility of infinite loop for pathological |
590 |
|
* scenes (e.g. absorbing materials) */ |
612 |
|
totalFlux /= repProgress; |
613 |
|
|
614 |
|
for (t = 0; t < NUM_PMAP_TYPES; t++) |
615 |
< |
if (photonMaps [t]) { |
615 |
> |
if (pmaps [t]) { |
616 |
|
if (photonRepTime) { |
617 |
|
sprintf(errmsg, "\nBuilding %s photon map...\n", pmapName [t]); |
618 |
|
eputs(errmsg); |
619 |
|
fflush(stderr); |
620 |
|
} |
621 |
|
|
622 |
< |
balancePhotons(photonMaps [t], &totalFlux); |
622 |
> |
balancePhotons(pmaps [t], &totalFlux); |
623 |
|
} |
624 |
|
|
625 |
|
/* Precompute photon irradiance if necessary */ |