Skip to main content
gamedev.net
🔒 Locked

Heightmap collision detection

Started by Madhed Dec 27, 2002 at 5:05 PM 1 replies 650+ views
Original Post
Madhed
Madhed
Hi out there! Can anybody show me some basic ideas about collision detection with heightmaps (point/HM sphere/HM etc...) Some code snippet would also help very much. My current algorith recursively divides the collision line at every full x and z coordinate so I can check against planes actually. However, it''s slow and buggy... I mean very buggy, I''m happy if I get stuck in the ground sometimes... Thx. --::[Madhed]::-
TheTaste
TheTaste
I''m kinda hackin through this stuff myself...here''s what I found. I hope I''m not insulting your intelligence.

1) Speed - If your having trouble with speed your probably making to many calculations. I use a newbized quadtree for polygon culling. I use the same thing for reducing the number of collision calculations that need to be done.

2) Collision - For each polygon that isn''t rejected I have to answer 2 questions. Is the point below the plane of the polygon. Is the point "inside" the polygon. If both answers are yes then a collision has occured. My method returns both the plane normal and how deep below the plane I am.

3) Stuck - Before actually moving I send a request to move to my collision code. This is the point I want to move to. If no collisions occur than the movement takes place. If there is a collision I can use the plane normal and penetration depth to determine how I need to modify the movement so that none of my model goes below the plane.

Hope that helps somewhat.
Madhed
Madhed
TheTaste:
Thank you very much.
I''ve been coding lately and optimizing my code.
It works now already perfect.
Sometimes, however, strange things happen.
The moving stuff is jumping from one point to another without even colliding with the ground.
When I finish this I will probably send something to GDNet. Maybe a tutorial or something

Speed - What I''m using is basically some kind of line drawing algorithm so I only get the quads that are below my line.
I don''t know how fast it is but I think it''s good enough. Have hacked through quadtrees but not made any test app yet.

Collision - My algorithm returns the fraction of the line until the point of collision, the point of collision and the collision normal.

Hey thanks for your answer again.
Watch out for my tutorial LOL

--::[Madhed]::--

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.