|
|
|
@ -141,7 +141,7 @@ namespace MWRender
|
|
|
|
|
std::map<uint16_t, int> indexes;
|
|
|
|
|
initTerrainTextures(&terrainData, cellX, cellY,
|
|
|
|
|
x * numTextures, y * numTextures,
|
|
|
|
|
numTextures, indexes);
|
|
|
|
|
numTextures, indexes, land->plugin);
|
|
|
|
|
|
|
|
|
|
if (mTerrainGroup.getTerrain(terrainX, terrainY) == NULL)
|
|
|
|
|
{
|
|
|
|
@ -200,8 +200,13 @@ namespace MWRender
|
|
|
|
|
void TerrainManager::initTerrainTextures(Terrain::ImportData* terrainData,
|
|
|
|
|
int cellX, int cellY,
|
|
|
|
|
int fromX, int fromY, int size,
|
|
|
|
|
std::map<uint16_t, int>& indexes)
|
|
|
|
|
std::map<uint16_t, int>& indexes, size_t plugin)
|
|
|
|
|
{
|
|
|
|
|
// FIXME: In a multiple esm configuration, we have multiple palettes. Since this code
|
|
|
|
|
// crosses cell boundaries, we no longer have a unique terrain palette. Instead, we need
|
|
|
|
|
// to adopt the following code for a dynamic palette. And this is evil - the current design
|
|
|
|
|
// does not work well for this task...
|
|
|
|
|
|
|
|
|
|
assert(terrainData != NULL && "Must have valid terrain data");
|
|
|
|
|
assert(fromX >= 0 && fromY >= 0 &&
|
|
|
|
|
"Can't get a terrain texture on terrain outside the current cell");
|
|
|
|
@ -214,12 +219,20 @@ namespace MWRender
|
|
|
|
|
//
|
|
|
|
|
//If we don't sort the ltex indexes, the splatting order may differ between
|
|
|
|
|
//cells which may lead to inconsistent results when shading between cells
|
|
|
|
|
int num = MWBase::Environment::get().getWorld()->getStore().landTexts.getSizePlugin(plugin);
|
|
|
|
|
std::set<uint16_t> ltexIndexes;
|
|
|
|
|
for ( int y = fromY - 1; y < fromY + size + 1; y++ )
|
|
|
|
|
{
|
|
|
|
|
for ( int x = fromX - 1; x < fromX + size + 1; x++ )
|
|
|
|
|
{
|
|
|
|
|
ltexIndexes.insert(getLtexIndexAt(cellX, cellY, x, y));
|
|
|
|
|
int idx = getLtexIndexAt(cellX, cellY, x, y);
|
|
|
|
|
// This is a quick hack to prevent the program from trying to fetch textures
|
|
|
|
|
// from a neighboring cell, which might originate from a different plugin,
|
|
|
|
|
// and use a separate texture palette. Right now, we simply cast it to the
|
|
|
|
|
// default texture (i.e. 0).
|
|
|
|
|
if (idx > num)
|
|
|
|
|
idx = 0;
|
|
|
|
|
ltexIndexes.insert(idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -231,7 +244,7 @@ namespace MWRender
|
|
|
|
|
iter != ltexIndexes.end();
|
|
|
|
|
++iter )
|
|
|
|
|
{
|
|
|
|
|
const uint16_t ltexIndex = *iter;
|
|
|
|
|
uint16_t ltexIndex = *iter;
|
|
|
|
|
//this is the base texture, so we can ignore this at present
|
|
|
|
|
if ( ltexIndex == baseTexture )
|
|
|
|
|
{
|
|
|
|
@ -244,8 +257,12 @@ namespace MWRender
|
|
|
|
|
{
|
|
|
|
|
//NB: All vtex ids are +1 compared to the ltex ids
|
|
|
|
|
|
|
|
|
|
assert( (int)MWBase::Environment::get().getWorld()->getStore().landTexts.getSize() >= (int)ltexIndex - 1 &&
|
|
|
|
|
"LAND.VTEX must be within the bounds of the LTEX array");
|
|
|
|
|
// NOTE: using the quick hack above, we should no longer end up with textures indices
|
|
|
|
|
// that are out of bounds. However, I haven't updated the test to a multi-palette
|
|
|
|
|
// system yet. We probably need more work here, so we skip it for now.
|
|
|
|
|
|
|
|
|
|
//assert( (int)MWBase::Environment::get().getWorld()->getStore().landTexts.getSize() >= (int)ltexIndex - 1 &&
|
|
|
|
|
//"LAND.VTEX must be within the bounds of the LTEX array");
|
|
|
|
|
|
|
|
|
|
std::string texture;
|
|
|
|
|
if ( ltexIndex == 0 )
|
|
|
|
@ -254,7 +271,7 @@ namespace MWRender
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
texture = MWBase::Environment::get().getWorld()->getStore().landTexts.search(ltexIndex-1)->texture;
|
|
|
|
|
texture = MWBase::Environment::get().getWorld()->getStore().landTexts.search(ltexIndex-1, plugin)->texture;
|
|
|
|
|
//TODO this is needed due to MWs messed up texture handling
|
|
|
|
|
texture = texture.substr(0, texture.rfind(".")) + ".dds";
|
|
|
|
|
}
|
|
|
|
|