ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmap.c
(Generate patch)

Comparing ray/src/rt/pmap.c (file contents):
Revision 2.7 by greg, Fri May 22 14:09:01 2015 UTC vs.
Revision 2.10 by greg, Tue Sep 1 16:27:52 2015 UTC

# Line 1 | Line 1
1 + #ifndef lint
2 + static const char RCSid[] = "$Id$";
3 + #endif
4   /*
5     ==================================================================
6     Photon map main module
# Line 8 | Line 11
11     supported by the Swiss National Science Foundation (SNSF, #147053)
12     ==================================================================
13    
11   $Id$
14   */
15  
16  
# Line 324 | Line 326 | void distribPhotons (PhotonMap **pmaps)
326     double totalFlux = 0;
327     PhotonMap *pm;
328    
329 <   for (t = 0; t < NUM_PMAP_TYPES && !photonMaps [t]; t++);
329 >   for (t = 0; t < NUM_PMAP_TYPES && !pmaps [t]; t++);
330     if (t >= NUM_PMAP_TYPES)
331        error(USER, "no photon maps defined");
332        
# Line 342 | Line 344 | void distribPhotons (PhotonMap **pmaps)
344        
345     /* Initialise all defined photon maps */
346     for (t = 0; t < NUM_PMAP_TYPES; t++)
347 <      initPhotonMap(photonMaps [t], t);
347 >      initPhotonMap(pmaps [t], t);
348  
349     initPhotonEmissionFuncs();
350     initPhotonScatterFuncs();
# Line 434 | Line 436 | void distribPhotons (PhotonMap **pmaps)
436              sprintf(errmsg, "too many prepasses");
437  
438              for (t = 0; t < NUM_PMAP_TYPES; t++)
439 <               if (photonMaps [t] && !photonMaps [t] -> heapEnd) {
439 >               if (pmaps [t] && !pmaps [t] -> heapEnd) {
440                    sprintf(errmsg2, ", no %s photons stored", pmapName [t]);
441                    strcat(errmsg, errmsg2);
442                 }
# Line 447 | Line 449 | void distribPhotons (PhotonMap **pmaps)
449           numEmit = FHUGE;
450          
451           for (t = 0; t < NUM_PMAP_TYPES; t++)
452 <            if (photonMaps [t])
453 <               numEmit = min(photonMaps [t] -> distribTarget, numEmit);
452 >            if (pmaps [t])
453 >               numEmit = min(pmaps [t] -> distribTarget, numEmit);
454                
455           numEmit *= preDistrib;
456        }
# Line 469 | Line 471 | void distribPhotons (PhotonMap **pmaps)
471            * Since this biases the photon density, addPhoton() promotes the
472            * flux of stored photons to compensate. */
473           for (t = 0; t < NUM_PMAP_TYPES; t++)
474 <            if ((pm = photonMaps [t])) {
474 >            if ((pm = pmaps [t])) {
475                 pm -> distribRatio = (double)pm -> distribTarget /
476                                      pm -> heapEnd - 1;
477  
# Line 494 | Line 496 | void distribPhotons (PhotonMap **pmaps)
496           /* Normalise distribution ratios and calculate number of photons to
497            * emit in main pass */
498           for (t = 0; t < NUM_PMAP_TYPES; t++)
499 <            if ((pm = photonMaps [t]))
499 >            if ((pm = pmaps [t]))
500                 pm -> distribRatio /= maxDistribRatio;
501                
502           if ((numEmit = repProgress * maxDistribRatio) < FTINY)
# Line 581 | Line 583 | void distribPhotons (PhotonMap **pmaps)
583        }
584        
585        for (t = 0; t < NUM_PMAP_TYPES; t++)
586 <         if (photonMaps [t] && !photonMaps [t] -> heapEnd) {
586 >         if (pmaps [t] && !pmaps [t] -> heapEnd) {
587              /* Double preDistrib in case a photon map is empty and redo
588               * pass 1 --> possibility of infinite loop for pathological
589               * scenes (e.g. absorbing materials) */
# Line 609 | Line 611 | void distribPhotons (PhotonMap **pmaps)
611     totalFlux /= repProgress;
612    
613     for (t = 0; t < NUM_PMAP_TYPES; t++)
614 <      if (photonMaps [t]) {
614 >      if (pmaps [t]) {
615           if (photonRepTime) {
616              sprintf(errmsg, "\nBuilding %s photon map...\n", pmapName [t]);
617              eputs(errmsg);
618              fflush(stderr);
619           }
620        
621 <         balancePhotons(photonMaps [t], &totalFlux);
621 >         balancePhotons(pmaps [t], &totalFlux);
622        }
623        
624     /* Precompute photon irradiance if necessary */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines