lukethor
|
 |
«
Posted
2012-02-28 15:57:39 » |
|
I am working on a game that introduces a Jbullet Character_object every certain amount of time into the physics world. The physics world only contain Static_Objects besides the character objects being introduced. Here are the two game states.
Stable state - I introduce only one Character_object into the system every 10 seconds , the game does not slow down the frames per second at all.
Unstable system - Enter a Character_object every three seconds. The games becomes slow and the FPS slow down from 60 FPS to 8 FPS. The system never recovers again.
The desired system is to be able to enter into the physics world a character_object every three seconds. Is there any way to enter into the world a character_object that does not introduce any force at all while the velocity of the object falls to a certain threshold ?
Here are the constructors for the Character_Object and the Static_object :
public Character(String name, String filepath,Vector3 pos) {
//Get box dimensions from libgdx Vector3 boxDims = box.getDimensions(); //Character shape, so construct the half extents and convert to JBullet's Vector type Vector3f halfExtents = new Vector3f(boxDims.x/2, boxDims.y/2, boxDims.z/2); CylinderShape shape = new CylinderShape(halfExtents); rigidBody = Physics.constructRigidBody(shape, 1, pos.x, pos.y, rigidBody.setFriction(0.6f); // Just bouncy rigidBody.setRestitution(0.5f); rigidBody.setDamping(0.10f,0.80f); rigidBody.setCollisionShape(shape); rigidBody.setCollisionFlags( rigidBody.getCollisionFlags() | CollisionFlags.CHARACTER_OBJECT); }
public StaticMeshObject(String name, String filepath,Vector3 pos) { meshInterface = new TriangleIndexVertexArray(); trimesh = new IndexedMesh(); meshInterface.addIndexedMesh(trimesh); BvhTriangleMeshShape meshShape = new BvhTriangleMeshShape(meshInterface, true, true) rigidBody = Physics.constructRigidBody(meshShape, 0, pos.x, pos.y, pos.z); rigidBody.setCollisionFlags(rigidBody.getCollisionFlags() | CollisionFlags.STATIC_OBJECT); }
|