Sign in to follow this  

Finding Collision Point

Recommended Posts

minardogl    122
I´m computing the collision between a moving sphere and a mesh. I´m using OpCode, so I use a capsule (LSS) to represent the sphere movement. Opcode returns me the list of triangles collisioning with the capsule. But beside the triangles, I also need the collision point where the capsule collides so I be able move the sphere to that point. Opcode, just give me the triangle indices. I can extract the vertices of that triangle. Computing the collision normal is fairly simple, But how could I compute the collision point between the capsule (LSS) and the triangle?

Share this post

Link to post
Share on other sites
Dim_Yimma_H    557
Getting the exact collision point/time of collision can be fairly complicated if using collision detection algorithms that only tests for overlapping geometry.

One way to get a good enough time of collision for arbitrary moving geometries is by using a binary search between the time before collision t1, and the time after collision t2. If a collision is detected during this time the time of movement tm is subdivided, for example tm = (t2 - t1) / 2.

The simulation is then re-run from t1 to t1 + tm. If collision is not detected then t1 + tm is the "closest" time before collision. If collision is detected then t1 + tm is the "closest" time after collision. This is repeated until tm is small enough. The point before collision is then approximated using velocity and tm.

Here's a link to a document that explains this:, see "Time of Contact".

There are other more specialized ways though. It's a good idea to use a capsule for sphere-mesh collision query, that tells that there is a collision. Since the sphere center is always offset from a triangle by its radius at the exact time of collision, the exact time is possible to find for a sphere. Offset the triangle by the sphere radius along the triangle normal, then perform a ray-triangle intersection test. That intersection is the center of the sphere at the time of collision.

I don't know if OPCODE can find the intersection point though, maybe you'll have to code the ray-triangle test yourself. Here's a reference for that:, see "Ray/Segment-Triangle Intersection". If several triangles are overlapped by the capsule, remember to find the closest intersection point.

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