MiniQuake

src/miniquake/server_collision.ml

Package
miniquake.server_collision
Reachable
Yes

Imports

Declarations

AREA_DEPTH

const AREA_DEPTH = 4

WinQuake's AREA_DEPTH=4 tree contains at most 31 nodes. Edicts are linked into exactly one solid or trigger list at the deepest node that fully contains their expanded bounds.

View source

AREA_NODE_CAPACITY

const AREA_NODE_CAPACITY = 31

Defines the area node capacity value used by `miniquake.server_collision`.

View source

areaEntityNext

areaEntityNext

Tracks the module-level area entity next state owned by `miniquake.server_collision`.

View source

areaEntityNode

areaEntityNode

Tracks the module-level area entity node state owned by `miniquake.server_collision`.

View source

areaEntityPrevious

areaEntityPrevious

Tracks the module-level area entity previous state owned by `miniquake.server_collision`.

View source

areaEntityTrigger

areaEntityTrigger

Tracks the module-level area entity trigger state owned by `miniquake.server_collision`.

View source

areaMachine

areaMachine

Tracks the module-level area machine state owned by `miniquake.server_collision`.

View source

areaNodeAxis

areaNodeAxis

Tracks the module-level area node axis state owned by `miniquake.server_collision`.

View source

areaNodeChild0

areaNodeChild0

Tracks the module-level area node child0 state owned by `miniquake.server_collision`.

View source

areaNodeChild1

areaNodeChild1

Tracks the module-level area node child1 state owned by `miniquake.server_collision`.

View source

areaNodeCount

areaNodeCount

Tracks the module-level area node count state owned by `miniquake.server_collision`.

View source

areaNodeDist

areaNodeDist

Tracks the module-level area node dist state owned by `miniquake.server_collision`.

View source

areaSolidHead

areaSolidHead

Tracks the module-level area solid head state owned by `miniquake.server_collision`.

View source

areaTriggerHead

areaTriggerHead

Tracks the module-level area trigger head state owned by `miniquake.server_collision`.

View source

boxesOverlap

function boxesOverlap(minsA, maxsA, minsB, maxsB)

Implements the `boxesOverlap` operation for `miniquake.server_collision` (boxes overlap).

ParameterTypeDefaultDescription
minsAdynamic—The mins a input consumed by `boxesOverlap`.
maxsAdynamic—The maxs a input consumed by `boxesOverlap`.
minsBdynamic—The mins b input consumed by `boxesOverlap`.
maxsBdynamic—The maxs b input consumed by `boxesOverlap`.

View source

checkBottom

function checkBottom(server, entityIndex)

SV_CheckBottom: first accept the common case where all four lower corners are solid, then trace the midpoint and corners down by two step heights.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.

View source

chooseTrace

function chooseTrace(best, candidate)

Implements the `chooseTrace` operation for `miniquake.server_collision` (choose trace).

ParameterTypeDefaultDescription
bestdynamic—The best input consumed by `chooseTrace`.
candidatedynamic—The candidate input consumed by `chooseTrace`.

View source

clipAreaEntity

function clipAreaEntity(server, index, start, mins, maxs, finish, moveType, passedEntity, passedOwner, passedSizeX, boxMins, boxMaxs, best)

Apply the stock SV_ClipToLinks filters to one broadphase candidate.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
indexdynamic—Zero-based index of the requested entry.
startdynamic—The start input consumed by `clipAreaEntity`.
minsdynamic—The mins input consumed by `clipAreaEntity`.
maxsdynamic—The maxs input consumed by `clipAreaEntity`.
finishdynamic—The finish input consumed by `clipAreaEntity`.
moveTypedynamic—The move type input consumed by `clipAreaEntity`.
passedEntitydynamic—The passed entity input consumed by `clipAreaEntity`.
passedOwnerdynamic—The passed owner input consumed by `clipAreaEntity`.
passedSizeXdynamic—The passed size x input consumed by `clipAreaEntity`.
boxMinsdynamic—The box mins input consumed by `clipAreaEntity`.
boxMaxsdynamic—The box maxs input consumed by `clipAreaEntity`.
bestdynamic—The best input consumed by `clipAreaEntity`.

