Table of Contents

Struct ContactData

Namespace
Jitter2.Dynamics
Assembly
Jitter2.dll

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

JHandle<RigidBodyData>

Body2

Handle to the second body's simulation data.

public JHandle<RigidBodyData> Body2

Field Value

JHandle<RigidBodyData>

Contact0

First contact point.

public ContactData.Contact Contact0

Field Value

ContactData.Contact

Contact1

Second contact point.

public ContactData.Contact Contact1

Field Value

ContactData.Contact

Contact2

Third contact point.

public ContactData.Contact Contact2

Field Value

ContactData.Contact

Contact3

Fourth contact point.

public ContactData.Contact Contact3

Field Value

ContactData.Contact

Friction

Combined friction coefficient for this contact pair.

public float Friction

Field Value

float

Key

Unique key identifying this arbiter's shape pair.

public ArbiterKey Key

Field Value

ArbiterKey

MaskContact0

Bit mask for contact slot 0.

public const uint MaskContact0 = 1

Field Value

uint

MaskContact1

Bit mask for contact slot 1.

public const uint MaskContact1 = 2

Field Value

uint

MaskContact2

Bit mask for contact slot 2.

public const uint MaskContact2 = 4

Field Value

uint

MaskContact3

Bit mask for contact slot 3.

public const uint MaskContact3 = 8

Field Value

uint

MaskContactAll

Bit mask indicating all four contact slots are in use.

public const uint MaskContactAll = 15

Field Value

uint

Mode

Determines which velocity components are updated by the solver.

public ContactData.SolveMode Mode

Field Value

ContactData.SolveMode

Restitution

Combined restitution coefficient for this contact pair.

public float Restitution

Field Value

float

SpeculativeRelaxationFactor

Relaxation factor for speculative contacts.

public float SpeculativeRelaxationFactor

Field Value

float

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

uint

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

bool

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

point1 JVector

Contact point on the first body in world space.

point2 JVector

Contact point on the second body in world space.

normal JVector

Contact 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

body1 RigidBody

The first rigid body.

body2 RigidBody

The second rigid body.

Iterate(bool)

Performs one solver iteration over all active contacts, applying corrective impulses.

public void Iterate(bool applyBias)

Parameters

applyBias bool

If true, applies position-correction bias.

PrepareForIteration(float)

Prepares all active contacts for solver iterations by computing effective masses and warm-starting impulses.

public void PrepareForIteration(float idt)

Parameters

idt float

Inverse 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

removeFlags ContactData.SolveMode

Flags 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()