Packageorg.generalrelativity.foam.dynamics
Classpublic class PhysicsEngine



Public Properties
 PropertyDefined by
  solverIterations : int
[write-only] Sets the number of times the timestep is subdivided and collision is checked
PhysicsEngine
Public Methods
 MethodDefined by
  
Creates a new Physics Engine

This should be viewed as a work in progress.

PhysicsEngine
  
addCollidable(collidable:ISimulatable):void
Adds a collidable element to the engine.
PhysicsEngine
  
addODESolver(solver:IODESolver):void
Adds an IODESolver to the engine.
PhysicsEngine
  
Gets an IBody that collides with the given point, if any
PhysicsEngine
  
removeCollidable(collidable:ISimulatable):void
Removes a collidable element from simulation
PhysicsEngine
  
Removes an IODESolver from the simulation
PhysicsEngine
  
Sets the engine's coarse collision detector
PhysicsEngine
  
Defines the collision factory used by the coarse detector to return IFineCollisionDetectors
PhysicsEngine
  
step(dt:Number = 1.0):void
This seemingly harmless little method is the heart of the physics simulation.
PhysicsEngine
Public Constants
 ConstantDefined by
  DEFAULT_COARSE_COLLISION_DETECTOR : Class
[static] offers a default ICoarseCollisionDetector class
PhysicsEngine
  SOLVER_ITERATIONS : int = 3
[static] offers a default number of iterations per frame
PhysicsEngine
Property detail
solverIterationsproperty
solverIterations:int  [write-only]

Sets the number of times the timestep is subdivided and collision is checked

Implementation
    public function set solverIterations(value:int):void

See also

Constructor detail
PhysicsEngine()constructor
public function PhysicsEngine()

Creates a new Physics Engine

This should be viewed as a work in progress. It currently uses a less-than-desirable approach to contact resolution. All functionality is pretty well broken out and shouldn't affect the user even given radical changes in future releases

Instantiation is typically handled through the Foam interface.

See also

Foam
Method detail
addCollidable()method
public function addCollidable(collidable:ISimulatable):void

Adds a collidable element to the engine. Because the engine draws a distinction between solvers and collidable elements, collidable elements can be added without needing its state solved and vice versa.

Parameters
collidable:ISimulatable — ISimulatable to add to collision list

See also

IODESolver
addCollidable
ICoarseCollisionDetector
addODESolver()method 
public function addODESolver(solver:IODESolver):void

Adds an IODESolver to the engine. Because the engine draws a distinction between solvers and collidable elements, IODESolvers can be added without being tested/solved for collision and vice versa.

Parameters
solver:IODESolver — IODESolver to add

See also

IODESolver
addCollidable
Foam.addElement
getBodyUnderPoint()method 
public function getBodyUnderPoint(point:Vector):IBody

Gets an IBody that collides with the given point, if any

Parameters
point:Vector — Vector to check against all bodies

Returns
IBody

See also

PointPolygonDetector
removeCollidable()method 
public function removeCollidable(collidable:ISimulatable):void

Removes a collidable element from simulation

Parameters
collidable:ISimulatable — element to remove
removeODESolver()method 
public function removeODESolver(solver:IODESolver):void

Removes an IODESolver from the simulation

Parameters
solver:IODESolver — IODESolver to remove
setCoarseCollisionDetector()method 
public function setCoarseCollisionDetector(detector:ICoarseCollisionDetector):void

Sets the engine's coarse collision detector

Parameters
detector:ICoarseCollisionDetector — ICoarseCollisionDetector to handle broad phase culling
setCollisionFactory()method 
public function setCollisionFactory(factory:ICollisionFactory):void

Defines the collision factory used by the coarse detector to return IFineCollisionDetectors

Parameters
factory:ICollisionFactory — CollisionFactory
step()method 
public function step(dt:Number = 1.0):void

This seemingly harmless little method is the heart of the physics simulation.

It takes a stepsize over which to advance the state of the system. The more discrete the time step (and resultant subdivided timesteps based on _solverIterations) the more realistic the simulation. Realism comes at the cost of performance.

Parameters
dt:Number (default = 1.0) — timestep with which to advance the system

See also

Foam.stepForward
Foam.stepBackward
IODESolver.step
resolveCollisions
Constant detail
DEFAULT_COARSE_COLLISION_DETECTORconstant
public static const DEFAULT_COARSE_COLLISION_DETECTOR:Class

offers a default ICoarseCollisionDetector class

SOLVER_ITERATIONSconstant 
public static const SOLVER_ITERATIONS:int = 3

offers a default number of iterations per frame