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

Comparing ray/src/rt/pmapdump.c (file contents):
Revision 2.7 by rschregle, Tue May 17 17:39:47 2016 UTC vs.
Revision 2.9 by rschregle, Sat Dec 9 18:40:43 2017 UTC

# Line 76 | Line 76 | const RadianceDef radDefs [] = {
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;
# Line 172 | Line 172 | int main (int argc, char** argv)
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
# Line 185 | Line 194 | int main (int argc, char** argv)
194        /* Skip primary rays */
195        pm.numPrimary = getint(sizeof(pm.numPrimary), pmapFile);
196        while (pm.numPrimary-- > 0) {
197 +         /* Skip source index & incident dir */
198           getint(sizeof(pri.srcIdx) + sizeof(pri.dir), pmapFile);
199 + #ifdef PMAP_PRIMARYPOS        
200 +         /* Skip primary hitpoint */
201           for (j = 0; j < 3; j++)
202              getflt(pmapFile);
203 + #endif
204        }
205  
206   #ifdef PMAP_OOC

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines