249 |
|
if (!strcasecmp(unit, "Foot")) return(.3048); |
250 |
|
if (!strcasecmp(unit, "Inch")) return(.0254); |
251 |
|
if (!strcasecmp(unit, "Centimeter")) return(.01); |
252 |
+ |
if (!strcasecmp(unit, "Millimeter")) return(.001); |
253 |
|
sprintf(errmsg, "unknown dimensional unit '%s'", unit); |
254 |
|
error(USER, errmsg); |
255 |
|
} |
377 |
|
) |
378 |
|
{ |
379 |
|
double *omega_iarr, *omega_oarr; |
380 |
< |
double dom, contrib, hemi_total; |
380 |
> |
double dom, contrib, hemi_total, full_total; |
381 |
|
int nneg; |
382 |
|
FVECT v; |
383 |
|
int i, o; |
446 |
|
BSDF_value(dp,i,o) = .0f; |
447 |
|
} |
448 |
|
} |
449 |
< |
if (hemi_total > 1.02) { |
449 |
> |
if (hemi_total > 1.01) { |
450 |
|
sprintf(errmsg, |
451 |
|
"incoming BSDF direction %d passes %.1f%% of light", |
452 |
|
i, 100.*hemi_total); |
457 |
|
sprintf(errmsg, "%d negative BSDF values (ignored)", nneg); |
458 |
|
error(WARNING, errmsg); |
459 |
|
} |
460 |
< |
/* reverse roles and check again */ |
460 |
> |
full_total = .0; /* reverse roles and check again */ |
461 |
|
for (o = 0; o < dp->nout; o++) { |
462 |
|
hemi_total = .0; |
463 |
|
for (i = dp->ninc; i--; ) |
464 |
|
hemi_total += BSDF_value(dp,i,o) * omega_iarr[i]; |
465 |
|
|
466 |
< |
if (hemi_total > 1.02) { |
466 |
> |
if (hemi_total > 1.01) { |
467 |
|
sprintf(errmsg, |
468 |
|
"outgoing BSDF direction %d collects %.1f%% of light", |
469 |
|
o, 100.*hemi_total); |
470 |
|
error(WARNING, errmsg); |
471 |
|
} |
472 |
+ |
full_total += hemi_total*omega_oarr[o]; |
473 |
+ |
} |
474 |
+ |
full_total /= PI; |
475 |
+ |
if (full_total > 1.00001) { |
476 |
+ |
sprintf(errmsg, "BSDF transfers %.4f%% of light", |
477 |
+ |
100.*full_total); |
478 |
+ |
error(WARNING, errmsg); |
479 |
|
} |
480 |
|
free(omega_iarr); free(omega_oarr); |
481 |
|
return(1); |