blaze.world
- class
World
;
- The world class manages all physics entities, dynamic simulation,
and asynchronous queries. The world also contains efficient memory
management facilities.
- this(bVec2 gravity, bool doSleep);
- Constructs a world object.
Params:
bVec2 gravity |
the world gravity vector. |
bool doSleep |
improve performance by not simulating inactive bodies. |
- void
allowSleep
(bool sleep);
- Allow or disallow sleeping
- void
destructionListener
(DestructionListener listener);
- Register a destruction listener.
- void
boundaryListener
(BoundaryListener listener);
- Register a broad-phase boundary listener.
- void
contactFilter
(ContactFilter filter);
- Register a contact filter to provide specific control over collision.
Otherwise the default filter is used (defaultFilter).
- void
contactListener
(ContactListener listener);
- Registers a contact event listener
- ContactListener
contactListener
();
- Returns:
the current contact listener
- Body
createBody
(BodyDef def);
- Create a rigid body given a definition. No reference to the definition
is retained.
Params:
BodyDef def |
the body definition to base the new body off of. |
Warning:
This function is locked during callbacks.
- void
destroyBody
(Body b);
- Destroy a rigid body given a definition. No reference to the definition
is retained. This function is locked during callbacks.
Params:
Body b |
the body to destroy |
Warning:
This automatically deletes all associated shapes and joints.
Warning:
This function is locked during callbacks.
- Joint
createJoint
(JointDef def);
- Create a joint to constrain bodies together. No reference to the definition
is retained. This may cause the connected bodies to cease colliding.
Warning:
This function is locked during callbacks.
- void
destroyJoint
(Joint j);
- Destroy a joint. This may cause the connected bodies to begin colliding.
Params:
Joint j |
the joint to destroy
Warning This function is locked during callbacks. |
- bool
addForce
(ForceGenerator fg);
- Applies a force to a rigid body.
- bool
removeForce
(ForceGenerator fg);
- Removes a force from a rigid body.
- ForceGenerator[]
forces
();
- Return a list of world
forces
- Body
groundBody
();
- The world provides a single static ground body with no collision shapes.
You can use this to simplify the creation of joints and static shapes.
- void
step
(float dt, int velocityIterations, int positionIterations);
- Take a time
step
. This performs collision detection, integration,
and constraint solution.
Params:
timeStep |
the amount of time to simulate, this should not vary. |
int velocityIterations |
for the velocity constraint solver. |
int positionIterations |
for the position constraint solver. |
- void
query
(AABB aabb, ref Shape[] results);
- Query the world for all shapes that potentially overlap the
provided AABB. You provide a shape pointer buffer of specified
size. The number of shapes found is returned.
Params:
AABB aabb |
the
query
box. |
Shape[] results |
an array in which the results are stored. |
- int
raycast
(Segment segment, Shape[] shapes, bool solidShapes, Object userData);
- Query the world for all shapes that intersect a given segment.
You provide a shape pointer buffer of specified size. The number of
shapes found is returned, and the buffer is filled in order of
intersection
Params:
Segment segment |
defines the begin and end point of the ray cast, from p1
to p2. Use Segment.Extend to create (semi-)infinite rays |
Shape[] shapes |
an array in which all intersecting shapes are stored |
bool solidShapes |
determines if shapes that the ray starts in are counted
as hits. |
Object userData |
passed through the worlds contact filter, with method
RayCollide. This can be used to filter valid shapes |
Returns:
the number of shapes found
BUGS:
This doesn't work. At all.
- Shape
raycastOne
(Segment segment, ref float lambda, ref bVec2 normal, bool solidShapes, Object userData);
- Performs a raycast as with Raycast, finding the first intersecting shape.
Params:
Segment segment |
defines the begin and end point of the ray cast, from p1 to
p2. Use Segment.Extend to create (semi-)infinite rays. |
float lambda |
returns the hit fraction. You can use this to compute the
contact point p = (1 - lambda) * segment.p1 + lambda * segment.p2 |
bVec2 normal |
returns the normal at the contact point. If there is no
intersection, the normal is not set. |
bool solidShapes |
determines if shapes that the ray starts in are counted
as hits. |
Returns:
the colliding shape shape, or null if not found
BUGS:
Because raycast doesn't work, this won't either.
- void
addFluidParticle
(Shape shape);
- Add fluid particles to the world
Params:
Shape shape |
the fluid shape to add. |
See Also:
blaze.collision.shapes.fluidParticle
- FluidParticle[]
particles
();
- Returns:
the Fluid Particle list (or null)
- Body
bodyList
();
- Get the world body list. With the returned body, use Body::GetNext to get
the next body in the world list. A null body indicates the end of the list.
Returns:
the head of the world body list.
- Joint
jointList
();
- Get the world joint list. With the returned joint, use Joint::GetNext to
get the next joint in the world list. A null joint indicates the end of
the list.
Returns:
the head of the world joint list.
- void
setWarmStarting
(bool flag);
- Enable/disable warm starting. For testing.
- void
setContinuousPhysics
(bool flag);
- Enable/disable continuous physics. For testing.
- void
validate
();
- Perform validation of internal data structures.
BUGS:
Currently does nothing.
- int
bodyCount
();
- Returns:
the number of bodies.
- int
jointCount
();
- Returns:
the number joints.
- void
gravity
(bVec2
gravity
);
- Change the global
gravity
vector.
Params:
bVec2
gravity
|
the new
gravity
vector |
- bVec2
gravity
();
- Returns:
the global
gravity
vector.
- bool
lock
();
- TODO:
change the name of this to "locked"
Returns:
true if the world is locked, false otherwise
|