Improved default settings, re-enambled smoothing and tri stripping of sampled data.

This commit is contained in:
Robert Osfield 2006-02-06 19:16:04 +00:00
parent 3936bcde9e
commit 6624f3aa62
2 changed files with 15 additions and 6 deletions

View File

@ -28,14 +28,21 @@ class OSGUTIL_EXPORT Simplifier : public osg::NodeVisitor
{
public:
Simplifier(float sampleRatio=1.0f, float maximumError=0.0f);
Simplifier(float sampleRatio=1.0f, float maximumError=FLT_MAX, float maximumLength=0.0);
void setSampleRatio(float sampleRatio) { _sampleRatio = sampleRatio; }
float getSampleRatio() const { return _sampleRatio; }
/** Set the maximum point error that all point removals must be less than to permit removal of a point.
* Note, Only used when down sampling. i.e. sampleRatio < 1.0*/
void setMaximumError(float error) { _maximumError = error; }
float getMaximumError() const { return _maximumError; }
/** Set the maximum length target that all edges must be shorted than.
* Note, Only used when up sampling i.e. sampleRatio > 1.0.*/
void setMaximumLength(float length) { _maximumLength = length; }
float getMaximumLength() const { return _maximumLength; }
class ContinueSimplificationCallback : public osg::Referenced
{
@ -64,7 +71,7 @@ class OSGUTIL_EXPORT Simplifier : public osg::NodeVisitor
virtual bool continueSimplificationImplementation(float nextError, unsigned int numOriginalPrimitives, unsigned int numRemainingPrimitives) const
{
if (getSampleRatio()<1.0) return ((float)numRemainingPrimitives > ((float)numOriginalPrimitives) * getSampleRatio()) && nextError<=getMaximumError();
else return ((float)numRemainingPrimitives < ((float)numOriginalPrimitives) * getSampleRatio());
else return ((float)numRemainingPrimitives < ((float)numOriginalPrimitives) * getSampleRatio()) && nextError>getMaximumLength();
}
@ -93,6 +100,7 @@ class OSGUTIL_EXPORT Simplifier : public osg::NodeVisitor
float _sampleRatio;
float _maximumError;
float _maximumLength;
osg::ref_ptr<ContinueSimplificationCallback> _continueSimplificationCallback;

View File

@ -53,7 +53,7 @@ public:
EdgeCollapse():
_computeErrorMetricUsingLength(false) { osg::notify(osg::NOTICE)<<"EdgeCollapse() CONSTRUCTOR"<<std::endl; }
_computeErrorMetricUsingLength(false) {}
~EdgeCollapse();
@ -1671,7 +1671,7 @@ void EdgeCollapse::copyBackToGeometry()
_geometry->getPrimitiveSetList().clear();
_geometry->addPrimitiveSet(primitives);
#if 0
#if 1
osgUtil::SmoothingVisitor::smooth(*_geometry);
osgUtil::TriStripVisitor stripper;
@ -1680,10 +1680,11 @@ void EdgeCollapse::copyBackToGeometry()
}
Simplifier::Simplifier(float sampleRatio, float maximumError):
Simplifier::Simplifier(float sampleRatio, float maximumError, float maximumLength):
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
_sampleRatio(sampleRatio),
_maximumError(maximumError)
_maximumError(maximumError),
_maximumLength(maximumLength)
{
}