Remove more unused code

This commit is contained in:
scrawl 2013-12-16 15:35:06 +01:00
parent 19e5978a01
commit eb5e4ecec2
8 changed files with 7 additions and 254 deletions

View file

@ -19,7 +19,7 @@ source_group(game FILES ${GAME} ${GAME_HEADER})
add_openmw_dir (mwrender
renderingmanager debugging sky camera animation npcanimation creatureanimation activatoranimation
actors objects renderinginterface localmap occlusionquery water shadows
compositors characterpreview externalrendering globalmap videoplayer ripplesimulation refraction
characterpreview externalrendering globalmap videoplayer ripplesimulation refraction
terrainstorage
)

View file

@ -80,7 +80,6 @@ namespace MWBase
Render_CollisionDebug,
Render_Wireframe,
Render_Pathgrid,
Render_Compositors,
Render_BoundingBoxes
};

View file

@ -1,8 +1,6 @@
#include "loadingscreen.hpp"
#include <OgreRenderWindow.h>
#include <OgreCompositorManager.h>
#include <OgreCompositorChain.h>
#include <openengine/ogre/fader.hpp>
@ -199,28 +197,7 @@ namespace MWGui
MWBase::Environment::get().getInputManager()->update(0, true);
Ogre::CompositorChain* chain = Ogre::CompositorManager::getSingleton().getCompositorChain(mWindow->getViewport(0));
bool hasCompositor = chain->getCompositor ("gbufferFinalizer");
if (!hasCompositor)
{
mWindow->getViewport(0)->setClearEveryFrame(false);
}
else
{
if (!mFirstLoad)
{
mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(chain->getCompositor ("gbufferFinalizer")->getTextureInstance ("no_mrt_output", 0)->getName());
mRectangle->setVisible(true);
}
for (unsigned int i = 0; i<chain->getNumCompositors(); ++i)
{
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), chain->getCompositor(i)->getCompositor()->getName(), false);
}
}
mWindow->getViewport(0)->setClearEveryFrame(false);
// First, swap buffers from last draw, then, queue an update of the
// window contents, but don't swap buffers (which would have
@ -231,15 +208,8 @@ namespace MWGui
mWindow->update(false);
if (!hasCompositor)
mWindow->getViewport(0)->setClearEveryFrame(true);
else
{
for (unsigned int i = 0; i<chain->getNumCompositors(); ++i)
{
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), chain->getCompositor(i)->getCompositor()->getName(), true);
}
}
mWindow->getViewport(0)->setClearEveryFrame(true);
mRectangle->setVisible(false);

View file

@ -1,108 +0,0 @@
#include "compositors.hpp"
#include <OgreViewport.h>
#include <OgreCompositorManager.h>
#include <OgreCompositorChain.h>
#include <OgreCompositionTargetPass.h>
using namespace MWRender;
Compositors::Compositors(Ogre::Viewport* vp) :
mViewport(vp)
, mEnabled(true)
{
}
Compositors::~Compositors()
{
Ogre::CompositorManager::getSingleton().removeCompositorChain(mViewport);
}
void Compositors::setEnabled (const bool enabled)
{
for (CompositorMap::iterator it=mCompositors.begin();
it != mCompositors.end(); ++it)
{
Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, it->first, enabled && it->second.first);
}
mEnabled = enabled;
}
void Compositors::recreate()
{
Ogre::CompositorManager::getSingleton().removeCompositorChain(mViewport);
CompositorMap temp = mCompositors;
mCompositors.clear();
for (CompositorMap::iterator it=temp.begin();
it != temp.end(); ++it)
{
addCompositor(it->first, it->second.second);
setCompositorEnabled(it->first, mEnabled && it->second.first);
}
}
void Compositors::addCompositor (const std::string& name, const int priority)
{
int id = 0;
for (CompositorMap::iterator it=mCompositors.begin();
it != mCompositors.end(); ++it)
{
if (it->second.second > priority)
break;
++id;
}
Ogre::CompositorManager::getSingleton().addCompositor (mViewport, name, id);
mCompositors[name] = std::make_pair(false, priority);
}
void Compositors::setCompositorEnabled (const std::string& name, const bool enabled)
{
mCompositors[name].first = enabled;
Ogre::CompositorManager::getSingleton().setCompositorEnabled (mViewport, name, enabled && mEnabled);
}
void Compositors::removeAll()
{
Ogre::CompositorManager::getSingleton().removeCompositorChain(mViewport);
mCompositors.clear();
}
bool Compositors::anyCompositorEnabled()
{
for (CompositorMap::iterator it=mCompositors.begin();
it != mCompositors.end(); ++it)
{
if (it->second.first && mEnabled)
return true;
}
return false;
}
void Compositors::countTrianglesBatches(unsigned int &triangles, unsigned int &batches)
{
triangles = 0;
batches = 0;
Ogre::CompositorInstance* c = NULL;
Ogre::CompositorChain* chain = Ogre::CompositorManager::getSingleton().getCompositorChain (mViewport);
// accumulate tris & batches from all compositors with all their render targets
for (unsigned int i=0; i < chain->getNumCompositors(); ++i)
{
if (chain->getCompositor(i)->getEnabled())
{
c = chain->getCompositor(i);
for (unsigned int j = 0; j < c->getTechnique()->getNumTargetPasses(); ++j)
{
std::string textureName = c->getTechnique()->getTargetPass(j)->getOutputName();
Ogre::RenderTarget* rt = c->getRenderTarget(textureName);
triangles += rt->getTriangleCount();
batches += rt->getBatchCount();
}
}
}
}

