1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-21 21:39:40 +00:00

Minor cleanup

This commit is contained in:
scrawl 2015-05-23 23:10:53 +02:00
parent da24e298ee
commit 152d690a7a
6 changed files with 42 additions and 42 deletions

View file

@ -22,8 +22,8 @@ source_group(game FILES ${GAME} ${GAME_HEADER})
add_openmw_dir (mwrender add_openmw_dir (mwrender
actors objects renderingmanager animation sky npcanimation vismask actors objects renderingmanager animation sky npcanimation vismask
creatureanimation effectmanager util renderinginterface pathgrid rendermode creatureanimation effectmanager util renderinginterface pathgrid rendermode
bulletdebugdraw globalmap characterpreview camera bulletdebugdraw globalmap characterpreview camera localmap
# localmap occlusionquery water shadows # occlusionquery water shadows
# ripplesimulation refraction # ripplesimulation refraction
# terrainstorage weaponanimation # terrainstorage weaponanimation
) )

View file

@ -1148,9 +1148,9 @@ namespace MWClass
if (ptr.getClass().getNpcStats(ptr).isWerewolf() if (ptr.getClass().getNpcStats(ptr).isWerewolf()
&& ptr.getClass().getCreatureStats(ptr).getStance(MWMechanics::CreatureStats::Stance_Run)) && ptr.getClass().getCreatureStats(ptr).getStance(MWMechanics::CreatureStats::Stance_Run))
{ {
//MWMechanics::WeaponType weaponType = MWMechanics::WeapType_None; MWMechanics::WeaponType weaponType = MWMechanics::WeapType_None;
//MWMechanics::getActiveWeapon(ptr.getClass().getCreatureStats(ptr), ptr.getClass().getInventoryStore(ptr), &weaponType); MWMechanics::getActiveWeapon(ptr.getClass().getCreatureStats(ptr), ptr.getClass().getInventoryStore(ptr), &weaponType);
//if (weaponType == MWMechanics::WeapType_None) if (weaponType == MWMechanics::WeapType_None)
return ""; return "";
} }

View file

