Improvements to osgProducer lib, in particular adding a mutex lock to the init() call in
SceneView to prevent init running multi-threaded.
This commit is contained in:
@@ -18,6 +18,9 @@ class OSGPRODUCER_EXPORT SceneHandler : public Producer::Camera::SceneHandler, p
|
||||
|
||||
SceneHandler( osg::DisplaySettings *ds = NULL);
|
||||
|
||||
/// override the init method to force it be run one at a time.
|
||||
virtual void init();
|
||||
|
||||
void cull(Producer::Camera &cam);
|
||||
|
||||
void draw(Producer::Camera &);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#include <osgProducer/SceneHandler>
|
||||
#include <Producer/Mutex>
|
||||
|
||||
using namespace osgUtil;
|
||||
using namespace osgProducer;
|
||||
@@ -14,8 +15,28 @@ SceneHandler::SceneHandler( osg::DisplaySettings *ds = NULL) :
|
||||
pm = new osg::RefMatrix;
|
||||
}
|
||||
|
||||
void SceneHandler::init()
|
||||
{
|
||||
static Producer::Mutex mutex;
|
||||
osg::notify(osg::INFO)<<"entering "<<this<<" init."<<std::endl;
|
||||
mutex.lock();
|
||||
osg::notify(osg::INFO)<<" running "<<this<<" init."<<std::endl;
|
||||
|
||||
SceneView::init();
|
||||
|
||||
osg::notify(osg::INFO)<<" done "<<this<<" init."<<std::endl;
|
||||
mutex.unlock();
|
||||
osg::notify(osg::INFO)<<" unlocked "<<this<<" init."<<std::endl;
|
||||
}
|
||||
|
||||
|
||||
void SceneHandler::cull(Producer::Camera &cam)
|
||||
{
|
||||
// static Producer::Mutex mutex;
|
||||
// osg::notify(osg::INFO)<<"entering "<<this<<" cull."<<std::endl;
|
||||
// mutex.lock();
|
||||
// osg::notify(osg::INFO)<<" running "<<this<<" cull."<<std::endl;
|
||||
|
||||
pm->set(cam.getProjectionMatrix());
|
||||
mm->set(cam.getPositionAndAttitudeMatrix());
|
||||
setProjectionMatrix( pm.get() );
|
||||
@@ -28,11 +49,24 @@ void SceneHandler::cull(Producer::Camera &cam)
|
||||
setViewport( x, y, w, h );
|
||||
|
||||
SceneView::cull();
|
||||
|
||||
// osg::notify(osg::INFO)<<" done "<<this<<" cull."<<std::endl;
|
||||
// mutex.unlock();
|
||||
// osg::notify(osg::INFO)<<" unlocked "<<this<<" cull."<<std::endl;
|
||||
}
|
||||
|
||||
void SceneHandler::draw(Producer::Camera &)
|
||||
{
|
||||
// static Producer::Mutex mutex;
|
||||
// osg::notify(osg::INFO)<<"entering "<<this<<" draw."<<std::endl;
|
||||
// mutex.lock();
|
||||
// osg::notify(osg::INFO)<<" running "<<this<<" draw."<<std::endl;
|
||||
//
|
||||
SceneView::draw();
|
||||
|
||||
// osg::notify(osg::INFO)<<" done "<<this<<" draw."<<std::endl;
|
||||
// mutex.unlock();
|
||||
// osg::notify(osg::INFO)<<" unlocked "<<this<<" draw."<<std::endl;
|
||||
}
|
||||
|
||||
void SceneHandler::setContextID( int id )
|
||||
|
||||
Reference in New Issue
Block a user