View file

@ -1,64 +0,0 @@
#ifndef GAME_MWRENDER_COMPOSITORS_H
#define GAME_MWRENDER_COMPOSITORS_H
#include <map>
#include <string>
namespace Ogre
{
class Viewport;
}
namespace MWRender
{
typedef std::map < std::string, std::pair<bool, int> > CompositorMap;
/// \brief Manages a set of compositors for one viewport
class Compositors
{
public:
Compositors(Ogre::Viewport* vp);
virtual ~Compositors();
/**
* enable or disable all compositors globally
*/
void setEnabled (const bool enabled);
void setViewport(Ogre::Viewport* vp) { mViewport = vp; }
/// recreate compositors (call this after viewport size changes)
void recreate();
bool toggle() { setEnabled(!mEnabled); return mEnabled; }
/**
* enable or disable a specific compositor
* @note enable has no effect if all compositors are globally disabled
*/
void setCompositorEnabled (const std::string& name, const bool enabled);
/**
* @param name of compositor
* @param priority, lower number will be first in the chain
*/
void addCompositor (const std::string& name, const int priority);
bool anyCompositorEnabled();
void countTrianglesBatches(unsigned int &triangles, unsigned int &batches);
void removeAll ();
protected:
/// maps compositor name to its "enabled" state
CompositorMap mCompositors;
bool mEnabled;
Ogre::Viewport* mViewport;
};
}
#endif

View file

