Page 1 of 1

Polygon Collision?

Posted: Thu Jun 16, 2011 12:23 am
by danlthemanl
I'm implementing a collision system into my Level editor, I have rectangle collision all done, but I can't figure out how polygon collision could possibly work. Is this built into Love2d? Is there an module or api that does this for me? or is it easy to implement that I just haven't thought of?

help!

Re: Polygon Collision?

Posted: Thu Jun 16, 2011 12:58 am
by tentus

Re: Polygon Collision?

Posted: Thu Jun 16, 2011 11:59 am
by Kadoba
It sounds like HardonCollider would be best suited for you. It's very easy to set up and use.

Re: Polygon Collision?

Posted: Fri Jun 17, 2011 12:39 am
by Ensayia
To answer more of your question, there is no existing implementation for collision other than the physics module and that only covers simple convex shapes from what I know. Anything more complex will require you to code it yourself.

A few seasoned users have done some simple libraries. Search for Fizz and HardonCollider on the wiki. Fizz isn't polygonal, but may contain code you can build from so long as you remember to credit Taehl. I know nothing of HC.

Love is a framework rather than an engine, something you can build these sort of features into through your own modules and/or libraries.

Re: Polygon Collision?

Posted: Fri Jun 17, 2011 1:11 am
by BlackBulletIV
Ensayia wrote:To answer more of your question, there is no existing implementation for collision other than the physics module and that only covers simple convex shapes from what I know. Anything more complex will require you to code it yourself.
For shapes, love.physics (which is a wrapper around Box2D) supports circles and 8-point, convex polygons (including a helper for rectangles). If you need something more complex than that, you would use multiple shapes in association with a body.

Whether you go for custom collision or the physics system depends on your needs. If you want some simple collision detection, custom is the way to go. If you want physics simulation, love.physics is most likely best.

Re: Polygon Collision?

Posted: Fri Jun 17, 2011 4:11 pm
by vrld
Ensayia wrote:To answer more of your question, there is no existing implementation for collision other than the physics module and that only covers simple convex shapes from what I know.
Not true. HardonCollider does support collision between points, circles and arbitrary simple (=non intersecting) polygons, including rectangles.

If you don't want to use the existing detection system, you can build your own using the shape:collidesWith() method. You can even go deeper and just use the Polygon class that provides useful things like triangulation and splitting into convex sub polygons.

Re: Polygon Collision?

Posted: Fri Jun 17, 2011 7:07 pm
by nevon
vrld wrote:
Ensayia wrote:To answer more of your question, there is no existing implementation for collision other than the physics module and that only covers simple convex shapes from what I know.
Not true. HardonCollider does support collision between points, circles and arbitrary simple (=non intersecting) polygons, including rectangles.
Wouldn't two colliding polygons per definition be intersecting? Or am I misunderstanding something here?

Re: Polygon Collision?

Posted: Fri Jun 17, 2011 8:47 pm
by Ensayia
I meant no existing implementation built into LOVE itself. Sorry if I confused people.

Re: Polygon Collision?

Posted: Fri Jun 17, 2011 9:37 pm
by Robin
nevon wrote:Wouldn't two colliding polygons per definition be intersecting? Or am I misunderstanding something here?
I think he meant polygons intersecting themselves.