Fixed precision issue with filling in the last element of the TransferFunction1D's osg::Image.

This commit is contained in:
Robert Osfield 2018-02-27 19:09:18 +00:00
parent 7b6eedbdf4
commit 6a4609c28f

View File

@ -87,6 +87,10 @@ void TransferFunction1D::assignToImage(float lower_v, const osg::Vec4& lower_c,
if (end_iPos < 0) return; if (end_iPos < 0) return;
if (end_iPos > endPos) end_iPos = endPos; if (end_iPos > endPos) end_iPos = endPos;
// clamp to ends to avoid any precision issues
if (lower_v == minimum) start_iPos = 0;
if (upper_v == maximum) end_iPos = endPos;
//OSG_NOTICE<<"TransferFunction1D::assignToImage[lower_v="<<lower_v<<", lower_c="<<lower_c<<", upper_v="<<upper_v<<" upper_c="<<upper_c<<std::endl; //OSG_NOTICE<<"TransferFunction1D::assignToImage[lower_v="<<lower_v<<", lower_c="<<lower_c<<", upper_v="<<upper_v<<" upper_c="<<upper_c<<std::endl;
//OSG_NOTICE<<" lower_iPos="<<lower_iPos<<" start_iPpos="<<start_iPos<<std::endl; //OSG_NOTICE<<" lower_iPos="<<lower_iPos<<" start_iPpos="<<start_iPos<<std::endl;
//OSG_NOTICE<<" upper_iPos="<<upper_iPos<<" end_iPpos="<<end_iPos<<std::endl; //OSG_NOTICE<<" upper_iPos="<<upper_iPos<<" end_iPpos="<<end_iPos<<std::endl;