@ -10,6 +10,7 @@
#include <OgreViewport.h> #include <OgreViewport.h>
#include <components/esm/fogstate.hpp> #include <components/esm/fogstate.hpp>
#include <components/settings/settings.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
@ -18,30 +19,20 @@
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp" #include "../mwworld/cellstore.hpp"
#include "renderconst.hpp"
#include "renderingmanager.hpp"
using namespace MWRender; using namespace MWRender;
using namespace Ogre; using namespace Ogre;
LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManager* rendering) LocalMap::LocalMap()
: mMapResolution(Settings::Manager::getInt("local map resolution", "Map")) : mMapResolution(Settings::Manager::getInt("local map resolution", "Map"))
, mAngle(0.f) , mAngle(0.f)
, mInterior(false) , mInterior(false)
{ {
mRendering = rend; // mCellCamera = mRendering->getScene()->createCamera("CellCamera");
mRenderingManager = rendering;
mCameraPosNode = mRendering->getScene()->getRootSceneNode()->createChildSceneNode();
mCameraRotNode = mCameraPosNode->createChildSceneNode();
mCameraNode = mCameraRotNode->createChildSceneNode();
mCellCamera = mRendering->getScene()->createCamera("CellCamera");
mCellCamera->setProjectionType(PT_ORTHOGRAPHIC); mCellCamera->setProjectionType(PT_ORTHOGRAPHIC);
mCameraNode->attachObject(mCellCamera); mCameraNode->attachObject(mCellCamera);
mLight = mRendering->getScene()->createLight();
mLight->setType (Ogre::Light::LT_DIRECTIONAL); mLight->setType (Ogre::Light::LT_DIRECTIONAL);
mLight->setDirection (Ogre::Vector3(0.3f, 0.3f, -0.7f)); mLight->setDirection (Ogre::Vector3(0.3f, 0.3f, -0.7f));
mLight->setVisible (false); mLight->setVisible (false);
@ -62,7 +53,6 @@ LocalMap::LocalMap(OEngine::Render::OgreRenderer* rend, MWRender::RenderingManag
vp->setOverlaysEnabled(false); vp->setOverlaysEnabled(false);
vp->setShadowsEnabled(false); vp->setShadowsEnabled(false);
vp->setBackgroundColour(ColourValue(0, 0, 0)); vp->setBackgroundColour(ColourValue(0, 0, 0));
vp->setVisibilityMask(RV_Map);
vp->setMaterialScheme("local_map"); vp->setMaterialScheme("local_map");
} }
@ -83,12 +73,11 @@ std::string LocalMap::coordStr(const int x, const int y)
void LocalMap::clear() void LocalMap::clear()
{ {
// Not actually removing the Textures here. That doesnt appear to work properly. It seems MyGUI still keeps some pointers.
mBuffers.clear();
} }
void LocalMap::saveFogOfWar(MWWorld::CellStore* cell) void LocalMap::saveFogOfWar(MWWorld::CellStore* cell)
{ {
/*
if (!mInterior) if (!mInterior)
{ {
std::string textureName = "Cell_"+coordStr(cell->getCell()->getGridX(), cell->getCell()->getGridY())+"_fog"; std::string textureName = "Cell_"+coordStr(cell->getCell()->getGridX(), cell->getCell()->getGridY())+"_fog";
@ -156,6 +145,7 @@ void LocalMap::saveFogOfWar(MWWorld::CellStore* cell)
cell->setFog(fog.release()); cell->setFog(fog.release());
} }
*/
} }
void LocalMap::requestMap(MWWorld::CellStore* cell, float zMin, float zMax) void LocalMap::requestMap(MWWorld::CellStore* cell, float zMin, float zMax)
@ -177,6 +167,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell, float zMin, float zMax)
// (and objects in a different cell can "bleed" into another cell's map if they cross the border) // (and objects in a different cell can "bleed" into another cell's map if they cross the border)
render((x+0.5f)*sSize, (y+0.5f)*sSize, zMin, zMax, static_cast<float>(sSize), static_cast<float>(sSize), name, true); render((x+0.5f)*sSize, (y+0.5f)*sSize, zMin, zMax, static_cast<float>(sSize), static_cast<float>(sSize), name, true);
/*
if (mBuffers.find(name) == mBuffers.end()) if (mBuffers.find(name) == mBuffers.end())
{ {
if (cell->getFog()) if (cell->getFog())
@ -184,6 +175,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell, float zMin, float zMax)
else else
createFogOfWar(name); createFogOfWar(name);
} }
*/
} }
void LocalMap::requestMap(MWWorld::CellStore* cell, void LocalMap::requestMap(MWWorld::CellStore* cell,
@ -241,6 +233,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell,
// If they changed by too much (for bounds, < padding is considered acceptable) then parts of the interior might not // If they changed by too much (for bounds, < padding is considered acceptable) then parts of the interior might not
// be covered by the map anymore. // be covered by the map anymore.
// The following code detects this, and discards the CellStore's fog state if it needs to. // The following code detects this, and discards the CellStore's fog state if it needs to.
/*
if (cell->getFog()) if (cell->getFog())
{ {
ESM::FogState* fog = cell->getFog(); ESM::FogState* fog = cell->getFog();
@ -265,6 +258,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell,
mAngle = fog->mNorthMarkerAngle; mAngle = fog->mNorthMarkerAngle;
} }
} }
*/
Vector2 center(mBounds.getCenter().x, mBounds.getCenter().y); Vector2 center(mBounds.getCenter().x, mBounds.getCenter().y);
@ -296,6 +290,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell,
render(newcenter.x - center.x, newcenter.y - center.y, zMin, zMax, static_cast<float>(sSize), static_cast<float>(sSize), texturePrefix); render(newcenter.x - center.x, newcenter.y - center.y, zMin, zMax, static_cast<float>(sSize), static_cast<float>(sSize), texturePrefix);
/*
if (!cell->getFog()) if (!cell->getFog())
createFogOfWar(texturePrefix); createFogOfWar(texturePrefix);
else else
@ -309,6 +304,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell,
ESM::FogTexture& esm = fog->mFogTextures[i]; ESM::FogTexture& esm = fog->mFogTextures[i];
loadFogOfWar(texturePrefix, esm); loadFogOfWar(texturePrefix, esm);
} }
*/
++i; ++i;
} }
} }
@ -316,6 +312,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell,
void LocalMap::createFogOfWar(const std::string& texturePrefix) void LocalMap::createFogOfWar(const std::string& texturePrefix)
{ {
/*
const std::string texName = texturePrefix + "_fog"; const std::string texName = texturePrefix + "_fog";
TexturePtr tex = createFogOfWarTexture(texName); TexturePtr tex = createFogOfWarTexture(texName);
@ -331,12 +328,14 @@ void LocalMap::createFogOfWar(const std::string& texturePrefix)
tex->getBuffer()->unlock(); tex->getBuffer()->unlock();
mBuffers[texturePrefix] = buffer; mBuffers[texturePrefix] = buffer;
*/
} }
Ogre::TexturePtr LocalMap::createFogOfWarTexture(const std::string &texName) Ogre::TexturePtr LocalMap::createFogOfWarTexture(const std::string &texName)
{ {
TexturePtr tex = TextureManager::getSingleton().getByName(texName); TexturePtr tex;// = TextureManager::getSingleton().getByName(texName);
if (tex.isNull()) /*
* if (tex.isNull())
{ {
tex = TextureManager::getSingleton().createManual( tex = TextureManager::getSingleton().createManual(
texName, texName,
@ -349,12 +348,14 @@ Ogre::TexturePtr LocalMap::createFogOfWarTexture(const std::string &texName)
this // ManualResourceLoader required if the texture contents are lost (due to lost devices nonsense that can occur with D3D) this // ManualResourceLoader required if the texture contents are lost (due to lost devices nonsense that can occur with D3D)
); );
} }
*/
return tex; return tex;
} }
void LocalMap::loadFogOfWar (const std::string& texturePrefix, ESM::FogTexture& esm) void LocalMap::loadFogOfWar (const std::string& texturePrefix, ESM::FogTexture& esm)
{ {
/*
std::vector<char>& data = esm.mImageData; std::vector<char>& data = esm.mImageData;
Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream(&data[0], data.size())); Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream(&data[0], data.size()));
Ogre::Image image; Ogre::Image image;
@ -376,6 +377,7 @@ void LocalMap::loadFogOfWar (const std::string& texturePrefix, ESM::FogTexture&
memcpy(&buffer[0], image.getData(), image.getSize()); memcpy(&buffer[0], image.getData(), image.getSize());
mBuffers[texturePrefix] = buffer; mBuffers[texturePrefix] = buffer;
*/
} }
void LocalMap::render(const float x, const float y, void LocalMap::render(const float x, const float y,
@ -390,15 +392,12 @@ void LocalMap::render(const float x, const float y,
// disable fog (only necessary for fixed function, the shader based // disable fog (only necessary for fixed function, the shader based
// materials already do this through local_map material configuration) // materials already do this through local_map material configuration)
float oldFogStart = mRendering->getScene()->getFogStart(); //mRendering->getScene()->setFog(FOG_NONE);
float oldFogEnd = mRendering->getScene()->getFogEnd();
Ogre::ColourValue oldFogColour = mRendering->getScene()->getFogColour();
mRendering->getScene()->setFog(FOG_NONE);
// set up lighting // set up lighting
Ogre::ColourValue oldAmbient = mRendering->getScene()->getAmbientLight(); //Ogre::ColourValue oldAmbient = mRendering->getScene()->getAmbientLight();
mRendering->getScene()->setAmbientLight(Ogre::ColourValue(0.3f, 0.3f, 0.3f)); //mRendering->getScene()->setAmbientLight(Ogre::ColourValue(0.3f, 0.3f, 0.3f));
mRenderingManager->disableLights(true); //mRenderingManager->disableLights(true);
mLight->setVisible(true); mLight->setVisible(true);
TexturePtr tex; TexturePtr tex;
@ -425,12 +424,12 @@ void LocalMap::render(const float x, const float y,
tex->getBuffer()->blit(mRenderTexture->getBuffer()); tex->getBuffer()->blit(mRenderTexture->getBuffer());
} }
mRenderingManager->enableLights(true); //mRenderingManager->enableLights(true);
mLight->setVisible(false); mLight->setVisible(false);
// re-enable fog // re-enable fog
mRendering->getScene()->setFog(FOG_LINEAR, oldFogColour, 0, oldFogStart, oldFogEnd); //mRendering->getScene()->setFog(FOG_LINEAR, oldFogColour, 0, oldFogStart, oldFogEnd);
mRendering->getScene()->setAmbientLight(oldAmbient); //mRendering->getScene()->setAmbientLight(oldAmbient);
} }
void LocalMap::worldToInteriorMapPosition (Ogre::Vector2 pos, float& nX, float& nY, int& x, int& y) void LocalMap::worldToInteriorMapPosition (Ogre::Vector2 pos, float& nX, float& nY, int& x, int& y)
@ -460,6 +459,8 @@ Ogre::Vector2 LocalMap::interiorMapToWorldPosition (float nX, float nY, int x, i
bool LocalMap::isPositionExplored (float nX, float nY, int x, int y, bool interior) bool LocalMap::isPositionExplored (float nX, float nY, int x, int y, bool interior)
{ {
return false;
/*
std::string texName = (interior ? mInteriorName + "_" : "Cell_") + coordStr(x, y); std::string texName = (interior ? mInteriorName + "_" : "Cell_") + coordStr(x, y);
if (mBuffers.find(texName) == mBuffers.end()) if (mBuffers.find(texName) == mBuffers.end())
@ -474,10 +475,12 @@ bool LocalMap::isPositionExplored (float nX, float nY, int x, int y, bool interi
Ogre::uint32 clr = mBuffers[texName][texV * sFogOfWarResolution + texU]; Ogre::uint32 clr = mBuffers[texName][texV * sFogOfWarResolution + texU];
uint8 alpha = (clr >> 24); uint8 alpha = (clr >> 24);
return alpha < 200; return alpha < 200;
*/
} }
void LocalMap::loadResource(Ogre::Resource* resource) void LocalMap::loadResource(Ogre::Resource* resource)
{ {
/*
std::string resourceName = resource->getName(); std::string resourceName = resource->getName();
size_t pos = resourceName.find("_fog"); size_t pos = resourceName.find("_fog");
if (pos != std::string::npos) if (pos != std::string::npos)
@ -498,10 +501,12 @@ void LocalMap::loadResource(Ogre::Resource* resource)
tex->createInternalResources(); tex->createInternalResources();
memcpy(tex->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), &buffer[0], sFogOfWarResolution*sFogOfWarResolution*4); memcpy(tex->getBuffer()->lock(HardwareBuffer::HBL_DISCARD), &buffer[0], sFogOfWarResolution*sFogOfWarResolution*4);
tex->getBuffer()->unlock(); tex->getBuffer()->unlock();
*/
} }
void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaternion& orientation) void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaternion& orientation)
{ {
/*
if (sFogOfWarSkip != 0) if (sFogOfWarSkip != 0)
{ {
static int count=0; static int count=0;
@ -607,4 +612,5 @@ void LocalMap::updatePlayer (const Ogre::Vector3& position, const Ogre::Quaterni
} }
} }
} }
*/
} }

