From 999a572b0782d0c61df1bbab609a1e57fa1eb273 Mon Sep 17 00:00:00 2001 From: T1ti <40864460+T1ti@users.noreply.github.com> Date: Tue, 7 May 2024 06:04:31 +0200 Subject: [PATCH] fix normals --- src/noggit/MapTile.cpp | 9 ++++++--- src/noggit/MapTile.h | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/noggit/MapTile.cpp b/src/noggit/MapTile.cpp index 7b74a5cd..df6db85f 100755 --- a/src/noggit/MapTile.cpp +++ b/src/noggit/MapTile.cpp @@ -122,7 +122,6 @@ void MapTile::finishLoading() std::vector lModelInstances; std::vector lWMOInstances; - std::vector mTextureFilenames; std::vector mModelFilenames; std::vector mWMOFilenames; @@ -373,6 +372,8 @@ void MapTile::finishLoading() auto& chunk = mChunks[x][z]; _renderer.initChunkData(chunk.get()); } + // can be cleared after texture sets are loaded in chunks. + mTextureFilenames.clear(); theFile.close(); @@ -1408,13 +1409,13 @@ void MapTile::setHeightmapImage(QImage const& baseimage, float min_height, float for (int l = 0; l < 16; ++l) { MapChunk* chunk = getChunk(k, l); - chunk->recalcNorms(); + // chunk->recalcNorms(); } } } } -void MapTile::setAlphaImage(QImage const& baseimage, unsigned layer) +void MapTile::setAlphaImage(QImage const& baseimage, unsigned layer, bool cleanup) { auto image = baseimage.convertToFormat(QImage::Format_RGBA8888); @@ -1443,6 +1444,8 @@ void MapTile::setAlphaImage(QImage const& baseimage, unsigned layer) chunk->texture_set->markDirty(); chunk->texture_set->apply_alpha_changes(); + if (cleanup) + chunk->texture_set->eraseUnusedTextures(); } } } diff --git a/src/noggit/MapTile.h b/src/noggit/MapTile.h index e1645af9..210488af 100755 --- a/src/noggit/MapTile.h +++ b/src/noggit/MapTile.h @@ -144,7 +144,7 @@ public: QImage getNormalmapImage(); void setHeightmapImage(QImage const& baseimage, float min_height, float max_height, int mode, bool tiledEdges); void setWatermapImage(QImage const& baseimage, float multiplier, int mode, bool tiledEdges); - void setAlphaImage(QImage const& image, unsigned layer); + void setAlphaImage(QImage const& image, unsigned layer, bool cleanup); void setVertexColorImage(QImage const& image, int mode, bool tiledEdges); void registerChunkUpdate(unsigned flags) { _chunk_update_flags |= flags; }; void endChunkUpdates() { _chunk_update_flags = 0; }; @@ -196,7 +196,7 @@ private: bool mBigAlpha; // Data to be loaded and later unloaded. - // std::vector mTextureFilenames; + std::vector mTextureFilenames; // std::vector mModelFilenames; // std::vector mWMOFilenames;