74 lines
2.8 KiB
C#
74 lines
2.8 KiB
C#
using System.Runtime.CompilerServices;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Prism
|
|
{
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct RaycastHit
|
|
{
|
|
public ulong EntityID { get; private set; }
|
|
public Vec3 Position { get; private set; }
|
|
public Vec3 Normal { get; private set; }
|
|
public float Distance { get; private set; }
|
|
}
|
|
|
|
public static class Physics
|
|
{
|
|
public static bool Raycast(Vec3 origin, Vec3 direction, float maxDistance, out RaycastHit hit)
|
|
{
|
|
return Raycast_Native(ref origin, ref direction, maxDistance, out hit);
|
|
}
|
|
|
|
public static Collider[] OverlapBox(Vec3 origin, Vec3 halfSize)
|
|
{
|
|
return OverlapBox_Native(ref origin, ref halfSize);
|
|
}
|
|
|
|
public static Collider[] OverlapCapsule(Vec3 origin, float radius, float halfHeight)
|
|
{
|
|
return OverlapCapsule_Native(ref origin, radius, halfHeight);
|
|
}
|
|
|
|
public static Collider[] OverlapSphere(Vec3 origin, float radius)
|
|
{
|
|
return OverlapSphere_Native(ref origin, radius);
|
|
}
|
|
|
|
public static int OverlapBoxNonAlloc(Vec3 origin, Vec3 halfSize, Collider[] colliders)
|
|
{
|
|
return OverlapBoxNonAlloc_Native(ref origin, ref halfSize, colliders);
|
|
}
|
|
|
|
public static int OverlapCapsuleNonAlloc(Vec3 origin, float radius, float halfHeight, Collider[] colliders)
|
|
{
|
|
return OverlapCapsuleNonAlloc_Native(ref origin, radius, halfHeight, colliders);
|
|
}
|
|
|
|
public static int OverlapSphereNonAlloc(Vec3 origin, float radius, Collider[] colliders)
|
|
{
|
|
return OverlapSphereNonAlloc_Native(ref origin, radius, colliders);
|
|
}
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
internal static extern bool Raycast_Native(ref Vec3 origin, ref Vec3 direction, float maxDistance, out RaycastHit hit);
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
internal static extern Collider[] OverlapBox_Native(ref Vec3 origin, ref Vec3 halfSize);
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
internal static extern Collider[] OverlapCapsule_Native(ref Vec3 origin, float radius, float halfHeight);
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
internal static extern Collider[] OverlapSphere_Native(ref Vec3 origin, float radius);
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
internal static extern int OverlapBoxNonAlloc_Native(ref Vec3 origin, ref Vec3 halfSize, Collider[] colliders);
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
internal static extern int OverlapCapsuleNonAlloc_Native(ref Vec3 origin, float radius, float halfHeight, Collider[] colliders);
|
|
|
|
[MethodImpl(MethodImplOptions.InternalCall)]
|
|
internal static extern int OverlapSphereNonAlloc_Native(ref Vec3 origin, float radius, Collider[] colliders);
|
|
}
|
|
} |