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