yolkbot
    Preparing search index...

    Class ColliderSet

    Every collider on a map, plus the queries the physics and the PathGraph run against them.

    This is a port of the collision world the game server builds, right down to the quirks: props are decomposed into boxes rather than collided as meshes, and a box is only ever considered for a query that reaches the cell it was placed in, even when the box itself sticks out further.

    Broad-phase is a flat cell hash rather than the server's BVH. Since every collider is registered under exactly one cell, and the server's BVH leaves are filtered by that same cell box, the two return identical candidate sets - this one just gets there without walking a tree.

    Index

    Constructors

    Methods

    • Checks whether nothing solid sits between two points

      Parameters

      Returns boolean

      Whether the two points can see each other

    • Looks up what occupies a cell

      Parameters

      • x: number

        The cell X

      • y: number

        The cell Y

      • z: number

        The cell Z

      Returns CellInfo | null

      The cell's contents, or null if the cell is air

    • Runs a callback over every box that could touch an axis-aligned region

      Parameters

      • minX: number

        The region's minimum X

      • minY: number

        The region's minimum Y

      • minZ: number

        The region's minimum Z

      • maxX: number

        The region's maximum X

      • maxY: number

        The region's maximum Y

      • maxZ: number

        The region's maximum Z

      • visit: (collider: Collider) => void

        Called once per candidate box

      Returns void

    • Checks whether a sphere fits somewhere without touching the map.

      This deliberately does not go through ColliderSet.sweep: a sweep reports the box it should push you out of, and a sphere buried deep enough inside a box has nowhere to be pushed, so the sweep comes up empty. That is faithful to the game - it is why you can end up inside scenery - but it would have the graph cheerfully route straight through solid walls.

      Parameters

      • x: number

        The sphere's centre X

      • y: number

        The sphere's centre Y

      • z: number

        The sphere's centre Z

      • radius: number

        The sphere's radius

      Returns boolean

      Whether the sphere is clear

    • Casts a ray against the map, using the same boxes every other query uses

      Parameters

      • origin: Position

        Where the ray starts

      • direction: Position

        The ray's direction; must be normalised

      • maxDistance: number

        How far along the ray to look

      Returns RayHit | null

      The nearest hit, or null

    • Finds the deepest overlap between a sphere and the map, and how to push the sphere back out. This is the one query the movement code runs, eight times per tick.

      Parameters

      • center: Position

        The sphere's centre

      • radius: number

        The sphere's radius

      • outResolve: Position

        Receives the vector that separates the sphere from the box

      • outNormal: Position

        Receives the surface normal at the contact

      Returns Collider | null

      The box that produced the deepest overlap, or null if the sphere is clear

    Properties

    depth: number

    The map's size along Z

    height: number

    The map's size along Y

    map: MapJSON

    The map this was built from

    size: number = 0

    How many boxes the map resolved to

    width: number

    The map's size along X