Table of Contents

Class PhysicsMesh

Namespace
Gravitas.Colliders
Assembly
Gravitas.dll

Owns immutable authored triangle topology and committed deterministic runtime mesh geometry.

public class PhysicsMesh
Inheritance
PhysicsMesh
Inherited Members

Constructors

PhysicsMesh(Vector3d[], int[], Vector3d, FixedQuaternion)

Creates a convex runtime mesh at a world-space pose.

public PhysicsMesh(Vector3d[] vertices, int[] triangles, Vector3d position, FixedQuaternion rotation)

Parameters

vertices Vector3d[]
triangles int[]
position Vector3d
rotation FixedQuaternion

PhysicsMesh(Vector3d[], int[], Vector3d, FixedQuaternion, MeshColliderMode)

Creates a runtime mesh with an explicit collision mode and world-space pose.

public PhysicsMesh(Vector3d[] vertices, int[] triangles, Vector3d position, FixedQuaternion rotation, MeshColliderMode mode)

Parameters

vertices Vector3d[]
triangles int[]
position Vector3d
rotation FixedQuaternion
mode MeshColliderMode

Fields

MaxTriangleCount

Maximum accepted triangle count for deterministic runtime mesh construction.

public const int MaxTriangleCount = 131072

Field Value

int

MaxVertexCount

Maximum accepted vertex count for deterministic runtime mesh construction.

public const int MaxVertexCount = 65535

Field Value

int

Properties

Bounds

Gets the committed world-space axis-aligned bounds.

public FixedBoundBox Bounds { get; }

Property Value

FixedBoundBox

IsClosedSurface

Gets whether the complete exact-position-welded triangle topology is one connected, consistently wound, closed two-manifold surface.

public bool IsClosedSurface { get; }

Property Value

bool

LocalBounds

Axis-aligned bounds of the source vertices in local mesh space.

public FixedBoundBox LocalBounds { get; }

Property Value

FixedBoundBox

Mode

Gets the mesh collision mode.

public MeshColliderMode Mode { get; }

Property Value

MeshColliderMode

OwnerScale

Gets the committed host or standalone scale factor.

public Vector3d OwnerScale { get; }

Property Value

Vector3d

PartScale

Gets the committed authored compound-part scale factor. Standalone meshes use FixedMathSharp.Vector3d.One.

public Vector3d PartScale { get; }

Property Value

Vector3d

ScaledLocalBounds

Gets the current centered, scaled bounds in mesh-local coordinates.

public FixedBoundBox ScaledLocalBounds { get; }

Property Value

FixedBoundBox

SurfaceMassProperties

Gets cached uniform thin-shell mass properties for the committed geometry.

public MeshSurfaceMassProperties SurfaceMassProperties { get; }

Property Value

MeshSurfaceMassProperties

TotalArea

Gets the current triangle surface area after local scale.

public Fixed64 TotalArea { get; }

Property Value

Fixed64

TriangleBvhBuildCount

Gets the number of committed triangle BVH builds.

public int TriangleBvhBuildCount { get; }

Property Value

int

TriangleCount

Gets the number of authored triangles.

public int TriangleCount { get; }

Property Value

int

Triangles

Holds all the triangles that make up the mesh in the form of indices to the vertices array. example: Triangles[0-3] = 4,2,3 means that the first triangle of the mesh is made up of the vertices _vertices[4], _vertices[2], _vertices[3]

public ReadOnlySpan<int> Triangles { get; }

Property Value

ReadOnlySpan<int>

VertexCount

Number of vertices in the immutable local mesh topology.

public int VertexCount { get; }

Property Value

int

Methods

CalculateInertiaTensor(Fixed64)

Calculates closed-volume mesh inertia for the supplied mass.

public Fixed3x3 CalculateInertiaTensor(Fixed64 mass)

Parameters

mass Fixed64

Returns

Fixed3x3

CalculateInertiaTensor(Fixed64, MeshInertiaPolicy)

Calculates mesh inertia for the supplied mass using the requested policy. This is a geometry/topology API; callers apply body mobility gates before requesting inertia.

public Fixed3x3 CalculateInertiaTensor(Fixed64 mass, MeshInertiaPolicy policy)

Parameters

mass Fixed64
policy MeshInertiaPolicy

Returns

Fixed3x3

CalculateInertiaTensor(Fixed64, MeshInertiaPolicy, Vector3d)

Calculates mesh inertia for the supplied mass about a specific local reference point. This is a geometry/topology API; callers apply body mobility gates before requesting inertia.

public Fixed3x3 CalculateInertiaTensor(Fixed64 mass, MeshInertiaPolicy policy, Vector3d localReferencePoint)

Parameters

mass Fixed64
policy MeshInertiaPolicy
localReferencePoint Vector3d

Returns

Fixed3x3

ConvertScaledLocalToWorld(Vector3d)

Materializes a scaled-local mesh point in world space.

public Vector3d ConvertScaledLocalToWorld(Vector3d scaledLocalPoint)

Parameters

scaledLocalPoint Vector3d

Returns

Vector3d

Exceptions

InvalidOperationException

The conceptual world point lies outside the representable coordinate domain.

ConvertWorldDirectionToLocal(Vector3d)

Expresses a world-space direction in the committed scaled-local mesh frame.

public Vector3d ConvertWorldDirectionToLocal(Vector3d worldDirection)

Parameters

worldDirection Vector3d

Returns

Vector3d

ConvertWorldToScaledLocal(Vector3d)

Expresses a world point in the committed scaled-local mesh frame.

