Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Convex Shape issue  (Read 1502 times)

0 Members and 1 Guest are viewing this topic.

wiiqwertyuiop

  • Newbie
  • *
  • Posts: 3
    • View Profile
Convex Shape issue
« on: December 28, 2023, 12:46:13 am »
I am trying to do some rotation on a object constructed of triangles. For the most part, this works. The issue I am having is at certain points, some of the convex shapes form a "line", and SFML seems to not like it or something. Here is the code I am using:

        sf::ConvexShape drawObj;

        drawObj.setPointCount(3);
        drawObj.setFillColor(sf::Color::Transparent);
        drawObj.setOutlineColor(sf::Color::White);
        drawObj.setOutlineThickness(2.0f);

        drawObj.setPoint(0, sf::Vector2f(249, 258));
        drawObj.setPoint(1, sf::Vector2f(353, 257));
        drawObj.setPoint(2, sf::Vector2f(529, 258));

        window.draw(drawObj);

which produces:



If I modify the middle point so it is further out (257 -> 275), it becomes more "normal":



I'm wondering what the problem is here, or what can be done about this.

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: Convex Shape issue
« Reply #1 on: December 28, 2023, 02:18:35 am »
The top shape is correct for the coordinates you gave.
The middle point is only 1 pixel higher (at 257) than the left and right points (each at 258), so it will look like a line.

wiiqwertyuiop

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Convex Shape issue
« Reply #2 on: December 28, 2023, 04:36:51 am »
My only question is why does it go across the whole screen? I'm trying to make it maintain the size.

texus

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • TGUI
    • Email
Re: Convex Shape issue
« Reply #3 on: December 28, 2023, 08:40:29 am »
TGUI: C++ SFML GUI

wiiqwertyuiop

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Convex Shape issue
« Reply #4 on: December 28, 2023, 09:09:07 am »
That's awesome thanks texus! For now I've switched to using sf::Vertex, since I've noticed this bug isn't present there. But good to know there is a fix for it!
« Last Edit: December 29, 2023, 12:49:19 am by wiiqwertyuiop »

 

anything