Table of Contents

Struct PhysicsMaterial

Namespace
Gravitas.Materials
Assembly
Gravitas.dll

Deterministic surface material coefficients used by contact response.

[MemoryPackable(GenerateType.Object)]
public readonly struct PhysicsMaterial : IEquatable<PhysicsMaterial>, IMemoryPackable<PhysicsMaterial>, IMemoryPackFormatterRegister
Implements
IMemoryPackable<PhysicsMaterial>
IMemoryPackFormatterRegister
Inherited Members

Remarks

Static and dynamic friction are non-negative Coulomb coefficients. Restitution is the bounce coefficient in the inclusive range [0, 1]. Dynamic friction cannot exceed static friction.

Constructors

PhysicsMaterial(Fixed64, Fixed64, Fixed64, PhysicsMaterialCombine, PhysicsMaterialCombine)

Creates a deterministic surface material.

[JsonConstructor]
public PhysicsMaterial(Fixed64 staticFriction, Fixed64 dynamicFriction, Fixed64 restitution, PhysicsMaterialCombine frictionCombine = PhysicsMaterialCombine.GeometricMean, PhysicsMaterialCombine restitutionCombine = PhysicsMaterialCombine.Minimum)

Parameters

staticFriction Fixed64
dynamicFriction Fixed64
restitution Fixed64
frictionCombine PhysicsMaterialCombine
restitutionCombine PhysicsMaterialCombine

Properties

Bouncy

A high-restitution surface that keeps the default friction values.

[JsonIgnore]
[MemoryPackIgnore]
public static PhysicsMaterial Bouncy { get; }

Property Value

PhysicsMaterial

Default

The release default surface: unit friction, half restitution, geometric friction combine, and minimum restitution combine.

[JsonIgnore]
[MemoryPackIgnore]
public static PhysicsMaterial Default { get; }

Property Value

PhysicsMaterial

DynamicFriction

Gets the friction coefficient used after tangential motion exceeds the static friction limit.

public Fixed64 DynamicFriction { get; }

Property Value

Fixed64

FrictionCombine

Gets this surface's preferred combine policy for static and dynamic friction coefficients.

public PhysicsMaterialCombine FrictionCombine { get; }

Property Value

PhysicsMaterialCombine

Frictionless

A surface with no contact friction and no restitution.

[JsonIgnore]
[MemoryPackIgnore]
public static PhysicsMaterial Frictionless { get; }

Property Value

PhysicsMaterial

Restitution

Gets the restitution coefficient. Zero removes closing velocity without bounce; one is fully elastic before the context restitution threshold is applied.

public Fixed64 Restitution { get; }

Property Value

Fixed64

RestitutionCombine

Gets this surface's preferred combine policy for restitution.

public PhysicsMaterialCombine RestitutionCombine { get; }

Property Value

PhysicsMaterialCombine

StaticFriction

Gets the friction coefficient used while tangential contact motion can be fully resisted by Coulomb static friction.

public Fixed64 StaticFriction { get; }

Property Value

Fixed64

Methods

CombineFriction(PhysicsMaterial, PhysicsMaterial, out Fixed64, out Fixed64)

Resolves effective static and dynamic friction coefficients for a pair of contacting surfaces.

public static void CombineFriction(PhysicsMaterial left, PhysicsMaterial right, out Fixed64 staticFriction, out Fixed64 dynamicFriction)

Parameters

left PhysicsMaterial
right PhysicsMaterial
staticFriction Fixed64
dynamicFriction Fixed64

CombineRestitution(PhysicsMaterial, PhysicsMaterial)

Resolves the effective restitution coefficient for a pair of contacting surfaces.

public static Fixed64 CombineRestitution(PhysicsMaterial left, PhysicsMaterial right)

Parameters

left PhysicsMaterial
right PhysicsMaterial

Returns

Fixed64

CombineScalar(Fixed64, Fixed64, PhysicsMaterialCombine)

Combines two scalar coefficients with one explicit deterministic policy.

public static Fixed64 CombineScalar(Fixed64 left, Fixed64 right, PhysicsMaterialCombine policy)

Parameters

left Fixed64
right Fixed64
policy PhysicsMaterialCombine

Returns

Fixed64

Equals(PhysicsMaterial)

public bool Equals(PhysicsMaterial other)

Parameters

other PhysicsMaterial

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ResolveDominantPolicy(PhysicsMaterialCombine, PhysicsMaterialCombine)

Resolves the contact policy when two surfaces specify different combine policies. The order is deterministic and independent of collider order.

public static PhysicsMaterialCombine ResolveDominantPolicy(PhysicsMaterialCombine left, PhysicsMaterialCombine right)

Parameters

left PhysicsMaterialCombine
right PhysicsMaterialCombine

Returns

PhysicsMaterialCombine

Operators

operator ==(PhysicsMaterial, PhysicsMaterial)

Determines whether two materials have equal coefficients and combine policies.

public static bool operator ==(PhysicsMaterial left, PhysicsMaterial right)

Parameters

left PhysicsMaterial
right PhysicsMaterial

Returns

bool

operator !=(PhysicsMaterial, PhysicsMaterial)

Determines whether two materials differ in any coefficient or combine policy.

public static bool operator !=(PhysicsMaterial left, PhysicsMaterial right)

Parameters

left PhysicsMaterial
right PhysicsMaterial

Returns

bool