diff --git a/src/noggit/MapChunk.cpp b/src/noggit/MapChunk.cpp index a22b4a60..d29a6efd 100755 --- a/src/noggit/MapChunk.cpp +++ b/src/noggit/MapChunk.cpp @@ -1285,9 +1285,9 @@ bool MapChunk::stampTexture(glm::vec3 const& pos, Brush *brush, float strength, return texture_set->stampTexture(xbase, zbase, pos.x, pos.z, brush, strength, pressure, std::move (texture), img, paint); } -bool MapChunk::replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture) +bool MapChunk::replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture, bool entire_chunk) { - return texture_set->replace_texture(xbase, zbase, pos.x, pos.z, radius, old_texture, std::move (new_texture)); + return texture_set->replace_texture(xbase, zbase, pos.x, pos.z, radius, old_texture, std::move (new_texture), entire_chunk); } bool MapChunk::canPaintTexture(scoped_blp_texture_reference texture) diff --git a/src/noggit/MapChunk.h b/src/noggit/MapChunk.h index 2989f1c9..656c8c8b 100755 --- a/src/noggit/MapChunk.h +++ b/src/noggit/MapChunk.h @@ -157,7 +157,7 @@ public: //! \todo implement Action stack for these bool paintTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture); bool stampTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint); - bool replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture); + 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); diff --git a/src/noggit/World.cpp b/src/noggit/World.cpp index 95d17945..af901bb4 100755 --- a/src/noggit/World.cpp +++ b/src/noggit/World.cpp @@ -1190,7 +1190,7 @@ bool World::sprayTexture(glm::vec3 const& pos, Brush *brush, float strength, flo return succ; } -bool World::replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture) +bool World::replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture, bool entire_chunk) { ZoneScoped; return for_all_chunks_in_range @@ -1198,7 +1198,7 @@ bool World::replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_textur , [&](MapChunk* chunk) { NOGGIT_CUR_ACTION->registerChunkTextureChange(chunk); - return chunk->replaceTexture(pos, radius, old_texture, new_texture); + return chunk->replaceTexture(pos, radius, old_texture, new_texture, entire_chunk); } ); } diff --git a/src/noggit/World.h b/src/noggit/World.h index ce59dfb6..eec45727 100755 --- a/src/noggit/World.h +++ b/src/noggit/World.h @@ -208,7 +208,7 @@ public: bool paintTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture); bool stampTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, scoped_blp_texture_reference texture, QImage* img, bool paint); bool sprayTexture(glm::vec3 const& pos, Brush *brush, float strength, float pressure, float spraySize, float sprayPressure, scoped_blp_texture_reference texture); - bool replaceTexture(glm::vec3 const& pos, float radius, scoped_blp_texture_reference const& old_texture, scoped_blp_texture_reference new_texture); + 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); void eraseTextures(glm::vec3 const& pos); void overwriteTextureAtCurrentChunk(glm::vec3 const& pos, scoped_blp_texture_reference const& oldTexture, scoped_blp_texture_reference newTexture); diff --git a/src/noggit/rendering/WorldRender.cpp b/src/noggit/rendering/WorldRender.cpp index f56a7092..3ff4a5e4 100755 --- a/src/noggit/rendering/WorldRender.cpp +++ b/src/noggit/rendering/WorldRender.cpp @@ -1663,4 +1663,4 @@ bool WorldRender::saveMinimap(TileIndex const& tile_idx, MinimapRenderSettings* pixel_buffer.release(); return true; -} \ No newline at end of file +} diff --git a/src/noggit/texture_set.cpp b/src/noggit/texture_set.cpp index 96d307fa..0a8deab2 100755 --- a/src/noggit/texture_set.cpp +++ b/src/noggit/texture_set.cpp @@ -817,6 +817,7 @@ bool TextureSet::replace_texture( float xbase , float radius , scoped_blp_texture_reference const& texture_to_replace , scoped_blp_texture_reference replacement_texture + , bool entire_chunk ) { float dist = misc::getShortestDist(x, z, xbase, zbase, CHUNKSIZE); @@ -826,6 +827,14 @@ bool TextureSet::replace_texture( float xbase return false; } + if (entire_chunk) + { + replace_texture(texture_to_replace, std::move (replacement_texture)); + _chunk->registerChunkUpdate(ChunkUpdateFlags::ALPHAMAP); + _need_lod_texture_map_update = true; + return true; + } + // if the chunk is fully inside the brush, just swap the 2 textures if (misc::square_is_in_circle(x, z, radius, xbase, zbase, CHUNKSIZE)) { @@ -1368,4 +1377,4 @@ std::array TextureSet::lod_texture_map() } return _doodadMapping; -} \ No newline at end of file +} diff --git a/src/noggit/texture_set.hpp b/src/noggit/texture_set.hpp index 832ff773..3e576836 100755 --- a/src/noggit/texture_set.hpp +++ b/src/noggit/texture_set.hpp @@ -55,6 +55,7 @@ public: , float radius , scoped_blp_texture_reference const& texture_to_replace , scoped_blp_texture_reference replacement_texture + , bool entire_chunk = false ); bool canPaintTexture(scoped_blp_texture_reference const& texture); diff --git a/src/noggit/ui/texture_swapper.cpp b/src/noggit/ui/texture_swapper.cpp index 9cf29c71..b890b96f 100755 --- a/src/noggit/ui/texture_swapper.cpp +++ b/src/noggit/ui/texture_swapper.cpp @@ -51,6 +51,11 @@ namespace Noggit auto brush_layout (new QFormLayout(brush_content)); _brush_mode_group->setLayout(brush_layout); + _swap_entire_chunk = new QCheckBox(brush_content); + _swap_entire_chunk->setText(tr("Entire chunk")); + _swap_entire_chunk->setCheckState(Qt::CheckState::Unchecked); + brush_layout->addRow(_swap_entire_chunk); + _radius_spin = new QDoubleSpinBox(brush_content); _radius_spin->setRange (0.f, 100.f); _radius_spin->setDecimals (2); diff --git a/src/noggit/ui/texture_swapper.hpp b/src/noggit/ui/texture_swapper.hpp index 590c0797..6ba78ca0 100755 --- a/src/noggit/ui/texture_swapper.hpp +++ b/src/noggit/ui/texture_swapper.hpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -35,6 +36,11 @@ namespace Noggit return _radius; } + bool entireChunk() const + { + return _swap_entire_chunk->isChecked(); + } + void change_radius(float change); bool brush_mode() const @@ -60,6 +66,7 @@ namespace Noggit QGroupBox* _brush_mode_group; QSlider* _radius_slider; + QCheckBox* _swap_entire_chunk; QDoubleSpinBox* _radius_spin; World* _world; }; diff --git a/src/noggit/ui/texturing_tool.cpp b/src/noggit/ui/texturing_tool.cpp index c0a44438..e144b66f 100755 --- a/src/noggit/ui/texturing_tool.cpp +++ b/src/noggit/ui/texturing_tool.cpp @@ -514,7 +514,8 @@ namespace Noggit { if (_texture_switcher->brush_mode()) { - world->replaceTexture(pos, _texture_switcher->radius(), to_swap.value(), texture); + std::cout << _texture_switcher->radius() << std::endl; + world->replaceTexture(pos, _texture_switcher->radius(), to_swap.value(), texture, _texture_switcher->entireChunk()); } else {