public class PhysicsSpace extends CollisionSpace implements ContactListener
btDiscreteDynamicsWorld.| Modifier and Type | Class and Description |
|---|---|
static class |
PhysicsSpace.BroadphaseType
Enumerate the available accelerators for broadphase collision detection.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
AXIS_X
index of the X axis
|
static int |
AXIS_Y
index of the Y axis
|
static int |
AXIS_Z
index of the Z axis
|
static java.util.logging.Logger |
logger
message logger for this class
|
loggerCloggerN| Constructor and Description |
|---|
PhysicsSpace(PhysicsSpace.BroadphaseType broadphaseType)
Instantiate a PhysicsSpace with sequential-impulse solvers.
|
PhysicsSpace(Vector3f worldMin,
Vector3f worldMax)
Instantiate a PhysicsSpace with an AXIS_SWEEP_3 broadphase accelerator
and sequential-impulse solvers.
|
PhysicsSpace(Vector3f worldMin,
Vector3f worldMax,
PhysicsSpace.BroadphaseType broadphaseType)
Instantiate a PhysicsSpace with sequential-impulse solvers.
|
PhysicsSpace(Vector3f worldMin,
Vector3f worldMax,
PhysicsSpace.BroadphaseType broadphaseType,
int numSolvers)
Instantiate a PhysicsSpace with the specified number of
sequential-impulse solvers.
|
PhysicsSpace(Vector3f worldMin,
Vector3f worldMax,
PhysicsSpace.BroadphaseType broadphaseType,
int numSolvers,
CollisionConfiguration configuration)
Instantiate a PhysicsSpace with the specified number of
sequential-impulse solvers.
|
PhysicsSpace(Vector3f worldMin,
Vector3f worldMax,
PhysicsSpace.BroadphaseType broadphaseType,
SolverType solverType)
Instantiate a PhysicsSpace with the specified contact-and-constraint
solver.
|
PhysicsSpace(Vector3f worldMin,
Vector3f worldMax,
PhysicsSpace.BroadphaseType broadphaseType,
SolverType solverType,
CollisionConfiguration configuration)
Instantiate a PhysicsSpace with the specified contact-and-constraint
solver.
|
| Modifier and Type | Method and Description |
|---|---|
void |
activateAll(boolean forceFlag)
Activate all rigid bodies in this space.
|
void |
add(java.lang.Object object)
Add the specified object to this space.
|
void |
addCollisionObject(PhysicsCollisionObject pco)
Add the specified collision object to this space.
|
void |
addJoint(PhysicsJoint joint)
Add the specified PhysicsJoint to this space.
|
void |
addTickListener(PhysicsTickListener listener)
Register the specified tick listener with this space.
|
boolean |
contains(PhysicsCollisionObject pco)
Test whether the specified collision object is added to this space.
|
boolean |
contains(PhysicsJoint joint)
Test whether the specified PhysicsJoint is added to this space.
|
int |
countJoints()
Count the joints in this space.
|
int |
countManifolds()
Count the collision manifolds in this space.
|
int |
countRigidBodies()
Count the rigid bodies in this space, including vehicles.
|
int |
countTickListeners()
Count how many tick listeners are registered with this space.
|
protected void |
create()
Must be invoked on the designated physics thread.
|
void |
destroy()
Remove all collision objects and physics joints.
|
float |
getAccuracy()
Read the accuracy: the time step used when maxSubSteps>0.
|
java.util.Collection<PhysicsCharacter> |
getCharacterList()
Enumerate physics characters that have been added to this space and not
yet removed.
|
Vector3f |
getGravity(Vector3f storeResult)
Copy the gravitational acceleration for newly-added bodies.
|
java.util.Collection<PhysicsJoint> |
getJointList()
Enumerate physics joints that have been added to this space and not yet
removed.
|
protected java.util.Map<java.lang.Long,PhysicsJoint> |
getJointMap()
Access the map from native IDs to physics joints.
|
java.util.Collection<PhysicsCollisionObject> |
getPcoList()
Enumerate collision objects that have been added to this space and not
yet removed.
|
static PhysicsSpace |
getPhysicsSpace()
Access the PhysicsSpace running on this thread.
|
java.util.Collection<PhysicsRigidBody> |
getRigidBodyList()
Enumerate rigid bodies (including vehicles) that have been added to this
space and not yet removed.
|
SolverInfo |
getSolverInfo()
Access parameters used by the contact-and-constraint solver.
|
SolverType |
getSolverType()
Determine the type of solver.
|
java.util.Collection<PhysicsVehicle> |
getVehicleList()
Enumerate physics vehicles that have been added to this space and not yet
removed.
|
protected static int |
getWorldType(long spaceId)
Determine the type of the underlying btDynamicsWorld.
|
protected void |
initSolverInfo()
Initialize the solverInfo field during create().
|
boolean |
isCcdWithStaticOnly()
Test whether CCD checks for collisions with static and kinematic bodies
(native field: m_ccdWithStaticOnly).
|
boolean |
isEmpty()
Test whether this space is empty.
|
boolean |
isUsingScr()
Test whether this space uses Speculative Contact Restitution (native
field: m_applySpeculativeContactRestitution).
|
long[] |
listManifoldIds()
Enumerate the native IDs of all collision manifolds in this space.
|
int |
maxSubSteps()
Read the maximum number of simulation steps per frame.
|
float |
maxTimeStep()
Read the maximum time step (imposed when maxSubSteps=0).
|
void |
onContactEnded(long manifoldId)
Invoked by native code immediately after a contact manifold is destroyed.
|
void |
onContactProcessed(PhysicsCollisionObject pcoA,
PhysicsCollisionObject pcoB,
long pointId)
Invoked by native code immediately after a contact point is refreshed
without being destroyed.
|
void |
onContactStarted(long manifoldId)
Invoked by native code immediately after a contact manifold is created.
|
void |
remove(java.lang.Object object)
Remove the specified object from this space.
|
void |
removeCollisionObject(PhysicsCollisionObject pco)
Remove the specified collision object from this space.
|
void |
removeJoint(PhysicsJoint joint)
Remove the specified PhysicsJoint from this space.
|
void |
removeTickListener(PhysicsTickListener listener)
De-register the specified tick listener.
|
void |
setAccuracy(float accuracy)
Alter the accuracy (time step used when maxSubSteps>0).
|
void |
setCcdWithStaticOnly(boolean setting)
Alter whether CCD checks for collisions with static and kinematic bodies
(native field: m_ccdWithStaticOnly).
|
void |
setGravity(Vector3f gravity)
Alter the gravitational acceleration acting on newly-added bodies.
|
void |
setMaxSubSteps(int steps)
Alter the maximum number of simulation steps per frame.
|
void |
setMaxTimeStep(float maxTimeStep)
Alter the maximum time step (imposed when maxSubSteps=0).
|
void |
update(float timeInterval)
Update this space.
|
void |
update(float timeInterval,
int maxSteps)
Update this space.
|
void |
update(float timeInterval,
int maxSteps,
boolean doEnded,
boolean doProcessed,
boolean doStarted)
Update this space.
|
protected void |
updateSolver()
Replace the existing contact-and-constraint solver with a new one of the
correct type.
|
void |
useScr(boolean setting)
Alter whether this space uses Speculative Contact Restitution (native
field: m_applySpeculativeContactRestitution).
|
contactTest, countCollisionObjects, countSolvers, getBroadphaseType, getCollisionSpace, getConfiguration, getGhostObjectList, getRayTestFlags, getWorldMax, getWorldMin, hasClosest, hasContact, initThread, isForceUpdateAllAabbs, isUsingDeterministicDispatch, jniEnvId, needsCollision, pairTest, rayTest, rayTest, rayTestDp, rayTestRaw, rayTestRaw, setForceUpdateAllAabbs, setRayTestFlags, sweepTest, useDeterministicDispatchcompareTo, countTrackers, dumpTrackers, equals, freeUnusedObjects, hasAssignedNativeObject, hashCode, nativeId, reassignNativeId, setNativeId, setNativeIdNotTracked, toString, unassignNativeObjectpublic static final int AXIS_X
public static final int AXIS_Y
public static final int AXIS_Z
public static final java.util.logging.Logger logger
public PhysicsSpace(PhysicsSpace.BroadphaseType broadphaseType)
broadphaseType - which broadphase accelerator to use (not null)public PhysicsSpace(Vector3f worldMin, Vector3f worldMax)
worldMin - the desired minimum coordinate values (not null,
unaffected)worldMax - the desired maximum coordinate values (not null,
unaffected)public PhysicsSpace(Vector3f worldMin, Vector3f worldMax, PhysicsSpace.BroadphaseType broadphaseType)
worldMin - the desired minimum coordinate values (not null,
unaffected, default=(-10k,-10k,-10k))worldMax - the desired maximum coordinate values (not null,
unaffected, default=(10k,10k,10k))broadphaseType - which broadphase accelerator to use (not null)public PhysicsSpace(Vector3f worldMin, Vector3f worldMax, PhysicsSpace.BroadphaseType broadphaseType, int numSolvers)
worldMin - the desired minimum coordinate values (not null,
unaffected, default=(-10k,-10k,-10k))worldMax - the desired maximum coordinate values (not null,
unaffected, default=(10k,10k,10k))broadphaseType - which broadphase accelerator to use (not null)numSolvers - the desired number of solvers in the thread-safe pool
(≥1, ≤64, default=numThreads)public PhysicsSpace(Vector3f worldMin, Vector3f worldMax, PhysicsSpace.BroadphaseType broadphaseType, int numSolvers, CollisionConfiguration configuration)
worldMin - the desired minimum coordinate values (not null,
unaffected, default=(-10k,-10k,-10k))worldMax - the desired maximum coordinate values (not null,
unaffected, default=(10k,10k,10k))broadphaseType - which broadphase accelerator to use (not null)numSolvers - the desired number of solvers in the thread-safe pool
(≥1, ≤64, default=numThreads)configuration - the desired configuration (not null)public PhysicsSpace(Vector3f worldMin, Vector3f worldMax, PhysicsSpace.BroadphaseType broadphaseType, SolverType solverType)
worldMin - the desired minimum coordinate values (not null,
unaffected, default=(-10k,-10k,-10k))worldMax - the desired maximum coordinate values (not null,
unaffected, default=(10k,10k,10k))broadphaseType - which broadphase accelerator to use (not null)solverType - the desired contact-and-constraint solver (not null)public PhysicsSpace(Vector3f worldMin, Vector3f worldMax, PhysicsSpace.BroadphaseType broadphaseType, SolverType solverType, CollisionConfiguration configuration)
worldMin - the desired minimum coordinate values (not null,
unaffected, default=(-10k,-10k,-10k))worldMax - the desired maximum coordinate values (not null,
unaffected, default=(10k,10k,10k))broadphaseType - which broadphase accelerator to use (not null)solverType - the desired contact-and-constraint solver (not null)configuration - the desired configuration (not null)public void activateAll(boolean forceFlag)
forceFlag - true to force activationpublic void addJoint(PhysicsJoint joint)
joint - the joint to add (not null, alias created)public void addTickListener(PhysicsTickListener listener)
Tick listeners are notified before and after each simulation step. A simulation step is not necessarily the same as a frame; it is more influenced by the accuracy of the PhysicsSpace.
listener - the listener to register (not null, alias created)setAccuracy(float)public boolean contains(PhysicsJoint joint)
joint - the joint to test (not null, unaffected)public int countJoints()
public int countManifolds()
public int countRigidBodies()
public int countTickListeners()
public float getAccuracy()
public java.util.Collection<PhysicsCharacter> getCharacterList()
public Vector3f getGravity(Vector3f storeResult)
storeResult - storage for the result (modified if not null)public java.util.Collection<PhysicsJoint> getJointList()
public static PhysicsSpace getPhysicsSpace()
public java.util.Collection<PhysicsRigidBody> getRigidBodyList()
public SolverInfo getSolverInfo()
public SolverType getSolverType()
public java.util.Collection<PhysicsVehicle> getVehicleList()
public boolean isCcdWithStaticOnly()
public boolean isUsingScr()
public long[] listManifoldIds()
PersistentManifoldspublic int maxSubSteps()
public float maxTimeStep()
public void removeJoint(PhysicsJoint joint)
joint - the joint to remove (not null)public void removeTickListener(PhysicsTickListener listener)
listener - the listener to de-register (not null, unaffected)addTickListener(com.jme3.bullet.PhysicsTickListener)public void setAccuracy(float accuracy)
In general, the smaller the time step, the more accurate (and compute-intensive) the simulation will be.
accuracy - the desired time step (in seconds, >0, default=1/60)public void setCcdWithStaticOnly(boolean setting)
setting - true to limit checking, false to check also for collisions
with dynamic bodies (default=false)public void setGravity(Vector3f gravity)
Typically, when a body is added to a space, the body's gravity gets set to that of the space. Thus, it is preferable to set the space's gravity before adding any bodies to the space.
gravity - the desired acceleration vector (in physics-space
coordinates, not null, unaffected, default=(0,-9.81,0))public void setMaxSubSteps(int steps)
Extra simulation steps help maintain determinism when the render fps drops below 1/accuracy. For example a value of 2 can compensate for frame rates as low as 30fps, assuming the physics has an accuracy of 1/60 sec.
Setting this value too high can depress the frame rate.
steps - the desired maximum number of steps (≥1) or 0 for a
variable time step (default=4)public void setMaxTimeStep(float maxTimeStep)
In general, the smaller the time step, the more accurate (and compute-intensive) the simulation will be.
maxTimeStep - the desired maximum time step (in seconds, >0,
default=0.1)public void update(float timeInterval)
timeInterval - the time interval to simulate (in seconds, ≥0)setMaxSubSteps(int)public void update(float timeInterval,
int maxSteps)
timeInterval - the time interval to simulate (in seconds, ≥0)maxSteps - the maximum number of steps of size accuracy
(≥1) or 0 for a single step of size timeIntervalpublic void update(float timeInterval,
int maxSteps,
boolean doEnded,
boolean doProcessed,
boolean doStarted)
timeInterval - the time interval to simulate (in seconds, ≥0)maxSteps - the maximum number of steps of size accuracy
(≥1) or 0 for a single step of size timeIntervaldoEnded - true to enable onContactEnded() callbacks, false
to skip themdoProcessed - true to enable onContactProcessed() callbacks,
false to skip themdoStarted - true to enable onContactStarted() callbacks,
false to skip thempublic void useScr(boolean setting)
setting - true to enable SCR, false to disable it (default=false)protected java.util.Map<java.lang.Long,PhysicsJoint> getJointMap()
protected static int getWorldType(long spaceId)
spaceId - the Bullet identifier for this space (non-zero)protected void initSolverInfo()
protected void updateSolver()
public void add(java.lang.Object object)
add in class CollisionSpaceobject - the collision object or PhysicsJoint to add (not null)public void addCollisionObject(PhysicsCollisionObject pco)
addCollisionObject in class CollisionSpacepco - the collision object to add (not null)public boolean contains(PhysicsCollisionObject pco)
contains in class CollisionSpacepco - the object to test (not null, unaffected)protected void create()
create in class CollisionSpacepublic void destroy()
destroy in class CollisionSpacepublic java.util.Collection<PhysicsCollisionObject> getPcoList()
getPcoList in class CollisionSpacepublic boolean isEmpty()
isEmpty in class CollisionSpacepublic void remove(java.lang.Object object)
remove in class CollisionSpaceobject - the collision object or PhysicsJoint to remove, or nullpublic void removeCollisionObject(PhysicsCollisionObject pco)
removeCollisionObject in class CollisionSpacepco - the collision object to remove (not null)public void onContactEnded(long manifoldId)
Override this method to customize how contacts are handled.
onContactEnded in interface ContactListenermanifoldId - the native ID of the btPersistentManifold (not
zero)public void onContactProcessed(PhysicsCollisionObject pcoA, PhysicsCollisionObject pcoB, long pointId)
Override this method to customize how contacts are handled.
onContactProcessed in interface ContactListenerpcoA - the first involved object (not null)pcoB - the 2nd involved object (not null)pointId - the native ID of the btManifoldPoint (not zero)public void onContactStarted(long manifoldId)
Override this method to customize how contacts are handled.
onContactStarted in interface ContactListenermanifoldId - the native ID of the btPersistentManifold (not
zero)