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.4 by rschregle, Thu May 31 12:34:16 2018 UTC vs.
Revision 1.7 by rschregle, Mon Mar 22 23:00:00 2021 UTC

# Line 14 | Line 14
14  
15   #include "pmapdata.h"   /* Includes pmapooc.h */
16   #include "source.h"
17 + #include "otspecial.h"
18   #include "oocsort.h"
19   #include "oocbuild.h"
20  
# Line 151 | Line 152 | int OOC_LoadPhotons (struct PhotonMap *pmap, FILE *nod
152  
153     if (OOC_LoadOctree(&pmap -> store, nodeFile, OOC_PhotonKey, leafFile))
154        return -1;
155 <      
155 >
156 > #ifdef DEBUG_OOC
157 >   /* Check octree for consistency */
158 >   if (OOC_Check(
159 >      &pmap -> store, OOC_ROOT(&pmap -> store),
160 >      pmap -> store.org, pmap -> store.size, 0
161 >   ))
162 >      return -1;
163 > #endif
164 >
165     return 0;
166   }
167  
# Line 244 | Line 254 | int OOC_FilterPhoton (void *p, void *fd)
254  
255  
256  
257 < void OOC_FindPhotons (struct PhotonMap *pmap, const FVECT pos, const FVECT norm)
257 > int OOC_FindPhotons (struct PhotonMap *pmap, const FVECT pos, const FVECT norm)
258   {
259     OOC_SearchFilter  filt;
260     OOC_FilterData    filtData;
# Line 270 | Line 280 | void OOC_FindPhotons (struct PhotonMap *pmap, const FV
280  
281     if (pmap -> maxDist2 < 0)
282        error(INTERNAL, "failed k-NN photon lookup in OOC_FindPhotons");
283 +  
284 +   /* Return success or failure (empty queue => none found) */
285 +   return pmap -> squeue.tail ? 0 : -1;
286   }
287  
288  
289  
290 < void OOC_Find1Photon (struct PhotonMap* pmap, const FVECT pos,
291 <                      const FVECT norm, Photon *photon)
290 > int OOC_Find1Photon (struct PhotonMap* pmap, const FVECT pos,
291 >                     const FVECT norm, Photon *photon)
292   {
293     OOC_SearchFilter     filt;
294     OOC_FilterData       filtData;
295 <   float                n [3];
295 >   float                n [3], maxDist2;
296    
297     /* Lazily init OOC cache */
298     if (!pmap -> store.cache)
# Line 293 | Line 306 | void OOC_Find1Photon (struct PhotonMap* pmap, const FV
306     filt.data = &filtData;
307     filt.func = OOC_FilterPhoton;
308    
309 <   pmap -> maxDist2 = OOC_Find1Nearest(&pmap -> store,
310 <                                       OOC_ROOT(&pmap -> store), 0,
311 <                                       pmap -> store.org, pmap -> store.size,
312 <                                       pos, &filt, photon, pmap -> maxDist2);
313 <
314 <   if (pmap -> maxDist2 < 0)
315 <      error(INTERNAL, "failed 1-NN photon lookup in OOC_Find1Photon");
309 >   maxDist2 = OOC_Find1Nearest(&pmap -> store,
310 >                               OOC_ROOT(&pmap -> store), 0,
311 >                               pmap -> store.org, pmap -> store.size,
312 >                               pos, &filt, photon, pmap -> maxDist2);
313 >                              
314 >   if (maxDist2 < 0)
315 >      error(INTERNAL, "failed 1-NN photon lookup in OOC_Find1Photon");      
316 >      
317 >   if (maxDist2 >= pmap -> maxDist2)
318 >      /* No photon found => failed */
319 >      return -1;
320 >   else {
321 >      /* Set photon distance => success */
322 >      pmap -> maxDist2 = maxDist2;
323 >      return 0;
324 >   }
325   }
326  
327  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines