Package com.jme3.bullet
Class PhysicsSpace
java.lang.Object
com.jme3.bullet.PhysicsSpace
PhysicsSpace - The central jbullet-jme physics space
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enuminterface with Broadphase types
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionPhysicsSpace(PhysicsSpace.BroadphaseType broadphaseType) PhysicsSpace(Vector3f worldMin, Vector3f worldMax) PhysicsSpace(Vector3f worldMin, Vector3f worldMax, PhysicsSpace.BroadphaseType broadphaseType) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidadds an object to the physics spacevoidadds all physics controls and joints in the given spatial node to the physics space (e.g.voidaddCollisionGroupListener(PhysicsCollisionGroupListener listener, int collisionGroup) Adds a listener for a specific collision group, such a listener can disable collisions when they happen.
 There can be only one listener per collision group.voidaddCollisionListener(PhysicsCollisionListener listener) Adds a CollisionListener that will be informed about collision eventsvoidvoidaddTickListener(PhysicsTickListener listener) Adds the specified listener to the physics tick listeners.voidapplies gravity value to all objectsvoidclears forces of all objectsvoidcreate()Has to be called from the (designated) physics threadvoiddestroy()destroys the current PhysicsSpace so that a new one can be createdvoid<V> Future<V> calls the callable on the next physics tick (ensuring e.g.static <V> Future<V> enqueueOnThisThread(Callable<V> callable) floatget the current accuracy of the physics computationcom.bulletphysics.dynamics.DynamicsWorldused internallygetGravity(Vector3f gravity) Gets the gravity of the PhysicsSpacestatic PhysicsSpaceGet the current PhysicsSpace running on this thread
 For parallel physics, this can also be called from the OpenGL thread to receive the PhysicsSpaceintPerforms a ray collision test and returns the results as a list of PhysicsRayTestResultsrayTest(Vector3f from, Vector3f to, List<PhysicsRayTestResult> results) Performs a ray collision test and returns the results as a list of PhysicsRayTestResultsvoidremoves an object from the physics spacevoidRemoves all physics controls and joints in the given spatial from the physics space (e.g.voidremoveCollisionGroupListener(int collisionGroup) voidRemoves a CollisionListener from the listvoidvoidremoveTickListener(PhysicsTickListener listener) voidsetAccuracy(float accuracy) sets the accuracy of the physics computation, default=1/60svoidsetBroadphaseType(PhysicsSpace.BroadphaseType broadphaseType) voidsetGravity(Vector3f gravity) Sets the gravity of the PhysicsSpace, set before adding physics objects!static voidUsed internallyvoidsetMaxSubSteps(int steps) Sets the maximum amount of extra steps that will be used to step the physics when the fps is below the physics fps.voidsetSolverNumIterations(int numIterations) Set the number of iterations used by the contact solver.voidsetWorldMax(Vector3f worldMax) only applies for AXIS_SWEEP broadphasevoidsetWorldMin(Vector3f worldMin) only applies for AXIS_SWEEP broadphasesweepTest(CollisionShape shape, Transform start, Transform end) Performs a sweep collision test and returns the results as a list of PhysicsSweepTestResults
 You have to use different Transforms for start and end (at least distance greater than 0.4f).sweepTest(CollisionShape shape, Transform start, Transform end, List<PhysicsSweepTestResult> results) Performs a sweep collision test and returns the results as a list of PhysicsSweepTestResults
 You have to use different Transforms for start and end (at least distance greater than 0.4f).voidupdate(float time) updates the physics spacevoidupdate(float time, int maxSteps) updates the physics space, uses maxSteps
- 
Field Details- 
AXIS_Xpublic static final int AXIS_Xindex of the X axis- See Also:
 
- 
AXIS_Ypublic static final int AXIS_Yindex of the Y axis- See Also:
 
- 
AXIS_Zpublic static final int AXIS_Zindex of the Z axis- See Also:
 
 
- 
- 
Constructor Details- 
PhysicsSpacepublic PhysicsSpace()
- 
PhysicsSpace
- 
PhysicsSpace
- 
PhysicsSpacepublic PhysicsSpace(Vector3f worldMin, Vector3f worldMax, PhysicsSpace.BroadphaseType broadphaseType) 
 
- 
- 
Method Details- 
getPhysicsSpaceGet the current PhysicsSpace running on this thread
 For parallel physics, this can also be called from the OpenGL thread to receive the PhysicsSpace- Returns:
- the PhysicsSpace running on this thread
 
- 
setLocalThreadPhysicsSpaceUsed internally- Parameters:
- space- which space to simulate on the current thread
 
- 
createpublic void create()Has to be called from the (designated) physics thread
- 
updatepublic void update(float time) updates the physics space- Parameters:
- time- the current time value
 
- 
updatepublic void update(float time, int maxSteps) updates the physics space, uses maxSteps- Parameters:
- time- the current time value
- maxSteps- the maximum number of steps of size accuracy (≥1) or 0 for a single step of size timeInterval
 
- 
distributeEventspublic void distributeEvents()
- 
enqueueOnThisThread
- 
enqueuecalls the callable on the next physics tick (ensuring e.g. force applying)- Type Parameters:
- V- the return type of the Callable
- Parameters:
- callable- the Callable to invoke
- Returns:
- a new AppTask
 
- 
addadds an object to the physics space- Parameters:
- obj- the PhysicsControl or Spatial with PhysicsControl to add
 
- 
addCollisionObject
- 
removeremoves an object from the physics space- Parameters:
- obj- the PhysicsControl or Spatial with PhysicsControl to remove
 
- 
removeCollisionObject
- 
addAlladds all physics controls and joints in the given spatial node to the physics space (e.g. after loading from disk) - recursive if node- Parameters:
- spatial- the rootnode containing the physics objects
 
- 
removeAllRemoves all physics controls and joints in the given spatial from the physics space (e.g. before saving to disk) - recursive if node- Parameters:
- spatial- the rootnode containing the physics objects
 
- 
getRigidBodyList
- 
getGhostObjectList
- 
getCharacterList
- 
getJointList
- 
getVehicleList
- 
setGravitySets the gravity of the PhysicsSpace, set before adding physics objects!- Parameters:
- gravity- the desired acceleration vector (in physics-space coordinates, not null, unaffected, default=0,-10,0)
 
- 
getGravityGets the gravity of the PhysicsSpace- Parameters:
- gravity- storage for the result (modified if not null)
- Returns:
- the acceleration vector (in physics-space coordinates, either gravity or a new instance)
 
- 
applyGravitypublic void applyGravity()applies gravity value to all objects
- 
clearForcespublic void clearForces()clears forces of all objects
- 
addTickListenerAdds the specified listener to the physics tick listeners. The listeners are called on each physics step, which is not necessarily each frame but is determined by the accuracy of the physics space.- Parameters:
- listener- the listener to register (not null, alias created)
 
- 
removeTickListener
- 
addCollisionListenerAdds a CollisionListener that will be informed about collision events- Parameters:
- listener- the CollisionListener to add
 
- 
removeCollisionListenerRemoves a CollisionListener from the list- Parameters:
- listener- the CollisionListener to remove
 
- 
addCollisionGroupListenerAdds a listener for a specific collision group, such a listener can disable collisions when they happen.
 There can be only one listener per collision group.- Parameters:
- listener- the listener to register (not null, alias created)
- collisionGroup- which group it should listen for (bitmask with exactly one bit set)
 
- 
removeCollisionGroupListenerpublic void removeCollisionGroupListener(int collisionGroup) 
- 
rayTestPerforms a ray collision test and returns the results as a list of PhysicsRayTestResults- Parameters:
- from- the starting location (physics-space coordinates, not null, unaffected)
- to- the ending location (in physics-space coordinates, not null, unaffected)
- Returns:
- a new list of results (not null)
 
- 
rayTestpublic List<PhysicsRayTestResult> rayTest(Vector3f from, Vector3f to, List<PhysicsRayTestResult> results) Performs a ray collision test and returns the results as a list of PhysicsRayTestResults- Parameters:
- from- the starting location (in physics-space coordinates, not null, unaffected)
- to- the ending location (in physics-space coordinates, not null, unaffected)
- results- the list to hold results (not null, modified)
- Returns:
- results
 
- 
sweepTestPerforms a sweep collision test and returns the results as a list of PhysicsSweepTestResults
 You have to use different Transforms for start and end (at least distance greater than 0.4f). SweepTest will not see a collision if it starts INSIDE an object and is moving AWAY from its center.- Parameters:
- shape- the shape to sweep (not null, convex, unaffected)
- start- the starting physics-space transform (not null, unaffected)
- end- the ending physics-space transform (not null, unaffected)
- Returns:
- a new list of results
 
- 
sweepTestpublic List<PhysicsSweepTestResult> sweepTest(CollisionShape shape, Transform start, Transform end, List<PhysicsSweepTestResult> results) Performs a sweep collision test and returns the results as a list of PhysicsSweepTestResults
 You have to use different Transforms for start and end (at least distance greater than 0.4f). SweepTest will not see a collision if it starts INSIDE an object and is moving AWAY from its center.- Parameters:
- shape- the shape to sweep (not null, convex, unaffected)
- start- the starting physics-space transform (not null, unaffected)
- end- the ending physics-space transform (not null, unaffected)
- results- the list to hold results (not null, modified)
- Returns:
- results
 
- 
destroypublic void destroy()destroys the current PhysicsSpace so that a new one can be created
- 
getDynamicsWorldpublic com.bulletphysics.dynamics.DynamicsWorld getDynamicsWorld()used internally- Returns:
- the dynamicsWorld
 
- 
getBroadphaseType
- 
setBroadphaseType
- 
setMaxSubStepspublic void setMaxSubSteps(int steps) Sets the maximum amount of extra steps that will be used to step the physics when the fps is below the physics fps. Doing this maintains determinism in physics. For example a maximum number of 2 can compensate for frame rates as low as 30fps when the physics has the default accuracy of 60 fps. Note that setting this value too high can make the physics drive down its own fps in case it's overloaded.- Parameters:
- steps- The maximum number of extra steps, default is 4.
 
- 
getAccuracypublic float getAccuracy()get the current accuracy of the physics computation- Returns:
- the current accuracy
 
- 
setAccuracypublic void setAccuracy(float accuracy) sets the accuracy of the physics computation, default=1/60s- Parameters:
- accuracy- the desired time step (in seconds, default=1/60)
 
- 
getWorldMin
- 
setWorldMinonly applies for AXIS_SWEEP broadphase- Parameters:
- worldMin- the desired minimum coordinates values (not null, unaffected, default=-10k,-10k,-10k)
 
- 
getWorldMax
- 
setWorldMaxonly applies for AXIS_SWEEP broadphase- Parameters:
- worldMax- the desired maximum coordinates values (not null, unaffected, default=10k,10k,10k)
 
- 
setSolverNumIterationspublic void setSolverNumIterations(int numIterations) Set the number of iterations used by the contact solver. The default is 10. Use 4 for low quality, 20 for high quality.- Parameters:
- numIterations- The number of iterations used by the contact and constraint solver.
 
- 
getSolverNumIterationspublic int getSolverNumIterations()
 
-