mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 06:35:21 +01:00
fix(editor): the brush keeps its models when the step of the stroke is gone from the history (Sonar)
A stroke held long enough for its step to be trimmed from the history took the step as null and the next model crashed the editor (Sonar S2259 in editormodebrush.cpp). The rest of the stroke now goes to a step of its own, which Ctrl+Z takes back. The other notes of the analysis, with no change of behaviour: the fill loops test their counter only and stop on the limit inside (S886), brush_on_line() is const, the step is found with std::to_address, the line shape of the brush is shape::along_line (it shadowed the line settings, S1117), and the test of the picks without finite settings is a helper (S134), with std::numbers::pi in the density test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DDcMn1p6qPUo2Cgx4KaVYU
This commit is contained in:
@@ -80,8 +80,10 @@ void grid_row(long long const Row, glm::dvec2 const &Centre, double const Radius
|
||||
auto const z{static_cast<double>(Row) * row};
|
||||
auto const first{static_cast<long long>(std::floor((Centre.x - Radius - shift) / Spacing))};
|
||||
auto const last{static_cast<long long>(std::ceil((Centre.x + Radius - shift) / Spacing))};
|
||||
for (auto c = first; c <= last && static_cast<int>(Made.size()) < dab_most; ++c)
|
||||
for (auto c = first; c <= last; ++c)
|
||||
{
|
||||
if (static_cast<int>(Made.size()) >= dab_most)
|
||||
break;
|
||||
glm::dvec2 const point{static_cast<double>(c) * Spacing + shift, z};
|
||||
// the points of one dab are Spacing apart by the grid itself; only a point an earlier dab put is there already, the same
|
||||
// point again, a hair away at most
|
||||
@@ -98,8 +100,12 @@ std::vector<glm::dvec2> grid_points(glm::dvec2 const &Centre, double const Radiu
|
||||
auto const row{Spacing * std::sqrt(3.0) * 0.5};
|
||||
auto const first_row{static_cast<long long>(std::floor((Centre.y - Radius) / row))};
|
||||
auto const last_row{static_cast<long long>(std::ceil((Centre.y + Radius) / row))};
|
||||
for (auto r = first_row; r <= last_row && static_cast<int>(made.size()) < dab_most; ++r)
|
||||
for (auto r = first_row; r <= last_row; ++r)
|
||||
{
|
||||
if (static_cast<int>(made.size()) >= dab_most)
|
||||
break;
|
||||
grid_row(r, Centre, Radius, Spacing, Taken, made);
|
||||
}
|
||||
return made;
|
||||
}
|
||||
|
||||
@@ -228,8 +234,10 @@ struct regular_line
|
||||
std::uniform_real_distribution each_way{-1.0, 1.0};
|
||||
// the places of the row counted in whole steps: no error added up along a long line
|
||||
auto const steps{static_cast<long long>(std::floor((line.length() + 1e-9 - shift) / spacing))};
|
||||
for (long long step = 0; step <= steps && static_cast<int>(Made.size()) < line_most; ++step)
|
||||
for (long long step = 0; step <= steps; ++step)
|
||||
{
|
||||
if (static_cast<int>(Made.size()) >= line_most)
|
||||
break;
|
||||
auto const at{shift + static_cast<double>(step) * spacing};
|
||||
auto const along_off{jitter > 0.0 ? jitter * each_way(random) : 0.0};
|
||||
auto const side_off{jitter > 0.0 ? jitter * each_way(random) : 0.0};
|
||||
@@ -249,8 +257,10 @@ struct regular_line
|
||||
auto const rows{static_cast<long long>(std::floor(std::max(0.0, settings.width) / spacing + 1e-9))};
|
||||
// the row on the line first, then the pairs of rows outwards: cut short by the limit, the band stays even
|
||||
row(0, taken, made);
|
||||
for (long long r = 1; r <= rows && static_cast<int>(made.size()) < line_most; ++r)
|
||||
for (long long r = 1; r <= rows; ++r)
|
||||
{
|
||||
if (static_cast<int>(made.size()) >= line_most)
|
||||
break;
|
||||
row(r, taken, made);
|
||||
row(-r, taken, made);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user