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

Author Topic: Deleting points in a shape  (Read 2089 times)

0 Members and 1 Guest are viewing this topic.

Mangocheese

  • Newbie
  • *
  • Posts: 5
    • View Profile
Deleting points in a shape
« on: March 25, 2010, 01:56:49 pm »
Hello again,

I searched high and low for a function or a way to delete the points within a shape, and I haven't been able to find anything!

How do I delete points from a shape?

Thanks

nulloid

  • Full Member
  • ***
  • Posts: 134
    • View Profile
Deleting points in a shape
« Reply #1 on: March 25, 2010, 03:29:00 pm »
Well, if it isn't added (yet), then either you write it for yourself in the sfml code, or you inherit a class from sf::Shape and add to it. Or, alternatively, you can create another sf::Shape, add points from the existing shape, but skip those points you want to "delete".

But a function like this would be useful, indeed :)

model76

  • Full Member
  • ***
  • Posts: 231
    • View Profile
Deleting points in a shape
« Reply #2 on: March 25, 2010, 04:15:10 pm »
Here is how I do it in my application: Keep a pure logical shape, and draw a new sf::shape based on that, whenever it changes.

A logical shape is an instance of a class that has an std::vector of sf::vector2f to keep track of the vertices, and methods to add and delete vertices.

Mangocheese

  • Newbie
  • *
  • Posts: 5
    • View Profile
Deleting points in a shape
« Reply #3 on: March 25, 2010, 04:48:32 pm »
Thanks for the prompt replies!

My application only needs to display the shape so I know where my logical shape is. So I just added this to the SFML Shape source code:

Code: [Select]

void Shape::ClearShape()
{
myPoints.clear();
    // Put a placeholder for the center of the shape
    myPoints.push_back(Point())
}


Pretty easy. Although, I am not too sure how much it "breaks" the shape, but it doesn't matter for me since I just use the logical shape anyway.