Added support for an View::Slave::UpdateSlaveCallback
This commit is contained in:
@@ -92,6 +92,7 @@ class OSG_EXPORT View : public virtual osg::Object
|
||||
/** Get the frame stamp of the view. */
|
||||
const osg::FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
|
||||
|
||||
|
||||
/** Slave allows one to up a camera that follows the master with a local offset to the project and view matrices.*/
|
||||
struct Slave
|
||||
{
|
||||
@@ -108,7 +109,8 @@ class OSG_EXPORT View : public virtual osg::Object
|
||||
_camera(rhs._camera),
|
||||
_projectionOffset(rhs._projectionOffset),
|
||||
_viewOffset(rhs._viewOffset),
|
||||
_useMastersSceneData(rhs._useMastersSceneData) {}
|
||||
_useMastersSceneData(rhs._useMastersSceneData),
|
||||
_updateSlaveCallback(rhs._updateSlaveCallback) {}
|
||||
|
||||
Slave& operator = (const Slave& rhs)
|
||||
{
|
||||
@@ -116,13 +118,28 @@ class OSG_EXPORT View : public virtual osg::Object
|
||||
_projectionOffset = rhs._projectionOffset;
|
||||
_viewOffset = rhs._viewOffset;
|
||||
_useMastersSceneData = rhs._useMastersSceneData;
|
||||
_updateSlaveCallback = rhs._updateSlaveCallback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Camera> _camera;
|
||||
osg::Matrixd _projectionOffset;
|
||||
osg::Matrixd _viewOffset;
|
||||
bool _useMastersSceneData;
|
||||
struct UpdateSlaveCallback : public virtual Referenced
|
||||
{
|
||||
virtual void updateSlave(osg::View& view, osg::View::Slave& slave) = 0;
|
||||
};
|
||||
|
||||
void updateSlave(View& view)
|
||||
{
|
||||
if (_updateSlaveCallback.valid()) _updateSlaveCallback->updateSlave(view, *this);
|
||||
else updateSlaveImplementation(view);
|
||||
}
|
||||
|
||||
virtual void updateSlaveImplementation(View& view);
|
||||
|
||||
osg::ref_ptr<osg::Camera> _camera;
|
||||
osg::Matrixd _projectionOffset;
|
||||
osg::Matrixd _viewOffset;
|
||||
bool _useMastersSceneData;
|
||||
osg::ref_ptr<UpdateSlaveCallback> _updateSlaveCallback;
|
||||
};
|
||||
|
||||
bool addSlave(osg::Camera* camera, bool useMastersSceneData=true) { return addSlave(camera, osg::Matrix::identity(), osg::Matrix::identity(), useMastersSceneData); }
|
||||
@@ -142,9 +159,6 @@ class OSG_EXPORT View : public virtual osg::Object
|
||||
|
||||
void updateSlaves();
|
||||
|
||||
void updateSlave(unsigned int i);
|
||||
|
||||
|
||||
protected :
|
||||
|
||||
virtual ~View();
|
||||
|
||||
Reference in New Issue
Block a user