SFML community forums

General => General discussions => Topic started by: Dejan Geci on July 23, 2014, 08:12:15 pm

Title: ConvexShape class
Post by: Dejan Geci on July 23, 2014, 08:12:15 pm
I was looking around the https://github.com/SFML/SFML.Net/pull/41 and it got me thinking...

ConvexShape class is not named properly (http://www.mathsisfun.com/definitions/convex.html). It should be named PolygonShape, since we can manually define points that create angles > 180°. Right?
Title: Re: ConvexShape class
Post by: Chaore on July 23, 2014, 08:25:44 pm
No Convexe is alright.

According to the tutorial:
Quote
Indeed, SFML is unable to draw concave shapes; if you need to draw a concave shape, you'll have to split it into multiple convex polygons (if possible).



For concave shape Thor library has a class to handle this:
http://www.bromeon.ch/libraries/thor/v2.0/doc/classthor_1_1_concave_shape.html
Title: Re: ConvexShape class
Post by: Laurent on July 23, 2014, 08:31:12 pm
It's great to start a public discussion about a class without reading its documentation or tutorials first...

Quote from: the doc
It is important to keep in mind that a convex shape must always be... convex, otherwise it may not be drawn correctly.
Title: Re: ConvexShape class
Post by: Dejan Geci on July 23, 2014, 11:58:10 pm
Thanks Chaore, you are right. I guess I'm used to reading the source code as documentation, and I didn't see any constraints in the code.
Title: Re: ConvexShape class
Post by: Nexus on July 24, 2014, 12:14:17 am
I guess I'm used to reading the source code as documentation
You must be working a lot with very badly documented software :P
Title: Re: ConvexShape class
Post by: zsbzsb on July 24, 2014, 12:21:38 am
I didn't see any constraints in the code.

There isn't any constraints imposed by the SFML library, the constraint comes from how OpenGL is able to handle primitive types.
Title: Re: ConvexShape class
Post by: motherbrain on July 25, 2014, 07:39:51 pm
It's great to start a public discussion about a class without reading its documentation or tutorials first...

Quote from: the doc
It is important to keep in mind that a convex shape must always be... convex, otherwise it may not be drawn correctly.

In the tutorial it says:
Quote
Officially, sf::ConvexShape can only create convex shapes. But in fact, its requirements are a little more relaxed. In fact, the only technical constraint that your shape must follow, is that if you draw a line from its center of gravity to any of its point, you mustn't cross an edge. With this relaxed definition, you can for example draw stars.

Title: Re: ConvexShape class
Post by: Laurent on July 25, 2014, 08:01:33 pm
It's more an implementation detail. If one day I change the way convex shapes are drawn, this may not be true anymore. I should probably remove this from the tutorial.