1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00

perf regression fix

This commit is contained in:
bzzt 2019-11-20 13:37:00 +00:00
parent 2fa4aa9f3f
commit f09125fc93
3 changed files with 10 additions and 4 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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;