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

Comparing ray/src/rt/pmapkdt.c (file contents):
Revision 1.3 by rschregle, Wed Jan 24 19:39:05 2018 UTC vs.
Revision 1.5 by greg, Thu Nov 8 00:54:07 2018 UTC

# Line 15 | Line 15
15  
16   #include "pmapdata.h"   /* Includes pmapkdt.h */
17   #include "source.h"
18 + #include "otspecial.h"
19 + #include "random.h"
20  
21  
22  
# Line 424 | Line 426 | void kdT_FindPhotons (struct PhotonMap *pmap, const FV
426    
427     /* Photon pos & normal stored at lower precision */
428     VCOPY(p, pos);
429 <   VCOPY(n, norm);
430 <   kdT_FindNearest(pmap, p, n, 1);
429 >   if (norm)
430 >      VCOPY(n, norm);
431 >   kdT_FindNearest(pmap, p, norm ? n : NULL, 1);
432   }
433  
434  
# Line 464 | Line 467 | static void kdT_Find1Nearest (PhotonMap *pmap, const f
467     d2 = DOT(dv, dv);
468    
469     if (d2 < pmap -> maxDist2 &&
470 <       DOT(norm, p -> norm) > PMAP_NORM_TOL * 127 * frandom()) {
470 >       (!norm || DOT(norm, p -> norm) > PMAP_NORM_TOL * 127 * frandom())) {
471        /* Closest photon so far with similar normal. We allow for tolerance
472         * to account for perturbation in the latter; note the photon normal
473         * is coded in the range [-127,127], hence we factor this in  */
# Line 483 | Line 486 | void kdT_Find1Photon (struct PhotonMap *pmap, const FV
486    
487     /* Photon pos & normal stored at lower precision */
488     VCOPY(p, pos);
489 <   VCOPY(n, norm);
490 <   kdT_Find1Nearest(pmap, p, n, &pnn, 1);
489 >   if (norm)
490 >      VCOPY(n, norm);  
491 >   kdT_Find1Nearest(pmap, p, norm ? n : NULL, &pnn, 1);
492     memcpy(photon, pnn, sizeof(Photon));
493   }
494  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines