This project has moved and is read-only. For the latest updates, please go here.

Collisions with simple splines?

Topics: Developer Forum
Sep 12, 2009 at 5:17 AM

Kudos for Farseer!  Thank you!

Is it possible to use Farseer to do collision detection with simple splines (as in NOT polygons)?  Think about simple mazes like you find in puzzle books.  I'd like to create mazes in Illustrator or Expression Design, then place the player in the maze and allow him to navigate it, colliding with and not being able to pass through walls as he goes.


Sep 12, 2009 at 2:39 PM

In future versions it might be easier to create mazes and similar collision scenarios. At the moment you will have to create your maze and then segment it. You can't create one huge geometry with the whole maze. It you have straight walls, it should not be a big problem to just segment it (divide it into segments and create a geometry for each segment). Manual segmentation is a lot better because you create fewer geometries with better polygon distribution. Example:

A part of a maze (a single wall) segmented:

Each part is a geometry. Problem with this is that it creates a lot of geometries and putting them together prove to be difficult. The seems can create weird collision behavior.

A part of a maze manually segmented:


The second one gives better performance and better collision behavior.

Sep 12, 2009 at 6:05 PM

Thanks for your thoughtful reply. 


I'm trying to avoid geometries altogether because I want to be able to enable the level creation from an easy to use tool like Expression Design, where a designer can just use the Pen tool to sketch out the maze, like so:


Image and video hosting by TinyPic

I can read in the XAML and generate the maze.  I might even want to animate the edges dynamically. Perhaps I need something like Box2D's EdgeShape?

Sep 12, 2009 at 6:22 PM

When I say geometries i mean the Geom object. Just like the Box2D Shape object. You need to use geometries unless you want to build some sort of broad phase yourself. (That is entirely possible since you only have player vs. maze and no inter-collisions between the maze parts itself).

If you want to avoid geometries, you need to hook into the SAT tools in the Vertices class. You need to create your maze from a bunch of polygons and then use the SAT tools to check the polygons of the player against the polygons of the maze (those that are in the area). Then you need to calculate the appropriate physics response after a collision has been detected.

I've been thinking about creating a curve geometry that are compatible with curves defined by popular tools (Vector drawing tools). It is on my todo list for Farseer Physics Engine 3.x

By the way: Box2D removed the edge shape.