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

Comparing ray/src/cv/bsdfrbf.c (file contents):
Revision 2.20 by greg, Sat Mar 8 18:16:49 2014 UTC vs.
Revision 2.21 by greg, Sat Mar 15 19:47:16 2014 UTC

# Line 72 | Line 72 | add_bsdf_data(double theta_out, double phi_out, double
72          ovec[1] = sin((M_PI/180.)*phi_out) * ovec[2];
73          ovec[2] = sqrt(1. - ovec[2]*ovec[2]);
74  
75 <        if (val <= 0)                   /* truncate to zero */
76 <                val = 0;
77 <        else if (!isDSF)
75 >        if (!isDSF)
76                  val *= ovec[2];         /* convert from BSDF to DSF */
77  
78                                          /* update BSDF histogram */
# Line 169 | Line 167 | smooth_region(int x0, int x1, int y0, int y1)
167   }
168  
169   /* Create new lobe based on integrated samples in region */
170 < static void
170 > static int
171   create_lobe(RBFVAL *rvp, int x0, int x1, int y0, int y1)
172   {
173          double  vtot = 0.0;
# Line 187 | Line 185 | create_lobe(RBFVAL *rvp, int x0, int x1, int y0, int y
185                                  progname);
186                  exit(1);
187          }
188 +        if (vtot <= 0)                  /* only create positive lobes */
189 +                return(0);
190                                          /* peak value based on integral */
191          vtot *= (x1-x0)*(y1-y0)*(2.*M_PI/GRIDRES/GRIDRES)/(double)nv;
192          rad = (RSCA/(double)GRIDRES)*(x1-x0);
# Line 194 | Line 194 | create_lobe(RBFVAL *rvp, int x0, int x1, int y0, int y
194          rvp->crad = ANG2R(rad);
195          rvp->gx = (x0+x1)>>1;
196          rvp->gy = (y0+y1)>>1;
197 +        return(1);
198   }
199  
200   /* Recursive function to build radial basis function representation */
# Line 235 | Line 236 | build_rbfrep(RBFVAL **arp, int *np, int x0, int x1, in
236                          return(-1);
237          }
238                                          /* create lobes for leaves */
239 <        if (!branched[0])
240 <                create_lobe(*arp+(*np)++, x0, xmid, y0, ymid);
241 <        if (!branched[1])
242 <                create_lobe(*arp+(*np)++, xmid, x1, y0, ymid);
243 <        if (!branched[2])
244 <                create_lobe(*arp+(*np)++, x0, xmid, ymid, y1);
245 <        if (!branched[3])
246 <                create_lobe(*arp+(*np)++, xmid, x1, ymid, y1);
247 <        nadded += nleaves;
239 >        if (!branched[0] && create_lobe(*arp+*np, x0, xmid, y0, ymid)) {
240 >                ++(*np); ++nadded;
241 >        }
242 >        if (!branched[1] && create_lobe(*arp+*np, xmid, x1, y0, ymid)) {
243 >                ++(*np); ++nadded;
244 >        }
245 >        if (!branched[2] && create_lobe(*arp+*np, x0, xmid, ymid, y1)) {
246 >                ++(*np); ++nadded;
247 >        }
248 >        if (!branched[3] && create_lobe(*arp+*np, xmid, x1, ymid, y1)) {
249 >                ++(*np); ++nadded;
250 >        }
251          return(nadded);
252   }
253  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines