Page 5 of 11

Re: Simple, lightweight, general purpose collision detection

Posted: Fri Jan 14, 2011 10:10 pm
by Taehl
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.

Re: Simple, lightweight, general purpose collision detection

Posted: Fri Jan 14, 2011 11:05 pm
by vrld
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:
trapped_in_boxes.jpg
trapped_in_boxes.jpg (5.47 KiB) Viewed 2136 times
As for optimization, I think a SpatialHash might be easier to implement than a QuadTree and might even be faster in some cases.

Re: Simple, lightweight, general purpose collision detection

Posted: Fri Jan 14, 2011 11:42 pm
by Taehl
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).

Re: Simple, lightweight, general purpose collision detection

Posted: Sat Jan 15, 2011 12:10 am
by kikito
vrld wrote:I think a SpatialHash might be easier to implement than a QuadTree and might even be faster in some cases.
I agree that it will be easier to implement. I can't imagine how it could be faster, tough.

Re: Simple, lightweight, general purpose collision detection

Posted: Sat Jan 15, 2011 2:25 am
by Taehl
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.

Re: Simple, lightweight, general purpose collision detection

Posted: Sat Jan 15, 2011 12:20 pm
by vrld
Taehl wrote:... I don't think I get what you're saying. Wouldn't that be physically correct?
I would expect it to move into the opposite direction.
kikito wrote:I agree that it will be easier to implement. I can't imagine how it could be faster, tough.
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.

Re: Simple, lightweight, general purpose collision detection

Posted: Sat Jan 15, 2011 5:02 pm
by TechnoCat
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.
Won't you still have to do a linear search in the index to find it and move it?

Re: Simple, lightweight, general purpose collision detection

Posted: Sat Jan 15, 2011 8:26 pm
by Taehl
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

Posted: Sat Jan 15, 2011 8:41 pm
by TechnoCat
Taehl wrote:This excellent tutorial was mentioned in another thread, and will be invaluable to anyone trying to make physics.
It was mentioned in this thread too actually. http://love2d.org/forums/viewtopic.php? ... 315#p24797

Re: Simple, lightweight, general purpose collision detection

Posted: Sun Jan 16, 2011 6:41 pm
by vrld
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.