implement radius based painting for area id
This commit is contained in:
@@ -1842,7 +1842,7 @@ void MapView::tick (float dt)
|
|||||||
if (_mod_shift_down)
|
if (_mod_shift_down)
|
||||||
{
|
{
|
||||||
// draw the selected AreaId on current selected chunk
|
// draw the selected AreaId on current selected chunk
|
||||||
_world->setAreaID(_cursor_pos, _selected_area_id, false);
|
_world->setAreaID(_cursor_pos, _selected_area_id, false, ZoneIDBrowser->brushRadius());
|
||||||
}
|
}
|
||||||
else if (_mod_ctrl_down)
|
else if (_mod_ctrl_down)
|
||||||
{
|
{
|
||||||
@@ -2348,6 +2348,9 @@ void MapView::draw_map()
|
|||||||
case editing_mode::mccv:
|
case editing_mode::mccv:
|
||||||
radius = shaderTool->brushRadius();
|
radius = shaderTool->brushRadius();
|
||||||
break;
|
break;
|
||||||
|
case editing_mode::areaid:
|
||||||
|
radius = ZoneIDBrowser->brushRadius();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \note Select terrain below mouse, if no item selected or the item is map.
|
//! \note Select terrain below mouse, if no item selected or the item is map.
|
||||||
@@ -2706,6 +2709,10 @@ void MapView::mouseMoveEvent (QMouseEvent* event)
|
|||||||
case editing_mode::mccv:
|
case editing_mode::mccv:
|
||||||
shaderTool->changeRadius(relative_movement.dx() / XSENS);
|
shaderTool->changeRadius(relative_movement.dx() / XSENS);
|
||||||
break;
|
break;
|
||||||
|
case editing_mode::areaid:
|
||||||
|
ZoneIDBrowser->changeRadius(relative_movement.dx() / XSENS);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1411,7 +1411,7 @@ void World::CropWaterADT(const tile_index& pos)
|
|||||||
for_tile_at(pos, [](MapTile* tile) { tile->CropWater(); });
|
for_tile_at(pos, [](MapTile* tile) { tile->CropWater(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::setAreaID(math::vector_3d const& pos, int id, bool adt)
|
void World::setAreaID(math::vector_3d const& pos, int id, bool adt, float radius)
|
||||||
{
|
{
|
||||||
if (adt)
|
if (adt)
|
||||||
{
|
{
|
||||||
@@ -1419,7 +1419,22 @@ void World::setAreaID(math::vector_3d const& pos, int id, bool adt)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for_chunk_at(pos, [&](MapChunk* chunk) { chunk->setAreaID(id);});
|
|
||||||
|
if (radius >= 0)
|
||||||
|
{
|
||||||
|
for_all_chunks_in_range(pos, radius,
|
||||||
|
[&] (MapChunk* chunk)
|
||||||
|
{
|
||||||
|
chunk->setAreaID(id);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for_chunk_at(pos, [&](MapChunk* chunk) { chunk->setAreaID(id);});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
unsigned int getAreaID (math::vector_3d const&);
|
unsigned int getAreaID (math::vector_3d const&);
|
||||||
void setAreaID(math::vector_3d const& pos, int id, bool adt);
|
void setAreaID(math::vector_3d const& pos, int id, bool adt, float radius = -1.0f);
|
||||||
|
|
||||||
selection_result intersect ( math::matrix_4x4 const& model_view
|
selection_result intersect ( math::matrix_4x4 const& model_view
|
||||||
, math::ray const&
|
, math::ray const&
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <noggit/Misc.h>
|
#include <noggit/Misc.h>
|
||||||
|
|
||||||
#include <QtWidgets/QVBoxLayout>
|
#include <QtWidgets/QVBoxLayout>
|
||||||
|
#include <QtWidgets/QFormLayout>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -21,8 +22,21 @@ namespace noggit
|
|||||||
, _area_tree(new QTreeWidget())
|
, _area_tree(new QTreeWidget())
|
||||||
, mapID(-1)
|
, mapID(-1)
|
||||||
{
|
{
|
||||||
new QVBoxLayout(this);
|
auto layout = new QFormLayout(this);
|
||||||
this->layout()->addWidget(_area_tree);
|
|
||||||
|
_radius_spin = new QDoubleSpinBox (this);
|
||||||
|
_radius_spin->setRange (0.0f, 250.0f);
|
||||||
|
_radius_spin->setDecimals (2);
|
||||||
|
_radius_spin->setValue (_radius);
|
||||||
|
|
||||||
|
layout->addRow ("Radius:", _radius_spin);
|
||||||
|
|
||||||
|
_radius_slider = new QSlider (Qt::Orientation::Horizontal, this);
|
||||||
|
_radius_slider->setRange (0, 100);
|
||||||
|
_radius_slider->setSliderPosition (_radius);
|
||||||
|
|
||||||
|
layout->addRow (_radius_slider);
|
||||||
|
layout->addRow (_area_tree);
|
||||||
|
|
||||||
|
|
||||||
connect ( _area_tree, &QTreeWidget::itemSelectionChanged
|
connect ( _area_tree, &QTreeWidget::itemSelectionChanged
|
||||||
@@ -35,6 +49,24 @@ namespace noggit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
connect ( _radius_spin, qOverload<double> (&QDoubleSpinBox::valueChanged)
|
||||||
|
, [&] (double v)
|
||||||
|
{
|
||||||
|
_radius = v;
|
||||||
|
QSignalBlocker const blocker(_radius_slider);
|
||||||
|
_radius_slider->setSliderPosition ((int)std::round (v));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
connect ( _radius_slider, &QSlider::valueChanged
|
||||||
|
, [&] (int v)
|
||||||
|
{
|
||||||
|
_radius = v;
|
||||||
|
QSignalBlocker const blocker(_radius_spin);
|
||||||
|
_radius_spin->setValue(v);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zone_id_browser::setMapID(int id)
|
void zone_id_browser::setMapID(int id)
|
||||||
@@ -89,6 +121,11 @@ namespace noggit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void zone_id_browser::changeRadius(float change)
|
||||||
|
{
|
||||||
|
_radius_spin->setValue (_radius + change);
|
||||||
|
}
|
||||||
|
|
||||||
QTreeWidgetItem* zone_id_browser::create_or_get_tree_widget_item(int area_id)
|
QTreeWidgetItem* zone_id_browser::create_or_get_tree_widget_item(int area_id)
|
||||||
{
|
{
|
||||||
auto it = _items.find(area_id);
|
auto it = _items.find(area_id);
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include <QtWidgets/QWidget>
|
#include <QtWidgets/QWidget>
|
||||||
#include <QtWidgets/QTreeWidget>
|
#include <QtWidgets/QTreeWidget>
|
||||||
|
#include <QtWidgets/QDoubleSpinBox>
|
||||||
|
#include <QtWidgets/QSlider>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -20,14 +22,22 @@ namespace noggit
|
|||||||
zone_id_browser(QWidget* parent = nullptr);
|
zone_id_browser(QWidget* parent = nullptr);
|
||||||
void setMapID(int id);
|
void setMapID(int id);
|
||||||
void setZoneID(int id);
|
void setZoneID(int id);
|
||||||
|
void changeRadius(float change);
|
||||||
|
|
||||||
|
float brushRadius() const { return _radius; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void selected (int area_id);
|
void selected (int area_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTreeWidget* _area_tree;
|
QTreeWidget* _area_tree;
|
||||||
|
|
||||||
|
QSlider* _radius_slider;
|
||||||
|
QDoubleSpinBox* _radius_spin;
|
||||||
|
|
||||||
std::map<int, QTreeWidgetItem*> _items;
|
std::map<int, QTreeWidgetItem*> _items;
|
||||||
int mapID;
|
int mapID;
|
||||||
|
float _radius = 15.0f;
|
||||||
|
|
||||||
void buildAreaList();
|
void buildAreaList();
|
||||||
QTreeWidgetItem* create_or_get_tree_widget_item(int area_id);
|
QTreeWidgetItem* create_or_get_tree_widget_item(int area_id);
|
||||||
|
|||||||
Reference in New Issue
Block a user