BGE/Occlusion

Alias: BGE.Occlusion


Static Methods

insetConvexPolygon( xs: Array.<float>, ys: Array.<float>, distance: float, ): BGE.CanvasPolygon

static

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 coordinates
  • distance (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

static

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

static

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

static

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>

static

Merges a static model's coplanar, edge-sharing triangles into convex panels that can act as occluders. Panels keep the source triangles' winding.

Parameters

Returns

  • Array.<BGE.OccluderPanel> — one panel per merged region; degenerate triangles are dropped

getFacesSize(faces: Array.<BGE.Model3dFace>): float

static

Largest extent of the model along any axis.

Parameters

Returns

  • float

mergePolygons( polygons: Array.<Array.<BGE.Math.Vector>>, normal: BGE.Math.Vector, epsilon: float, ): void

static

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>

static

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

static

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

static

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

static

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>

static

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

static

Parameters

  • polygon (Array.<BGE.Math.Vector>)
  • normal (BGE.Math.Vector)

Returns

  • boolean