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

Comparing ray/src/rt/pmapdata.c (file contents):
Revision 2.8 by rschregle, Tue May 26 13:31:19 2015 UTC vs.
Revision 2.14 by rschregle, Thu Feb 4 11:36:59 2016 UTC

# Line 1 | Line 1
1 + #ifndef lint
2 + static const char RCSid[] = "$Id$";
3 + #endif
4   /*
5     ==================================================================
6     Photon map data structures and kd-tree handling
# Line 8 | Line 11
11     supported by the Swiss National Science Foundation (SNSF, #147053)
12     ==================================================================  
13    
11   $Id$
14   */
15  
16  
# Line 229 | Line 231 | static void nearestNeighbours (PhotonMap* pmap, const
231           nearestNeighbours(pmap, pos, norm, node << 1);
232     }
233  
234 <   /* Reject photon if normal faces away (ignored for volume photons) */
235 <   if (norm && DOT(norm, p -> norm) <= 0.5 * frandom())
234 >   /* Reject photon if normal faces away (ignored for volume photons) with
235 >    * 50% tolerance to account for perturbation; note photon normal is coded
236 >    * in range [-127,127].  */
237 >   if (norm && DOT(norm, p -> norm) <= 63.5 * frandom())
238        return;
239        
240     if (isContribPmap(pmap) && pmap -> srcContrib) {
# Line 337 | Line 341 | void findPhotons (PhotonMap* pmap, const RAY* ray)
341        pmap -> minError = FHUGE;
342        pmap -> maxError = -FHUGE;
343        pmap -> rmsError = 0;
344 <      /* Maximum search radius limit is based on avg photon distance to
344 >      /* SQUARED max search radius limit is based on avg photon distance to
345         * centre of gravity, unless fixed by user (maxDistFix > 0) */
346        pmap -> maxDist0 = pmap -> maxDistLimit =
347 <         maxDistFix > 0 ? maxDistFix
347 >         maxDistFix > 0 ? maxDistFix * maxDistFix
348                          : PMAP_MAXDIST_COEFF * pmap -> squeueSize *
349                            pmap -> CoGdist / pmap -> heapSize;
350     }
# Line 362 | Line 366 | void findPhotons (PhotonMap* pmap, const RAY* ray)
366           nearestNeighbours(pmap, pos, norm, 1);
367        }
368  
369 + #ifdef PMAP_ITSYBITSY
370 +      if (pmap -> maxDist < FTINY) {
371 +         sprintf(errmsg, "itsy bitsy teeny weeny photon search radius %e",
372 +                 sqrt(pmap -> maxDist));
373 +         error(WARNING, errmsg);
374 +      }
375 + #endif
376 +
377        if (pmap -> squeueEnd < pmap -> squeueSize * pmap -> gatherTolerance) {
378           /* Short lookup; too few photons found */
379           if (pmap -> squeueEnd > PMAP_SHORT_LOOKUP_THRESH) {
# Line 392 | Line 404 | void findPhotons (PhotonMap* pmap, const RAY* ray)
404                 sprintf(errmsg,
405                         redo ? "restarting photon lookup with max radius %.1e"
406                              : "max photon lookup radius adjusted to %.1e",
407 <                       pmap -> maxDist0);
407 >                       sqrt(pmap -> maxDist0));
408                 error(WARNING, errmsg);
409   #endif
410              }
411   #ifdef PMAP_LOOKUP_REDO
412              else {
413                 sprintf(errmsg, "max photon lookup radius clamped to %.1e",
414 <                       pmap -> maxDist0);
414 >                       sqrt(pmap -> maxDist0));
415                 error(WARNING, errmsg);
416              }
417   #endif
# Line 461 | Line 473 | static void nearest1Neighbour (PhotonMap *pmap, const
473     dv [2] = pos [2] - p -> pos [2];
474     d2 = DOT(dv, dv);
475    
476 <   if (d2 < pmap -> maxDist && DOT(norm, p -> norm) > 0.5 * frandom()) {
477 <      /* Closest photon so far with similar normal */
476 >   if (d2 < pmap -> maxDist && DOT(norm, p -> norm) > 63.5 * frandom()) {
477 >      /* Closest photon so far with similar normal. We allow a 50% tolerance
478 >       * to account for perturbation in the latter; note the photon normal
479 >       * is coded in the range [-127,127].  */  
480        pmap -> maxDist = d2;
481        *photon = p;
482     }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines