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.3 by rschregle, Fri May 8 13:20:23 2015 UTC vs.
Revision 2.7 by rschregle, Tue May 26 11:26:27 2015 UTC

# Line 19 | Line 19
19   #include "otypes.h"
20   #include "source.h"
21   #include "rcontrib.h"
22 + #include "random.h"
23  
24  
25  
# Line 66 | Line 67 | void initPhotonMap (PhotonMap *pmap, PhotonMapType t)
67   const PhotonPrimary* addPhotonPrimary (PhotonMap *pmap, const RAY *ray)
68   {
69     PhotonPrimary *prim = NULL;
70 +   FVECT dvec;
71    
72     if (!pmap || !ray)
73        return NULL;
# Line 98 | Line 100 | const PhotonPrimary* addPhotonPrimary (PhotonMap *pmap
100     prim -> srcIdx = -1;
101        
102     /* Reverse incident direction to point to light source */
103 <   prim -> dir [0] = -ray -> rdir [0];
104 <   prim -> dir [1] = -ray -> rdir [1];
105 <   prim -> dir [2] = -ray -> rdir [2];
103 >   dvec [0] = -ray -> rdir [0];
104 >   dvec [1] = -ray -> rdir [1];
105 >   dvec [2] = -ray -> rdir [2];
106 >   prim -> dir = encodedir(dvec);
107  
108 <   VCOPY(prim -> org, ray -> rorg);
108 >   VCOPY(prim -> pos, ray -> rop);
109    
110     return prim;
111   }
# Line 227 | Line 230 | static void nearestNeighbours (PhotonMap* pmap, const
230     }
231  
232     /* Reject photon if normal faces away (ignored for volume photons) */
233 <   if (norm && DOT(norm, p -> norm) <= 0)
233 >   if (norm && DOT(norm, p -> norm) <= 0.5 * frandom())
234        return;
235        
236     if (isContribPmap(pmap) && pmap -> srcContrib) {
# Line 238 | Line 241 | static void nearestNeighbours (PhotonMap* pmap, const
241        if (srcIdx < 0 || srcIdx >= nsources)
242           error(INTERNAL, "invalid light source index in photon map");
243        
244 <      srcMod = objptr(source [srcIdx].so -> omod);
244 >      srcMod = findmaterial(source [srcIdx].so);
245  
246        /* Reject photon if contributions from light source which emitted it
247         * are not sought */
# Line 453 | Line 456 | static void nearest1Neighbour (PhotonMap *pmap, const
456     dv [2] = pos [2] - p -> pos [2];
457     d2 = DOT(dv, dv);
458    
459 <   if (d2 < pmap -> maxDist && DOT(norm, p -> norm) > 0) {
459 >   if (d2 < pmap -> maxDist && DOT(norm, p -> norm) > 0.5 * frandom()) {
460        /* Closest photon so far with similar normal */
461        pmap -> maxDist = d2;
462        *photon = p;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines