From 565222159b29339cd4a27a7cca96972374b30278 Mon Sep 17 00:00:00 2001 From: T1ti Date: Thu, 19 Jan 2023 02:38:59 +0100 Subject: [PATCH 01/14] fix update flags for imports --- src/noggit/MapTile.cpp | 4 ++++ src/noggit/MapView.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/noggit/MapTile.cpp b/src/noggit/MapTile.cpp index d6b39ffc..56d16956 100755 --- a/src/noggit/MapTile.cpp +++ b/src/noggit/MapTile.cpp @@ -1300,6 +1300,8 @@ void MapTile::setAlphaImage(QImage const& image, unsigned layer) if (layer >= chunk->texture_set->num()) continue; + chunk->registerChunkUpdate(ChunkUpdateFlags::ALPHAMAP); + chunk->texture_set->create_temporary_alphamaps_if_needed(); auto& temp_alphamaps = chunk->texture_set->getTempAlphamaps()->value(); @@ -1366,6 +1368,8 @@ void MapTile::setVertexColorImage(QImage const& image, int mode) { MapChunk* chunk = getChunk(k, l); + chunk->registerChunkUpdate(ChunkUpdateFlags::MCCV); + glm::vec3* colors = chunk->getVertexColors(); for (unsigned y = 0; y < SUM; ++y) diff --git a/src/noggit/MapView.cpp b/src/noggit/MapView.cpp index 7ae78d1a..a6cbe0cb 100755 --- a/src/noggit/MapView.cpp +++ b/src/noggit/MapView.cpp @@ -1813,7 +1813,7 @@ void MapView::setupAssistMenu() ( makeCurrent(); OpenGL::context::scoped_setter const _(::gl, context()); - NOGGIT_ACTION_MGR->beginAction(this, Noggit::ActionFlags::eCHUNKS_TEXTURE); + NOGGIT_ACTION_MGR->beginAction(this, Noggit::ActionFlags::eCHUNKS_TERRAIN); _world->importAllADTsHeightmaps(adt_import_height_params_multiplier->value(), adt_import_height_params_mode->currentIndex()); NOGGIT_ACTION_MGR->endAction(); ) @@ -1832,7 +1832,7 @@ void MapView::setupAssistMenu() ( makeCurrent(); OpenGL::context::scoped_setter const _(::gl, context()); - NOGGIT_ACTION_MGR->beginAction(this, Noggit::ActionFlags::eCHUNKS_TEXTURE); + NOGGIT_ACTION_MGR->beginAction(this, Noggit::ActionFlags::eCHUNKS_VERTEX_COLOR); _world->importAllADTVertexColorMaps(adt_import_vcol_params_mode->currentIndex()); NOGGIT_ACTION_MGR->endAction(); ) From ba3b01450fbc94990b1d723eecd5567a9797c560 Mon Sep 17 00:00:00 2001 From: T1ti Date: Sat, 21 Jan 2023 03:17:44 +0100 Subject: [PATCH 02/14] fix heightmaps image loading for multiple formats --- src/noggit/MapTile.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/noggit/MapTile.cpp b/src/noggit/MapTile.cpp index 56d16956..48c09920 100755 --- a/src/noggit/MapTile.cpp +++ b/src/noggit/MapTile.cpp @@ -1203,8 +1203,11 @@ QImage MapTile::getAlphamapImage(std::string const& filename) return std::move(image); } -void MapTile::setHeightmapImage(QImage const& image, float multiplier, int mode) +void MapTile::setHeightmapImage(QImage const& baseimage, float multiplier, int mode) // image { + // convert to RGBA64 to properly load all type of images (grayscales don't load properly otherwise) + auto image = baseimage.convertToFormat(QImage::Format_RGBA64); + unsigned const LONG{9}, SHORT{8}, SUM{LONG + SHORT}, DSUM{SUM * 2}; for (int k = 0; k < 16; ++k) From 9adc98b3a72d348e57b5a2a63edb742f587a70d1 Mon Sep 17 00:00:00 2001 From: T1ti Date: Sat, 21 Jan 2023 03:18:48 +0100 Subject: [PATCH 03/14] implement global texture swapping --- src/noggit/MapChunk.cpp | 9 ++++--- src/noggit/MapChunk.h | 2 +- src/noggit/World.cpp | 45 +++++++++++++++++++++++++++++++ src/noggit/World.h | 4 +++ src/noggit/World.inl | 17 ++++++++++++ src/noggit/texture_set.cpp | 7 ++++- src/noggit/texture_set.hpp | 2 +- src/noggit/ui/texture_swapper.cpp | 11 ++++++++ 8 files changed, 91 insertions(+), 6 deletions(-) diff --git a/src/noggit/MapChunk.cpp b/src/noggit/MapChunk.cpp index b585e98e..2e52e255 100755 --- a/src/noggit/MapChunk.cpp +++ b/src/noggit/MapChunk.cpp @@ -1280,10 +1280,13 @@ int MapChunk::addTexture(scoped_blp_texture_reference texture) return texture_set->addTexture(std::move (texture)); } -void MapChunk::switchTexture(scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture) +bool MapChunk::switchTexture(scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture) { - texture_set->replace_texture(oldTexture, std::move (newTexture)); - registerChunkUpdate(ChunkUpdateFlags::ALPHAMAP); + bool changed = texture_set->replace_texture(oldTexture, std::move (newTexture)); + if (changed) + registerChunkUpdate(ChunkUpdateFlags::ALPHAMAP); + + return changed; } bool MapChunk::paintTexture(glm::vec3 const& pos, Brush* brush, float strength, float pressure, scoped_blp_texture_reference texture) diff --git a/src/noggit/MapChunk.h b/src/noggit/MapChunk.h index 03f62e10..3237ea09 100755 --- a/src/noggit/MapChunk.h +++ b/src/noggit/MapChunk.h @@ -160,7 +160,7 @@ public: bool replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture, bool entire_chunk = false); bool canPaintTexture(scoped_blp_texture_reference texture); int addTexture(scoped_blp_texture_reference texture); - void switchTexture(scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture); + bool switchTexture(scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture); void eraseTextures(); void eraseTexture(scoped_blp_texture_reference const& tex); void change_texture_flag(scoped_blp_texture_reference const& tex, std::size_t flag, bool add); diff --git a/src/noggit/World.cpp b/src/noggit/World.cpp index 7de4606b..a0a496b0 100755 --- a/src/noggit/World.cpp +++ b/src/noggit/World.cpp @@ -2031,6 +2031,51 @@ void World::swapTexture(glm::vec3 const& pos, scoped_blp_texture_reference tex) } } +void World::swapTextureGlobal(scoped_blp_texture_reference tex) +{ + ZoneScoped; + if (!!Noggit::Ui::selected_texture::get()) + { + + for (size_t z = 0; z < 64; z++) + { + for (size_t x = 0; x < 64; x++) + { + TileIndex tile(x, z); + + bool unload = !mapIndex.tileLoaded(tile) && !mapIndex.tileAwaitingLoading(tile); + MapTile* mTile = mapIndex.loadTile(tile); + + if (mTile) + { + mTile->wait_until_loaded(); + + bool tile_changed = false; + for_all_chunks_on_tile(mTile, [&](MapChunk* chunk) + { + // NOGGIT_CUR_ACTION->registerChunkTextureChange(chunk); + bool swapped = chunk->switchTexture(tex, *Noggit::Ui::selected_texture::get()); + if (swapped) + tile_changed = true; + }); + + if (tile_changed) + { + mTile->saveTile(this); + mapIndex.markOnDisc(tile, true); + mapIndex.unsetChanged(tile); + } + + if (unload) + { + mapIndex.unloadTile(tile); + } + } + } + } + } +} + void World::removeTexture(glm::vec3 const& pos, scoped_blp_texture_reference tex) { ZoneScoped; diff --git a/src/noggit/World.h b/src/noggit/World.h index 1a26da4b..6b0ec593 100755 --- a/src/noggit/World.h +++ b/src/noggit/World.h @@ -191,6 +191,9 @@ public: template void for_all_chunks_on_tile (glm::vec3 const& pos, Fun&&); + template + void for_all_chunks_on_tile(MapTile* tile, Fun&& fun); + template void for_chunk_at(glm::vec3 const& pos, Fun&& fun); template @@ -216,6 +219,7 @@ public: void clear_shadows(glm::vec3 const& pos); void clearTextures(glm::vec3 const& pos); void swapTexture(glm::vec3 const& pos, scoped_blp_texture_reference tex); + void swapTextureGlobal(scoped_blp_texture_reference tex); void removeTexture(glm::vec3 const& pos, scoped_blp_texture_reference tex); void removeTexDuplicateOnADT(glm::vec3 const& pos); void change_texture_flag(glm::vec3 const& pos, scoped_blp_texture_reference const& tex, std::size_t flag, bool add); diff --git a/src/noggit/World.inl b/src/noggit/World.inl index e795186d..c36d2963 100755 --- a/src/noggit/World.inl +++ b/src/noggit/World.inl @@ -25,6 +25,23 @@ void World::for_all_chunks_on_tile (glm::vec3 const& pos, Fun&& fun) } } +template +void World::for_all_chunks_on_tile(MapTile* tile, Fun&& fun) +{ + if (tile && tile->finishedLoading()) + { + mapIndex.setChanged(tile); + + for (size_t ty = 0; ty < 16; ++ty) + { + for (size_t tx = 0; tx < 16; ++tx) + { + fun(tile->getChunk(ty, tx)); + } + } + } +} + template void World::for_chunk_at(glm::vec3 const& pos, Fun&& fun) { diff --git a/src/noggit/texture_set.cpp b/src/noggit/texture_set.cpp index 0a8deab2..9b23836a 100755 --- a/src/noggit/texture_set.cpp +++ b/src/noggit/texture_set.cpp @@ -87,7 +87,7 @@ int TextureSet::addTexture (scoped_blp_texture_reference texture) return texLevel; } -void TextureSet::replace_texture (scoped_blp_texture_reference const& texture_to_replace, scoped_blp_texture_reference replacement_texture) +bool TextureSet::replace_texture (scoped_blp_texture_reference const& texture_to_replace, scoped_blp_texture_reference replacement_texture) { int texture_to_replace_level = -1, replacement_texture_level = -1; @@ -122,6 +122,11 @@ void TextureSet::replace_texture (scoped_blp_texture_reference const& texture_to // merge_layers(texture_to_replace_level, replacement_texture_level); } } + + if (texture_to_replace_level != -1 || replacement_texture_level != -1) + return true; + else + return false; } void TextureSet::swap_layers(int layer_1, int layer_2) diff --git a/src/noggit/texture_set.hpp b/src/noggit/texture_set.hpp index 3e576836..0f58104a 100755 --- a/src/noggit/texture_set.hpp +++ b/src/noggit/texture_set.hpp @@ -45,7 +45,7 @@ public: // return true if at least 1 texture has been erased bool eraseUnusedTextures(); void swap_layers(int layer_1, int layer_2); - void replace_texture(scoped_blp_texture_reference const& texture_to_replace, scoped_blp_texture_reference replacement_texture); + bool replace_texture(scoped_blp_texture_reference const& texture_to_replace, scoped_blp_texture_reference replacement_texture); bool paintTexture(float xbase, float zbase, float x, float z, Brush* brush, float strength, float pressure, scoped_blp_texture_reference texture); bool stampTexture(float xbase, float zbase, float x, float z, Brush* brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* image, bool paint); bool replace_texture( float xbase diff --git a/src/noggit/ui/texture_swapper.cpp b/src/noggit/ui/texture_swapper.cpp index 7b4b2718..0209632b 100755 --- a/src/noggit/ui/texture_swapper.cpp +++ b/src/noggit/ui/texture_swapper.cpp @@ -36,12 +36,14 @@ namespace Noggit QPushButton* select = new QPushButton("Select", this); QPushButton* swap_adt = new QPushButton("Swap ADT", this); + QPushButton* swap_global = new QPushButton("Swap Global(All ADTs)", this); QPushButton* remove_text_adt = new QPushButton(tr("Remove this texture from ADT"), this); layout->addRow(new QLabel("Texture to swap")); layout->addRow(_texture_to_swap_display); layout->addRow(select); layout->addRow(swap_adt); + layout->addRow(swap_global); layout->addRow(remove_text_adt); _brush_mode_group = new QGroupBox("Brush mode", this); @@ -89,6 +91,15 @@ namespace Noggit } }); + connect(swap_global, &QPushButton::clicked, [this, camera_pos, map_view]() { + if (_texture_to_swap) + { + // ActionManager::instance()->beginAction(map_view, ActionFlags::eCHUNKS_TEXTURE); + _world->swapTextureGlobal(_texture_to_swap.value()); + // ActionManager::instance()->endAction(); + } + }); + connect(remove_text_adt, &QPushButton::clicked, [this, camera_pos, map_view]() { if (_texture_to_swap) { From 6ec6fdf0934a703184db9d4fa1135608e20ead45 Mon Sep 17 00:00:00 2001 From: T1ti Date: Sat, 21 Jan 2023 22:20:13 +0100 Subject: [PATCH 04/14] -properly export missing texture from chunk as black instead of white -separate implementation of layer 0 and missing texture -properly export layer 0 as (255-sum(MCAL[1]...MCAL[3]) ) instead of full white chunks --- src/noggit/MapTile.cpp | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/noggit/MapTile.cpp b/src/noggit/MapTile.cpp index 48c09920..63852f37 100755 --- a/src/noggit/MapTile.cpp +++ b/src/noggit/MapTile.cpp @@ -1164,20 +1164,25 @@ QImage MapTile::getAlphamapImage(std::string const& filename) MapChunk *chunk = getChunk(i, j); unsigned layer = 0; + bool chunk_has_texture = false; for (int k = 0; k < chunk->texture_set->num(); ++k) { - if (chunk->texture_set->filename(k) == filename) - layer = k; + if (chunk->texture_set->filename(k) == filename) + { + layer = k; + chunk_has_texture = true; + } } - if (!layer) + if (!chunk_has_texture) { for (int k = 0; k < 64; ++k) { for (int l = 0; l < 64; ++l) { - image.setPixelColor((i * 64) + k, (j * 64) + l, QColor(255, 255, 255, 255)); + // if texture is not in the chunk, set chunk to black + image.setPixelColor((i * 64) + k, (j * 64) + l, QColor(0, 0, 0, 255)); } } } @@ -1186,14 +1191,31 @@ QImage MapTile::getAlphamapImage(std::string const& filename) chunk->texture_set->apply_alpha_changes(); auto alphamaps = chunk->texture_set->getAlphamaps(); - auto alpha_layer = alphamaps->at(layer - 1).value(); - for (int k = 0; k < 64; ++k) { for (int l = 0; l < 64; ++l) { - int value = alpha_layer.getAlpha(64 * l + k); - image.setPixelColor((i * 64) + k, (j * 64) + l, QColor(value, value, value, 255)); + if (layer == 0) // titi test + { + // WoW calculates layer 0 as 255 - sum(Layer[1]...Layer[3]) + int layers_sum = 0; + if (alphamaps->at(0).has_value()) + layers_sum += alphamaps->at(0).value().getAlpha(64 * l + k); + if (alphamaps->at(1).has_value()) + layers_sum += alphamaps->at(1).value().getAlpha(64 * l + k); + if (alphamaps->at(2).has_value()) + layers_sum += alphamaps->at(2).value().getAlpha(64 * l + k); + + int value = std::clamp((255 - layers_sum), 0, 255); + image.setPixelColor((i * 64) + k, (j * 64) + l, QColor(value, value, value, 255)); + } + else // layer 1-3 + { + auto alpha_layer = alphamaps->at(layer - 1).value(); + + int value = alpha_layer.getAlpha(64 * l + k); + image.setPixelColor((i * 64) + k, (j * 64) + l, QColor(value, value, value, 255)); + } } } } From 30eece58974219c599e1dfaa3e9c39e785d0e3df Mon Sep 17 00:00:00 2001 From: T1ti Date: Sat, 21 Jan 2023 22:30:36 +0100 Subject: [PATCH 05/14] auto convert image format import for vertex colors and alphamaps --- src/noggit/MapTile.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/noggit/MapTile.cpp b/src/noggit/MapTile.cpp index 63852f37..e98542a3 100755 --- a/src/noggit/MapTile.cpp +++ b/src/noggit/MapTile.cpp @@ -1314,8 +1314,10 @@ void MapTile::setHeightmapImage(QImage const& baseimage, float multiplier, int m } } -void MapTile::setAlphaImage(QImage const& image, unsigned layer) +void MapTile::setAlphaImage(QImage const& baseimage, unsigned layer) { + auto image = baseimage.convertToFormat(QImage::Format_RGBA8888); + for (int k = 0; k < 16; ++k) { for (int l = 0; l < 16; ++l) @@ -1383,8 +1385,10 @@ QImage MapTile::getVertexColorsImage() return std::move(image); } -void MapTile::setVertexColorImage(QImage const& image, int mode) +void MapTile::setVertexColorImage(QImage const& baseimage, int mode) { + QImage image = baseimage.convertToFormat(QImage::Format_RGBA8888); + unsigned const LONG{9}, SHORT{8}, SUM{LONG + SHORT}, DSUM{SUM * 2}; for (int k = 0; k < 16; ++k) @@ -1454,9 +1458,6 @@ void MapTile::setVertexColorImage(QImage const& image, int mode) } } - - - void MapTile::recalcExtents() { if (!_extents_dirty) From 8d82075552561e3ed41d759c00fc904eebef786a Mon Sep 17 00:00:00 2001 From: T1ti Date: Thu, 26 Jan 2023 21:47:15 +0100 Subject: [PATCH 06/14] Use grayscale instead of rgba for images import/export. need testing --- src/noggit/MapTile.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/noggit/MapTile.cpp b/src/noggit/MapTile.cpp index e98542a3..cd315ff2 100755 --- a/src/noggit/MapTile.cpp +++ b/src/noggit/MapTile.cpp @@ -1049,7 +1049,8 @@ void MapTile::initEmptyChunks() QImage MapTile::getHeightmapImage(float min_height, float max_height) { - QImage image(257, 257, QImage::Format_RGBA64); + // QImage image(257, 257, QImage::Format_RGBA64); + QImage image(257, 257, QImage::Format_Grayscale16); unsigned const LONG{9}, SHORT{8}, SUM{LONG + SHORT}, DSUM{SUM * 2}; @@ -1121,7 +1122,8 @@ QImage MapTile::getNormalmapImage() QImage MapTile::getAlphamapImage(unsigned layer) { - QImage image(1024, 1024, QImage::Format_RGBA8888); + // QImage image(1024, 1024, QImage::Format_RGBA8888); + QImage image(1024, 1024, QImage::Format_Grayscale8); image.fill(Qt::black); for (int i = 0; i < 16; ++i) @@ -1154,7 +1156,8 @@ QImage MapTile::getAlphamapImage(unsigned layer) QImage MapTile::getAlphamapImage(std::string const& filename) { - QImage image(1024, 1024, QImage::Format_RGBA8888); + // QImage image(1024, 1024, QImage::Format_RGBA8888); + QImage image(1024, 1024, QImage::Format_Grayscale8); image.fill(Qt::black); for (int i = 0; i < 16; ++i) @@ -1228,7 +1231,8 @@ QImage MapTile::getAlphamapImage(std::string const& filename) void MapTile::setHeightmapImage(QImage const& baseimage, float multiplier, int mode) // image { // convert to RGBA64 to properly load all type of images (grayscales don't load properly otherwise) - auto image = baseimage.convertToFormat(QImage::Format_RGBA64); + // auto image = baseimage.convertToFormat(QImage::Format_RGBA64); + auto image = baseimage.convertToFormat(QImage::Format_Grayscale16); unsigned const LONG{9}, SHORT{8}, SUM{LONG + SHORT}, DSUM{SUM * 2}; @@ -1316,7 +1320,8 @@ void MapTile::setHeightmapImage(QImage const& baseimage, float multiplier, int m void MapTile::setAlphaImage(QImage const& baseimage, unsigned layer) { - auto image = baseimage.convertToFormat(QImage::Format_RGBA8888); + // auto image = baseimage.convertToFormat(QImage::Format_RGBA8888); + auto image = baseimage.convertToFormat(QImage::Format_Grayscale8); for (int k = 0; k < 16; ++k) { From dad27c62587a2ec1c2e811d7a5c7683dbfbdf303 Mon Sep 17 00:00:00 2001 From: T1ti Date: Thu, 26 Jan 2023 21:48:47 +0100 Subject: [PATCH 07/14] log format errors in MD5 file --- src/noggit/map_index.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/noggit/map_index.cpp b/src/noggit/map_index.cpp index f0034b4c..0d1dee3d 100755 --- a/src/noggit/map_index.cpp +++ b/src/noggit/map_index.cpp @@ -1094,6 +1094,13 @@ void MapIndex::loadMinimapMD5translate() QStringList line_split = line.split(QRegExp("[\t]")); + if (line_split.length() < 2) + { + std::string text = "Failed to read md5translate.trs.\nLine \"" + line.toStdString() + "\n has no tab spacing. Spacing must be only a tab character and not spaces."; + LogError << text << std::endl; + throw std::logic_error(text); + } + if (cur_dir.length()) { _minimap_md5translate[cur_dir.toStdString()][line_split[0].toStdString()] = line_split[1].toStdString(); From 20ab9637184aafc92baca10ec38f5f625f226941 Mon Sep 17 00:00:00 2001 From: T1ti Date: Sun, 29 Jan 2023 05:03:37 +0100 Subject: [PATCH 08/14] fix crash with some WDLs --- src/noggit/map_horizon.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/noggit/map_horizon.cpp b/src/noggit/map_horizon.cpp index c2ae1969..fb97983b 100755 --- a/src/noggit/map_horizon.cpp +++ b/src/noggit/map_horizon.cpp @@ -189,13 +189,15 @@ map_horizon::map_horizon(const std::string& basename, const MapIndex * const ind wdl_file.read(_tiles[y][x]->height_17, 17 * 17 * sizeof(int16_t)); wdl_file.read(_tiles[y][x]->height_16, 16 * 16 * sizeof(int16_t)); - - wdl_file.read(&fourcc, 4); - if (fourcc == 'MAHO') + if (wdl_file.getPos() < wdl_file.getSize()) { - wdl_file.read(&size, 4); - assert(size == 0x20); - wdl_file.read(_tiles[y][x]->holes, 16 * sizeof(int16_t)); + wdl_file.read(&fourcc, 4); + if (fourcc == 'MAHO') + { + wdl_file.read(&size, 4); + assert(size == 0x20); + wdl_file.read(_tiles[y][x]->holes, 16 * sizeof(int16_t)); + } } } From 54242d3c51674c5b6cfef545e863460bade4d9b5 Mon Sep 17 00:00:00 2001 From: T1ti Date: Thu, 27 Apr 2023 02:15:54 +0000 Subject: [PATCH 09/14] Update texture_swapper.cpp --- src/noggit/ui/texture_swapper.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/noggit/ui/texture_swapper.cpp b/src/noggit/ui/texture_swapper.cpp index 0209632b..6465a673 100755 --- a/src/noggit/ui/texture_swapper.cpp +++ b/src/noggit/ui/texture_swapper.cpp @@ -94,9 +94,8 @@ namespace Noggit connect(swap_global, &QPushButton::clicked, [this, camera_pos, map_view]() { if (_texture_to_swap) { - // ActionManager::instance()->beginAction(map_view, ActionFlags::eCHUNKS_TEXTURE); + // TODO : action manager _world->swapTextureGlobal(_texture_to_swap.value()); - // ActionManager::instance()->endAction(); } }); From b2fe7c5c722f03ef8f836c5f971f3ffdec735b61 Mon Sep 17 00:00:00 2001 From: T1ti Date: Thu, 27 Apr 2023 02:16:42 +0000 Subject: [PATCH 10/14] Update MapTile.cpp --- src/noggit/MapTile.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/noggit/MapTile.cpp b/src/noggit/MapTile.cpp index cd315ff2..61c1344d 100755 --- a/src/noggit/MapTile.cpp +++ b/src/noggit/MapTile.cpp @@ -1049,7 +1049,6 @@ void MapTile::initEmptyChunks() QImage MapTile::getHeightmapImage(float min_height, float max_height) { - // QImage image(257, 257, QImage::Format_RGBA64); QImage image(257, 257, QImage::Format_Grayscale16); unsigned const LONG{9}, SHORT{8}, SUM{LONG + SHORT}, DSUM{SUM * 2}; @@ -1122,7 +1121,6 @@ QImage MapTile::getNormalmapImage() QImage MapTile::getAlphamapImage(unsigned layer) { - // QImage image(1024, 1024, QImage::Format_RGBA8888); QImage image(1024, 1024, QImage::Format_Grayscale8); image.fill(Qt::black); From 4c7b742ac157a717a24291bf4c3661d884f0cffd Mon Sep 17 00:00:00 2001 From: T1ti Date: Tue, 11 Jul 2023 01:37:18 +0200 Subject: [PATCH 11/14] fix merge conflicts --- src/noggit/MapTile.cpp | 8 ++++---- src/noggit/MapTile.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/noggit/MapTile.cpp b/src/noggit/MapTile.cpp index b4e1e42f..381381bb 100755 --- a/src/noggit/MapTile.cpp +++ b/src/noggit/MapTile.cpp @@ -1228,11 +1228,11 @@ QImage MapTile::getAlphamapImage(std::string const& filename) return std::move(image); } -void MapTile::setHeightmapImage(QImage const& baseimage, float multiplier, int mode) // image +void MapTile::setHeightmapImage(QImage const& baseimage, float multiplier, int mode, bool tiledEdges) // image { // convert to RGBA64 to properly load all type of images (grayscales don't load properly otherwise) - // auto image = baseimage.convertToFormat(QImage::Format_RGBA64); - auto image = baseimage.convertToFormat(QImage::Format_Grayscale16); + auto image = baseimage.convertToFormat(QImage::Format_RGBA64); + // auto image = baseimage.convertToFormat(QImage::Format_Grayscale16); unsigned const LONG{9}, SHORT{8}, SUM{LONG + SHORT}, DSUM{SUM * 2}; for (int k = 0; k < 16; ++k) @@ -1454,7 +1454,7 @@ QImage MapTile::getVertexColorsImage() return std::move(image); } -void MapTile::setVertexColorImage(QImage const& baseimage, int mode) +void MapTile::setVertexColorImage(QImage const& baseimage, int mode, bool tiledEdges) { QImage image = baseimage.convertToFormat(QImage::Format_RGBA8888); diff --git a/src/noggit/MapTile.h b/src/noggit/MapTile.h index bb04538d..0e8c5d8b 100755 --- a/src/noggit/MapTile.h +++ b/src/noggit/MapTile.h @@ -141,7 +141,7 @@ public: QImage getAlphamapImage(std::string const& filename); QImage getVertexColorsImage(); QImage getNormalmapImage(); - void setHeightmapImage(QImage const& image, float multiplier, int mode, bool tiledEdges); + void setHeightmapImage(QImage const& baseimage, float multiplier, int mode, bool tiledEdges); void setAlphaImage(QImage const& image, unsigned layer); void setVertexColorImage(QImage const& image, int mode, bool tiledEdges); void registerChunkUpdate(unsigned flags) { _chunk_update_flags |= flags; }; From f87e1933bb76ec2ab12b047dbeac1a1c843a14f9 Mon Sep 17 00:00:00 2001 From: T1ti Date: Tue, 11 Jul 2023 01:46:26 +0200 Subject: [PATCH 12/14] remove comments --- src/noggit/MapTile.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/noggit/MapTile.cpp b/src/noggit/MapTile.cpp index 381381bb..e4167d94 100755 --- a/src/noggit/MapTile.cpp +++ b/src/noggit/MapTile.cpp @@ -1230,9 +1230,7 @@ QImage MapTile::getAlphamapImage(std::string const& filename) void MapTile::setHeightmapImage(QImage const& baseimage, float multiplier, int mode, bool tiledEdges) // image { - // convert to RGBA64 to properly load all type of images (grayscales don't load properly otherwise) - auto image = baseimage.convertToFormat(QImage::Format_RGBA64); - // auto image = baseimage.convertToFormat(QImage::Format_Grayscale16); + auto image = baseimage.convertToFormat(QImage::Format_Grayscale16); unsigned const LONG{9}, SHORT{8}, SUM{LONG + SHORT}, DSUM{SUM * 2}; for (int k = 0; k < 16; ++k) @@ -1384,7 +1382,6 @@ void MapTile::setHeightmapImage(QImage const& baseimage, float multiplier, int m void MapTile::setAlphaImage(QImage const& baseimage, unsigned layer) { - // auto image = baseimage.convertToFormat(QImage::Format_RGBA8888); auto image = baseimage.convertToFormat(QImage::Format_Grayscale8); for (int k = 0; k < 16; ++k) From a10763affb7dcf738cf833eea03910572f9970b1 Mon Sep 17 00:00:00 2001 From: T1ti Date: Tue, 11 Jul 2023 01:49:18 +0200 Subject: [PATCH 13/14] more comments --- src/noggit/MapTile.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/noggit/MapTile.cpp b/src/noggit/MapTile.cpp index e4167d94..bee9975d 100755 --- a/src/noggit/MapTile.cpp +++ b/src/noggit/MapTile.cpp @@ -1049,7 +1049,6 @@ void MapTile::initEmptyChunks() QImage MapTile::getHeightmapImage(float min_height, float max_height) { - // QImage image(257, 257, QImage::Format_RGBA64); QImage image(257, 257, QImage::Format_Grayscale16); unsigned const LONG{9}, SHORT{8}, SUM{LONG + SHORT}, DSUM{SUM * 2}; @@ -1122,7 +1121,6 @@ QImage MapTile::getNormalmapImage() QImage MapTile::getAlphamapImage(unsigned layer) { - // QImage image(1024, 1024, QImage::Format_RGBA8888); QImage image(1024, 1024, QImage::Format_Grayscale8); image.fill(Qt::black); @@ -1156,7 +1154,6 @@ QImage MapTile::getAlphamapImage(unsigned layer) QImage MapTile::getAlphamapImage(std::string const& filename) { - // QImage image(1024, 1024, QImage::Format_RGBA8888); QImage image(1024, 1024, QImage::Format_Grayscale8); image.fill(Qt::black); From b61ac0e35b7c55ec4ffe98c6f82df6aa94a3bf35 Mon Sep 17 00:00:00 2001 From: T1ti Date: Tue, 11 Jul 2023 01:59:54 +0200 Subject: [PATCH 14/14] fix merge issues --- src/noggit/MapTile.cpp | 4 ++-- src/noggit/MapView.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/noggit/MapTile.cpp b/src/noggit/MapTile.cpp index 5c63c77c..bee9975d 100755 --- a/src/noggit/MapTile.cpp +++ b/src/noggit/MapTile.cpp @@ -1225,7 +1225,7 @@ QImage MapTile::getAlphamapImage(std::string const& filename) return std::move(image); } -<<<<<<<<< Temporary merge branch 1 +void MapTile::setHeightmapImage(QImage const& baseimage, float multiplier, int mode, bool tiledEdges) // image { auto image = baseimage.convertToFormat(QImage::Format_Grayscale16); @@ -1448,7 +1448,7 @@ QImage MapTile::getVertexColorsImage() return std::move(image); } -<<<<<<<<< Temporary merge branch 1 +void MapTile::setVertexColorImage(QImage const& baseimage, int mode, bool tiledEdges) { QImage image = baseimage.convertToFormat(QImage::Format_RGBA8888); diff --git a/src/noggit/MapView.cpp b/src/noggit/MapView.cpp index c1af9068..2fbc2fba 100755 --- a/src/noggit/MapView.cpp +++ b/src/noggit/MapView.cpp @@ -1827,6 +1827,7 @@ void MapView::setupAssistMenu() makeCurrent(); OpenGL::context::scoped_setter const _(::gl, context()); NOGGIT_ACTION_MGR->beginAction(this, Noggit::ActionFlags::eCHUNKS_TERRAIN); + _world->importAllADTsHeightmaps(adt_import_height_params_multiplier->value(), adt_import_height_params_mode->currentIndex(), adt_import_height_tiled_edges->isChecked()); NOGGIT_ACTION_MGR->endAction(); ) @@ -1845,6 +1846,7 @@ void MapView::setupAssistMenu() makeCurrent(); OpenGL::context::scoped_setter const _(::gl, context()); NOGGIT_ACTION_MGR->beginAction(this, Noggit::ActionFlags::eCHUNKS_VERTEX_COLOR); + _world->importAllADTVertexColorMaps(adt_import_vcol_params_mode->currentIndex(), adt_import_vcol_params_mode_tiled_edges->isChecked()); NOGGIT_ACTION_MGR->endAction(); )