SFML community forums

Help => General => Topic started by: Doodlemeat on February 20, 2014, 01:21:17 am

Title: Bug found in thors ConcaveShape
Post by: Doodlemeat on February 20, 2014, 01:21:17 am
Hello.
I found a bug, maybe 2 of them with thor ConcaveShape.

First bug:
A ConcaveShape is not filled with any color. This happens randomly from what I have seen. And yes, I am 100% sure I fill it with color since. It fills with color more often than it does'nt
(http://i.imgur.com/aJxMg44.png)

Second bug:
Sometimes when I call

rt.draw(shape);

where rt is rendertarget and shape is a thor::ConcaveShape, the program crashes with this message:
(http://i.imgur.com/AGsSMdf.png)
here is the callstack:
(http://i.imgur.com/5L6O2Qm.png)

Here lies my code. In Soundripple.cpp.
There is not other file that manipulates the ConcaveShape.
https://github.com/doodlemeat/ProjectTerminal/blob/master/Stealth/SoundRipple.cpp
Title: Re: Bug found in thors ConcaveShape
Post by: thomas9459 on February 20, 2014, 03:09:22 am
Can you provide a SSCCE (http://sscce.org/) so that others can test the code in question? Otherwise, it ends up just being guesswork...
Title: Re: Bug found in thors ConcaveShape
Post by: Doodlemeat on February 20, 2014, 10:31:44 am
So you want the .sln file ? I think you will need all other dependencies like boost and such?
Title: Re: Bug found in thors ConcaveShape
Post by: Nexus on February 20, 2014, 11:02:29 am
No, we want a complete and minimal example that reproduces the problem (http://en.sfml-dev.org/forums/index.php?topic=5559.msg36368#msg36368). Please read the link carefully.
Title: Re: Bug found in thors ConcaveShape
Post by: Doodlemeat on March 05, 2014, 02:24:18 am
Hello!
Sorry for taking so long time.

Below is a .rar file of everything that is included. That is


Built with visual studio 2013 at Windows 8.
Only configured for debug mode.
http://www.sendspace.com/file/ysni67 (http://www.sendspace.com/file/ysni67)
Title: Re: Bug found in thors ConcaveShape
Post by: Doodlemeat on March 05, 2014, 01:44:17 pm
UPDATE!
I just want to tell you that the second bug is not related to the topic. Its a mistake by me, but the first bug is still there :)
Title: Re: Bug found in thors ConcaveShape
Post by: Nexus on March 09, 2014, 06:35:24 pm
I could reduce the problem to the following list of points:
(344, 248)
(120, 248)
(184, 248)
(184, 181)

The problem here is that three points of adjacent triangles are on a line (y=248). This is a limitation of the Delaunay triangulation and stated in the documentation:
Quote from: thor::triangulate() (http://www.bromeon.ch/libraries/thor/v2.0/doc/group___math.html#ga5574e6a3bfed531b608dedf10c204a83)
Note that the triangulation may meet problems at 4 co-circular points or at 3 or more collinear points.
This led to a removal of too many triangles in the cleanup step during thor::triangulatePolygon() called from thor::ConcaveShape, so that the convex shapes composing the concave shape were left empty.

I agree that this limitation is annoying, I'll investigate alternatives. For the concave shape it might suffice to simply offset points randomly by a tiny amount, but I actually prefer a clean solution that also works for other triangulations.
Title: Re: Bug found in thors ConcaveShape
Post by: Nexus on March 09, 2014, 10:43:47 pm
Should be fixed now :)

I improved the triangulation so that this specific case is recognized. It won't be possible to handle all situations of 3 collinear points (e.g. only 3 vertices in total), but most reasonable scenarios should be handled correctly now.