#### Archived

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

# 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.

## 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 on other sites
get closest point from centre of the sphere on the triangle, and check if that point is in the sphere.

Thank you.

##### Share on other sites
Helo

This wont work if triangle is very big and sphere is very small!

why?

##### Share on other sites
What if the sphere intersected the triangle's edge, but the vertices that define that edge were both outside of the sphere?

And for the record, please search a bit. Took me all of 15 seconds to find this:

Ta da! The magic of the intarweb!

[edited by - The Reindeer Effect on April 15, 2004 5:16:33 PM]

##### 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.

1. 1
Rutin
67
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633419
• Total Posts
3011787
• ### Who's Online (See full list)

There are no registered users currently online

×