Simple, lightweight, general purpose collision detection
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Simple, lightweight, general purpose collision detection
Another update to my demo: Boxes are now randomly-sized (to show that rectangles aren't slower than squares, and just to look more interesting), and ability to dynamically enable/disable their physics.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: Simple, lightweight, general purpose collision detection
Looks neat. Three bugs though:
One: When I stand next to a box, so that the player and the box are touching, and the box is touching a wall, the player can't jump anymore.
Two: When I jump onto one box and then run off one side, the box will slide into the same direction.
Three: Things are intersecting: As for optimization, I think a SpatialHash might be easier to implement than a QuadTree and might even be faster in some cases.
One: When I stand next to a box, so that the player and the box are touching, and the box is touching a wall, the player can't jump anymore.
Two: When I jump onto one box and then run off one side, the box will slide into the same direction.
Three: Things are intersecting: As for optimization, I think a SpatialHash might be easier to implement than a QuadTree and might even be faster in some cases.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Simple, lightweight, general purpose collision detection
1) That's due to me using a quick'n'dirty way of telling if the player is standing on the ground. With a tweak or two, it'll be fixed.
2) ... I don't think I get what you're saying. Wouldn't that be physically correct?
3) They only intersect if you stack 3 or more shapes. But you know what? If you need to stack stuff that badly, you should be using love.physics anyway. If you just need a few simple pushable boxes or enemies that can jump and fall, I think this will do the trick.
In other news, I'm currently adding support for mobile static shapes (read: moving platforms).
2) ... I don't think I get what you're saying. Wouldn't that be physically correct?
3) They only intersect if you stack 3 or more shapes. But you know what? If you need to stack stuff that badly, you should be using love.physics anyway. If you just need a few simple pushable boxes or enemies that can jump and fall, I think this will do the trick.
In other news, I'm currently adding support for mobile static shapes (read: moving platforms).
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Simple, lightweight, general purpose collision detection
I agree that it will be easier to implement. I can't imagine how it could be faster, tough.vrld wrote:I think a SpatialHash might be easier to implement than a QuadTree and might even be faster in some cases.
When I write def I mean function.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Simple, lightweight, general purpose collision detection
Updated the fizz demo again. Now dynamics can ride moving statics! I've also added some stuff to let you mess around more: Better box-spawning controls, a box that follows the cursor (so you can shove stuff around), and the ability to add/remove platforms. I also made the player-box move in a more traditional platformer style (better sliding, air-control, hold-the-button-to-jump-higher, and the ever-popular butt-stomp).
EDIT) And crouching. And it'll be squished / forced to crouch if it's touched both on top and on bottom.
EDIT) And crouching. And it'll be squished / forced to crouch if it's touched both on top and on bottom.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: Simple, lightweight, general purpose collision detection
I would expect it to move into the opposite direction.Taehl wrote:... I don't think I get what you're saying. Wouldn't that be physically correct?
For inserting shapes into a quad tree, you have to do tree traversal and possibly rebuild part of the tree. Same thing if you move stuff around in the quad tree, especially if the object moves to another quadrant that is higher up in the hierarchy. With a spatial hash doing both takes constant time.kikito wrote:I agree that it will be easier to implement. I can't imagine how it could be faster, tough.
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Simple, lightweight, general purpose collision detection
Won't you still have to do a linear search in the index to find it and move it?vrld wrote:Same thing if you move stuff around in the quad tree, especially if the object moves to another quadrant that is higher up in the hierarchy. With a spatial hash doing both takes constant time.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Simple, lightweight, general purpose collision detection
This excellent tutorial was mentioned in another thread, and will be invaluable to anyone trying to make physics.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Simple, lightweight, general purpose collision detection
It was mentioned in this thread too actually. http://love2d.org/forums/viewtopic.php? ... 315#p24797Taehl wrote:This excellent tutorial was mentioned in another thread, and will be invaluable to anyone trying to make physics.
Re: Simple, lightweight, general purpose collision detection
Update on HardonCollider:
Some errors were fixed, a TODO eliminated (the one about the translation direction) and a few things were easier. I also started to document the whole thing:
http://vrld.github.com/HardonCollider/
There will be a tutorial featuring how to write a simple game using HardonCollider soon.
Some errors were fixed, a TODO eliminated (the one about the translation direction) and a few things were easier. I also started to document the whole thing:
http://vrld.github.com/HardonCollider/
There will be a tutorial featuring how to write a simple game using HardonCollider soon.
Who is online
Users browsing this forum: No registered users and 0 guests