BGE/Occlusion
Alias: BGE.Occlusion
Static Methods
insetConvexPolygon(
xs: Array.<float>,
ys: Array.<float>,
distance: float,
): BGE.CanvasPolygon
Shrinks a convex canvas-space polygon by moving every edge distance px inward.
Parameters
xs(Array.<float>) — vertex x coordinates, in order around the polygon (either winding)ys(Array.<float>) — vertex y coordinatesdistance(float) — how far to move each edge in; 0 or less returns the polygon as is
Returns
BGE.CanvasPolygon— the shrunk polygon, or invalid if it has fewer than 3 distinct corners or the inset would collapse it
getPolygonArea(xs: Array.<float>, ys: Array.<float>): float
The area of a simple canvas-space polygon, in either winding.
Parameters
xs(Array.<float>)ys(Array.<float>)
Returns
float
getSignedDoubleArea(xs: Array.<float>, ys: Array.<float>): float
Twice the polygon's signed area (shoelace), positive when counter-clockwise with y up.
Parameters
xs(Array.<float>)ys(Array.<float>)
Returns
float
dropFlatCorners(
xs: Array.<float>,
ys: Array.<float>,
): BGE.CanvasPolygon
A copy of the polygon without repeated or (nearly) collinear corners, which have no edge direction to offset. Dropping one only trims a sliver off a convex polygon. invalid when fewer than 3 corners remain.
Parameters
xs(Array.<float>)ys(Array.<float>)
Returns
buildModelPanels(
faces: Array.<BGE.Model3dFace>,
): Array.<BGE.OccluderPanel>
Merges a static model's coplanar, edge-sharing triangles into convex panels that can act as occluders. Panels keep the source triangles' winding.
Parameters
faces(Array.<BGE.Model3dFace>) — triangles in model-local space
Returns
Array.<BGE.OccluderPanel>— one panel per merged region; degenerate triangles are dropped
getFacesSize(faces: Array.<BGE.Model3dFace>): float
Largest extent of the model along any axis.
Parameters
faces(Array.<BGE.Model3dFace>)
Returns
float
mergePolygons(
polygons: Array.<Array.<BGE.Math.Vector>>,
normal: BGE.Math.Vector,
epsilon: float,
): void
Greedily merges polygons that share an edge while the result stays convex.
Parameters
polygons(Array.<Array.<BGE.Math.Vector>>)normal(BGE.Math.Vector)epsilon(float)
Returns
void
tryMerge(
p: Array.<BGE.Math.Vector>,
q: Array.<BGE.Math.Vector>,
normal: BGE.Math.Vector,
epsilon: float,
): Array.<BGE.Math.Vector>
Joins two polygons along a shared edge (walked in opposite directions, as same-winding neighbours do), or returns invalid when they share none or the union isn't convex.
Parameters
p(Array.<BGE.Math.Vector>)q(Array.<BGE.Math.Vector>)normal(BGE.Math.Vector)epsilon(float)
Returns
Array.<BGE.Math.Vector>
isOnPolygonEdge(
point: BGE.Math.Vector,
polygon: Array.<BGE.Math.Vector>,
epsilon: float,
): boolean
Whether point lies within epsilon of one of the polygon's edges.
Parameters
point(BGE.Math.Vector)polygon(Array.<BGE.Math.Vector>)epsilon(float)
Returns
boolean
isSamePoint(
a: BGE.Math.Vector,
b: BGE.Math.Vector,
epsilon: float,
): boolean
Parameters
a(BGE.Math.Vector)b(BGE.Math.Vector)epsilon(float)
Returns
boolean
getTurnSine(
a: BGE.Math.Vector,
b: BGE.Math.Vector,
c: BGE.Math.Vector,
normal: BGE.Math.Vector,
): float
The turn at b (coming from a, going to c), signed against the plane normal and scaled by the edge lengths so it is the sine of the angle.
Parameters
a(BGE.Math.Vector)b(BGE.Math.Vector)c(BGE.Math.Vector)normal(BGE.Math.Vector)
Returns
float
dropCollinear(
polygon: Array.<BGE.Math.Vector>,
normal: BGE.Math.Vector,
): Array.<BGE.Math.Vector>
Parameters
polygon(Array.<BGE.Math.Vector>)normal(BGE.Math.Vector)
Returns
Array.<BGE.Math.Vector>
isConvex(
polygon: Array.<BGE.Math.Vector>,
normal: BGE.Math.Vector,
): boolean
Parameters
polygon(Array.<BGE.Math.Vector>)normal(BGE.Math.Vector)
Returns
boolean