select curLine in next step, only drawing lines for resulting hull

This commit is contained in:
incredibleLeitman 2020-11-30 19:57:56 +01:00
parent 0500981fdd
commit ade947d219

View File

@ -265,8 +265,6 @@ void Display::update ()
m_points.erase(m_points.begin() + i); m_points.erase(m_points.begin() + i);
} }
} }
//setCurrentLine(); // set current line in next step
} }
else else
{ {
@ -309,10 +307,6 @@ void Display::update ()
m_lines.push_back(Line(Point(left.x, left.y), Point(right.x, right.y))); m_lines.push_back(Line(Point(left.x, left.y), Point(right.x, right.y)));
m_lines.push_back(Line(Point(right.x, right.y), Point(left.x, left.y))); // add first line in both directions to work with "right side" m_lines.push_back(Line(Point(right.x, right.y), Point(left.x, left.y))); // add first line in both directions to work with "right side"
// set current line just by taking the only one (in one direction)
m_curLineIdx = 1;
m_curLine = m_lines[1];
} }
} }
else if (curStep == 2) else if (curStep == 2)
@ -457,10 +451,11 @@ void Display::render (sf::RenderWindow &window)
// draw already calculated hull points // draw already calculated hull points
std::sort(m_hullPoints.begin(), m_hullPoints.end(), less); // sort clockwise std::sort(m_hullPoints.begin(), m_hullPoints.end(), less); // sort clockwise
size_t points = m_points.size();
size_t elements = m_hullPoints.size(); size_t elements = m_hullPoints.size();
for (size_t i = 0; i < elements; ++i) for (size_t i = 0; i < elements; ++i)
{ {
window.draw(m_hullPoints[i]); if (points > 0 || m_curLineIdx != -1) window.draw(m_hullPoints[i]);
sf::Vertex ptTo; sf::Vertex ptTo;
if (i < elements - 1) ptTo = sf::Vertex(m_hullPoints[i + 1].getPosition(), sf::Color::Blue); if (i < elements - 1) ptTo = sf::Vertex(m_hullPoints[i + 1].getPosition(), sf::Color::Blue);