1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

fix bug in "fixColour" and "fixNormal"

fix issue in vtx texture selection
This commit is contained in:
florent.teppe 2023-05-18 19:51:02 +02:00
parent c2e652b8a0
commit 427b6ea39a

View File

@ -110,8 +110,6 @@ namespace ESMTerrain
osg::Vec3f& normal, ESM::ExteriorCellLocation cellLocation, int col, int row, LandCache& cache) osg::Vec3f& normal, ESM::ExteriorCellLocation cellLocation, int col, int row, LandCache& cache)
{ {
const LandObject* land = getLand(cellLocation, cache);
const ESM::LandData* data = land ? land->getData(ESM::Land::DATA_VNML) : nullptr;
const int landSize = ESM::getLandSize(cellLocation.mWorldspace); const int landSize = ESM::getLandSize(cellLocation.mWorldspace);
while (col >= landSize - 1) while (col >= landSize - 1)
@ -134,7 +132,8 @@ namespace ESMTerrain
--cellLocation.mX; --cellLocation.mX;
row += landSize - 1; row += landSize - 1;
} }
const LandObject* land = getLand(cellLocation, cache);
const ESM::LandData* data = land ? land->getData(ESM::Land::DATA_VNML) : nullptr;
if (data) if (data)
{ {
normal.x() = data->getNormals()[col * landSize * 3 + row * 3]; normal.x() = data->getNormals()[col * landSize * 3 + row * 3];
@ -161,8 +160,7 @@ namespace ESMTerrain
void Storage::fixColour( void Storage::fixColour(
osg::Vec4ub& color, ESM::ExteriorCellLocation cellLocation, int col, int row, LandCache& cache) osg::Vec4ub& color, ESM::ExteriorCellLocation cellLocation, int col, int row, LandCache& cache)
{ {
const LandObject* land = getLand(cellLocation, cache);
const ESM::LandData* data = land ? land->getData(ESM::Land::DATA_VCLR) : nullptr;
const int landSize = ESM::getLandSize(cellLocation.mWorldspace); const int landSize = ESM::getLandSize(cellLocation.mWorldspace);
if (col == landSize - 1) if (col == landSize - 1)
@ -175,7 +173,8 @@ namespace ESMTerrain
++cellLocation.mX; ++cellLocation.mX;
row = 0; row = 0;
} }
const LandObject* land = getLand(cellLocation, cache);
const ESM::LandData* data = land ? land->getData(ESM::Land::DATA_VCLR) : nullptr;
if (data) if (data)
{ {
color.r() = data->getColors()[col * landSize * 3 + row * 3]; color.r() = data->getColors()[col * landSize * 3 + row * 3];
@ -342,6 +341,7 @@ namespace ESMTerrain
// For the first/last row/column, we need to get the texture from the neighbour cell // For the first/last row/column, we need to get the texture from the neighbour cell
// to get consistent blending at the borders // to get consistent blending at the borders
--x; --x;
ESM::ExteriorCellLocation cellLocationIn = cellLocation;
if (x < 0) if (x < 0)
{ {
--cellLocation.mX; --cellLocation.mX;
@ -359,6 +359,9 @@ namespace ESMTerrain
y -= ESM::Land::LAND_TEXTURE_SIZE; y -= ESM::Land::LAND_TEXTURE_SIZE;
} }
if (cellLocation != cellLocationIn)
land = getLand(cellLocation, cache);
assert(x < ESM::Land::LAND_TEXTURE_SIZE); assert(x < ESM::Land::LAND_TEXTURE_SIZE);
assert(y < ESM::Land::LAND_TEXTURE_SIZE); assert(y < ESM::Land::LAND_TEXTURE_SIZE);