View source

clipAreaNode

function clipAreaNode(server, node, start, mins, maxs, finish, moveType, passedEntity, passedOwner, passedSizeX, boxMins, boxMaxs, best)

Recursively clip only the area nodes intersected by the swept move bounds.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
nodedynamic—The node input consumed by `clipAreaNode`.
startdynamic—The start input consumed by `clipAreaNode`.
minsdynamic—The mins input consumed by `clipAreaNode`.
maxsdynamic—The maxs input consumed by `clipAreaNode`.
finishdynamic—The finish input consumed by `clipAreaNode`.
moveTypedynamic—The move type input consumed by `clipAreaNode`.
passedEntitydynamic—The passed entity input consumed by `clipAreaNode`.
passedOwnerdynamic—The passed owner input consumed by `clipAreaNode`.
passedSizeXdynamic—The passed size x input consumed by `clipAreaNode`.
boxMinsdynamic—The box mins input consumed by `clipAreaNode`.
boxMaxsdynamic—The box maxs input consumed by `clipAreaNode`.
bestdynamic—The best input consumed by `clipAreaNode`.

View source

clipToEntity

function clipToEntity(server, entityIndex, start, mins, maxs, finish)

Trace to entity through the collision world.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
startdynamic—The start input consumed by `clipToEntity`.
minsdynamic—The mins input consumed by `clipToEntity`.
maxsdynamic—The maxs input consumed by `clipToEntity`.
finishdynamic—The finish input consumed by `clipToEntity`.

View source

COLLISION_OFFSET_CACHE_SIZE

const COLLISION_OFFSET_CACHE_SIZE = 64

The C engine resolves entvars_t members at compile time. MiniLang must look them up by name, but collision invokes the same small field set millions of times while monsters chase. Keep a module-local direct cache so those hot reads do not repeatedly enter the generic VM definition lookup machinery.

View source

collisionOffsetKeys

collisionOffsetKeys

Tracks the module-level collision offset keys state owned by `miniquake.server_collision`.

View source

collisionOffsetMachine

collisionOffsetMachine

Tracks the module-level collision offset machine state owned by `miniquake.server_collision`.

View source

collisionOffsetValues

collisionOffsetValues

Tracks the module-level collision offset values state owned by `miniquake.server_collision`.

View source

computedEntityBounds

function computedEntityBounds(server, entityIndex)

Computes d entity bounds for `miniquake.server_collision`.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.

View source

createAreaNode

function createAreaNode(depth, minX, minY, maxX, maxY)

Recursively construct the same horizontal binary partition as SV_CreateAreaNode in world.c.

ParameterTypeDefaultDescription
depthdynamic—The depth input consumed by `createAreaNode`.
minXdynamic—The min x input consumed by `createAreaNode`.
minYdynamic—The min y input consumed by `createAreaNode`.
maxXdynamic—The max x input consumed by `createAreaNode`.
maxYdynamic—The max y input consumed by `createAreaNode`.

View source

emptyPlane

function emptyPlane()

Implements the `emptyPlane` operation for `miniquake.server_collision` (empty plane).

View source

ensureAreaTree

function ensureAreaTree(server)

Initialize the area tree for a new QuakeC edict table and seed it from the currently linked bounds. Subsequent SV_LinkEdict calls maintain it in O(1).

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.

View source

entityAbsMax

function entityAbsMax(server, entityIndex)

Implements the `entityAbsMax` operation for `miniquake.server_collision` (entity abs max).

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.

View source

entityAbsMin

function entityAbsMin(server, entityIndex)

Implements the `entityAbsMin` operation for `miniquake.server_collision` (entity abs min).

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.

View source

