Move terrain grid implementation to a component so the editor can use it (Feature #1597)

deque
scrawl 11 years ago
parent 982453d4f6
commit 8c26f802e6

@ -23,7 +23,7 @@ add_openmw_dir (mwrender
renderingmanager debugging sky camera animation npcanimation creatureanimation activatoranimation renderingmanager debugging sky camera animation npcanimation creatureanimation activatoranimation
actors objects renderinginterface localmap occlusionquery water shadows actors objects renderinginterface localmap occlusionquery water shadows
characterpreview globalmap videoplayer ripplesimulation refraction characterpreview globalmap videoplayer ripplesimulation refraction
terrainstorage renderconst effectmanager weaponanimation terraingrid terrainstorage renderconst effectmanager weaponanimation
) )
add_openmw_dir (mwinput add_openmw_dir (mwinput

@ -23,6 +23,7 @@
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include <components/terrain/defaultworld.hpp> #include <components/terrain/defaultworld.hpp>
#include <components/terrain/terraingrid.hpp>
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
@ -45,7 +46,6 @@
#include "globalmap.hpp" #include "globalmap.hpp"
#include "terrainstorage.hpp" #include "terrainstorage.hpp"
#include "effectmanager.hpp" #include "effectmanager.hpp"
#include "terraingrid.hpp"
using namespace MWRender; using namespace MWRender;
using namespace Ogre; using namespace Ogre;
@ -1045,7 +1045,7 @@ void RenderingManager::enableTerrain(bool enable)
mTerrain = new Terrain::DefaultWorld(mRendering.getScene(), new MWRender::TerrainStorage(), RV_Terrain, mTerrain = new Terrain::DefaultWorld(mRendering.getScene(), new MWRender::TerrainStorage(), RV_Terrain,
Settings::Manager::getBool("shader", "Terrain"), Terrain::Align_XY, 1, 64); Settings::Manager::getBool("shader", "Terrain"), Terrain::Align_XY, 1, 64);
else 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); Settings::Manager::getBool("shader", "Terrain"), Terrain::Align_XY);
mTerrain->applyMaterials(Settings::Manager::getBool("enabled", "Shadows"), mTerrain->applyMaterials(Settings::Manager::getBool("enabled", "Shadows"),
Settings::Manager::getBool("split", "Shadows")); Settings::Manager::getBool("split", "Shadows"));

@ -76,7 +76,7 @@ add_component_dir (translation
add_definitions(-DTERRAIN_USE_SHADER=1) add_definitions(-DTERRAIN_USE_SHADER=1)
add_component_dir (terrain 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 add_component_dir (loadinglistener

@ -4,12 +4,9 @@
#include <OgreSceneNode.h> #include <OgreSceneNode.h>
#include <OgreAxisAlignedBox.h> #include <OgreAxisAlignedBox.h>
#include "../mwbase/environment.hpp" #include "chunk.hpp"
#include "../mwbase/world.hpp"
#include <components/terrain/chunk.hpp> namespace Terrain
namespace MWRender
{ {
TerrainGrid::TerrainGrid(Ogre::SceneManager *sceneMgr, Terrain::Storage *storage, int visibilityFlags, bool shaders, Terrain::Alignment align) 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) Ogre::AxisAlignedBox TerrainGrid::getWorldBoundingBox (const Ogre::Vector2& center)
{ {
int cellX, cellY; float cellSize = getStorage()->getCellWorldSize();
MWBase::Environment::get().getWorld()->positionToIndex(center.x, center.y, cellX, cellY);
int cellX = std::floor(center.x/cellSize);
int cellY = std::floor(center.y/cellSize);
Grid::iterator it = mGrid.find(std::make_pair(cellX, cellY)); Grid::iterator it = mGrid.find(std::make_pair(cellX, cellY));
if (it == mGrid.end()) if (it == mGrid.end())

@ -1,16 +1,12 @@
#ifndef OPENMW_MWRENDER_TERRAINGRID_H #ifndef COMPONENTS_TERRAIN_TERRAINGRID_H
#define OPENMW_MWRENDER_TERRAINGRID_H #define COMPONENTS_TERRAIN_TERRAINGRID_H
#include <components/terrain/world.hpp> #include "world.hpp"
#include <components/terrain/material.hpp> #include "material.hpp"
namespace Terrain namespace Terrain
{ {
class Chunk; class Chunk;
}
namespace MWRender
{
struct GridElement struct GridElement
{ {
Loading…
Cancel
Save