Line Collision Checking - possible?

Mar 16, 2009 at 3:32 PM
Imagine a character can fire lasers. On the moment of firing, there should be an instant collision with the first geom in the same collision category (following the direction of the laser). One would like to know which geom it hit, and on what relative point.

Any ideas on how to perform this sort of Line Collision check?
Mar 16, 2009 at 6:17 PM
well, if your asking if you could see what collision points came in contact you could use the debug view.
Mar 16, 2009 at 7:52 PM
Edited Mar 16, 2009 at 7:54 PM
At the moment, there is nothing built into the library for doing this, but it is in the works for version 2.1.

See this thread.
Mar 17, 2009 at 12:31 AM
We actually do have a mechanism for checking line-to-line collisions. (this includes line-to-geometry collision). But there is no higher-level API to utilize it on the same level as normal geometries. This means you can't just create a line and expect it to collide with everything else in the physics simulator. When we get stuff like CCD (continuous collision detection) into Farseer Physics we will have a look at line collisions.

No worries tho. What you are asking should be possible with the current implementation. Use the CollisionHelper class to check for intersections between 2 lines. You can also check against a line and geometry (geometries are just a bunch of lines because they are all treated like polygons).

I've actually just uploaded a new demo to AdvancedSamples (demo9) that demonstrates the use of line-to-geometries collision detection.
Download checkin 48273 under the source code tab to check it out.
Mar 17, 2009 at 10:53 AM
Thanks for the replies. I will take a look at your example, genbox.