Ball to Ball Collision - Detection and Handling

前端 未结 14 1407
逝去的感伤
逝去的感伤 2020-11-22 05:29

With the help of the Stack Overflow community I\'ve written a pretty basic-but fun physics simulator.

\"alt

14条回答
  •  渐次进展
    2020-11-22 05:42

    I see it hinted here and there, but you could also do a faster calculation first, like, compare the bounding boxes for overlap, and THEN do a radius-based overlap if that first test passes.

    The addition/difference math is much faster for a bounding box than all the trig for the radius, and most times, the bounding box test will dismiss the possibility of a collision. But if you then re-test with trig, you're getting the accurate results that you're seeking.

    Yes, it's two tests, but it will be faster overall.

提交回复
热议问题