Implement your own physics world by extending this class

Constructor

new()

Initialize physics stuff here

Variables

@:value(50)updateRate:Int = 50

For a consistant and performant physics simulation, a fixed rate is used always regardless of framerate. This is 50hz by default, but you can change it if you need it.

Note: Setting this value above the game framerate will cause physics updates to be called more than once per frame, it's better to keep this value under 100 ticks per second and use physics interpolation instead.

@:value(1 / 50)timeStep:Float = 1 / 50

This is the time passed between each physics step, this can be used to slow down or speed up the simulation while updating it at the same rate.

@:value(4)subSteps:UInt = 4

This is the amount of physics update ocurring between frames for accurate collision detection, a value of 4 is decent enough, but it can be increased or decreased for a tradeoff between accuracy and speed.

Too low of a value can cause high-speed objects to go trough other objects or cause jittering.

onPhysicsUpdate:(dt:Float) ‑> Void

A function to call alongside world_Step

Used in FoxScene to call member's physicsUpdate()

private@:value(0)elapsedTime:Float = 0

@:value(0)timeSinceLastStep:Float = 0

@:value(0)currentTime:Float = 0

Methods

step(dt:Float):UInt

Steps the physics simulation.

Internally, this has a delta counter so updates happen at a fixed rate. If the application update rate is lower than updateRate, more calls will happen per frame.

Parameters:

dt

The actual elapsed time for the application

Returns:

The number of iteration steps needed for compensation. Can be 0, meaning no step is required this frame

physicsStep(dt:Float):Void

The physics engine step function

Inherited Variables

Defined by FoxBasic

@:value("FoxBasic")name:String = "FoxBasic"

@:value(true)visible:Bool = true

@:value(true)active:Bool = true

@:value(null)scene:FoxScene = null

@:value(false)__destroyed:Bool = false

animation:FoxAnimationPlayer

An animation controller for this basic. Although properties have to be manually linked, this is intended to be a general-purpose animator for this object

Inherited Methods

Defined by FoxBasic

physicsUpdate(dt:Float):Void

Called when a physics frame occurs, this is a constant update regardless of framerate for a consistant physics simulation.

draw(camera:FoxCamera):Void

Intended for transforms, actual drawing happens in the camera render pass

pushDrawData(scene:FoxScene):Void

This function gets called when the scene starts building draw groups.

It should call the scene's addToDrawGroups() function for every drawable of this object.

Override this with your custom draw data function.

Note: Internal use only, it is a performance critical operation, keep it fast.

computeBounds(output:BoundingBox):Void

Gets the bounding box of all meshes and models inside groups

In FoxBasic this is just a template, do the actual implementation in your models and groups

Parameters:

output

the Bounding Box where to store the result

testAndCull(camera:FoxCamera):Void

Performs frustum culling by checking the bounding box against a camera frustum

isVisible():Bool

Template function that returns the final visibility for the basic. Frustum culling can affect this.

isActive():Bool

Template function that returns the final activated state for the basic. Frustum culling can affect this.

privateset_visible(v:Bool):Bool