From d773d358c436143e06854bba3d9c603df918f3db Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 1 Apr 2014 18:56:57 +0000 Subject: [PATCH] Improved the setting of sample density/ratio so that they are consistent --- src/osgVolume/Property.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/osgVolume/Property.cpp b/src/osgVolume/Property.cpp index 8f7a085b5..de688ddd0 100644 --- a/src/osgVolume/Property.cpp +++ b/src/osgVolume/Property.cpp @@ -452,7 +452,8 @@ bool PropertyAdjustmentCallback::handle(const osgGA::GUIEventAdapter& ea,osgGA:: if (ea.getMouseYOrientation()==osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS) v = 1.0f-v; float v2 = v*v; - float v4 = v2*v2; + float sampleRatio = powf((1.0f-v)*2.0f,3.0f); + float sampleDensity = (1.0/sampleRatio)/512.0f; if (_updateAlphaCutOff && cpv._isoProperty.valid()) { @@ -480,26 +481,23 @@ bool PropertyAdjustmentCallback::handle(const osgGA::GUIEventAdapter& ea,osgGA:: if (_updateSampleDensity && cpv._sampleDensityProperty.valid()) { - OSG_NOTICE<<"Setting sample density to "<setValue(v4); + OSG_NOTICE<<"Setting sample density to "<setValue(sampleDensity); } if (_updateSampleDensity && cpv._sampleDensityWhenMovingProperty.valid()) { - OSG_INFO<<"Setting sample density when moving to "<setValue(v4); + OSG_INFO<<"Setting sample density when moving to "<setValue(sampleDensity); } if (_updateSampleDensity && cpv._sampleRatioProperty.valid()) { - float sampleDensity = v4; - float sampleRatio = 1.0/(512*sampleDensity); OSG_NOTICE<<"Setting sample ratio to "<setValue(sampleRatio); } if (_updateSampleDensity && cpv._sampleRatioWhenMovingProperty.valid()) { - float sampleRatio = (1.0-v2)*20.0; OSG_NOTICE<<"Setting sample ratio to "<setValue(sampleRatio); }