I seem to have some problems getting the rigid bodies in my game to automatically go to sleep/deactivate when they are lying still somewhere. I'm using bullet with double precision on Linux. I set up the physics world like this:
Code: Select all
btCollisionDispatcher* dispatcher = new btCollisionDispatcher();
btVector3 world_min(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
btVector3 world_max(btScalar( 1e30),btScalar( 1e30),btScalar( 1e30));
btBroadphaseInterface* pair_cache = new btAxisSweep3(world_min,world_max);
btConstraintSolver* constraint_solver = new btSequentialImpulseConstraintSolver();
physics_world_ = new btDiscreteDynamicsWorld(dispatcher,pair_cache,constraint_solver);
//-----------------
// Add the terrain
//-----------------
btCollisionShape* terrain_collision_shape = new WbBulletTerrain(terrain_);
btTransform terrain_transform;
terrain_transform.setIdentity();
terrain_transform.setOrigin(btVector3(0,0,0));
btVector3 terrain_inertia(0,0,0);
btDefaultMotionState* terrain_motion_state = new btDefaultMotionState(terrain_transform);
btRigidBody* terrain_body = new btRigidBody(0.0,
terrain_motion_state,
terrain_collision_shape,
terrain_inertia,
0.0, // Linear damping
0.0, // Angular damping
0.8, // Friction
1.0); // Restitution
physics_world_->addRigidBody(terrain_body);
Is there something that has to be done in order to have the rigidbodies automatically sleep, like they do in the CcdPhysicsDemo? I can't seem to find anything in that demo that does anything to influence this (except for the kinematic ground version that disables deactivation).
Also, I'm wondering about what the concept of simulation islands is all about. Is this something that has to be enabled, or does it work automatically by itself?
What does the world size that is set in btAxisSweep3(world_min,world_max); actually influence? I have set it so huge as the game world in our game covers the entire earth globe (like in Google Earth), but maybe this can cause something to break.
Best regards,
Ola