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

Comparing ray/src/rt/pmapcontrib.c (file contents):
Revision 2.4 by rschregle, Fri May 8 13:20:23 2015 UTC vs.
Revision 2.5 by greg, Wed May 20 12:58:31 2015 UTC

# Line 23 | Line 23
23  
24  
25  
26 extern int contrib;     /* coeff/contrib flag */
27
28
29
26   static void setPmapContribParams (PhotonMap *pmap, LUTAB *srcContrib)
27   /* Set parameters for light source contributions */
28   {
# Line 103 | Line 99 | void photonContrib (PhotonMap *pmap, RAY *ray, COLOR i
99     PhotonSQNode   *sq;
100     float          r, invArea;
101     RREAL          rayCoeff [3];
102 <   FVECT          rdir, rop;
107 <
102 >
103     setcolor(irrad, 0, 0, 0);
104  
105     if (!pmap -> maxGather)
# Line 115 | Line 110 | void photonContrib (PhotonMap *pmap, RAY *ray, COLOR i
110        if (islight(objptr(ray -> ro -> omod) -> otype))
111           return;
112  
113 <   /* Set context for binning function evaluation and get cumulative path
113 >   /* Get cumulative path
114      * coefficient up to photon lookup point */
120   worldfunc(RCCONTEXT, ray);
115     raycontrib(rayCoeff, ray, PRIMARY);
116  
123   /* Save incident ray's direction and hitpoint */
124   VCOPY(rdir, ray -> rdir);
125   VCOPY(rop, ray -> rop);
126
117     /* Lookup photons */
118     pmap -> squeueEnd = 0;
119     findPhotons(pmap, ray);
# Line 164 | Line 154 | void photonContrib (PhotonMap *pmap, RAY *ray, COLOR i
154        if (pmap -> srcContrib) {
155           const PhotonPrimary *primary = pmap -> primary +
156                                          sq -> photon -> primary;
157 <         OBJREC *srcMod = objptr(source [primary -> srcIdx].so -> omod);
157 >         SRCREC *sp = &source[primary -> srcIdx];
158 >         OBJREC *srcMod = objptr(sp -> so -> omod);
159           MODCONT *srcContrib = (MODCONT*)lu_find(pmap -> srcContrib,
160                                                   srcMod -> oname) -> data;
161          
162           if (srcContrib) {
163              /* Photon's emitting light source has modifier whose
164               * contributions are sought */
165 +            double srcBinReal;
166              int srcBin;
167 +            RAY srcRay;
168  
169 <            /* Set incident dir and origin of photon's primary ray on
170 <             * light source for dummy shadow ray, and evaluate binning
171 <             * function */
172 <            VCOPY(ray -> rdir, primary -> dir);
173 <            VCOPY(ray -> rop, primary -> org);
174 <            srcBin = evalue(srcContrib -> binv) + .5;
175 <
176 <            if (srcBin < 0 || srcBin >= srcContrib -> nbins) {
169 >            if (srcContrib -> binv -> type != NUM) {
170 >               /* Use intersection function to set shadow ray parameters
171 >                */
172 >               rayorigin(&srcRay, SHADOW, NULL, NULL);
173 >               srcRay.rsrc = primary -> srcIdx;
174 >               VCOPY(srcRay.rorg, primary -> pos);
175 >               VCOPY(srcRay.rdir, primary -> dir);
176 >               if (!(source [primary -> srcIdx].sflags & SDISTANT ?
177 >                        sourcehit(&srcRay) :
178 >                        (*ofun[sp -> so -> otype].funp)(sp -> so, &srcRay)))
179 >                    continue;           /* XXX shouldn't happen! */
180 >               worldfunc(RCCONTEXT, &srcRay);
181 >               set_eparams((char *)srcContrib -> params);
182 >          }
183 >            if ((srcBinReal = evalue(srcContrib -> binv)) < -.5)
184 >                continue;               /* silently ignore negative bins */
185 >  
186 >            if ((srcBin = srcBinReal + .5) >= srcContrib -> nbins) {
187                 error(WARNING, "bad bin number (ignored)");
188                 continue;
189              }
# Line 204 | Line 207 | void photonContrib (PhotonMap *pmap, RAY *ray, COLOR i
207           else fprintf(stderr, "Skipped contrib from %s\n", srcMod -> oname);
208        }
209     }
210 <  
208 <   /* Restore incident ray's direction and hitpoint */
209 <   VCOPY(ray -> rdir, rdir);
210 <   VCOPY(ray -> rop, rop);
211 <    
210 >        
211     return;
212   }
213  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines