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

Author Topic: Rectangle intersection  (Read 1770 times)

0 Members and 1 Guest are viewing this topic.

cobrapitz

  • Newbie
  • *
  • Posts: 3
    • View Profile
Rectangle intersection
« on: June 16, 2014, 07:51:15 pm »
Hello,
i need help to solve this problem..

My problem is the fact that my mouse intersects with a rotated rectangleshape as if it would be a non-rotated square  :o


so my question is how to cut this off ( for my collision detection )?

Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: Rectangle intersection
« Reply #1 on: June 16, 2014, 08:05:12 pm »
Just google this up, there are tons of solutions out there, probably also here on the forums, too.
Failing to succeed does not mean failing to progress!

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Rectangle intersection
« Reply #2 on: June 16, 2014, 08:07:39 pm »
I'm pretty sure SFML supports this:
rect.getGlobalBounds().contains(mousePos);
« Last Edit: June 16, 2014, 08:46:18 pm by Ixrec »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Rectangle intersection
« Reply #3 on: June 16, 2014, 08:42:01 pm »
Nothing to add to Geheim's post. The algorithm is pretty basic and can be found easily with Google.

Quote
I'm pretty sure SFML supports this
SFML doesn't support rotated rectangles. The global bounds of a rotated entity is the axis-aligned bounding box of the entity's bouding box -- the outer rect in cobrapitz's drawing.
« Last Edit: June 16, 2014, 08:43:46 pm by Laurent »
Laurent Gomila - SFML developer

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Rectangle intersection
« Reply #4 on: June 16, 2014, 08:45:20 pm »
Ah, right.  It should work for sprites though.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Rectangle intersection
« Reply #5 on: June 16, 2014, 08:48:29 pm »
Not if they are rotated.
Laurent Gomila - SFML developer

 

anything