WallsView

Works out which wall strips a BGE.DrawableWalls shows each frame, DOOM-style: no ray is cast against the level. The segments in view are walked front to back (BGE.WallsBsp) and projected onto a fan of rays across the screen, one strip per ray. Each ray keeps an open window of elevation slopes, (height - eye) / forward depth, that nearer walls narrow: a wall on the floor closes it up to its top, one reaching above the screen closes it down to its foot. A closed ray costs nothing more, so cost follows screen coverage, and a short wall leaves taller ones behind it showing.

Every wall point on one ray's bearing lies in one vertical plane through the eye, which projects to one screen line, so the window is exact at any pitch.

Pieces are recorded front to back (per ray: pieceNext from rayFirstPiece) and drawn back to front; a piece partly behind a nearer short wall is drawn whole and painted over.

Properties

  • rayCount (integer)
  • firstTan (float)
  • tanStep (float)
  • levelForward (BGE.Math.Vector)
  • levelRight (BGE.Math.Vector)
  • originX (float)
  • originY (float)
  • originZ (float)
  • hideTolerance (float) — How much nearer than a point a wall must be to hide it, in forward depth (strips round
  • allowLevelPath (boolean) — A level, unrolled camera takes a shorter path; false always takes the general one (tests).
  • lodDepth (float) — Forward depth past which walls (level or pitched, unrolled camera) draw one strip per two
  • pieceCount (integer) — Pieces of the last update(), grown and never shrunk; meaningful below pieceCount.
  • pieceSegment (Array.<integer>)
  • pieceAlong (Array.<float>) — 0..1 along the segment
  • pieceDepth (Array.<float>) — Forward depth (along levelForward)
  • pieceX (Array.<float>) — The strip's foot on the canvas, its foot-to-top length, width and lean (degrees, as
  • pieceY (Array.<float>)
  • pieceLength (Array.<float>)
  • pieceWidth (Array.<float>)
  • pieceAngle (Array.<float>)
  • pieceRay (Array.<integer>)
  • pieceWide (Array.<boolean>) — Whether the piece also covers the ray left of its own (see lodDepth)
  • pieceNext (Array.<integer>) — The ray's next piece further away, or -1
  • pieceSlopeLow (Array.<float>) — The wall's elevation slopes at the piece, foot and top
  • pieceSlopeHigh (Array.<float>)
  • recordSurfaces (boolean) — With recordSurfaces on, update() also lists the floor and ceiling each ray sees between
  • floorCount (integer)
  • floorRay (Array.<integer>)
  • floorTop (Array.<float>)
  • floorBottom (Array.<float>)
  • floorRunCount (integer)
  • floorRunY (Array.<float>)
  • floorRunFirst (Array.<integer>)
  • ceilingCount (integer)
  • ceilingRay (Array.<integer>)
  • ceilingTop (Array.<float>)
  • ceilingBottom (Array.<float>)
  • ceilingRunCount (integer)
  • ceilingRunY (Array.<float>)
  • ceilingRunFirst (Array.<integer>)
  • rayFirstPiece (Array.<integer>) — Per ray: the nearest piece (-1 for none), the forward depth its window closed at and the
  • rayCloseDepth (Array.<float>)
  • rayNearestDepth (Array.<float>)
  • nearestWallDepth (float) — The least of rayNearestDepth this frame: nothing nearer than this can be behind a wall
  • partsInView (integer) — BSP parts (segments, split where walls cross) the last update() found in view, and
  • partsVisited (integer)

Constructor

new WallsView( segments: Array.<BGE.WallSegment>, bsp: BGE.WallsBsp, ): WallsView

Parameters


Instance Methods

setSegments( segments: Array.<BGE.WallSegment>, bsp: BGE.WallsBsp, ): void

Parameters

Returns

  • void

update( camera: BGE.Camera3d, stripWidth: integer, farDistance?: float, ): boolean

Walks the segments for this frame. stripWidth is the screen width in pixels one ray covers. Returns false (rayCount 0) if the camera looks too close to straight up or down.

Parameters

  • camera (BGE.Camera3d)
  • stripWidth (integer)
  • farDistance (float, optional, default: "0.0") — how far out to walk, in forward depth; 0 for the camera's draw distance

Returns

  • boolean

getDepth(i: integer): float

The forward depth at which ray i's view closed (a wall covers all of it from there on), or 1e30. Valid for i in 0..rayCount-1 (unchecked).

Parameters

  • i (integer)

Returns

  • float

getNearestDepth(i: integer): float

The forward depth of the nearest wall on ray i, or 1e30.

Parameters

  • i (integer)

Returns

  • float

findSpan( points: Array.<BGE.Math.Vector>, out: BGE.WallsSpan, ): boolean

Fills out with the rays covering a set of world points. Invalid if empty or any point is level with or behind the camera horizontally.

Parameters

  • points (Array.<BGE.Math.Vector>)
  • out (BGE.WallsSpan) — the span to fill

Returns

  • boolean — out.valid

isPointHidden(point: BGE.Math.Vector): boolean

True when a wall nearer than the point (by more than hideTolerance) covers it.

Parameters

  • point (BGE.Math.Vector)

Returns

  • boolean