QualityController

Chooses a render quality level from measured frame times. Game runs one for you after enableAdaptiveQuality(); you don't normally create one yourself.

Properties

  • targetFps (float)
  • minLevel (integer)
  • maxLevel (integer)
  • windowSeconds (float)
  • outlierFrameSeconds (float)
  • hitchFrameMultiple (float)
  • hitchesToStepDown (integer)
  • hitchWindowSeconds (float)
  • settleSeconds (float)
  • stepDownBelowFraction (float)
  • stepUpHeadroomFraction (float)
  • stepUpSustainSeconds (float)
  • maxMeasurableFps (float)
  • stepDownCooldownSeconds (float)
  • probeFailWindowSeconds (float)
  • probeBackoffSeconds (float)
  • stillProbeBackoffSeconds (float)
  • stepUpJumpFraction (float)
  • stillCameraSeconds (float)
  • stillSettleSeconds (float)
  • stillSampleSeconds (float)
  • cameraMoveMaxStepDown (integer)

Constructor

new QualityController( options?: BGE.AdaptiveQualityOptions, ): QualityController

Parameters


Instance Methods

setTarget( targetFps: float, minLevel: integer, maxLevel: integer, ): void

Sets the frame rate and range to hold, e.g. for a scene with its own. Backoffs are forgotten, since a level that failed elsewhere says little here.

Parameters

  • targetFps (float)
  • minLevel (integer) — a BGE.RenderQualityLevel value
  • maxLevel (integer) — a BGE.RenderQualityLevel value

Returns

  • void

noteCamera(dt: float, moved: boolean): void

Feed whether the camera moved this frame, before update(). Moving again after a still spell keeps the level; update() steps down from there if frames fall short.

Parameters

  • dt (float)
  • moved (boolean) — whether the camera moved or turned this frame

Returns

  • void

isCameraStill(): boolean

Returns

  • boolean — whether the controller is treating the camera as still

levelForCameraStart(currentLevel: integer): integer

The level to draw at when the camera starts moving from still, before that frame draws: the level last in force while it moved, if lower, so the first moving frames don't draw at the still camera's level (#557). Call only when the camera moves this frame.

Parameters

  • currentLevel (integer) — the level currently applied

Returns

  • integer

update(dt: float, currentLevel: integer): integer

Feed one frame's duration; returns the level to use (currentLevel if no change).

Parameters

  • dt (float) — full frame time in seconds, including the buffer swap
  • currentLevel (integer) — the level currently applied

Returns

  • integer

notifyLevelChanged(): void

Call after a new level has been applied: clears the average and waits out the settle period so one-off rebuild costs don't count against the new level.

Returns

  • void

notifySceneChanged(): void

Call after a scene change, for the same reason as notifyLevelChanged().

Returns

  • void