コード例 #1
0
    private void CollisionBoxBox()
    {
        FixedList128 <float3> verticesA = ColPhysics.GetAABBVerticesOBB(posA, extentsA);
        FixedList128 <float3> verticesB = ColPhysics.GetAABBVerticesOBB(posB, extentsB);

        verticesA = ColPhysics.GetRotatedVerticesOBB(verticesA, posA, rotA);
        verticesB = ColPhysics.GetRotatedVerticesOBB(verticesB, posB, rotB);
        FixedList512 <float3> projectionAxes = ColPhysics.GetProjectionAxesOBBSAT(verticesA, verticesB);

        if (ColPhysics.BoxIntersectsBox(projectionAxes, verticesA, verticesB, out float minOverlap, out float3 mtvAxis))
        {
            isColliding = true;

            if (resolveCollisions)
            {
                ColPhysics.ResolveBoxCollision(ref posA, ref posB, minOverlap, mtvAxis);
            }
        }
    }