Added support into osg::RenderInfo for a stack of Cameras that allow querries

of which camera is currently active to be querried from within the draw traversal.
This commit is contained in:
Robert Osfield 2007-07-14 17:07:59 +00:00
parent af19e71024
commit 1f0edca631
3 changed files with 19 additions and 2 deletions

View File

@ -30,6 +30,7 @@ public:
RenderInfo(const RenderInfo& rhs):
_state(rhs._state),
_view(rhs._view),
_cameras(rhs._cameras),
_userData(rhs._userData) {}
RenderInfo(State* state, View* view):
@ -40,6 +41,7 @@ public:
{
_state = rhs._state;
_view = rhs._view;
_cameras = rhs._cameras;
_userData = rhs._userData;
return *this;
}
@ -54,14 +56,22 @@ public:
View* getView() { return _view.get(); }
const View* getView() const { return _view.get(); }
void pushCamera(Camera* camera) { _cameras.push_back(camera); }
void popCamera() { if (_cameras.empty()) _cameras.pop_back(); }
Camera* getCurrentCamera() { return _cameras.empty() ? 0 : _cameras.back(); }
void setUserData(Referenced* userData) { _userData = userData; }
Referenced* getUserData() { return _userData.get(); }
const Referenced* getUserData() const { return _userData.get(); }
protected:
typedef std::vector<Camera*> Cameras;
ref_ptr<State> _state;
observer_ptr<View> _view;
Cameras _cameras;
ref_ptr<Referenced> _userData;
};

View File

@ -989,6 +989,9 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr
return;
}
// push the stages camera so that drawing code can querry it
if (_camera) renderInfo.pushCamera(_camera);
// set up the back buffer.
state.applyAttribute(_viewport.get());
@ -1048,6 +1051,10 @@ void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& pr
RenderBin::drawImplementation(renderInfo,previous);
state.apply();
// pop the render stages camera.
if (_camera) renderInfo.popCamera();
}
void RenderStage::drawPostRenderStages(osg::RenderInfo& renderInfo,RenderLeaf*& previous)