27 |
|
int output_orient = 0; |
28 |
|
|
29 |
|
/* BSDF histogram */ |
30 |
< |
int bsdf_hist[HISTLEN]; |
30 |
> |
unsigned long bsdf_hist[HISTLEN]; |
31 |
|
|
32 |
|
/* BSDF value for boundary regions */ |
33 |
|
double bsdf_min = 0; |
259 |
|
eval_rbfrep(const RBFNODE *rp, const FVECT outvec) |
260 |
|
{ |
261 |
|
double minval = bsdf_min*output_orient*outvec[2]; |
262 |
+ |
int pos[2]; |
263 |
|
double res = 0; |
264 |
|
const RBFVAL *rbfp; |
265 |
|
FVECT odir; |
266 |
< |
double sig2; |
266 |
> |
double rad2; |
267 |
|
int n; |
268 |
|
/* check for wrong side */ |
269 |
|
if (outvec[2] > 0 ^ output_orient > 0) |
271 |
|
/* use minimum if no information avail. */ |
272 |
|
if (rp == NULL) |
273 |
|
return(minval); |
274 |
+ |
/* optimization for fast lobe culling */ |
275 |
+ |
pos_from_vec(pos, outvec); |
276 |
|
/* sum radial basis function */ |
277 |
|
rbfp = rp->rbfa; |
278 |
|
for (n = rp->nrbf; n--; rbfp++) { |
279 |
+ |
int d2 = (pos[0]-rbfp->gx)*(pos[0]-rbfp->gx) + |
280 |
+ |
(pos[1]-rbfp->gy)*(pos[1]-rbfp->gy); |
281 |
+ |
rad2 = R2ANG(rbfp->crad); |
282 |
+ |
rad2 *= rad2; |
283 |
+ |
if (d2 > (38.*GRIDRES*GRIDRES/M_PI/M_PI)*rad2) |
284 |
+ |
continue; |
285 |
|
ovec_from_pos(odir, rbfp->gx, rbfp->gy); |
286 |
< |
sig2 = R2ANG(rbfp->crad); |
278 |
< |
sig2 = (DOT(odir,outvec) - 1.) / (sig2*sig2); |
279 |
< |
if (sig2 > -19.) |
280 |
< |
res += rbfp->peak * exp(sig2); |
286 |
> |
res += rbfp->peak * exp((DOT(odir,outvec) - 1.) / rad2); |
287 |
|
} |
288 |
|
if (res < minval) /* never return less than minval */ |
289 |
|
return(minval); |