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.5 by rschregle, Fri May 8 13:20:23 2015 UTC vs.
Revision 2.9 by greg, Tue Aug 18 18:45:55 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 101 | Line 104 | void savePmaps (const PhotonMap **pmaps, int argc, cha
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  
# Line 324 | Line 327 | void distribPhotons (PhotonMap **pmaps)
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        
# Line 342 | Line 345 | void distribPhotons (PhotonMap **pmaps)
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();
# Line 434 | Line 437 | void distribPhotons (PhotonMap **pmaps)
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                 }
# Line 447 | Line 450 | void distribPhotons (PhotonMap **pmaps)
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        }
# Line 469 | Line 472 | void distribPhotons (PhotonMap **pmaps)
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  
# Line 494 | Line 497 | void distribPhotons (PhotonMap **pmaps)
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)
# Line 509 | Line 512 | void distribPhotons (PhotonMap **pmaps)
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;
# Line 581 | Line 584 | void distribPhotons (PhotonMap **pmaps)
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) */
# Line 609 | Line 612 | void distribPhotons (PhotonMap **pmaps)
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 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines