Jump to content
  • Advertisement
Sign in to follow this  
schupf

Determine contact edge of 2 boxes

This topic is 2442 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

Hello!

I have a "simple" problem, yet I could not figure out how to solve this. Assume I have 2 boxes, 1 is static (the black one), the other one is moving (please look at the attachment).

I have sketched 3 cases in the picture. All 3 moving boxes have the same movement direction. I want to determine WHICH edge of the static black box is hit first by the moving box (I need this to resolve the collision)
So in my sketch the green and blue box will hit +Y edge of the black box. The red box will hit the -X edge of the black box. If the blue box was smaller, it would hit the -X edge. So its obvious that the contact edge depends on the extent of the static box, the moving box and the direction.

Do you know a "simple" algorithm to detect the contact edge (the edge where the first contact occurs)?

Share this post


Link to post
Share on other sites
Advertisement

Hello!

I have a "simple" problem, yet I could not figure out how to solve this. Assume I have 2 boxes, 1 is static (the black one), the other one is moving (please look at the attachment).

I have sketched 3 cases in the picture. All 3 moving boxes have the same movement direction. I want to determine WHICH edge of the static black box is hit first by the moving box (I need this to resolve the collision)
So in my sketch the green and blue box will hit +Y edge of the black box. The red box will hit the -X edge of the black box. If the blue box was smaller, it would hit the -X edge. So its obvious that the contact edge depends on the extent of the static box, the moving box and the direction.

Do you know a "simple" algorithm to detect the contact edge (the edge where the first contact occurs)?


Yes :)

For each pair of boxes:

* Expand the large box by the extents of the smaller box
* Shrink the smaller box down to a point
* Ray-cast from the point along the velocity of the smaller box
* Intersection point is the first point of contact between the boxes, get the edge from this

Cheers, Paul.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!