public final class World extends Object
| Modifier and Type | Method and Description |
|---|---|
void |
clearForces()
Call this after you are done with time steps to clear the forces.
|
float |
computeParticleCollisionEnergy() |
Body |
createBody(BodyDef def)
Create a rigid body given a definition.
|
Joint |
createJoint(JointDef def)
Create a joint to constrain bodies together.
|
int |
createParticle(ParticleDef def)
Create a particle whose properties have been defined.
|
ParticleGroup |
createParticleGroup(ParticleGroupDef def)
Create a particle group whose properties have been defined.
|
void |
destroyBody(Body body)
Destroy a rigid body.
|
void |
destroyJoint(Joint j)
Destroy a joint.
|
void |
destroyParticle(int index)
Destroy a particle.
|
void |
destroyParticle(int index,
boolean callDestructionListener)
Destroy a particle.
|
void |
destroyParticlesInGroup(ParticleGroup group)
Destroy particles in a group without enabling the destruction callback for destroyed particles.
|
void |
destroyParticlesInGroup(ParticleGroup group,
boolean callDestructionListener)
Destroy particles in a group.
|
int |
destroyParticlesInShape(Shape shape,
Transform xf)
Destroy particles inside a shape without enabling the destruction callback for destroyed
particles.
|
int |
destroyParticlesInShape(Shape shape,
Transform xf,
boolean callDestructionListener)
Destroy particles inside a shape.
|
boolean |
getAutoClearForces() |
Array<Body> |
getBodies()
DO NOT MODIFY.
|
int |
getBodyCount() |
int |
getContactCount() |
Contact |
getContactList()
Get the world contact list.
|
DestructionListener |
getDestructionListener() |
Vec2 |
getGravity() |
int |
getJointCount() |
Joint |
getJointList()
Get the world joint list.
|
int |
getParticleBodyContactCount() |
ParticleBodyContact[] |
getParticleBodyContacts() |
ParticleColor[] |
getParticleColorBuffer() |
int |
getParticleContactCount() |
ParticleContact[] |
getParticleContacts() |
int |
getParticleCount() |
float |
getParticleDamping() |
float |
getParticleDensity() |
ParticleDestructionListener |
getParticleDestructionListener() |
int[] |
getParticleFlagsBuffer()
Get the particle data.
|
float |
getParticleGravityScale() |
ParticleGroup[] |
getParticleGroupBuffer() |
int |
getParticleGroupCount() |
ParticleGroup[] |
getParticleGroupList()
Get the world particle group list.
|
int |
getParticleMaxCount() |
Vec2[] |
getParticlePositionBuffer() |
float |
getParticleRadius() |
ParticleSystem |
getParticleSystem() |
Object[] |
getParticleUserDataBuffer() |
Vec2[] |
getParticleVelocityBuffer() |
IWorldPool |
getPool() |
int |
getProxyCount() |
int |
getTreeBalance() |
int |
getTreeHeight() |
float |
getTreeQuality() |
boolean |
isAllowSleep() |
boolean |
isContinuousPhysics() |
boolean |
isLocked() |
boolean |
isSleepingAllowed() |
boolean |
isSubStepping() |
boolean |
isWarmStarting() |
void |
joinParticleGroups(ParticleGroup groupA,
ParticleGroup groupB)
Join two particle groups.
|
void |
queryAABB(ParticleQueryCallback particleCallback,
AABB aabb)
Query the world for all particles that potentially overlap the provided AABB.
|
void |
queryAABB(QueryCallback callback,
AABB aabb)
Query the world for all fixtures that potentially overlap the provided AABB.
|
void |
queryAABB(QueryCallback callback,
ParticleQueryCallback particleCallback,
AABB aabb)
Query the world for all fixtures and particles that potentially overlap the provided AABB.
|
void |
raycast(ParticleRaycastCallback particleCallback,
Vec2 point1,
Vec2 point2)
Ray-cast the world for all particles in the path of the ray.
|
void |
raycast(RayCastCallback callback,
ParticleRaycastCallback particleCallback,
Vec2 point1,
Vec2 point2)
Ray-cast the world for all fixtures and particles in the path of the ray.
|
void |
raycast(RayCastCallback callback,
Vec2 point1,
Vec2 point2)
Ray-cast the world for all fixtures in the path of the ray.
|
void |
setAllowSleep(boolean flag) |
void |
setAutoClearForces(boolean flag)
Set flag to control automatic clearing of forces after each time step.
|
void |
setContactFilter(ContactFilter filter)
Register a contact filter to provide specific control over collision.
|
void |
setContactListener(ContactListener listener)
Register a contact event listener.
|
void |
setContinuousPhysics(boolean flag)
Enable/disable continuous physics.
|
void |
setDestructionListener(DestructionListener listener)
Register a destruction listener.
|
void |
setGravity(Vec2 gravity)
Change the global gravity vector.
|
void |
setParticleColorBuffer(ParticleColor[] buffer,
int capacity) |
void |
setParticleDamping(float damping)
Damping is used to reduce the velocity of particles.
|
void |
setParticleDensity(float density)
Change the particle density.
|
void |
setParticleDestructionListener(ParticleDestructionListener listener) |
void |
setParticleFlagsBuffer(int[] buffer,
int capacity)
Set a buffer for particle data.
|
void |
setParticleGravityScale(float gravityScale)
Change the particle gravity scale.
|
void |
setParticleMaxCount(int count)
Set the maximum number of particles.
|
void |
setParticlePositionBuffer(Vec2[] buffer,
int capacity) |
void |
setParticleRadius(float radius)
Change the particle radius.
|
void |
setParticleUserDataBuffer(Object[] buffer,
int capacity) |
void |
setParticleVelocityBuffer(Vec2[] buffer,
int capacity) |
void |
setSleepingAllowed(boolean sleepingAllowed) |
void |
setSubStepping(boolean subStepping) |
void |
setWarmStarting(boolean flag)
Enable/disable warm starting.
|
void |
step(float dt,
int velocityIterations,
int positionIterations)
Take a time step.
|
public World(Vec2 gravity)
public Body createBody(BodyDef def)
def - body definitionpublic void destroyBody(Body body)
body - body to destroypublic Joint createJoint(JointDef def)
def - joint definitionpublic void destroyJoint(Joint j)
j - jointpublic void step(float dt,
int velocityIterations,
int positionIterations)
dt - the amount of time to simulate, this should not varyvelocityIterations - for the velocity constraint solverpositionIterations - for the position constraint solverpublic void queryAABB(QueryCallback callback, ParticleQueryCallback particleCallback, AABB aabb)
callback - a user implemented callback classparticleCallback - callback for particlesaabb - the query boxpublic void queryAABB(QueryCallback callback, AABB aabb)
callback - a user implemented callback classaabb - the query boxpublic void queryAABB(ParticleQueryCallback particleCallback, AABB aabb)
particleCallback - callback for particlesaabb - the query boxpublic void raycast(RayCastCallback callback, ParticleRaycastCallback particleCallback, Vec2 point1, Vec2 point2)
callback - a user implemented callback classparticleCallback - the particle callback classpoint1 - the ray starting pointpoint2 - the ray ending pointpublic void raycast(RayCastCallback callback, Vec2 point1, Vec2 point2)
callback - a user implemented callback classpoint1 - the ray starting pointpoint2 - the ray ending pointpublic void raycast(ParticleRaycastCallback particleCallback, Vec2 point1, Vec2 point2)
particleCallback - the particle callback classpoint1 - the ray starting pointpoint2 - the ray ending pointpublic void clearForces()
setAutoClearForces(boolean)public int createParticle(ParticleDef def)
public void destroyParticle(int index)
index - particle indexpublic void destroyParticle(int index,
boolean callDestructionListener)
index - of the particle to destroycallDestructionListener - whether to call the destruction listener just before the particle is destroyedpublic int destroyParticlesInShape(Shape shape, Transform xf)
shape - which encloses particles that should be destroyed.xf - transform applied to the shape.public int destroyParticlesInShape(Shape shape, Transform xf, boolean callDestructionListener)
shape - which encloses particles that should be destroyed.xf - transform applied to the shape.callDestructionListener - whether to call the world b2DestructionListener for each particle destroyed.public ParticleGroup createParticleGroup(ParticleGroupDef def)
def - particle group definitionpublic void joinParticleGroups(ParticleGroup groupA, ParticleGroup groupB)
groupA - the first group. Expands to encompass the second group.groupB - the second group. It is destroyed.public void destroyParticlesInGroup(ParticleGroup group, boolean callDestructionListener)
group - the particle group to destroy.callDestructionListener - Whether to call the world b2DestructionListener for each particle is destroyed.public void destroyParticlesInGroup(ParticleGroup group)
group - the particle group to destroy.public ParticleGroup[] getParticleGroupList()
public int getParticleGroupCount()
public int getParticleCount()
public int getParticleMaxCount()
public void setParticleMaxCount(int count)
count - numberpublic void setParticleDensity(float density)
density - particle densitypublic float getParticleDensity()
public void setParticleGravityScale(float gravityScale)
gravityScale - gravity scalepublic float getParticleGravityScale()
public void setParticleDamping(float damping)
damping - particle dampingpublic float getParticleDamping()
public void setParticleRadius(float radius)
radius - particle radiuspublic float getParticleRadius()
public int[] getParticleFlagsBuffer()
public Vec2[] getParticlePositionBuffer()
public Vec2[] getParticleVelocityBuffer()
public ParticleColor[] getParticleColorBuffer()
public ParticleGroup[] getParticleGroupBuffer()
public Object[] getParticleUserDataBuffer()
public void setParticleFlagsBuffer(int[] buffer,
int capacity)
buffer - is a pointer to a block of memory.capacity - is the number of values in the block.public void setParticlePositionBuffer(Vec2[] buffer, int capacity)
public void setParticleVelocityBuffer(Vec2[] buffer, int capacity)
public void setParticleColorBuffer(ParticleColor[] buffer, int capacity)
public void setParticleUserDataBuffer(Object[] buffer, int capacity)
public ParticleContact[] getParticleContacts()
public int getParticleContactCount()
public ParticleBodyContact[] getParticleBodyContacts()
public int getParticleBodyContactCount()
public float computeParticleCollisionEnergy()
public Joint getJointList()
public Contact getContactList()
public boolean isSleepingAllowed()
public void setSleepingAllowed(boolean sleepingAllowed)
public void setWarmStarting(boolean flag)
flag - warm starting flagpublic boolean isWarmStarting()
public void setContinuousPhysics(boolean flag)
flag - continuous physics flagpublic boolean isContinuousPhysics()
public int getProxyCount()
public int getBodyCount()
public int getJointCount()
public int getContactCount()
public int getTreeHeight()
public int getTreeBalance()
public float getTreeQuality()
public void setGravity(Vec2 gravity)
gravity - gravity vectorpublic Vec2 getGravity()
public IWorldPool getPool()
public DestructionListener getDestructionListener()
public void setDestructionListener(DestructionListener listener)
listener - destruction listenerpublic ParticleDestructionListener getParticleDestructionListener()
public void setParticleDestructionListener(ParticleDestructionListener listener)
public boolean isAllowSleep()
public void setAllowSleep(boolean flag)
public void setSubStepping(boolean subStepping)
public boolean isSubStepping()
public ParticleSystem getParticleSystem()
public void setAutoClearForces(boolean flag)
flag - automatically clear forces flagpublic boolean getAutoClearForces()
public void setContactFilter(ContactFilter filter)
filter - contact filterpublic void setContactListener(ContactListener listener)
listener - contact listenerpublic boolean isLocked()
Copyright © 2018. All rights reserved.