Cube on Cube collision detection algorithm?

前端 未结 2 807
北恋
北恋 2021-01-06 10:43

I\'m trying to find the most efficient way to check if 2 arbitrarily sized cubes collide with each other. The sides of the cubes are not necessarily all equal in length (a b

2条回答
  •  我在风中等你
    2021-01-06 10:58

    Since both boxes are axis-aligned you can just compare their extents:

      return (a.max_x() >= b.min_x() and a.min_x() <= b.max_x())
         and (a.max_y() >= b.min_y() and a.min_y() <= b.max_y())
         and (a.max_z() >= b.min_z() and a.min_z() <= b.max_z())
    

提交回复
热议问题