Sign in to follow this  
Vile V

Collision Resolution

Recommended Posts

Vile V    100
Good day everyone,

I'm currently working on the very simple collision handling I'm going to use in my game. Its basically nothing more than rectangular collision detection and resolution. The resolution itself isn't supposed to do anything other than place the dynamic rectangles back where they're supposed to be. I've worked out two methods so far that work in the simplest of cases. Those cases are one dynamic shape hitting a single static one while moving either just vertically, or just horizontally.

In the first I normalize the velocity vector of the moving rectangle and after determining how deeply the shape penetrated the static rectangle, I multiply the height and width by the normalized vector to determine where the rectangle should be moved. This works for the simple case.
The second is simpler. I simply check which direction the rectangle was moving in and if a collision occurs I set it's X and Y to where they're supposed to go using the coordinates and size of the static rectangle. This also works for the simple case.

As you can probably see by now, problems arrise when a rectangle is moving along a surface and is given an X and a Y velocity.

My question is basically: How does the resolution for colliding rectangles work? I've found hordes of tutorials and articles online about these cases but they're applicable to far more complicated scenes. All I need are rectangles that are unable to intersect.

I hope this is clear enough and thank you for any replies,

Vile

Share this post


Link to post
Share on other sites
Volgogradetzzz    1101
You should track min penetration depth vector - and it will lie along vertical or horizontal axis (I assume your rectangles are AABB - i.e. their axes are parallel to world axes). In simplest case you should translate your object back by amount of that penetration depth vector (you can consider both rectangles masses and move them apart proportionally). Another way - is predict time of impact of both objects and not let them penetrate at all - for AABB it's simple enougth - you can check tutorial that I post resently - it's just about it.

Share this post


Link to post
Share on other sites
Vile V    100
[quote name='Volgogradetzzz' timestamp='1306241539' post='4815092']
You should track min penetration depth vector - and it will lie along vertical or horizontal axis (I assume your rectangles are AABB - i.e. their axes are parallel to world axes). In simplest case you should translate your object back by amount of that penetration depth vector (you can consider both rectangles masses and move them apart proportionally). Another way - is predict time of impact of both objects and not let them penetrate at all - for AABB it's simple enougth - you can check tutorial that I post resently - it's just about it.
[/quote]


Alright, thank you for the rapid reply. (I only just reposted 5 seconds ago O_o)
I'll take a look at your tutorial if i get stuck.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this