@ -8,10 +8,6 @@
#include <OgreViewport.h>
#include <OgreCamera.h>
#include <OgreTextureManager.h>
#include <OgreCompositorManager.h>
#include <OgreCompositorChain.h>
#include <OgreCompositionTargetPass.h>
#include <OgreCompositionPass.h>
#include <OgreHardwarePixelBuffer.h>
#include <OgreControllerManager.h>
#include <OgreMeshManager.h>
@ -43,7 +39,6 @@
#include "shadows.hpp"
#include "localmap.hpp"
#include "water.hpp"
#include "compositors.hpp"
#include "npcanimation.hpp"
#include "externalrendering.hpp"
#include "globalmap.hpp"
@ -87,8 +82,6 @@ RenderingManager::RenderingManager(OEngine::Render::OgreRenderer& _rend, const b
mRendering.getWindow()->addListener(this);
mRendering.setWindowListener(this);
mCompositors = new Compositors(mRendering.getViewport());
mWater = 0;
// material system
@ -157,8 +150,6 @@ RenderingManager::RenderingManager(OEngine::Render::OgreRenderer& _rend, const b
sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false");
sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makeProperty<sh::Vector4> (new sh::Vector4(0,0,0,0)));
applyCompositors();
mRootNode = mRendering.getScene()->getRootSceneNode();
mRootNode->createChildSceneNode("player");
@ -198,7 +189,6 @@ RenderingManager::~RenderingManager ()
delete mTerrain;
delete mLocalMap;
delete mOcclusionQuery;
delete mCompositors;
delete mWater;
delete mVideoPlayer;
delete mActors;
@ -478,29 +468,21 @@ bool RenderingManager::toggleRenderMode(int mode)
{
if (mRendering.getCamera()->getPolygonMode() == PM_SOLID)
{
mCompositors->setEnabled(false);
mRendering.getCamera()->setPolygonMode(PM_WIREFRAME);
return true;
}
else
{
mCompositors->setEnabled(true);
mRendering.getCamera()->setPolygonMode(PM_SOLID);
return false;
}
}
else if (mode == MWBase::World::Render_BoundingBoxes)
else //if (mode == MWBase::World::Render_BoundingBoxes)
{
bool show = !mRendering.getScene()->getShowBoundingBoxes();
mRendering.getScene()->showBoundingBoxes(show);
return show;
}
else //if (mode == MWBase::World::Render_Compositors)
{
return mCompositors->toggle();
}
}
void RenderingManager::configureFog(MWWorld::Ptr::CellStore &mCell)
@ -745,11 +727,6 @@ Ogre::Vector4 RenderingManager::boundingBoxToScreen(Ogre::AxisAlignedBox bounds)
return Vector4(min_x, min_y, max_x, max_y);
}
Compositors* RenderingManager::getCompositors()
{
return mCompositors;
}
void RenderingManager::processChangedSettings(const Settings::CategorySettingVector& settings)
{
bool changeRes = false;
@ -795,7 +772,6 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec
}
else if (it->second == "shader" && it->first == "Water")
{
applyCompositors();
sh::Factory::getInstance ().setGlobalSetting ("simple_water", Settings::Manager::getBool("shader", "Water") ? "false" : "true");
rebuild = true;
mRendering.getViewport ()->setClearEveryFrame (true);
@ -883,28 +859,16 @@ void RenderingManager::windowResized(int x, int y)
Settings::Manager::setInt("resolution x", "Video", x);
Settings::Manager::setInt("resolution y", "Video", y);
mRendering.adjustViewport();
mCompositors->recreate();
mVideoPlayer->setResolution (x, y);
MWBase::Environment::get().getWindowManager()->windowResized(x,y);
}
void RenderingManager::applyCompositors()
{
}
void RenderingManager::getTriangleBatchCount(unsigned int &triangles, unsigned int &batches)
{
if (mCompositors->anyCompositorEnabled())
{
mCompositors->countTrianglesBatches(triangles, batches);
}
else
{
triangles = mRendering.getWindow()->getTriangleCount();
batches = mRendering.getWindow()->getBatchCount();
}
batches = mRendering.getWindow()->getBatchCount();
triangles = mRendering.getWindow()->getTriangleCount();
}
void RenderingManager::setupPlayer(const MWWorld::Ptr &ptr)

View file

@ -48,7 +48,6 @@ namespace MWRender
class Shadows;
class LocalMap;
class Water;
class Compositors;
class ExternalRendering;
class GlobalMap;
class VideoPlayer;
@ -96,7 +95,6 @@ public:
void renderPlayer(const MWWorld::Ptr &ptr);
SkyManager* getSkyManager();
Compositors* getCompositors();
void toggleLight();
bool toggleRenderMode(int mode);
@ -224,8 +222,6 @@ private:
void setMenuTransparency(float val);
void applyCompositors();
bool mSunEnabled;
MWWorld::Fallback* mFallback;
@ -269,8 +265,6 @@ private:
MWRender::Shadows* mShadows;
MWRender::Compositors* mCompositors;
VideoPlayer* mVideoPlayer;
};

View file

@ -133,8 +133,6 @@ namespace MWRender {
RenderingManager* mRendering;
SkyManager* mSky;
std::string mCompositorName;
Ogre::MaterialPtr mMaterial;
bool mUnderwaterEffect;