Complex Collision Detection Without Physics

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
kexisse
Citizen
Posts: 56
Joined: Wed Jun 13, 2012 2:52 pm

Complex Collision Detection Without Physics

Post by kexisse »

This might be a stupid question, but I'd really like to get some stuff clarified.

I'm trying to do collision detection for complex shapes (convex and concave polygons), but I don't care about real-world physics. I just want to know when bodies are touching, so I can apply my own simplified physics rules.

I've tried using HardonCollider but adding custom polygons to the HC class, and subclassing, is a massive headache. Is it possible to use the built-in love.physics to just do collision, without any of the physics stuff?
Would there be a big performance problem if I did that?
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Complex Collision Detection Without Physics

Post by TechnoCat »

kexisse wrote:I'm trying to do collision detection for complex shapes (convex and concave polygons), but I don't care about real-world physics. I just want to know when bodies are touching, so I can apply my own simplified physics rules.

I've tried using HardonCollider but adding custom polygons to the HC class, and subclassing, is a massive headache.
HC does concave and convex polygons. What sort of shapes were you trying to subclass?
User avatar
kexisse
Citizen
Posts: 56
Joined: Wed Jun 13, 2012 2:52 pm

Re: Complex Collision Detection Without Physics

Post by kexisse »

I have level terrain that consists of arbitrary polygons. I wanted to subclass one of the 3 (or more?) Polygon shapes in HC (I don't know which is best to subclass). I tried using composition rather than inheritance (my Poly has a reference to a shape), but I end up duplicating vertices, positions, width/height, and having to update both my Poly and the HC Shape every time I move or change anything. Also I tried inheritance but as far as I understand it's not possible to add custom shapes to HC, you have to use the addRectangle() etc. methods.

At the moment I have my composition hack and it sort of works, but it feels like the wrong way of doing things. My terrain does not Have a collision shape, it IS a collision shape.
Rad3k
Citizen
Posts: 69
Joined: Mon Aug 08, 2011 12:28 pm

Re: Complex Collision Detection Without Physics

Post by Rad3k »

kexisse wrote:I have level terrain that consists of arbitrary polygons. I wanted to subclass one of the 3 (or more?) Polygon shapes in HC (I don't know which is best to subclass). I tried using composition rather than inheritance (my Poly has a reference to a shape), but I end up duplicating vertices, positions, width/height, and having to update both my Poly and the HC Shape every time I move or change anything. Also I tried inheritance but as far as I understand it's not possible to add custom shapes to HC, you have to use the addRectangle() etc. methods.

At the moment I have my composition hack and it sort of works, but it feels like the wrong way of doing things. My terrain does not Have a collision shape, it IS a collision shape.
I don't have any experience with HC, but if you wanted to use love.physics stuff, you'd still need to do composition. I guess that where you come from, inheritance is the way of dealing with things, but here you have to be flexible, as Lua is a multi-paradigm language.

As for duplicating vertices, positions, etc. why not use get/set methods instead?
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 56 guests