Skip to main content

RealisticSolver

A collision solver figures out how to position colliders such that they are no longer overlapping

Solvers are executed in the order

  1. preSolve
  2. solveVelocity
  3. solvePosition
  4. postSolve

Implements

Index

Constructors

constructor

  • RealisticSolver(config: DeepRequired<{ contactSolveBias?: ContactSolveBias; maxPositionCorrection?: number; positionIterations?: number; slop?: number; steeringFactor?: number; velocityIterations?: number; warmStart?: boolean } | undefined>): RealisticSolver
  • Parameters

    • config: DeepRequired<{ contactSolveBias?: ContactSolveBias; maxPositionCorrection?: number; positionIterations?: number; slop?: number; steeringFactor?: number; velocityIterations?: number; warmStart?: boolean } | undefined>

    Returns RealisticSolver

Properties

publicconfig

config: DeepRequired<{ contactSolveBias?: ContactSolveBias; maxPositionCorrection?: number; positionIterations?: number; slop?: number; steeringFactor?: number; velocityIterations?: number; warmStart?: boolean } | undefined>

directionMap

directionMap: Map<string, horizontal | vertical> = ...

distanceMap

distanceMap: Map<string, number> = ...

idToContactConstraint

idToContactConstraint: Map<string, ContactConstraintPoint[]> = ...

lastFrameContacts

lastFrameContacts: Map<string, CollisionContact> = ...

Methods

getContactConstraints

postSolve

  • Parameters

    • contacts: CollisionContact[]
    • emitEvents: boolean = true

      whether postcollision/aftercollisionresolve fire, only the last substep of a frame does

    Returns void

preSolve

  • Prepares the contact constraints (effective masses, lever arms, restitution targets) and warm starts them


    Parameters

    • contacts: CollisionContact[]
    • substep: number = 0

      index of the substep within the frame, precollision/beforecollisionresolve are only emitted on the first

    Returns void

publicsolve

  • Solve the contacts for one physics (sub)step


    Parameters

    • contacts: CollisionContact[]
    • optional_duration: number

      length of the step in ms, unused but kept so substep/substepCount line up positionally with the CollisionSolver interface

    • substep: number = 0

      index of the substep within the frame, collision events are emitted on the first and last substep only

    • substepCount: number = 1

      total substeps in the frame

    Returns CollisionContact[]

solvePosition

  • Iteratively solve the position overlap constraint


    Parameters

    Returns void

solveVelocity

warmStart

  • Warm up body's based on previous frame contact points


    Parameters

    Returns void