Represents a collision or contact between objects. See CollisionSim and CollisionAdvance.

interface Collision {
    bilateral(): boolean;
    closeEnough(allowTiny): boolean;
    contact(): boolean;
    getDetectedTime(): number;
    getDistance(): number;
    getEstimatedTime(): number;
    getImpulse(): number;
    getVelocity(): number;
    illegalState(): boolean;
    isColliding(): boolean;
    isTouching(): boolean;
    needsHandling(): boolean;
    setNeedsHandling(needsHandling): void;
    updateCollision(time): void;
}

Implemented by

Methods

  • Returns true if this represents a bilateral constraint which can both push and pull; for example a Joint between two objects.

    Returns boolean

    true if this is a bilateral constraint

  • Whether close enough to the point when this Collision can be handled. The allowTiny parameter exists because of cases where a small distance collision cannot be backed-up in time to get near to the preferred target 'half gap' distance.

    Parameters

    • allowTiny: boolean

      regard as 'close enough' Collisions that have smaller distance than distance accuracy would normally allow

    Returns boolean

    true if close enough to the point when this Collision can be handled.

  • Returns true if this is a stable contact: the objects are touching but not colliding.

    Returns boolean

    true if this is a stable contact

  • Returns the simulation time when the Collision was detected.

    Returns number

    the simulation time when the Collision was detected

  • Returns the distance between the objects. Negative distance means the objects are interpenetrating.

    Returns number

    the distance between the objects

  • Returns the estimated time when this Collision should be handled by firing an impulse.

    Returns number

    the estimated time when this Collision should be handled or NaN if unknown.

  • Returns size of impulse (change in momentum) that was applied to this Collision.

    Returns number

    size of impulse that was applied to this Collision, or NaN if no impulse applied.

  • Returns the relative normal velocity between the two collision points. Negative velocity means the objects are colliding, positive means they are separating.

    Returns number

    relative normal velocity between the two collision points, negative means colliding

  • Returns true if this represents an illegal state, typically because objects are interpenetrating.

    Returns boolean

    true if this represents an illegal state

  • Returns true if this represents a collision state, generally when two objects are interpenetrating. The collision search mechanism implemented by AdvanceStrategy.advance operates to set the simulation at a time very close to but just before any Collision is happening, see getEstimatedTime.

    Returns boolean

    true if this represents a collision state

  • Whether the distance is small enough that the objects are touching each other so that impulses can be transmitted.

    Returns boolean

    whether the objects are touching each other

  • Returns true if this Collision needs to be resolved, such as by applying an impulse to reverse the velocities of the objects. This remains true even after backing up in time.

    Returns boolean

    true if this Collision needs to be resolved

  • Mark this Collision as one that needs handling because it is has caused the collision engine to backup in time in order to resolve this Collision. This is useful because after backing up in time, a Collision may no longer report itself as isColliding.

    Parameters

    • needsHandling: boolean

      true if this Collision needs to be resolved

    Returns void

  • Updates the information in this Collision to reflect current position and velocity of bodies. This is used after backing up in time to the moment before the collision.

    Parameters

    • time: number

      the current simulation time

    Returns void

Generated using TypeDoc