namespace Brutal.JoltApi; /// Which contact callback a was recorded from. public enum ContactEventKind : uint { /// Two bodies started touching (). Added = 0, /// Two bodies are still touching (). Persisted = 1, /// Two bodies stopped touching (). Removed = 2, } /// Which kinds of event a records. [Flags] public enum ContactEventMask : uint { /// Nothing. None = 0, /// Contacts starting. Added = 1 << (int)ContactEventKind.Added, /// Contacts continuing, one event per touching pair per step: the noisy one. Persisted = 1 << (int)ContactEventKind.Persisted, /// Contacts ending. Removed = 1 << (int)ContactEventKind.Removed, /// Contacts starting and ending, without the per-step persisted events. AddedAndRemoved = Added | Removed, /// Every kind. All = Added | Persisted | Removed, } /// One contact event, as hands it back. /// /// Everything is copied at the time of the callback, so an event stays valid after the bodies move or go away. /// A event only carries the body and sub-shape IDs, since that's all Jolt /// reports when a contact ends; its geometry and user data are zero. /// [StructLayout(LayoutKind.Explicit, Size = 64)] public struct ContactEvent { // Laid out like the shim's JoltContactEvent, 64 bytes (asserted there and in the tests) /// Whether the contact started, continued or ended. [FieldOffset(0)] public ContactEventKind Kind; /// The first body's ID. [FieldOffset(4)] public uint Body1; /// The second body's ID. [FieldOffset(8)] public uint Body2; /// The sub-shape of the first body that's touching. [FieldOffset(12)] public uint SubShape1; /// The sub-shape of the second body that's touching. [FieldOffset(16)] public uint SubShape2; /// How far the shapes overlap along . [FieldOffset(20)] public float PenetrationDepth; /// The contact normal in world space, pointing from body 1 towards body 2. [FieldOffset(24)] public float3 Normal; /// The first contact point, on body 1, in world space. [FieldOffset(36)] public float3 Point; /// The first body's user data. [FieldOffset(48)] public ulong UserData1; /// The second body's user data. [FieldOffset(56)] public ulong UserData2; }