mirror of
https://github.com/UOH-CS-Level5/551455-graphics-programming-2526-the-repo-Zyb3rWolfi.git
synced 2025-11-29 00:43:08 +00:00
27 lines
715 B
C#
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;
|
|
}
|
|
} |