entityFloat

function entityFloat(server, entityIndex, name, fallback)

Implements the `entityFloat` operation for `miniquake.server_collision` (entity float).

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
namedynamic—Stable name that identifies the requested object or option.
fallbackdynamic—Value to use when the requested input is unavailable or invalid.

View source

entityString

function entityString(server, entityIndex, name, fallback)

Implements the `entityString` operation for `miniquake.server_collision` (entity string).

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
namedynamic—Stable name that identifies the requested object or option.
fallbackdynamic—Value to use when the requested input is unavailable or invalid.

View source

entityValid

function entityValid(server, entityIndex)

Report whether entity valid holds for the active state.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.

View source

entityVector

function entityVector(server, entityIndex, name, fallback)

Implements the `entityVector` operation for `miniquake.server_collision` (entity vector).

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
namedynamic—Stable name that identifies the requested object or option.
fallbackdynamic—Value to use when the requested input is unavailable or invalid.

View source

entityVectorZero

function entityVectorZero(server, entityIndex, name)

Read a generated QuakeC vector and allocate the zero fallback only for a genuinely missing field. Stock progs.dat contains all collision vectors; passing zeroVector() eagerly at every call site formerly created more than one million dead Vec3 values in a 300-frame e1m2 sample.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
namedynamic—Stable name that identifies the requested object or option.

View source

entityWord

function entityWord(server, entityIndex, name, fallback)

Implements the `entityWord` operation for `miniquake.server_collision` (entity word).

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
namedynamic—Stable name that identifies the requested object or option.
fallbackdynamic—Value to use when the requested input is unavailable or invalid.

View source

executeTouch

function executeTouch(server, selfIndex, otherIndex)

Execute touch.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
selfIndexdynamic—Zero-based index of the requested entry.
otherIndexdynamic—Zero-based index of the requested entry.

View source

fieldOffset

function fieldOffset(server, name)

Implements the `fieldOffset` operation for `miniquake.server_collision` (field offset).

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
namedynamic—Stable name that identifies the requested object or option.

View source

impact

function impact(server, firstEntity, secondEntity)

Implements the `impact` operation for `miniquake.server_collision` (impact).

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
firstEntitydynamic—The first entity input consumed by `impact`.
secondEntitydynamic—The second entity input consumed by `impact`.

View source

insertAreaEntity

function insertAreaEntity(entityIndex, bounds, solid)

Insert one linked edict into its deepest non-splitting area node.

ParameterTypeDefaultDescription
entityIndexdynamic—Zero-based index of the requested entry.
boundsdynamic—The bounds input consumed by `insertAreaEntity`.
soliddynamic—Stable identifier of the requested entry.

View source

linkedEntityBounds

function linkedEntityBounds(server, entityIndex)

Return the abs bounds maintained by SV_LinkEdict. Hand-built unit fixtures may omit the link step and leave both generated vectors zeroed, so retain a computed fallback for that non-production case.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.

View source

modelSubIndex

function modelSubIndex(name)

Return model sub index derived from the active module state.

ParameterTypeDefaultDescription
namedynamic—Stable name that identifies the requested object or option.

View source

move

function move(server, start, mins, maxs, finish, moveType, passedEntity)

SV_Move: clip first against the world, then every potentially intersecting solid edict. Area nodes are an optimization only; a linear scan has the same observable Quake semantics and is suitable for the stock MAX_EDICTS limit.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
startdynamic—The start input consumed by `move`.
minsdynamic—The mins input consumed by `move`.
maxsdynamic—The maxs input consumed by `move`.
finishdynamic—The finish input consumed by `move`.
moveTypedynamic—The move type input consumed by `move`.
passedEntitydynamic—The passed entity input consumed by `move`.

View source

moveBounds

function moveBounds(start, mins, maxs, finish)

Transfer data for move bounds.

