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 */ |
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; |
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); |
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 */ |
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 |
|
|
262 |
|
comp_bsdf_min(); |
263 |
|
/* create RBF node list */ |
264 |
|
rbfarr = NULL; nn = 0; |
265 |
< |
if (build_rbfrep(&rbfarr, &nn, 0, GRIDRES, 0, GRIDRES) <= 0) |
266 |
< |
goto memerr; |
265 |
> |
if (build_rbfrep(&rbfarr, &nn, 0, GRIDRES, 0, GRIDRES) <= 0) { |
266 |
> |
if (nn) |
267 |
> |
goto memerr; |
268 |
> |
fprintf(stderr, "%s: no usable data in make_rbfrep()\n", |
269 |
> |
progname); |
270 |
> |
exit(1); |
271 |
> |
} |
272 |
|
/* (re)allocate RBF array */ |
273 |
|
newnode = (RBFNODE *)realloc(rbfarr, |
274 |
|
sizeof(RBFNODE) + sizeof(RBFVAL)*(nn-1)); |