Hi guys I'm trying to create my own version of sf::Shape for more specific needs.
I had a look at the source and I don't understand the following:
void sf::Shape::update()
[...]
m_vertices.resize(count + 2); // + 2 for center and repeated first point
// Position
for (std::size_t i = 0; i < count; ++i)
m_vertices[i + 1].position = getPoint(i);
m_vertices[count + 1].position = m_vertices[1].position;
// Update the bounding rectangle
m_vertices[0] = m_vertices[1]; // so that the result of getBounds() is correct
m_insideBounds = m_vertices.getBounds();
// Compute the center and make it the first vertex
m_vertices[0].position.x = m_insideBounds.left + m_insideBounds.width / 2;
m_vertices[0].position.y = m_insideBounds.top + m_insideBounds.height / 2;
[...]
In my shape class I have the bounding rect already calculated but I guess it's here for texture mapping and other features, what I want to ask is why you need the point in the center? Is it required? I've played with my raw vertices and it seems to work fine without it. Same with the "first repeated point" why do you need it? Can I have a polygon or circle just from "raw" vertices and render it with sf::PrimitiveType::TriangleFan and have it work fine?