diff --git a/apps/opencs/view/render/terrainstorage.hpp b/apps/opencs/view/render/terrainstorage.hpp index 032261ad47..74c30ce5c6 100644 --- a/apps/opencs/view/render/terrainstorage.hpp +++ b/apps/opencs/view/render/terrainstorage.hpp @@ -18,6 +18,8 @@ namespace CSVRender TerrainStorage(const CSMWorld::Data& data); void setAlteredHeight(int inCellX, int inCellY, float heightMap); void resetHeights(); + + virtual bool useAlteration() const { return true; } float getSumOfAlteredAndTrueHeight(int cellX, int cellY, int inCellX, int inCellY); float* getAlteredHeight(int inCellX, int inCellY); diff --git a/components/esmterrain/storage.cpp b/components/esmterrain/storage.cpp index 52af530f5b..021ae32e90 100644 --- a/components/esmterrain/storage.cpp +++ b/components/esmterrain/storage.cpp @@ -201,6 +201,8 @@ namespace ESMTerrain LandCache cache; + bool alteration = useAlteration(); + float vertY_ = 0; // of current cell corner for (int cellY = startCellY; cellY < startCellY + std::ceil(size); ++cellY) { @@ -251,11 +253,12 @@ namespace ESMTerrain float height = defaultHeight; if (heightData) height = heightData->mHeights[col*ESM::Land::LAND_SIZE + row]; - + if (alteration) + height += getAlteredHeight(col, row); (*positions)[static_cast(vertX*numVerts + vertY)] = osg::Vec3f((vertX / float(numVerts - 1) - 0.5f) * size * Constants::CellSizeInUnits, (vertY / float(numVerts - 1) - 0.5f) * size * Constants::CellSizeInUnits, - height + getAlteredHeight(col, row)); + height); if (normalData) { @@ -290,8 +293,8 @@ namespace ESMTerrain color.g() = 255; color.b() = 255; } - - adjustColor(col, row, heightData, color); //Does nothing by default, override in OpenMW-CS + if (alteration) + adjustColor(col, row, heightData, color); //Does nothing by default, override in OpenMW-CS // Unlike normals, colors mostly connect seamlessly between cells, but not always... if (col == ESM::Land::LAND_SIZE-1 || row == ESM::Land::LAND_SIZE-1) diff --git a/components/esmterrain/storage.hpp b/components/esmterrain/storage.hpp index 65e531e5c5..a5f62ba48d 100644 --- a/components/esmterrain/storage.hpp +++ b/components/esmterrain/storage.hpp @@ -125,6 +125,7 @@ namespace ESMTerrain inline const LandObject* getLand(int cellX, int cellY, LandCache& cache); + virtual bool useAlteration() const { return false; } virtual void adjustColor(int col, int row, const ESM::Land::LandData *heightData, osg::Vec4ub& color) const; virtual float getAlteredHeight(int col, int row) const;