BGE/BSP
Alias: BGE.BSP
Static Methods
buildTree(items: Array.<BGE.BSP.StaticItem>): object
Builds a classification-only BSP tree over static quads - no polygon splitting (see the design spec for why). Picks the first item as each node's splitting plane and partitions every other remaining item to front/back by which side of that plane its center falls on.
Parameters
items(Array.<BGE.BSP.StaticItem>)
Returns
object—invalidfor an empty list, else{item, front, back}
collectDrawOrder(
node: object,
cameraPosition: BGE.Math.Vector,
dynamicItems: Array.<BGE.BSP.DynamicItem>,
result: Array.<dynamic>,
): void
Walks the tree back-to-front relative to cameraPosition, appending each static item's sceneObj payload to result in the correct draw position, with dynamicItems classified against each node's plane and interleaved at the matching point instead of being split. A leaf (node = invalid) appends its remaining dynamicItems sorted by depthKey ascending.
Parameters
node(object) — result of buildTree(), or invalidcameraPosition(BGE.Math.Vector)dynamicItems(Array.<BGE.BSP.DynamicItem>)result(Array.<dynamic>) — appended to in draw order - not returned, so a caller can reuse one array across a partial traversal if ever needed
Returns
void
appendLeafDynamicItems(
dynamicItems: Array.<BGE.BSP.DynamicItem>,
result: Array.<dynamic>,
): void
Parameters
dynamicItems(Array.<BGE.BSP.DynamicItem>)result(Array.<dynamic>)
Returns
void
Other
StaticItem
One static quad's plane, in world space - planePoint/planeNormal come from the quad's own BGE.Math.CornerPoints.getCenter()/getNormal(). sceneObj is an opaque payload this module never inspects - the caller gets it back unchanged in collectDrawOrder()'s result.
Properties
sceneObj(dynamic)planePoint(BGE.Math.Vector)planeNormal(BGE.Math.Vector)
DynamicItem
One dynamic (non-static) object being threaded into the BSP walk. depthKey mirrors BGE.SceneObject.negDistanceFromCamera's convention (ascending = farthest from the camera first) - used only to order objects that land in the same leaf, where no more static geometry disambiguates them further.
Properties
sceneObj(dynamic)position(BGE.Math.Vector)depthKey(float)