Swap texture on chunk even if texture set is full
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <QtWidgets/QDoubleSpinBox>
|
||||
#include <QtWidgets/QGroupBox>
|
||||
#include <QtWidgets/QCheckBox>
|
||||
#include <QtWidgets/QSlider>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <optional>
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user