View file

@ -1,8 +1,6 @@
#ifndef GAME_RENDER_LOCALMAP_H #ifndef GAME_RENDER_LOCALMAP_H
#define GAME_RENDER_LOCALMAP_H #define GAME_RENDER_LOCALMAP_H
#include <openengine/ogre/renderer.hpp>
#include <OgreAxisAlignedBox.h> #include <OgreAxisAlignedBox.h>
#include <OgreColourValue.h> #include <OgreColourValue.h>
#include <OgreResource.h> #include <OgreResource.h>
@ -24,10 +22,10 @@ namespace MWRender
/// ///
/// \brief Local map rendering /// \brief Local map rendering
/// ///
class LocalMap : public Ogre::ManualResourceLoader class LocalMap
{ {
public: public:
LocalMap(OEngine::Render::OgreRenderer*, MWRender::RenderingManager* rendering); LocalMap();
~LocalMap(); ~LocalMap();
virtual void loadResource(Ogre::Resource* resource); virtual void loadResource(Ogre::Resource* resource);
@ -84,9 +82,6 @@ namespace MWRender
bool isPositionExplored (float nX, float nY, int x, int y, bool interior); bool isPositionExplored (float nX, float nY, int x, int y, bool interior);
private: private:
OEngine::Render::OgreRenderer* mRendering;
MWRender::RenderingManager* mRenderingManager;
int mMapResolution; int mMapResolution;
// the dynamic texture is a bottleneck, so don't set this too high // the dynamic texture is a bottleneck, so don't set this too high

View file

@ -1,6 +1,7 @@
#include "loudness.hpp" #include "loudness.hpp"
#include <stdint.h> #include <stdint.h>
#include <limits>
#include "soundmanagerimp.hpp" #include "soundmanagerimp.hpp"
@ -31,7 +32,7 @@ namespace MWSound
else if (type == SampleType_Int16) else if (type == SampleType_Int16)
{ {
value = *reinterpret_cast<const uint16_t*>(&data[sample*advance]); value = *reinterpret_cast<const uint16_t*>(&data[sample*advance]);
value /= float(std::numeric_limits<Ogre::int16>::max()); value /= float(std::numeric_limits<uint16_t>::max());
} }
else if (type == SampleType_Float32) else if (type == SampleType_Float32)
{ {

View file

@ -7,8 +7,6 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <OgreVector3.h>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"