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

UsageMask

Bits 0–3 mark contacts that are currently valid; bits 4–7 mark contacts used in the last solve.

public uint UsageMask

Field Value

uint

Remarks

A contact can be used by the solver and then break as the bodies move during the same step. Its solver bit remains set even though its current-validity bit has been cleared.

Properties

IsHardwareAccelerated

Gets whether the contact solver can use hardware-accelerated vector operations.

public static bool IsHardwareAccelerated { get; }

Property Value

bool

Settings

The settings of the world this contact belongs to.

public ref ContactSettings Settings { get; }

Property Value

ContactSettings

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

Unit contact normal pointing from the first body toward the second.

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(in TimeStep)

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

public void PrepareForIteration(in TimeStep timeStep)

Parameters

timeStep TimeStep

The full step and substep timing information.

ResetImpulses()

Clears the accumulated normal and friction impulses of all active contacts.

public void ResetImpulses()

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.

SkipWarmStart()

Skips replaying accumulated impulses on the next preparation of each active contact.

public void SkipWarmStart()

UpdatePosition()

Updates contact positions after integration and removes contacts whose normal separation exceeds one tenth of the break threshold or whose tangential drift exceeds the full threshold.

public void UpdatePosition()