Fix self-referencing camera

openmw-37
scrawl 9 years ago
parent 7776c49fc1
commit 8e3bc981a2

@ -62,9 +62,8 @@ namespace
class CameraUpdateGlobalCallback : public osg::NodeCallback class CameraUpdateGlobalCallback : public osg::NodeCallback
{ {
public: public:
CameraUpdateGlobalCallback(osg::Camera* cam, MWRender::GlobalMap* parent) CameraUpdateGlobalCallback(MWRender::GlobalMap* parent)
: mRendered(false) : mRendered(false)
, mCamera(cam)
, mParent(parent) , mParent(parent)
{ {
} }
@ -73,7 +72,7 @@ namespace
{ {
if (mRendered) if (mRendered)
{ {
mCamera->setNodeMask(0); node->setNodeMask(0);
return; return;
} }
@ -82,13 +81,12 @@ namespace
if (!mRendered) if (!mRendered)
{ {
mRendered = true; mRendered = true;
mParent->markForRemoval(mCamera); mParent->markForRemoval(static_cast<osg::Camera*>(node));
} }
} }
private: private:
bool mRendered; bool mRendered;
osg::ref_ptr<osg::Camera> mCamera;
MWRender::GlobalMap* mParent; MWRender::GlobalMap* mParent;
}; };
@ -263,7 +261,7 @@ namespace MWRender
else else
camera->setClearMask(GL_NONE); camera->setClearMask(GL_NONE);
camera->setUpdateCallback(new CameraUpdateGlobalCallback(camera, this)); camera->setUpdateCallback(new CameraUpdateGlobalCallback(this));
camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT, osg::Camera::PIXEL_BUFFER_RTT); camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT, osg::Camera::PIXEL_BUFFER_RTT);
camera->attach(osg::Camera::COLOR_BUFFER, mOverlayTexture); camera->attach(osg::Camera::COLOR_BUFFER, mOverlayTexture);

@ -30,22 +30,21 @@ namespace
class CameraLocalUpdateCallback : public osg::NodeCallback class CameraLocalUpdateCallback : public osg::NodeCallback
{ {
public: public:
CameraLocalUpdateCallback(osg::Camera* cam, MWRender::LocalMap* parent) CameraLocalUpdateCallback(MWRender::LocalMap* parent)
: mRendered(false) : mRendered(false)
, mCamera(cam)
, mParent(parent) , mParent(parent)
{ {
} }
virtual void operator()(osg::Node*, osg::NodeVisitor*) virtual void operator()(osg::Node* node, osg::NodeVisitor*)
{ {
if (mRendered) if (mRendered)
mCamera->setNodeMask(0); node->setNodeMask(0);
if (!mRendered) if (!mRendered)
{ {
mRendered = true; mRendered = true;
mParent->markForRemoval(mCamera); mParent->markForRemoval(static_cast<osg::Camera*>(node));
} }
// Note, we intentionally do not traverse children here. The map camera's scene data is the same as the master camera's, // Note, we intentionally do not traverse children here. The map camera's scene data is the same as the master camera's,
@ -55,7 +54,6 @@ namespace
private: private:
bool mRendered; bool mRendered;
osg::ref_ptr<osg::Camera> mCamera;
MWRender::LocalMap* mParent; MWRender::LocalMap* mParent;
}; };
@ -205,7 +203,7 @@ osg::ref_ptr<osg::Camera> LocalMap::createOrthographicCamera(float x, float y, f
camera->setStateSet(stateset); camera->setStateSet(stateset);
camera->setGraphicsContext(mViewer->getCamera()->getGraphicsContext()); camera->setGraphicsContext(mViewer->getCamera()->getGraphicsContext());
camera->setViewport(0, 0, mMapResolution, mMapResolution); camera->setViewport(0, 0, mMapResolution, mMapResolution);
camera->setUpdateCallback(new CameraLocalUpdateCallback(camera, this)); camera->setUpdateCallback(new CameraLocalUpdateCallback(this));
return camera; return camera;
} }

Loading…
Cancel
Save