Struct ContactData
Holds up to four ContactData.Contact structs for a single shape-to-shape collision.
public struct ContactData
- Inherited Members
Remarks
This structure is stored in unmanaged memory and accessed via Handle. The UsageMask bitfield indicates which of the four contact slots are active.
The returned data is valid only while the associated arbiter exists and must not be accessed concurrently with Step(float, bool). Do not cache references to this structure.
Fields
Body1
Handle to the first body's simulation data.
public JHandle<RigidBodyData> Body1
Field Value
Body2
Handle to the second body's simulation data.
public JHandle<RigidBodyData> Body2
Field Value
Contact0
First contact point.
public ContactData.Contact Contact0
Field Value
Contact1
Second contact point.
public ContactData.Contact Contact1
Field Value
Contact2
Third contact point.
public ContactData.Contact Contact2
Field Value
Contact3
Fourth contact point.
public ContactData.Contact Contact3
Field Value
Friction
Combined friction coefficient for this contact pair.
public float Friction
Field Value
Key
Unique key identifying this arbiter's shape pair.
public ArbiterKey Key
Field Value
MaskContact0
Bit mask for contact slot 0.
public const uint MaskContact0 = 1
Field Value
MaskContact1
Bit mask for contact slot 1.
public const uint MaskContact1 = 2
Field Value
MaskContact2
Bit mask for contact slot 2.
public const uint MaskContact2 = 4
Field Value
MaskContact3
Bit mask for contact slot 3.
public const uint MaskContact3 = 8
Field Value
MaskContactAll
Bit mask indicating all four contact slots are in use.
public const uint MaskContactAll = 15
Field Value
Mode
Determines which velocity components are updated by the solver.
public ContactData.SolveMode Mode
Field Value
Restitution
Combined restitution coefficient for this contact pair.
public float Restitution
Field Value
SpeculativeRelaxationFactor
Relaxation factor for speculative contacts.
public float SpeculativeRelaxationFactor
Field Value
UsageMask
The least four significant bits indicate which contacts are considered intact (bit set), broken (bit unset). Bits 5-8 indicate which contacts were intact/broken during the solving-phase.
public uint UsageMask
Field Value
Examples
A sphere may slide down a ramp. Within one timestep Jitter may detect the collision, create the contact, solve the contact, integrate velocities and positions and then consider the contact as broken, since the movement orthogonal to the contact normal exceeds a threshold. This results in no intact contact before calling Step(float, bool) and no intact contact after the call. However, the corresponding bit for the solver-phase will be set in this scenario.
Properties
IsHardwareAccelerated
Gets a value indicating whether the current system supports hardware acceleration for SIMD (Single Instruction, Multiple Data) operations.
public static bool IsHardwareAccelerated { get; }
Property Value
Methods
AddContact(in JVector, in JVector, in JVector)
Adds a new collision result to the contact manifold. Keeps at most four points.
public void AddContact(in JVector point1, in JVector point2, in JVector normal)
Parameters
point1JVectorContact point on the first body in world space.
point2JVectorContact point on the second body in world space.
normalJVectorContact normal pointing from body 2 to body 1.
Init(RigidBody, RigidBody)
Initializes this contact data for a pair of rigid bodies.
public void Init(RigidBody body1, RigidBody body2)
Parameters
Iterate(bool)
Performs one solver iteration over all active contacts, applying corrective impulses.
public void Iterate(bool applyBias)
Parameters
PrepareForIteration(float)
Prepares all active contacts for solver iterations by computing effective masses and warm-starting impulses.
public void PrepareForIteration(float idt)
Parameters
idtfloatInverse of the timestep (1/dt).
ResetMode(SolveMode)
Resets the solve mode based on the current motion types of the bodies, then removes the specified flags.
public void ResetMode(ContactData.SolveMode removeFlags = SolveMode.None)
Parameters
removeFlagsContactData.SolveModeFlags to remove from the full solve mode.
UpdatePosition()
Updates contact positions after integration and removes contacts that have separated beyond the break threshold.
public void UpdatePosition()