add overlapBox/Sphere/Capsule function, fixed OnWake/OnSleep not work

This commit is contained in:
2025-12-28 22:40:48 +08:00
parent d0eed3a33d
commit 9a44dd8d79
34 changed files with 1439 additions and 280 deletions

View File

@ -46,6 +46,25 @@ namespace Prism
Z = Mathf.Clamp(Z, min.Z, max.Z);
}
public float Length()
{
return (float)Math.Sqrt(X * X + Y * Y + Z * Z);
}
public Vec3 Normalized()
{
float length = Length();
return new Vec3(X / length, Y / length, Z / length);
}
public void Normalize()
{
float length = Length();
X = X / length;
Y = Y / length;
Z = Z / length;
}
public Vec2 XY {
get { return new Vec2(X, Y); }
@ -79,6 +98,11 @@ namespace Prism
return new Vec3(left.X + right.X, left.Y + right.Y, left.Z + right.Z);
}
public static Vec3 operator +(Vec3 left, float right)
{
return new Vec3(left.X + right, left.Y + right, left.Z + right);
}
public static Vec3 operator -(Vec3 left, Vec3 right)
{
return new Vec3(left.X - right.X, left.Y - right.Y, left.Z - right.Z);