Fix self-referencing camera

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

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

@ -30,22 +30,21 @@ namespace
class CameraLocalUpdateCallback : public osg::NodeCallback
{
public:
CameraLocalUpdateCallback(osg::Camera* cam, MWRender::LocalMap* parent)
CameraLocalUpdateCallback(MWRender::LocalMap* parent)
: mRendered(false)
, mCamera(cam)
, mParent(parent)
{
}
virtual void operator()(osg::Node*, osg::NodeVisitor*)
virtual void operator()(osg::Node* node, osg::NodeVisitor*)
{
if (mRendered)
mCamera->setNodeMask(0);
node->setNodeMask(0);
if (!mRendered)
{
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,
@ -55,7 +54,6 @@ namespace
private:
bool mRendered;
osg::ref_ptr<osg::Camera> mCamera;
MWRender::LocalMap* mParent;
};
@ -205,7 +203,7 @@ osg::ref_ptr<osg::Camera> LocalMap::createOrthographicCamera(float x, float y, f
camera->setStateSet(stateset);
camera->setGraphicsContext(mViewer->getCamera()->getGraphicsContext());
camera->setViewport(0, 0, mMapResolution, mMapResolution);
camera->setUpdateCallback(new CameraLocalUpdateCallback(camera, this));
camera->setUpdateCallback(new CameraLocalUpdateCallback(this));
return camera;
}

Loading…
Cancel
Save