diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 9e4a8a0ac..6df6210ee 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -23,7 +23,7 @@ add_openmw_dir (mwrender renderingmanager debugging sky camera animation npcanimation creatureanimation activatoranimation actors objects renderinginterface localmap occlusionquery water shadows characterpreview globalmap videoplayer ripplesimulation refraction - terrainstorage renderconst effectmanager weaponanimation terraingrid + terrainstorage renderconst effectmanager weaponanimation ) add_openmw_dir (mwinput diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index a1d34f12f..ed6b56f37 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -23,6 +23,7 @@ #include #include +#include #include "../mwworld/esmstore.hpp" #include "../mwworld/class.hpp" @@ -45,7 +46,6 @@ #include "globalmap.hpp" #include "terrainstorage.hpp" #include "effectmanager.hpp" -#include "terraingrid.hpp" using namespace MWRender; using namespace Ogre; @@ -1045,7 +1045,7 @@ void RenderingManager::enableTerrain(bool enable) mTerrain = new Terrain::DefaultWorld(mRendering.getScene(), new MWRender::TerrainStorage(), RV_Terrain, Settings::Manager::getBool("shader", "Terrain"), Terrain::Align_XY, 1, 64); else - mTerrain = new MWRender::TerrainGrid(mRendering.getScene(), new MWRender::TerrainStorage(), RV_Terrain, + mTerrain = new Terrain::TerrainGrid(mRendering.getScene(), new MWRender::TerrainStorage(), RV_Terrain, Settings::Manager::getBool("shader", "Terrain"), Terrain::Align_XY); mTerrain->applyMaterials(Settings::Manager::getBool("enabled", "Shadows"), Settings::Manager::getBool("split", "Shadows")); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 5fb0f3d14..2ff2dc3db 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -76,7 +76,7 @@ add_component_dir (translation add_definitions(-DTERRAIN_USE_SHADER=1) add_component_dir (terrain - quadtreenode chunk world defaultworld storage material buffercache defs + quadtreenode chunk world defaultworld terraingrid storage material buffercache defs ) add_component_dir (loadinglistener diff --git a/apps/openmw/mwrender/terraingrid.cpp b/components/terrain/terraingrid.cpp similarity index 95% rename from apps/openmw/mwrender/terraingrid.cpp rename to components/terrain/terraingrid.cpp index f2bd92061..fe322a6bf 100644 --- a/apps/openmw/mwrender/terraingrid.cpp +++ b/components/terrain/terraingrid.cpp @@ -4,12 +4,9 @@ #include #include -#include "../mwbase/environment.hpp" -#include "../mwbase/world.hpp" +#include "chunk.hpp" -#include - -namespace MWRender +namespace Terrain { TerrainGrid::TerrainGrid(Ogre::SceneManager *sceneMgr, Terrain::Storage *storage, int visibilityFlags, bool shaders, Terrain::Alignment align) @@ -145,8 +142,10 @@ void TerrainGrid::setVisible(bool visible) Ogre::AxisAlignedBox TerrainGrid::getWorldBoundingBox (const Ogre::Vector2& center) { - int cellX, cellY; - MWBase::Environment::get().getWorld()->positionToIndex(center.x, center.y, cellX, cellY); + float cellSize = getStorage()->getCellWorldSize(); + + int cellX = std::floor(center.x/cellSize); + int cellY = std::floor(center.y/cellSize); Grid::iterator it = mGrid.find(std::make_pair(cellX, cellY)); if (it == mGrid.end()) diff --git a/apps/openmw/mwrender/terraingrid.hpp b/components/terrain/terraingrid.hpp similarity index 93% rename from apps/openmw/mwrender/terraingrid.hpp rename to components/terrain/terraingrid.hpp index 1b5250dcf..7cbf45576 100644 --- a/apps/openmw/mwrender/terraingrid.hpp +++ b/components/terrain/terraingrid.hpp @@ -1,16 +1,12 @@ -#ifndef OPENMW_MWRENDER_TERRAINGRID_H -#define OPENMW_MWRENDER_TERRAINGRID_H +#ifndef COMPONENTS_TERRAIN_TERRAINGRID_H +#define COMPONENTS_TERRAIN_TERRAINGRID_H -#include -#include +#include "world.hpp" +#include "material.hpp" namespace Terrain { class Chunk; -} - -namespace MWRender -{ struct GridElement {