Commit ab4b3677 authored by Andrei Kortunov's avatar Andrei Kortunov

Merge branch '16' into 'master'

perf regression fix

See merge request !157
parents 721a7de8 f09125fc
Pipeline #99858678 passed with stages
in 34 minutes and 52 seconds
......@@ -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);
......
......@@ -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<unsigned int>(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)
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment