mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 10:05:23 +01:00
fix(editor): a stroke of the brush leaves the density set on the ground it goes over
The density of the random and the feathered fills was counted for the whole circle of every dab. The circles of a stroke overlap (a dab every half of the radius), so each place got its share from every dab that went over it: 5 models a 100 m² set came to some 15 on the ground, and more wherever the cursor came back. The count was also rounded for each dab, so a circle too small for half a model (1 m at 4 a 100 m²) never got any. A stroke now keeps the circles of its dabs beside the places of its models (scatter::stroke). A dab draws as many places as the density asks for in its circle and keeps each with the chance of what the ground there is short of: nothing where an earlier dab of the stroke has filled it, so the overlaps and the way back add no more. The count is the whole part of what is asked for and one more with the chance of its fraction, so small circles and low densities get their share over the stroke. The feathered fill is as dense as set in the middle of the stroke and thins out towards its edge; a single dab of it used to squeeze the whole count of the circle into its middle. The uniform fill (the grid) is as it was. The tooltip of the density says what it counts.
This commit is contained in:
@@ -78,7 +78,7 @@ void editor_mode::brush_press()
|
||||
{
|
||||
mouseHold = true;
|
||||
m_brush_has_last = false;
|
||||
m_brush_taken.clear();
|
||||
m_brush_done = {};
|
||||
auto const &settings{ui()->brush()};
|
||||
if (settings.way != brush_object_list::kind::single && settings.stroke == brush_object_list::shape::line)
|
||||
{
|
||||
@@ -138,14 +138,14 @@ void editor_mode::brush_dab()
|
||||
oldPos = centre;
|
||||
m_brush_has_last = true;
|
||||
auto &stroke{m_history.back()};
|
||||
auto const points{scatter::dab({centre.x, centre.z}, settings, m_brush_taken, m_brush_random)};
|
||||
if (static_cast<int>(points.size()) >= scatter::dab_most)
|
||||
// the dab goes to what the stroke has done: its circle isn't filled again, and its places are taken whether a model stands
|
||||
// there or failed, so it isn't tried there on every move
|
||||
auto const points{scatter::dab({centre.x, centre.z}, settings, m_brush_done, m_brush_random)};
|
||||
if (auto const cut_short{settings.mode != scatter::fill::uniform && scatter::dab_wanted(settings) > scatter::dab_most}; cut_short || static_cast<int>(points.size()) >= scatter::dab_most)
|
||||
ui()->set_status(format(STR_C("Brush: a dab puts %d models at most; widen the spacing or narrow the circle for the rest"), scatter::dab_most));
|
||||
for (auto const &point : points)
|
||||
{
|
||||
auto *model{place_brush_model({point.x, brush_height(point, centre.y), point.y})};
|
||||
// the place is taken either way, so a model which failed isn't tried there on every move
|
||||
m_brush_taken.push_back(point);
|
||||
if (model == nullptr)
|
||||
continue;
|
||||
EditorSnapshot::array_copy copy;
|
||||
|
||||
Reference in New Issue
Block a user