Skip to main content
gamedev.net
🔒 Locked

Detect collision doesn't work

Started by ParityCheck Apr 5, 2005 at 6:41 AM 2 replies 650+ views
Original Post
ParityCheck
ParityCheck
This is a weird problem. I have two meshes with their boundingshpere radii and boundingsphere centers calculated and stored. WHen the meshes are moved the transformation matrix that is applied to the mesh is applied to the bounding sphere centers. However my detectcollision function which does somewhat like this: if((mesh1.radius + mesh2.radius) > (distance_between_centers)) return true; else return false returns some wierd results. When the meshes actually appear to touch and move into each other it still doesn't return true as it should when the collision occurs. Is there something wrong with my mesh? I actually copy pasted the code from another project of mine, which works just fine except that the meshes loaded are different mesh files. What could be wrong here?
Keep coding..
Wan
Wan
That peice of pseudo code should work.
So based on that, the only thing I can think of is that either the radius of (one of) the two meshes is incorrect, or the distance between the centers is not properly calculated (result is a negative number, or distince is calculated before some matrix translations/rotations are applied, stuff like that).
If none of the above is causing the problem, it's has to do with something else in your code, making it kind of impossible to give any hints.
matthughson
matthughson
It sounds like you are transforming the mesh by your transformation matrix, but not your bounding spheres. Maybe print out some debug information to make sure your object is being drawn at the same spot that you are checking for collision at.

Matt Hughson
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]

Topic Locked

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

Sign in to reply to this topic.