implement radius based input for hole tool
This commit is contained in:
@@ -1038,7 +1038,7 @@ bool MapChunk::isHole(int i, int j)
|
||||
return (holes & ((1 << ((j * 4) + i)))) != 0;
|
||||
}
|
||||
|
||||
void MapChunk::setHole(math::vector_3d const& pos, bool big, bool add)
|
||||
void MapChunk::setHole(math::vector_3d const& pos, float radius, bool big, bool add)
|
||||
{
|
||||
if (big)
|
||||
{
|
||||
@@ -1046,8 +1046,21 @@ void MapChunk::setHole(math::vector_3d const& pos, bool big, bool add)
|
||||
}
|
||||
else
|
||||
{
|
||||
int v = 1 << ((int)((pos.z - zbase) / MINICHUNKSIZE) * 4 + (int)((pos.x - xbase) / MINICHUNKSIZE));
|
||||
holes = add ? (holes | v) : (holes & ~v);
|
||||
for (int x = 0; x < 4; ++x)
|
||||
{
|
||||
for (int y = 0; y < 4; ++y)
|
||||
{
|
||||
if (misc::getShortestDist(pos.x, pos.z, xbase + (MINICHUNKSIZE * x),
|
||||
zbase + (MINICHUNKSIZE * y), MINICHUNKSIZE) <= radius)
|
||||
{
|
||||
int v = 1 << (y * 4 + x);
|
||||
holes = add ? (holes | v) : (holes & ~v);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
initStrip();
|
||||
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
|
||||
//! \todo implement Action stack for these
|
||||
bool isHole(int i, int j);
|
||||
void setHole(math::vector_3d const& pos, bool big, bool add);
|
||||
void setHole(math::vector_3d const& pos, float radius, bool big, bool add);
|
||||
|
||||
void setFlag(bool value, uint32_t);
|
||||
|
||||
|
||||
@@ -1840,11 +1840,11 @@ void MapView::tick (float dt)
|
||||
// no undermap check here, else it's impossible to remove holes
|
||||
if (_mod_shift_down)
|
||||
{
|
||||
_world->setHole(_cursor_pos, _mod_alt_down, false);
|
||||
_world->setHole(_cursor_pos, holeTool->brushRadius(),_mod_alt_down, false);
|
||||
}
|
||||
else if (_mod_ctrl_down && !underMap)
|
||||
{
|
||||
_world->setHole(_cursor_pos, _mod_alt_down, true);
|
||||
_world->setHole(_cursor_pos, holeTool->brushRadius(), _mod_alt_down, true);
|
||||
}
|
||||
break;
|
||||
case editing_mode::areaid:
|
||||
@@ -2362,6 +2362,9 @@ void MapView::draw_map()
|
||||
case editing_mode::areaid:
|
||||
radius = ZoneIDBrowser->brushRadius();
|
||||
break;
|
||||
case editing_mode::holes:
|
||||
radius = holeTool->brushRadius();
|
||||
break;
|
||||
}
|
||||
|
||||
//! \note Select terrain below mouse, if no item selected or the item is map.
|
||||
@@ -2723,6 +2726,9 @@ void MapView::mouseMoveEvent (QMouseEvent* event)
|
||||
case editing_mode::areaid:
|
||||
ZoneIDBrowser->changeRadius(relative_movement.dx() / XSENS);
|
||||
break;
|
||||
case editing_mode::holes:
|
||||
holeTool->changeRadius(relative_movement.dx() / XSENS);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1647,14 +1647,21 @@ void World::overwriteTextureAtCurrentChunk(math::vector_3d const& pos, scoped_bl
|
||||
for_chunk_at(pos, [&](MapChunk* chunk) {chunk->switchTexture(oldTexture, std::move (newTexture));});
|
||||
}
|
||||
|
||||
void World::setHole(math::vector_3d const& pos, bool big, bool hole)
|
||||
void World::setHole(math::vector_3d const& pos, float radius, bool big, bool hole)
|
||||
{
|
||||
for_chunk_at(pos, [&](MapChunk* chunk) { chunk->setHole(pos, big, hole); });
|
||||
for_all_chunks_in_range
|
||||
( pos, radius
|
||||
, [&](MapChunk* chunk)
|
||||
{
|
||||
chunk->setHole(pos, radius, big, hole);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void World::setHoleADT(math::vector_3d const& pos, bool hole)
|
||||
{
|
||||
for_all_chunks_on_tile(pos, [&](MapChunk* chunk) { chunk->setHole(pos, true, hole); });
|
||||
for_all_chunks_on_tile(pos, [&](MapChunk* chunk) { chunk->setHole(pos, 1.0f, true, hole); });
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ public:
|
||||
void removeTexDuplicateOnADT(math::vector_3d const& pos);
|
||||
void change_texture_flag(math::vector_3d const& pos, scoped_blp_texture_reference const& tex, std::size_t flag, bool add);
|
||||
|
||||
void setHole(math::vector_3d const& pos, bool big, bool hole);
|
||||
void setHole(math::vector_3d const& pos, float radius, bool big, bool hole);
|
||||
void setHoleADT(math::vector_3d const& pos, bool hole);
|
||||
|
||||
void addM2 ( std::string const& filename
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace noggit
|
||||
layout->addRow ("Radius:", _radius_spin);
|
||||
|
||||
_radius_slider = new QSlider (Qt::Orientation::Horizontal, this);
|
||||
_radius_slider->setRange (0, 100);
|
||||
_radius_slider->setRange (0, 250);
|
||||
_radius_slider->setSliderPosition (_radius);
|
||||
|
||||
layout->addRow (_radius_slider);
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace noggit
|
||||
layout->addRow ("Radius:", _radius_spin);
|
||||
|
||||
_radius_slider = new QSlider (Qt::Orientation::Horizontal, this);
|
||||
_radius_slider->setRange (0, 100);
|
||||
_radius_slider->setRange (0, 250);
|
||||
_radius_slider->setSliderPosition (_radius);
|
||||
|
||||
layout->addRow (_radius_slider);
|
||||
|
||||
Reference in New Issue
Block a user