27 lines
715 B
C#

using OpenTK.Mathematics;
namespace TheLabs;
public class BoxCollider
{
public Vector3 Center;
public Vector3 HalfSize;
public BoxCollider(Vector3 center, Vector3 halfSize)
{
Center = center;
HalfSize = halfSize * 0.5f;
}
public Vector3 Min => Center - HalfSize;
public Vector3 Max => Center + HalfSize;
public bool CheckCollision(BoxCollider other)
{
bool collisionX = Max.X >= other.Min.X && Min.X <= other.Max.X;
bool collisionY = Max.Y >= other.Min.Y && Min.Y <= other.Max.Y;
bool collisionZ = Max.Z >= other.Min.Z && Min.Z <= other.Max.Z;
return collisionX && collisionY && collisionZ;
}
}