mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-06 15:45:34 +00:00
perf regression fix
This commit is contained in:
parent
2fa4aa9f3f
commit
f09125fc93
3 changed files with 10 additions and 4 deletions
|
@ -18,6 +18,8 @@ namespace CSVRender
|
||||||
TerrainStorage(const CSMWorld::Data& data);
|
TerrainStorage(const CSMWorld::Data& data);
|
||||||
void setAlteredHeight(int inCellX, int inCellY, float heightMap);
|
void setAlteredHeight(int inCellX, int inCellY, float heightMap);
|
||||||
void resetHeights();
|
void resetHeights();
|
||||||
|
|
||||||
|
virtual bool useAlteration() const { return true; }
|
||||||
float getSumOfAlteredAndTrueHeight(int cellX, int cellY, int inCellX, int inCellY);
|
float getSumOfAlteredAndTrueHeight(int cellX, int cellY, int inCellX, int inCellY);
|
||||||
float* getAlteredHeight(int inCellX, int inCellY);
|
float* getAlteredHeight(int inCellX, int inCellY);
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,8 @@ namespace ESMTerrain
|
||||||
|
|
||||||
LandCache cache;
|
LandCache cache;
|
||||||
|
|
||||||
|
bool alteration = useAlteration();
|
||||||
|
|
||||||
float vertY_ = 0; // of current cell corner
|
float vertY_ = 0; // of current cell corner
|
||||||
for (int cellY = startCellY; cellY < startCellY + std::ceil(size); ++cellY)
|
for (int cellY = startCellY; cellY < startCellY + std::ceil(size); ++cellY)
|
||||||
{
|
{
|
||||||
|
@ -251,11 +253,12 @@ namespace ESMTerrain
|
||||||
float height = defaultHeight;
|
float height = defaultHeight;
|
||||||
if (heightData)
|
if (heightData)
|
||||||
height = heightData->mHeights[col*ESM::Land::LAND_SIZE + row];
|
height = heightData->mHeights[col*ESM::Land::LAND_SIZE + row];
|
||||||
|
if (alteration)
|
||||||
|
height += getAlteredHeight(col, row);
|
||||||
(*positions)[static_cast<unsigned int>(vertX*numVerts + vertY)]
|
(*positions)[static_cast<unsigned int>(vertX*numVerts + vertY)]
|
||||||
= osg::Vec3f((vertX / float(numVerts - 1) - 0.5f) * size * Constants::CellSizeInUnits,
|
= osg::Vec3f((vertX / float(numVerts - 1) - 0.5f) * size * Constants::CellSizeInUnits,
|
||||||
(vertY / float(numVerts - 1) - 0.5f) * size * Constants::CellSizeInUnits,
|
(vertY / float(numVerts - 1) - 0.5f) * size * Constants::CellSizeInUnits,
|
||||||
height + getAlteredHeight(col, row));
|
height);
|
||||||
|
|
||||||
if (normalData)
|
if (normalData)
|
||||||
{
|
{
|
||||||
|
@ -290,8 +293,8 @@ namespace ESMTerrain
|
||||||
color.g() = 255;
|
color.g() = 255;
|
||||||
color.b() = 255;
|
color.b() = 255;
|
||||||
}
|
}
|
||||||
|
if (alteration)
|
||||||
adjustColor(col, row, heightData, color); //Does nothing by default, override in OpenMW-CS
|
adjustColor(col, row, heightData, color); //Does nothing by default, override in OpenMW-CS
|
||||||
|
|
||||||
// Unlike normals, colors mostly connect seamlessly between cells, but not always...
|
// Unlike normals, colors mostly connect seamlessly between cells, but not always...
|
||||||
if (col == ESM::Land::LAND_SIZE-1 || row == ESM::Land::LAND_SIZE-1)
|
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);
|
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 void adjustColor(int col, int row, const ESM::Land::LandData *heightData, osg::Vec4ub& color) const;
|
||||||
virtual float getAlteredHeight(int col, int row) const;
|
virtual float getAlteredHeight(int col, int row) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue