Improves to CullStack.
From M.Grngr. options support for f=switching off internal imagery in .ive files
This commit is contained in:
@@ -25,6 +25,9 @@ CullStack::CullStack()
|
||||
_bbCornerFar = 7;
|
||||
_currentReuseMatrixIndex=0;
|
||||
_identity = new RefMatrix();
|
||||
|
||||
_index_modelviewCullingStack = 0;
|
||||
_back_modelviewCullingStack = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +36,6 @@ CullStack::~CullStack()
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
void CullStack::reset()
|
||||
{
|
||||
|
||||
@@ -48,8 +50,11 @@ void CullStack::reset()
|
||||
|
||||
_clipspaceCullingStack.clear();
|
||||
_projectionCullingStack.clear();
|
||||
_modelviewCullingStack.clear();
|
||||
|
||||
|
||||
//_modelviewCullingStack.clear();
|
||||
_index_modelviewCullingStack=0;
|
||||
_back_modelviewCullingStack = 0;
|
||||
|
||||
osg::Vec3 lookVector(0.0,0.0,-1.0);
|
||||
|
||||
_bbCornerFar = (lookVector.x()>=0?1:0) |
|
||||
@@ -59,14 +64,17 @@ void CullStack::reset()
|
||||
_bbCornerNear = (~_bbCornerFar)&7;
|
||||
}
|
||||
|
||||
|
||||
void CullStack::pushCullingSet()
|
||||
{
|
||||
_MVPW_Stack.push_back(0L);
|
||||
|
||||
if (_modelviewStack.empty())
|
||||
{
|
||||
_modelviewCullingStack.push_back(_projectionCullingStack.back());
|
||||
|
||||
if (_index_modelviewCullingStack==0)
|
||||
{
|
||||
if (_modelviewCullingStack.empty())
|
||||
_modelviewCullingStack.push_back(CullingSet());
|
||||
|
||||
_modelviewCullingStack[_index_modelviewCullingStack++].set(_projectionCullingStack.back());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -104,11 +112,19 @@ void CullStack::pushCullingSet()
|
||||
float scaleRatio = 0.701f/sqrtf(scale_00.length2()+scale_10.length2());
|
||||
|
||||
pixelSizeVector *= scaleRatio;
|
||||
|
||||
|
||||
_modelviewCullingStack.push_back(new osg::CullingSet(*_projectionCullingStack.back(),*_modelviewStack.back(),pixelSizeVector));
|
||||
if (_index_modelviewCullingStack>=_modelviewCullingStack.size())
|
||||
{
|
||||
_modelviewCullingStack.push_back(CullingSet());
|
||||
}
|
||||
|
||||
_modelviewCullingStack[_index_modelviewCullingStack++].set(_projectionCullingStack.back(),*_modelviewStack.back(),pixelSizeVector);
|
||||
|
||||
}
|
||||
|
||||
_back_modelviewCullingStack = &_modelviewCullingStack[_index_modelviewCullingStack-1];
|
||||
|
||||
// const osg::Polytope& polytope = _modelviewCullingStack.back()->getFrustum();
|
||||
// const osg::Polytope::PlaneList& pl = polytope.getPlaneList();
|
||||
// std::cout <<"new cull stack"<<std::endl;
|
||||
@@ -119,13 +135,16 @@ void CullStack::pushCullingSet()
|
||||
// std::cout << " plane "<<*pl_itr<<std::endl;
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CullStack::popCullingSet()
|
||||
{
|
||||
_MVPW_Stack.pop_back();
|
||||
|
||||
_modelviewCullingStack.pop_back();
|
||||
--_index_modelviewCullingStack;
|
||||
if (_index_modelviewCullingStack>0) _back_modelviewCullingStack = &_modelviewCullingStack[_index_modelviewCullingStack-1];
|
||||
|
||||
}
|
||||
|
||||
void CullStack::pushViewport(osg::Viewport* viewport)
|
||||
@@ -144,17 +163,18 @@ void CullStack::pushProjectionMatrix(RefMatrix* matrix)
|
||||
{
|
||||
_projectionStack.push_back(matrix);
|
||||
|
||||
osg::CullingSet* cullingSet = new osg::CullingSet();
|
||||
_projectionCullingStack.push_back(osg::CullingSet());
|
||||
osg::CullingSet& cullingSet = _projectionCullingStack.back();
|
||||
|
||||
// set up view frustum.
|
||||
cullingSet->getFrustum().setToUnitFrustum(((_cullingMode&NEAR_PLANE_CULLING)!=0),((_cullingMode&FAR_PLANE_CULLING)!=0));
|
||||
cullingSet->getFrustum().transformProvidingInverse(*matrix);
|
||||
cullingSet.getFrustum().setToUnitFrustum(((_cullingMode&NEAR_PLANE_CULLING)!=0),((_cullingMode&FAR_PLANE_CULLING)!=0));
|
||||
cullingSet.getFrustum().transformProvidingInverse(*matrix);
|
||||
|
||||
// set the culling mask ( There should be a more elegant way!) Nikolaus H.
|
||||
cullingSet->setCullingMask(_cullingMode);
|
||||
cullingSet.setCullingMask(_cullingMode);
|
||||
|
||||
// set the small feature culling.
|
||||
cullingSet->setSmallFeatureCullingPixelSize(_smallFeatureCullingPixelSize);
|
||||
cullingSet.setSmallFeatureCullingPixelSize(_smallFeatureCullingPixelSize);
|
||||
|
||||
// set up the relevant occluders which a related to this projection.
|
||||
for(ShadowVolumeOccluderList::iterator itr=_occluderList.begin();
|
||||
@@ -165,12 +185,11 @@ void CullStack::pushProjectionMatrix(RefMatrix* matrix)
|
||||
if (itr->matchProjectionMatrix(*matrix))
|
||||
{
|
||||
//std::cout << " ** activating occluder"<<std::endl;
|
||||
cullingSet->addOccluder(*itr);
|
||||
cullingSet.addOccluder(*itr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_projectionCullingStack.push_back(cullingSet);
|
||||
|
||||
// need to recompute frustum volume.
|
||||
_frustumVolume = -1.0f;
|
||||
|
||||
@@ -2025,7 +2025,7 @@ bool _verifyBindings(const osg::Geometry& geom, const A& arrayData)
|
||||
}
|
||||
|
||||
template<class A>
|
||||
bool _computeCorrectBindingsAndArraySizes(const osg::Geometry& geom, A& arrayData, const char* arrayName)
|
||||
void _computeCorrectBindingsAndArraySizes(const osg::Geometry& geom, A& arrayData, const char* arrayName)
|
||||
{
|
||||
if (!geom.getVertexArray() || geom.getVertexArray()==0)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,8 @@ using namespace osgGA;
|
||||
|
||||
AnimationPathManipulator::AnimationPathManipulator(osg::AnimationPath* animationPath)
|
||||
{
|
||||
_printOutTiminInfo = true;
|
||||
|
||||
_animationPath = animationPath;
|
||||
_timeOffset = 0.0;
|
||||
_timeScale = 1.0;
|
||||
@@ -17,6 +19,8 @@ AnimationPathManipulator::AnimationPathManipulator(osg::AnimationPath* animation
|
||||
|
||||
AnimationPathManipulator::AnimationPathManipulator( const std::string& filename )
|
||||
{
|
||||
_printOutTiminInfo = true;
|
||||
|
||||
_animationPath = new osg::AnimationPath;
|
||||
_animationPath->setLoopMode(osg::AnimationPath::LOOP);
|
||||
_timeOffset = 0.0f;
|
||||
@@ -140,19 +144,22 @@ void AnimationPathManipulator::handleFrame( double time )
|
||||
|
||||
++_numOfFramesSinceStartOfTimedPeriod;
|
||||
|
||||
double delta = (animTime-_animStartOfTimedPeriod);
|
||||
if (delta>=_animationPath->getPeriod())
|
||||
if (_printOutTiminInfo)
|
||||
{
|
||||
double frameRate = (double)_numOfFramesSinceStartOfTimedPeriod/delta;
|
||||
osg::notify(osg::INFO) <<"AnimatonPath completed in "<<delta<<" seconds, completing "<<_numOfFramesSinceStartOfTimedPeriod<<" frames,"<<std::endl;
|
||||
osg::notify(osg::INFO) <<" average frame rate = "<<frameRate<<std::endl;
|
||||
|
||||
// reset counters for next loop.
|
||||
_realStartOfTimedPeriod = time;
|
||||
_animStartOfTimedPeriod = animTime;
|
||||
|
||||
_numOfFramesSinceStartOfTimedPeriod = 0;
|
||||
}
|
||||
double delta = (animTime-_animStartOfTimedPeriod);
|
||||
if (delta>=_animationPath->getPeriod())
|
||||
{
|
||||
double frameRate = (double)_numOfFramesSinceStartOfTimedPeriod/delta;
|
||||
osg::notify(osg::NOTICE) <<"AnimatonPath completed in "<<delta<<" seconds, completing "<<_numOfFramesSinceStartOfTimedPeriod<<" frames,"<<std::endl;
|
||||
osg::notify(osg::NOTICE) <<" average frame rate = "<<frameRate<<std::endl;
|
||||
|
||||
// reset counters for next loop.
|
||||
_realStartOfTimedPeriod = time;
|
||||
_animStartOfTimedPeriod = animTime;
|
||||
|
||||
_numOfFramesSinceStartOfTimedPeriod = 0;
|
||||
}
|
||||
}
|
||||
|
||||
cp.getMatrix( _matrix );
|
||||
}
|
||||
|
||||
@@ -60,11 +60,17 @@ class IVEReaderWriter : public ReaderWriter
|
||||
return result;
|
||||
}
|
||||
|
||||
virtual WriteResult writeNode(const Node& node,std::ostream& fout, const osgDB::ReaderWriter::Options*)
|
||||
virtual WriteResult writeNode(const Node& node,std::ostream& fout, const osgDB::ReaderWriter::Options* options)
|
||||
{
|
||||
try
|
||||
{
|
||||
ive::DataOutputStream out(&fout);
|
||||
|
||||
if (options)
|
||||
{
|
||||
out.setIncludeImageData(options->getOptionString().find("noTexturesInIVEFile")==std::string::npos);
|
||||
osg::notify(osg::DEBUG_INFO) << "ive::DataOutpouStream.setIncludeImageData()=" << out.getIncludeImageData() << std::endl;
|
||||
}
|
||||
|
||||
out.writeNode(const_cast<osg::Node*>(&node));
|
||||
return WriteResult::FILE_SAVED;
|
||||
|
||||
Reference in New Issue
Block a user