Java libgdx中两个边界框之间的碰撞检测

Java libgdx中两个边界框之间的碰撞检测,java,android,collision-detection,libgdx,game-physics,Java,Android,Collision Detection,Libgdx,Game Physics,在我的libgdx游戏中,我有地图和玩家对象的3D边界框。我想知道它们是否在三维空间中碰撞。我如何才能做到这一点?您可以使用以下方法: public static boolean intersectsWith(BoundingBox boundingBox1, BoundingBox boundingBox2) { Vector3 otherMin = boundingBox1.getMin(); Vector3 otherMax = boundingBo

在我的libgdx游戏中,我有地图和玩家对象的3D边界框。我想知道它们是否在三维空间中碰撞。我如何才能做到这一点?

您可以使用以下方法:

    public static boolean intersectsWith(BoundingBox boundingBox1, BoundingBox boundingBox2) {
        Vector3 otherMin = boundingBox1.getMin();
        Vector3 otherMax = boundingBox1.getMax();
        Vector3 min = boundingBox2.getMin();
        Vector3 max = boundingBox2.getMax();

        return (min.x < otherMax.x) && (max.x > otherMin.x)
            && (min.y < otherMax.y) && (max.y > otherMin.y)
            && (min.z < otherMax.z) && (max.z > otherMin.z);
    }
公共静态布尔相交(BoundingBox boundingBox1,BoundingBox boundingBox2){
Vector3 otherMin=boundingBox1.getMin();
Vector3 otherMax=boundingBox1.getMax();
Vector3 min=boundingBox2.getMin();
Vector3 max=boundingBox2.getMax();
返回(最小xotherMin.x)
&&(最小y<其他最大y)&(最大y>其他最小y)
&&(最小zotherMin.z);
}
它是按照这个方法建模的:

为什么这“不是一个真正的问题”,而这里是?