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

Comparing ray/src/rt/pmapooc.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 245 | Line 245 | int OOC_FilterPhoton (void *p, void *fd)
245  
246  
247  
248 < void OOC_FindPhotons (struct PhotonMap *pmap, const FVECT pos, const FVECT norm)
248 > int OOC_FindPhotons (struct PhotonMap *pmap, const FVECT pos, const FVECT norm)
249   {
250     OOC_SearchFilter  filt;
251     OOC_FilterData    filtData;
# Line 271 | Line 271 | void OOC_FindPhotons (struct PhotonMap *pmap, const FV
271  
272     if (pmap -> maxDist2 < 0)
273        error(INTERNAL, "failed k-NN photon lookup in OOC_FindPhotons");
274 +  
275 +   /* Return success or failure (empty queue => none found) */
276 +   return pmap -> squeue.tail ? 0 : -1;
277   }
278  
279  
280  
281 < void OOC_Find1Photon (struct PhotonMap* pmap, const FVECT pos,
282 <                      const FVECT norm, Photon *photon)
281 > int OOC_Find1Photon (struct PhotonMap* pmap, const FVECT pos,
282 >                     const FVECT norm, Photon *photon)
283   {
284     OOC_SearchFilter     filt;
285     OOC_FilterData       filtData;
286 <   float                n [3];
286 >   float                n [3], maxDist2;
287    
288     /* Lazily init OOC cache */
289     if (!pmap -> store.cache)
# Line 294 | Line 297 | void OOC_Find1Photon (struct PhotonMap* pmap, const FV
297     filt.data = &filtData;
298     filt.func = OOC_FilterPhoton;
299    
300 <   pmap -> maxDist2 = OOC_Find1Nearest(&pmap -> store,
301 <                                       OOC_ROOT(&pmap -> store), 0,
302 <                                       pmap -> store.org, pmap -> store.size,
303 <                                       pos, &filt, photon, pmap -> maxDist2);
304 <
305 <   if (pmap -> maxDist2 < 0)
306 <      error(INTERNAL, "failed 1-NN photon lookup in OOC_Find1Photon");
300 >   maxDist2 = OOC_Find1Nearest(&pmap -> store,
301 >                               OOC_ROOT(&pmap -> store), 0,
302 >                               pmap -> store.org, pmap -> store.size,
303 >                               pos, &filt, photon, pmap -> maxDist2);
304 >                              
305 >   if (maxDist2 < 0)
306 >      error(INTERNAL, "failed 1-NN photon lookup in OOC_Find1Photon");      
307 >      
308 >   if (maxDist2 >= pmap -> maxDist2)
309 >      /* No photon found => failed */
310 >      return -1;
311 >   else {
312 >      /* Set photon distance => success */
313 >      pmap -> maxDist2 = maxDist2;
314 >      return 0;
315 >   }
316   }
317  
318  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines