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

Author Topic: Check if line intersects shape  (Read 1407 times)

0 Members and 1 Guest are viewing this topic.

jdm1891

  • Newbie
  • *
  • Posts: 17
    • View Profile
Check if line intersects shape
« on: December 13, 2016, 02:37:31 am »
I have a a sf::VertexArray that makes a line, and I have a shape(sf::Shape).

How can I check if the line goes through the shape?

Note though because I am using the sf::Shape class and not a specific shape so I would prefer to only use getPoint() and getPointCount() to do it

This is for lighting so it is very important that I don't use a rectangle. The reason I want to do this is to find where the light needs to stop being drawn(I have it as a mask over the world), which is when the light intersects an object. If you know a better way to do this please tell me!
« Last Edit: December 13, 2016, 02:40:37 am by jdm1891 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Check if line intersects shape
« Reply #1 on: December 13, 2016, 07:19:22 am »
This is the kind of question that is immediately answered with Google. You didn't even search, did you?

https://www.google.com/search?q=line+polygon+intersection
Laurent Gomila - SFML developer