Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

davidkosenina

Pixel perfect collision detection.

This topic is 5333 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Helo I have one very small player with bounding sphere for collision detection and one very big boss. I would like to do collision detection, so that I would chech every triangle from boos with player bounding spheare. Question: Haw to do triangle - spheare collision test?

Share this post


Link to post
Share on other sites
Advertisement
get closest point from centre of the sphere on the triangle, and check if that point is in the sphere.

Share this post


Link to post
Share on other sites
it''s fine. the closest point on the triangle from the sphere centre will be somewhere the edge. And if that point on the edge is inside the sphere, it means that the edge intersects the sphere, therefore, the triangle also intersects the sphere.

if the sphere centre hovers straight above the triangle, the closest point will be on the triangle plane. Equally, if the point on the plane is inside the sphere, then the sphere intersects the triangle.

What I mean by closest point is not closest vertex. there''s a difference.

in 3D, you can check out this. It''s based on that principle.

in 2D, you can do the same calculations mathematically, or check if the vertices are in the sphere, then if the closest point on each edges is in the sphere, and if the sphere centre itself is inside the triangle, although like that, it''s a lot less elegant.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!