ParameterTypeDefaultDescription
startdynamic—The start input consumed by `moveBounds`.
minsdynamic—The mins input consumed by `moveBounds`.
maxsdynamic—The maxs input consumed by `moveBounds`.
finishdynamic—The finish input consumed by `moveBounds`.

View source

pushEntity

function pushEntity(server, entityIndex, push)

Add state for push entity.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
pushdynamic—The push input consumed by `pushEntity`.

View source

relinkAreaEntity

function relinkAreaEntity(server, entityIndex, bounds, solid)

Refresh an edict's area-list membership after its abs bounds change.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
boundsdynamic—The bounds input consumed by `relinkAreaEntity`.
soliddynamic—Stable identifier of the requested entry.

View source

setEntityFloat

function setEntityFloat(server, entityIndex, name, value)

Sets entity float for `miniquake.server_collision`.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
namedynamic—Stable name that identifies the requested object or option.
valuedynamic—Value consumed by `setEntityFloat`.

View source

setEntityVector

function setEntityVector(server, entityIndex, name, value)

Sets entity vector for `miniquake.server_collision`.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
namedynamic—Stable name that identifies the requested object or option.
valuedynamic—Value consumed by `setEntityVector`.

View source

setEntityWord

function setEntityWord(server, entityIndex, name, value)

Update module state for entity word.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
namedynamic—Stable name that identifies the requested object or option.
valuedynamic—Value consumed by `setEntityWord`.

View source

testEntityPosition

function testEntityPosition(server, entityIndex)

Verify entity position against the expected Quake behavior.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.

View source

touchAreaNode

function touchAreaNode(server, node, entityIndex, absMin, absMax)

Visit only trigger-area nodes intersected by one linked edict.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
nodedynamic—The node input consumed by `touchAreaNode`.
entityIndexdynamic—Zero-based index of the requested entry.
absMindynamic—The abs min input consumed by `touchAreaNode`.
absMaxdynamic—The abs max input consumed by `touchAreaNode`.

View source

touchTriggers

function touchTriggers(server, entityIndex)

Implements the `touchTriggers` operation for `miniquake.server_collision` (touch triggers).

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.

View source

touchTriggersWithBounds

function touchTriggersWithBounds(server, entityIndex, absMin, absMax)

Implements the `touchTriggersWithBounds` operation for `miniquake.server_collision` (touch triggers with bounds).

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
absMindynamic—The abs min input consumed by `touchTriggersWithBounds`.
absMaxdynamic—The abs max input consumed by `touchTriggersWithBounds`.

View source

traceAgainstBox

function traceAgainstBox(server, entityIndex, start, mins, maxs, finish)

Trace against box through the collision world.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
startdynamic—The start input consumed by `traceAgainstBox`.
minsdynamic—The mins input consumed by `traceAgainstBox`.
maxsdynamic—The maxs input consumed by `traceAgainstBox`.
finishdynamic—The finish input consumed by `traceAgainstBox`.

View source

traceAgainstBrush

function traceAgainstBrush(server, entityIndex, start, mins, maxs, finish)

Trace against brush through the collision world.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.
startdynamic—The start input consumed by `traceAgainstBrush`.
minsdynamic—The mins input consumed by `traceAgainstBrush`.
maxsdynamic—The maxs input consumed by `traceAgainstBrush`.
finishdynamic—The finish input consumed by `traceAgainstBrush`.

View source

unlinkAreaEntity

function unlinkAreaEntity(entityIndex)

Remove one edict from its current O(1) area-list position.

ParameterTypeDefaultDescription
entityIndexdynamic—Zero-based index of the requested entry.

View source

updateEntityBounds

function updateEntityBounds(server, entityIndex)

Update module state for entity bounds.

ParameterTypeDefaultDescription
serverdynamic—Server state participating in the operation.
entityIndexdynamic—Zero-based index of the requested entry.

View source

zeroVector

function zeroVector()

Implements the `zeroVector` operation for `miniquake.server_collision` (zero vector).

View source