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.5 by greg, Thu Nov 8 00:54:07 2018 UTC vs.
Revision 1.6 by rschregle, Wed Apr 8 15:14:21 2020 UTC

# Line 419 | Line 419 | static void kdT_FindNearest (PhotonMap *pmap, const fl
419  
420  
421  
422 < void kdT_FindPhotons (struct PhotonMap *pmap, const FVECT pos,
423 <                      const FVECT norm)
422 > int kdT_FindPhotons (struct PhotonMap *pmap, const FVECT pos,
423 >                     const FVECT norm)
424   {
425     float p [3], n [3];
426    
# Line 429 | Line 429 | void kdT_FindPhotons (struct PhotonMap *pmap, const FV
429     if (norm)
430        VCOPY(n, norm);
431     kdT_FindNearest(pmap, p, norm ? n : NULL, 1);
432 +  
433 +   /* Return success or failure (empty queue => none found) */
434 +   return pmap -> squeue.tail ? 0 : -1;
435   }
436  
437  
# Line 478 | Line 481 | static void kdT_Find1Nearest (PhotonMap *pmap, const f
481  
482  
483  
484 < void kdT_Find1Photon (struct PhotonMap *pmap, const FVECT pos,
485 <                      const FVECT norm, Photon *photon)
484 > int kdT_Find1Photon (struct PhotonMap *pmap, const FVECT pos,
485 >                     const FVECT norm, Photon *photon)
486   {
487     float    p [3], n [3];
488 <   Photon   *pnn;
488 >   Photon   *pnn = NULL;
489    
490     /* Photon pos & normal stored at lower precision */
491     VCOPY(p, pos);
492     if (norm)
493        VCOPY(n, norm);  
494 <   kdT_Find1Nearest(pmap, p, norm ? n : NULL, &pnn, 1);
495 <   memcpy(photon, pnn, sizeof(Photon));
494 >   kdT_Find1Nearest(pmap, p, norm ? n : NULL, &pnn, 1);  
495 >   if (!pnn)
496 >      /* No photon found => failed */
497 >      return -1;
498 >   else {
499 >      /* Copy found photon => successs */
500 >      memcpy(photon, pnn, sizeof(Photon));
501 >      return 0;
502 >   }
503   }
504  
505  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines