Fixed two possible reasons for nan values, Issue 2194

This commit is contained in:
Ingo
2014-03-24 16:30:41 +01:00
parent 0ec0ba01d0
commit 10353416c9

View File

@@ -171,9 +171,14 @@ class CurveFactory {
{ {
if (comp>0.0) { if (comp>0.0) {
float val = level+(hlrange-65536.0); float val = level+(hlrange-65536.0);
if(val == 0.0f) // to avoid division by zero
val = 0.000001f;
float Y = val*exp_scale/hlrange; float Y = val*exp_scale/hlrange;
Y *= comp;
if(Y <= -1.0) // to avoid log(<=0)
Y = -.999999f;
float R = hlrange/(val*comp); float R = hlrange/(val*comp);
return log(1.0+Y*comp)*R; return log(1.0+Y)*R;
} else { } else {
return exp_scale; return exp_scale;
} }