Addd OsgSceneHandler::s/getCleanUpOnNextFrame() and support for it in the draw() method,
when CleanUpOnNextFrame is enabled the next frame simple deleted OpenGL objects without doing any draw traversal.
This commit is contained in:
parent
e9c25115fb
commit
e8d6df7583
@ -76,18 +76,26 @@ class OSGPRODUCER_EXPORT OsgSceneHandler : public Producer::Camera::SceneHandler
|
|||||||
Callback* getCullCallback() { return _cullCallback.get(); }
|
Callback* getCullCallback() { return _cullCallback.get(); }
|
||||||
const Callback* getCullCallback() const { return _cullCallback.get(); }
|
const Callback* getCullCallback() const { return _cullCallback.get(); }
|
||||||
|
|
||||||
|
|
||||||
virtual void draw(Producer::Camera& camera)
|
virtual void draw(Producer::Camera& camera)
|
||||||
{
|
{
|
||||||
if (_flushOfAllDeletedGLObjectsOnNextFrame && _sceneView.valid())
|
if (_cleanUpOnNextFrame)
|
||||||
{
|
{
|
||||||
_sceneView->flushAllDeletedGLObjects();
|
_sceneView->flushAllDeletedGLObjects();
|
||||||
|
_flushOfAllDeletedGLObjectsOnNextFrame = false;
|
||||||
|
_cleanUpOnNextFrame = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_flushOfAllDeletedGLObjectsOnNextFrame && _sceneView.valid())
|
||||||
|
{
|
||||||
|
_sceneView->flushAllDeletedGLObjects();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_drawCallback.valid()) (*_drawCallback)(*this,camera);
|
||||||
|
else drawImplementation(camera);
|
||||||
|
|
||||||
|
_flushOfAllDeletedGLObjectsOnNextFrame = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_drawCallback.valid()) (*_drawCallback)(*this,camera);
|
|
||||||
else drawImplementation(camera);
|
|
||||||
|
|
||||||
_flushOfAllDeletedGLObjectsOnNextFrame = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void drawImplementation(Producer::Camera& camera);
|
virtual void drawImplementation(Producer::Camera& camera);
|
||||||
@ -102,6 +110,10 @@ class OSGPRODUCER_EXPORT OsgSceneHandler : public Producer::Camera::SceneHandler
|
|||||||
|
|
||||||
bool getFlushOfAllDeletedGLObjectsOnNextFrame() const { return _flushOfAllDeletedGLObjectsOnNextFrame; }
|
bool getFlushOfAllDeletedGLObjectsOnNextFrame() const { return _flushOfAllDeletedGLObjectsOnNextFrame; }
|
||||||
|
|
||||||
|
void setCleanUpOnNextFrame(bool flag) { _cleanUpOnNextFrame = flag; }
|
||||||
|
|
||||||
|
bool getCleanUpOnNextFrame() const { return _cleanUpOnNextFrame; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual ~OsgSceneHandler() {}
|
virtual ~OsgSceneHandler() {}
|
||||||
@ -117,6 +129,7 @@ class OSGPRODUCER_EXPORT OsgSceneHandler : public Producer::Camera::SceneHandler
|
|||||||
osg::Timer_t _previousFrameStartTick;
|
osg::Timer_t _previousFrameStartTick;
|
||||||
|
|
||||||
bool _flushOfAllDeletedGLObjectsOnNextFrame;
|
bool _flushOfAllDeletedGLObjectsOnNextFrame;
|
||||||
|
bool _cleanUpOnNextFrame;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -736,7 +736,7 @@ void OsgCameraGroup::cleanup_frame()
|
|||||||
++itr)
|
++itr)
|
||||||
{
|
{
|
||||||
(*itr)->getSceneView()->releaseAllGLObjects();
|
(*itr)->getSceneView()->releaseAllGLObjects();
|
||||||
(*itr)->setFlushOfAllDeletedGLObjectsOnNextFrame(true);
|
(*itr)->setCleanUpOnNextFrame(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure that the registry all flushes all its texture objects.
|
// make sure that the registry all flushes all its texture objects.
|
||||||
|
@ -26,6 +26,7 @@ OsgSceneHandler::OsgSceneHandler( osg::DisplaySettings *ds) :
|
|||||||
_frameStartTick = 0;
|
_frameStartTick = 0;
|
||||||
_previousFrameStartTick = 0;
|
_previousFrameStartTick = 0;
|
||||||
_flushOfAllDeletedGLObjectsOnNextFrame = false;
|
_flushOfAllDeletedGLObjectsOnNextFrame = false;
|
||||||
|
_cleanUpOnNextFrame = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsgSceneHandler::init()
|
void OsgSceneHandler::init()
|
||||||
|
@ -45,6 +45,9 @@ BEGIN_OBJECT_REFLECTOR(osgProducer::OsgSceneHandler)
|
|||||||
I_Method1(void, setContextID, IN, int, id);
|
I_Method1(void, setContextID, IN, int, id);
|
||||||
I_Method1(void, setFlushOfAllDeletedGLObjectsOnNextFrame, IN, bool, flag);
|
I_Method1(void, setFlushOfAllDeletedGLObjectsOnNextFrame, IN, bool, flag);
|
||||||
I_Method0(bool, getFlushOfAllDeletedGLObjectsOnNextFrame);
|
I_Method0(bool, getFlushOfAllDeletedGLObjectsOnNextFrame);
|
||||||
|
I_Method1(void, setCleanUpOnNextFrame, IN, bool, flag);
|
||||||
|
I_Method0(bool, getCleanUpOnNextFrame);
|
||||||
|
I_Property(bool, CleanUpOnNextFrame);
|
||||||
I_Property(osgProducer::OsgSceneHandler::Callback *, ClearCallback);
|
I_Property(osgProducer::OsgSceneHandler::Callback *, ClearCallback);
|
||||||
I_WriteOnlyProperty(int, ContextID);
|
I_WriteOnlyProperty(int, ContextID);
|
||||||
I_Property(osgProducer::OsgSceneHandler::Callback *, CullCallback);
|
I_Property(osgProducer::OsgSceneHandler::Callback *, CullCallback);
|
||||||
|
Loading…
Reference in New Issue
Block a user