SFML community forums
General => Feature requests => Topic started by: Keith99 on June 26, 2018, 01:32:16 pm
-
Hi, I hope this is the right place for this. I would like to request a small addition to the ConvexShape:
Add a setPoints function (with an s at the end) to it.
Currently I am doing some experiments involving drawing convex shapes with 1000s of points and calling addPoint for each one kills performance (I think due to SFML updating internal data each time a point is added). All I would like is:
void ConvexShape::setPoints(std::vector<Vector2f> points)
{
m_points=points;
Update();
}
(points could be passed by reference but there may be a case for by value if std::move can be used?)
thanks
-
What kills performances is probably the call to update(), which recomputes the shape's geometry, for each new point, while it could be done once at the end. Instead of a setPoints function, we should probably do lazy updates (like in other classes).
In the meantime, you can easily work around this problem: look at sf::ConvexShape, it is made of 7 lines of code so I think you can create your own shape class based on it, with the optimizations that you need ;)
-
Good point yes, I had forgotten SFML shape class can be user extended.