skip loading tile textures and models when not needed. Major improvement and fix for wdl generation
This commit is contained in:
@@ -24,8 +24,8 @@
|
||||
#include <QImage>
|
||||
#include <limits>
|
||||
|
||||
MapChunk::MapChunk(MapTile* maintile, BlizzardArchive::ClientFile* f, bool bigAlpha,
|
||||
tile_mode mode, Noggit::NoggitRenderContext context, bool init_empty, int chunk_idx)
|
||||
MapChunk::MapChunk(MapTile* maintile, BlizzardArchive::ClientFile* f, bool bigAlpha,tile_mode mode
|
||||
, Noggit::NoggitRenderContext context, bool init_empty, int chunk_idx, bool load_textures)
|
||||
: _mode(mode)
|
||||
, mt(maintile)
|
||||
, use_big_alphamap(bigAlpha)
|
||||
@@ -148,6 +148,11 @@ MapChunk::MapChunk(MapTile* maintile, BlizzardArchive::ClientFile* f, bool bigAl
|
||||
xbase = xbase*-1.0f + ZEROPOINT;
|
||||
}
|
||||
|
||||
if (!load_textures)
|
||||
{
|
||||
this->header.nLayers = 0;
|
||||
}
|
||||
|
||||
texture_set = std::make_unique<TextureSet>(this, f, base, maintile, bigAlpha,
|
||||
!!header_flags.flags.do_not_fix_alpha_map, mode == tile_mode::uid_fix_all, _context);
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ private:
|
||||
|
||||
public:
|
||||
MapChunk(MapTile* mt, BlizzardArchive::ClientFile* f, bool bigAlpha, tile_mode mode, Noggit::NoggitRenderContext context
|
||||
, bool init_empty = false, int chunk_idx = 0);
|
||||
, bool init_empty = false, int chunk_idx = 0, bool load_textures = true);
|
||||
|
||||
auto getHoleMask(void) const -> unsigned { return static_cast<unsigned>(holes); }
|
||||
MapTile *mt;
|
||||
|
||||
@@ -41,6 +41,7 @@ MapTile::MapTile( int pX
|
||||
, World* world
|
||||
, Noggit::NoggitRenderContext context
|
||||
, tile_mode mode
|
||||
, bool pLoadTextures
|
||||
)
|
||||
: AsyncObject(pFilename)
|
||||
, _renderer(this)
|
||||
@@ -54,6 +55,7 @@ MapTile::MapTile( int pX
|
||||
, _tile_is_being_reloaded(reloading_tile)
|
||||
, mBigAlpha(pBigAlpha)
|
||||
, _load_models(pLoadModels)
|
||||
, _load_textures(pLoadTextures)
|
||||
, _world(world)
|
||||
, _context(context)
|
||||
, _chunk_update_flags(ChunkUpdateFlags::VERTEX | ChunkUpdateFlags::ALPHAMAP
|
||||
@@ -161,23 +163,25 @@ void MapTile::finishLoading()
|
||||
|
||||
// - MTEX ----------------------------------------------
|
||||
|
||||
theFile.seek(Header.mtex + 0x14);
|
||||
theFile.read(&fourcc, 4);
|
||||
theFile.read(&size, 4);
|
||||
|
||||
assert(fourcc == 'MTEX');
|
||||
|
||||
if (_load_textures)
|
||||
{
|
||||
char const* lCurPos = reinterpret_cast<char const*>(theFile.getPointer());
|
||||
char const* lEnd = lCurPos + size;
|
||||
theFile.seek(Header.mtex + 0x14);
|
||||
theFile.read(&fourcc, 4);
|
||||
theFile.read(&size, 4);
|
||||
|
||||
assert(fourcc == 'MTEX');
|
||||
|
||||
while (lCurPos < lEnd)
|
||||
{
|
||||
mTextureFilenames.push_back(BlizzardArchive::ClientData::normalizeFilenameInternal(std::string(lCurPos)));
|
||||
lCurPos += strlen(lCurPos) + 1;
|
||||
char const* lCurPos = reinterpret_cast<char const*>(theFile.getPointer());
|
||||
char const* lEnd = lCurPos + size;
|
||||
|
||||
while (lCurPos < lEnd)
|
||||
{
|
||||
mTextureFilenames.push_back(BlizzardArchive::ClientData::normalizeFilenameInternal(std::string(lCurPos)));
|
||||
lCurPos += strlen(lCurPos) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_load_models)
|
||||
{
|
||||
// - MMDX ----------------------------------------------
|
||||
@@ -359,7 +363,7 @@ void MapTile::finishLoading()
|
||||
unsigned x = nextChunk / 16;
|
||||
unsigned z = nextChunk % 16;
|
||||
|
||||
mChunks[x][z] = std::make_unique<MapChunk> (this, &theFile, mBigAlpha, _mode, _context);
|
||||
mChunks[x][z] = std::make_unique<MapChunk> (this, &theFile, mBigAlpha, _mode, _context, false, 0, _load_textures);
|
||||
|
||||
auto& chunk = mChunks[x][z];
|
||||
_renderer.initChunkData(chunk.get());
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
, World*
|
||||
, Noggit::NoggitRenderContext context
|
||||
, tile_mode mode = tile_mode::edit
|
||||
, bool pLoadTextures = true
|
||||
);
|
||||
~MapTile();
|
||||
|
||||
@@ -205,6 +206,7 @@ private:
|
||||
std::array<float, 145 * 256 * 4> _chunk_heightmap_buffer;
|
||||
|
||||
bool _load_models;
|
||||
bool _load_textures;
|
||||
World* _world;
|
||||
|
||||
|
||||
|
||||
@@ -428,7 +428,9 @@ void map_horizon::save_wdl(World* world, bool regenerate)
|
||||
if (!horizon_tile || regenerate)
|
||||
{
|
||||
bool unload = !world->mapIndex.tileLoaded(index) && !world->mapIndex.tileAwaitingLoading(index);
|
||||
MapTile* mTile = world->mapIndex.loadTile(index);
|
||||
MapTile* mTile = world->mapIndex.loadTile(index, false, false, false);
|
||||
|
||||
auto nloadedtiles = world->mapIndex.getNLoadedTiles();
|
||||
|
||||
if (mTile)
|
||||
mTile->wait_until_loaded();
|
||||
|
||||
@@ -360,7 +360,7 @@ void MapIndex::setFlag(bool to, glm::vec3 const& pos, uint32_t flag)
|
||||
}
|
||||
}
|
||||
|
||||
MapTile* MapIndex::loadTile(const TileIndex& tile, bool reloading)
|
||||
MapTile* MapIndex::loadTile(const TileIndex& tile, bool reloading, bool load_models, bool load_textures)
|
||||
{
|
||||
if (!hasTile(tile))
|
||||
{
|
||||
@@ -382,7 +382,7 @@ MapTile* MapIndex::loadTile(const TileIndex& tile, bool reloading)
|
||||
}
|
||||
|
||||
mTiles[tile.z][tile.x].tile = std::make_unique<MapTile> (static_cast<int>(tile.x), static_cast<int>(tile.z), filename.str(),
|
||||
mBigAlpha, true, use_mclq_green_lava(), reloading, _world, _context);
|
||||
mBigAlpha, load_models, use_mclq_green_lava(), reloading, _world, _context, tile_mode::edit, load_textures);
|
||||
|
||||
MapTile* adt = mTiles[tile.z][tile.x].tile.get();
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
void create_empty_wdl();
|
||||
|
||||
void enterTile(const TileIndex& tile);
|
||||
MapTile *loadTile(const TileIndex& tile, bool reloading = false);
|
||||
MapTile *loadTile(const TileIndex& tile, bool reloading = false, bool load_models = true, bool load_textures = true);
|
||||
|
||||
void update_model_tile(const TileIndex& tile, model_update type, SceneObject* instance);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user