mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 06:15:35 +00:00
Update overlays independently from multiple viewports.
This commit is contained in:
parent
47c5bc9a19
commit
e58e5c2bf5
9 changed files with 146 additions and 6 deletions
|
@ -82,7 +82,7 @@ opencs_units (view/render
|
||||||
|
|
||||||
opencs_units_noqt (view/render
|
opencs_units_noqt (view/render
|
||||||
navigation navigation1st navigationfree navigationorbit lighting lightingday lightingnight
|
navigation navigation1st navigationfree navigationorbit lighting lightingday lightingnight
|
||||||
lightingbright object cell textoverlay
|
lightingbright object cell textoverlay overlaymask
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_hdrs_noqt (view/render
|
opencs_hdrs_noqt (view/render
|
||||||
|
|
52
apps/opencs/view/render/overlaymask.cpp
Normal file
52
apps/opencs/view/render/overlaymask.cpp
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#include "overlaymask.hpp"
|
||||||
|
|
||||||
|
#include <OgreOverlayManager.h>
|
||||||
|
#include <OgreOverlayContainer.h>
|
||||||
|
|
||||||
|
#include "textoverlay.hpp"
|
||||||
|
#include "../../model/world/cellcoordinates.hpp"
|
||||||
|
|
||||||
|
namespace CSVRender
|
||||||
|
{
|
||||||
|
|
||||||
|
// ideas from http://www.ogre3d.org/forums/viewtopic.php?f=5&t=44828#p486334
|
||||||
|
OverlayMask::OverlayMask(std::map<CSMWorld::CellCoordinates, TextOverlay *> &overlays, Ogre::Viewport* viewport)
|
||||||
|
: mTextOverlays(overlays), mViewport(viewport)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
OverlayMask::~OverlayMask()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void OverlayMask::setViewport(Ogre::Viewport *viewport)
|
||||||
|
{
|
||||||
|
mViewport = viewport;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OverlayMask::preViewportUpdate(const Ogre::RenderTargetViewportEvent &event)
|
||||||
|
{
|
||||||
|
if(event.source == mViewport)
|
||||||
|
{
|
||||||
|
Ogre::OverlayManager &overlayMgr = Ogre::OverlayManager::getSingleton();
|
||||||
|
for(Ogre::OverlayManager::OverlayMapIterator iter = overlayMgr.getOverlayIterator();
|
||||||
|
iter.hasMoreElements();)
|
||||||
|
{
|
||||||
|
Ogre::Overlay* item = iter.getNext();
|
||||||
|
for(Ogre::Overlay::Overlay2DElementsIterator it = item->get2DElementsIterator();
|
||||||
|
it.hasMoreElements();)
|
||||||
|
{
|
||||||
|
Ogre::OverlayContainer* container = it.getNext();
|
||||||
|
container->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<CSMWorld::CellCoordinates, TextOverlay *>::iterator it = mTextOverlays.begin();
|
||||||
|
for(; it != mTextOverlays.end(); ++it)
|
||||||
|
{
|
||||||
|
it->second->show(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
42
apps/opencs/view/render/overlaymask.hpp
Normal file
42
apps/opencs/view/render/overlaymask.hpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#ifndef OPENCS_VIEW_OVERLAYMASK_H
|
||||||
|
#define OPENCS_VIEW_OVERLAYMASK_H
|
||||||
|
|
||||||
|
#include <OgreRenderTargetListener.h>
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class Viewport;
|
||||||
|
class RendertargetViewportEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSMWorld
|
||||||
|
{
|
||||||
|
class CellCoordinates;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSVRender
|
||||||
|
{
|
||||||
|
class TextOverlay;
|
||||||
|
|
||||||
|
class OverlayMask : public Ogre::RenderTargetListener
|
||||||
|
{
|
||||||
|
|
||||||
|
std::map<CSMWorld::CellCoordinates, TextOverlay *> &mTextOverlays;
|
||||||
|
Ogre::Viewport* mViewport;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
OverlayMask(std::map<CSMWorld::CellCoordinates, TextOverlay *> &overlays,
|
||||||
|
Ogre::Viewport* viewport);
|
||||||
|
|
||||||
|
virtual ~OverlayMask();
|
||||||
|
|
||||||
|
void setViewport(Ogre::Viewport *viewport);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void preViewportUpdate(const Ogre::RenderTargetViewportEvent &event) override;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // OPENCS_VIEW_OVERLAYMASK_H
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include <components/esm/loadland.hpp>
|
#include <components/esm/loadland.hpp>
|
||||||
#include "textoverlay.hpp"
|
#include "textoverlay.hpp"
|
||||||
|
#include "overlaymask.hpp"
|
||||||
|
|
||||||
#include "../../model/world/tablemimedata.hpp"
|
#include "../../model/world/tablemimedata.hpp"
|
||||||
#include "../../model/world/idtable.hpp"
|
#include "../../model/world/idtable.hpp"
|
||||||
|
@ -89,6 +90,7 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
||||||
it->second->setDesc(region);
|
it->second->setDesc(region);
|
||||||
it->second->update();
|
it->second->update();
|
||||||
}
|
}
|
||||||
|
modified = true;
|
||||||
}
|
}
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
@ -155,6 +157,11 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
||||||
textDisp->setDesc(desc); // FIXME: config setting
|
textDisp->setDesc(desc); // FIXME: config setting
|
||||||
textDisp->update();
|
textDisp->update();
|
||||||
mTextOverlays.insert(std::make_pair(*iter, textDisp));
|
mTextOverlays.insert(std::make_pair(*iter, textDisp));
|
||||||
|
if(!mOverlayMask)
|
||||||
|
{
|
||||||
|
mOverlayMask = new OverlayMask(mTextOverlays, getViewport());
|
||||||
|
addRenderTargetListener(mOverlayMask);
|
||||||
|
}
|
||||||
|
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +296,7 @@ std::string CSVRender::PagedWorldspaceWidget::getStartupInstruction()
|
||||||
|
|
||||||
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc::Document& document)
|
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc::Document& document)
|
||||||
: WorldspaceWidget (document, parent), mDocument (document), mWorldspace ("std::default"),
|
: WorldspaceWidget (document, parent), mDocument (document), mWorldspace ("std::default"),
|
||||||
mControlElements(NULL), mDisplayCellCoord(true)
|
mControlElements(NULL), mDisplayCellCoord(true), mOverlayMask(NULL)
|
||||||
{
|
{
|
||||||
QAbstractItemModel *cells =
|
QAbstractItemModel *cells =
|
||||||
document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells);
|
document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells);
|
||||||
|
@ -317,6 +324,9 @@ CSVRender::PagedWorldspaceWidget::~PagedWorldspaceWidget()
|
||||||
{
|
{
|
||||||
delete iter->second;
|
delete iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeRenderTargetListener(mOverlayMask);
|
||||||
|
delete mOverlayMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::PagedWorldspaceWidget::useViewHint (const std::string& hint)
|
void CSVRender::PagedWorldspaceWidget::useViewHint (const std::string& hint)
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace CSVRender
|
||||||
{
|
{
|
||||||
|
|
||||||
class TextOverlay;
|
class TextOverlay;
|
||||||
|
class OverlayMask;
|
||||||
|
|
||||||
class PagedWorldspaceWidget : public WorldspaceWidget
|
class PagedWorldspaceWidget : public WorldspaceWidget
|
||||||
{
|
{
|
||||||
|
@ -24,6 +25,7 @@ namespace CSVRender
|
||||||
CSVWidget::SceneToolToggle *mControlElements;
|
CSVWidget::SceneToolToggle *mControlElements;
|
||||||
bool mDisplayCellCoord;
|
bool mDisplayCellCoord;
|
||||||
std::map<CSMWorld::CellCoordinates, TextOverlay *> mTextOverlays;
|
std::map<CSMWorld::CellCoordinates, TextOverlay *> mTextOverlays;
|
||||||
|
OverlayMask *mOverlayMask;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -190,6 +190,24 @@ namespace CSVRender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SceneWidget::addRenderTargetListener(Ogre::RenderTargetListener *listener)
|
||||||
|
{
|
||||||
|
mWindow->addListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SceneWidget::removeRenderTargetListener(Ogre::RenderTargetListener *listener)
|
||||||
|
{
|
||||||
|
mWindow->removeListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ogre::Viewport *SceneWidget::getViewport()
|
||||||
|
{
|
||||||
|
if (!mWindow)
|
||||||
|
updateOgreWindow();
|
||||||
|
|
||||||
|
return mViewport;
|
||||||
|
}
|
||||||
|
|
||||||
Ogre::SceneManager *SceneWidget::getSceneManager()
|
Ogre::SceneManager *SceneWidget::getSceneManager()
|
||||||
{
|
{
|
||||||
return mSceneMgr;
|
return mSceneMgr;
|
||||||
|
|
|
@ -16,6 +16,7 @@ namespace Ogre
|
||||||
class RenderWindow;
|
class RenderWindow;
|
||||||
class Viewport;
|
class Viewport;
|
||||||
class OverlaySystem;
|
class OverlaySystem;
|
||||||
|
class RenderTargetListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CSVWidget
|
namespace CSVWidget
|
||||||
|
@ -51,6 +52,12 @@ namespace CSVRender
|
||||||
void setNavigation (Navigation *navigation);
|
void setNavigation (Navigation *navigation);
|
||||||
///< \attention The ownership of \a navigation is not transferred to *this.
|
///< \attention The ownership of \a navigation is not transferred to *this.
|
||||||
|
|
||||||
|
void addRenderTargetListener(Ogre::RenderTargetListener *listener);
|
||||||
|
|
||||||
|
void removeRenderTargetListener(Ogre::RenderTargetListener *listener);
|
||||||
|
|
||||||
|
Ogre::Viewport *getViewport();
|
||||||
|
|
||||||
Ogre::SceneManager *getSceneManager();
|
Ogre::SceneManager *getSceneManager();
|
||||||
|
|
||||||
Ogre::Camera *getCamera();
|
Ogre::Camera *getCamera();
|
||||||
|
|
|
@ -217,6 +217,14 @@ TextOverlay::~TextOverlay()
|
||||||
overlayMgr->destroy(mOverlay);
|
overlayMgr->destroy(mOverlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextOverlay::show(bool show)
|
||||||
|
{
|
||||||
|
if(show)
|
||||||
|
mContainer->show();
|
||||||
|
else
|
||||||
|
mContainer->hide();
|
||||||
|
}
|
||||||
|
|
||||||
void TextOverlay::enable(bool enable)
|
void TextOverlay::enable(bool enable)
|
||||||
{
|
{
|
||||||
if(enable == mOverlay->isVisible())
|
if(enable == mOverlay->isVisible())
|
||||||
|
|
|
@ -49,12 +49,13 @@ namespace CSVRender
|
||||||
TextOverlay(const Ogre::MovableObject* obj, const Ogre::Camera* camera, const Ogre::String &id);
|
TextOverlay(const Ogre::MovableObject* obj, const Ogre::Camera* camera, const Ogre::String &id);
|
||||||
virtual ~TextOverlay();
|
virtual ~TextOverlay();
|
||||||
|
|
||||||
void enable(bool enable);
|
void enable(bool enable); // controlled from scene widget toolbar visibility mask
|
||||||
|
void show(bool show); // for updating from render target listener
|
||||||
bool isEnabled();
|
bool isEnabled();
|
||||||
void setCaption(const Ogre::String& text);
|
void setCaption(const Ogre::String& text);
|
||||||
void setDesc(const Ogre::String& text);
|
void setDesc(const Ogre::String& text);
|
||||||
void update();
|
void update();
|
||||||
QRect container();
|
QRect container(); // for detection of mouse click on the overlay
|
||||||
Ogre::String getCaption() { return mCaption; } // FIXME: debug
|
Ogre::String getCaption() { return mCaption; } // FIXME: debug
|
||||||
Ogre::String getDesc() { return mDesc; }
|
Ogre::String getDesc() { return mDesc; }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue