From fa76d1631b35895d8b61034e789c714cd7abeb8c Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 20 Aug 2013 12:08:46 +0200 Subject: [PATCH] Some terrain fixes --- apps/openmw/mwrender/renderingmanager.cpp | 3 ++- apps/openmw/mwworld/worldimp.cpp | 9 +++------ components/terrain/quadtreenode.cpp | 4 ++-- components/terrain/storage.hpp | 2 ++ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 2d129a3fb..44f421a6e 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -1003,7 +1003,8 @@ void RenderingManager::resetCamera() float RenderingManager::getTerrainHeightAt(Ogre::Vector3 worldPos) { - assert(mTerrain); + if (!mTerrain || !mTerrain->getVisible()) + return -std::numeric_limits::max(); return mTerrain->getHeightAt(worldPos); } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index aceb9fe34..b44ca3069 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1027,13 +1027,10 @@ namespace MWWorld return; } - if (ptr.getCell()->isExterior()) - { - float terrainHeight = mRendering->getTerrainHeightAt(pos); + float terrainHeight = mRendering->getTerrainHeightAt(pos); - if (pos.z < terrainHeight) - pos.z = terrainHeight; - } + if (pos.z < terrainHeight) + pos.z = terrainHeight; ptr.getRefData().getPosition().pos[2] = pos.z + 20; // place slightly above. will snap down to ground with code below diff --git a/components/terrain/quadtreenode.cpp b/components/terrain/quadtreenode.cpp index ec6a670dc..7faf81a5c 100644 --- a/components/terrain/quadtreenode.cpp +++ b/components/terrain/quadtreenode.cpp @@ -46,12 +46,12 @@ namespace // Algorithm described by Hanan Samet - 'Neighbour Finding in Quadtrees' // http://www.cs.umd.edu/~hjs/pubs/SametPRIP81.pdf - Terrain::QuadTreeNode* searchNeighbourRecursive (Terrain::QuadTreeNode* currentNode, Terrain::Direction dir) + QuadTreeNode* searchNeighbourRecursive (QuadTreeNode* currentNode, Direction dir) { if (!currentNode->getParent()) return NULL; // Arrived at root node, the root node does not have neighbours - Terrain::QuadTreeNode* nextNode; + QuadTreeNode* nextNode; if (adjacent(currentNode->getDirection(), dir)) nextNode = searchNeighbourRecursive(currentNode->getParent(), dir); else diff --git a/components/terrain/storage.hpp b/components/terrain/storage.hpp index 419439e19..b82f6bbb6 100644 --- a/components/terrain/storage.hpp +++ b/components/terrain/storage.hpp @@ -14,6 +14,8 @@ namespace Terrain /// We keep storage of terrain data abstract here since we need different implementations for game and editor class Storage { + public: + virtual ~Storage() {} private: virtual ESM::Land* getLand (int cellX, int cellY) = 0; virtual const ESM::LandTexture* getLandTexture(int index, short plugin) = 0;