public Vector3d ConvertWorldToScaledLocal(Vector3d worldPoint)

Parameters

worldPoint Vector3d

Returns

Vector3d

Exceptions

InvalidOperationException

The exact relative displacement lies outside the representable coordinate domain.

GetFaceNormalWorld(int)

Gets a triangle face normal in world space.

public Vector3d GetFaceNormalWorld(int index)

Parameters

index int

Returns

Vector3d

GetFrontalArea(Vector3d)

Gets the projected mesh area facing a world-space direction.

public Fixed64 GetFrontalArea(Vector3d direction)

Parameters

direction Vector3d

Returns

Fixed64

GetLocalTriangleVertices(int, out Vector3d, out Vector3d, out Vector3d)

Gets one triangle's committed scaled vertices in local mesh space.

public void GetLocalTriangleVertices(int index, out Vector3d first, out Vector3d second, out Vector3d third)

Parameters

index int
first Vector3d
second Vector3d
third Vector3d

GetSupportVertexWorld(Vector3d)

Materializes the world-space vertex with the greatest projection onto direction, preserving source vertex order for ties.

public Vector3d GetSupportVertexWorld(Vector3d direction)

Parameters

direction Vector3d

Returns

Vector3d

Exceptions

InvalidOperationException

The conceptual support vertex lies outside the representable world-coordinate domain.

GetTriangleVertices(int, out Vector3d, out Vector3d, out Vector3d)

Gets one triangle's vertices in world space.

public void GetTriangleVertices(int index, out Vector3d first, out Vector3d second, out Vector3d third)

Parameters

index int
first Vector3d
second Vector3d
third Vector3d

GetTrianglesInLocalBounds(FixedBoundVolume, SwiftList<int>)

Writes triangle indices overlapping scaled-local bounds into a caller-owned buffer.

public void GetTrianglesInLocalBounds(FixedBoundVolume localBounds, SwiftList<int> result)

Parameters

localBounds FixedBoundVolume
result SwiftList<int>

GetTrianglesInWorldBounds(FixedBoundVolume, SwiftList<int>)

Writes triangle indices overlapping world-space bounds into a caller-owned buffer.

public void GetTrianglesInWorldBounds(FixedBoundVolume worldBounds, SwiftList<int> result)

Parameters

worldBounds FixedBoundVolume
result SwiftList<int>

GetVertexWorld(int)

Materializes one scaled vertex in world space.

public Vector3d GetVertexWorld(int index)

Parameters

index int

Returns

Vector3d

Exceptions

InvalidOperationException

The conceptual vertex lies outside the representable world-coordinate domain.

TryConvertScaledLocalToWorld(Vector3d, out Vector3d)

Attempts to materialize a scaled-local mesh point in world space.

public bool TryConvertScaledLocalToWorld(Vector3d scaledLocalPoint, out Vector3d worldPoint)

Parameters

scaledLocalPoint Vector3d
worldPoint Vector3d

Returns

bool

TryConvertWorldDirectionToLocal(Vector3d, out Vector3d)

Attempts to express a world-space direction in the committed scaled-local mesh frame.

public bool TryConvertWorldDirectionToLocal(Vector3d worldDirection, out Vector3d localDirection)

Parameters

worldDirection Vector3d
localDirection Vector3d

Returns

bool

TryConvertWorldToScaledLocal(Vector3d, out Vector3d)

Attempts to express a world point in the committed scaled-local mesh frame without saturating the relative displacement.

public bool TryConvertWorldToScaledLocal(Vector3d worldPoint, out Vector3d localPoint)

Parameters

worldPoint Vector3d
localPoint Vector3d

Returns

bool

TryGetClosedVolumeMassProperties(out MeshMassProperties, out MeshVolumeValidationResult)

Gets cached closed-volume mass properties when this mesh is a valid closed triangle shell.

public bool TryGetClosedVolumeMassProperties(out MeshMassProperties properties, out MeshVolumeValidationResult result)

Parameters

properties MeshMassProperties
result MeshVolumeValidationResult

Returns

bool

TryGetSupportVertexWorld(Vector3d, out Vector3d)

Attempts to materialize the world-space vertex with the greatest projection onto direction, preserving source vertex order for ties.

public bool TryGetSupportVertexWorld(Vector3d direction, out Vector3d vertex)

Parameters

direction Vector3d
vertex Vector3d

Returns

bool

TryGetTriangleVertices(int, out Vector3d, out Vector3d, out Vector3d)

Attempts to materialize one triangle's absolute world vertices. Canonical collision and query paths should consume scaled-local geometry instead.

public bool TryGetTriangleVertices(int index, out Vector3d first, out Vector3d second, out Vector3d third)

Parameters

index int
first Vector3d
second Vector3d
third Vector3d

Returns

bool

TryGetVertexWorld(int, out Vector3d)

Attempts to materialize one scaled vertex in world space.

public bool TryGetVertexWorld(int index, out Vector3d vertex)

Parameters

index int
vertex Vector3d

Returns

bool

UpdatePosition(Vector3d, FixedQuaternion)

Updates the mesh world-space position and rigid rotation.

public void UpdatePosition(Vector3d position, FixedQuaternion rotation)

Parameters

position Vector3d
rotation FixedQuaternion

UpdateTransform(Vector3d, FixedQuaternion, Vector3d)

Updates the mesh center, normalized rigid rotation, and strictly positive authored scale.

public void UpdateTransform(Vector3d position, FixedQuaternion rotation, Vector3d scale)

Parameters

position Vector3d
rotation FixedQuaternion
scale Vector3d