Merge remote-tracking branch 'origin/main'
# Conflicts: # managed/RayTrace/RayTraceApi/RayTraceApi.cs
This commit is contained in:
commit
6ca9d60a40
1 changed files with 307 additions and 309 deletions
|
|
@ -11,7 +11,7 @@ namespace RayTraceAPI
|
|||
{
|
||||
#region Native Structs (matching C++ layout exactly)
|
||||
[Flags]
|
||||
public enum InteractionLayers: ulong
|
||||
public enum InteractionLayers : ulong
|
||||
{
|
||||
None = 0,
|
||||
Solid = 0x1,
|
||||
|
|
@ -80,7 +80,8 @@ namespace RayTraceAPI
|
|||
DrawBeam = 0;
|
||||
}
|
||||
|
||||
public TraceOptions(InteractionLayers interactsAs, InteractionLayers interactsWith, InteractionLayers interactsExclude = 0, bool drawBeam = false)
|
||||
public TraceOptions(InteractionLayers interactsAs, InteractionLayers interactsWith,
|
||||
InteractionLayers interactsExclude = 0, bool drawBeam = false)
|
||||
{
|
||||
InteractsAs = (ulong)interactsAs;
|
||||
InteractsWith = (ulong)interactsWith;
|
||||
|
|
@ -114,8 +115,10 @@ namespace RayTraceAPI
|
|||
[FieldOffset(12)] public uint BaseNameHash;
|
||||
[FieldOffset(16)] public int ListIndex;
|
||||
[FieldOffset(20)] public int BaseListIndex;
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
[FieldOffset(24)] public bool Hidden;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)] [FieldOffset(24)]
|
||||
public bool Hidden;
|
||||
|
||||
[FieldOffset(32)] public CUtlString Description;
|
||||
[FieldOffset(40)] public CPhysSurfacePropertiesPhysicsTrace Physics;
|
||||
[FieldOffset(80)] public CPhysSurfacePropertiesSoundNamesTrace AudioSounds;
|
||||
|
|
@ -312,52 +315,39 @@ namespace RayTraceAPI
|
|||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 208)]
|
||||
public unsafe struct TraceResult
|
||||
public struct TraceResult
|
||||
{
|
||||
// Start position
|
||||
[FieldOffset(0)] public float StartPosX;
|
||||
[FieldOffset(4)] public float StartPosY;
|
||||
[FieldOffset(8)] public float StartPosZ;
|
||||
|
||||
// End position
|
||||
[FieldOffset(12)] public float EndPosX;
|
||||
[FieldOffset(16)] public float EndPosY;
|
||||
[FieldOffset(20)] public float EndPosZ;
|
||||
|
||||
// Hit point
|
||||
[FieldOffset(24)] public float HitPointX;
|
||||
[FieldOffset(28)] public float HitPointY;
|
||||
[FieldOffset(32)] public float HitPointZ;
|
||||
|
||||
// Hit normal
|
||||
[FieldOffset(36)] public float NormalX;
|
||||
[FieldOffset(40)] public float NormalY;
|
||||
[FieldOffset(44)] public float NormalZ;
|
||||
|
||||
// Fraction & hit offset
|
||||
[FieldOffset(48)] public float Fraction;
|
||||
[FieldOffset(52)] public float HitOffset;
|
||||
|
||||
// Hit triangle / hitbox
|
||||
[FieldOffset(56)] public int TriangleIndex;
|
||||
[FieldOffset(60)] public int HitboxBoneIndex;
|
||||
|
||||
// Flags/metadata are 32-bit values in native trace result
|
||||
[FieldOffset(64)] public InteractionLayers Contents;
|
||||
[FieldOffset(68)] public RayType_t RayType;
|
||||
[FieldOffset(72)] public int AllSolid;
|
||||
[FieldOffset(76)] public int ExactHitPoint;
|
||||
|
||||
// Raw pointers (8 bytes each on x64)
|
||||
[FieldOffset(80)] public nint HitEntityHandle;
|
||||
[FieldOffset(88)] public nint HitboxHandle;
|
||||
[FieldOffset(96)] public nint SurfacePropsHandle;
|
||||
[FieldOffset(104)] public nint BodyHandle;
|
||||
[FieldOffset(112)] public nint ShapeHandle;
|
||||
|
||||
[FieldOffset(128)] public CTransform BodyTransform;
|
||||
[FieldOffset(160)] public RnCollisionAttr_t ShapeAttributes;
|
||||
|
||||
// Helper properties for vectors
|
||||
public Vector3 StartPos => new(StartPosX, StartPosY, StartPosZ);
|
||||
public Vector3 EndPos => new(EndPosX, EndPosY, EndPosZ);
|
||||
public Vector3 HitPoint => new(HitPointX, HitPointY, HitPointZ);
|
||||
|
|
@ -366,9 +356,17 @@ namespace RayTraceAPI
|
|||
public bool DidHit => Fraction < 1.0f;
|
||||
public bool IsAllSolid => AllSolid != 0;
|
||||
public bool HasExactHit => ExactHitPoint != 0;
|
||||
public CPhysSurfacePropertiesTrace SurfaceProps => SurfacePropsHandle == 0 ? default : Marshal.PtrToStructure<CPhysSurfacePropertiesTrace>(SurfacePropsHandle);
|
||||
public CHitBox Hitbox => HitboxHandle == 0 ? default : Marshal.PtrToStructure<CHitBox>(HitboxHandle);
|
||||
public CEntityInstance? HitEntity => HitEntityHandle == 0 ? null : new CEntityInstance(HitEntityHandle);
|
||||
|
||||
public CEntityInstance? HitEntity
|
||||
=> HitEntityHandle == 0 ? null : new CEntityInstance(HitEntityHandle);
|
||||
|
||||
public CHitBox Hitbox
|
||||
=> HitboxHandle == 0 ? default : Marshal.PtrToStructure<CHitBox>(HitboxHandle);
|
||||
|
||||
public CPhysSurfacePropertiesTrace SurfaceProps
|
||||
=> SurfacePropsHandle == 0
|
||||
? default
|
||||
: Marshal.PtrToStructure<CPhysSurfacePropertiesTrace>(SurfacePropsHandle);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue