diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/entity.cc | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc index da94896..a59c85c 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -623,11 +623,13 @@ void Entity::reset() zone()->physics()->addRigidBody(entity_body); } - // transfer entity location to motion state - body()->setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f)); + // transfer entity location to body body()->setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f)); + body()->setAngularVelocity(btVector3(0.0f, 0.0f, 0.0f)); + body()->clearForces(); body()->setWorldTransform(t); + set_dirty(); } @@ -761,19 +763,26 @@ void EntityDynamic::reset() // transfer entity location to motion state body()->setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f)); - body()->setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f)); + body()->setAngularVelocity(btVector3(0.0f, 0.0f, 0.0f)); body()->setWorldTransform(t); + body()->clearForces(); if (motionstate()) { motionstate()->setWorldTransform(t); } if (entity_state == Docked) { - body()->setLinearFactor(btVector3(0.0f, 0.0f, 0.0f)); - body()->setAngularFactor(btVector3(0.0f, 0.0f, 0.0f)); + //body()->setLinearFactor(btVector3(0.0f, 0.0f, 0.0f)); + //body()->setAngularFactor(btVector3(0.0f, 0.0f, 0.0f)); + entity_body->setActivationState(DISABLE_SIMULATION); } else { - body()->setLinearFactor(btVector3(1.0f, 1.0f, 1.0f)); - body()->setAngularFactor(btVector3(1.0f, 1.0f, 1.0f)); + //body()->setLinearFactor(btVector3(1.0f, 1.0f, 1.0f)); + //body()->setAngularFactor(btVector3(1.0f, 1.0f, 1.0f)); + if (entity_mass) { + entity_body->setActivationState(DISABLE_DEACTIVATION); + } else { + entity_body->setActivationState(ISLAND_SLEEPING); + } } set_dirty(); @@ -1210,7 +1219,6 @@ void EntityControlable::reset() // create physics body entity_body_info = new btRigidBody::btRigidBodyConstructionInfo(entity_mass, entity_motionstate, entity_collision_shape, inertia); entity_body = new btRigidBody(*entity_body_info); - entity_body->setActivationState(DISABLE_DEACTIVATION); //entity_body->setCollisionFlags(entity_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); @@ -1222,17 +1230,20 @@ void EntityControlable::reset() } } + body()->clearForces(); body()->setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f)); - body()->setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f)); + body()->setAngularVelocity(btVector3(0.0f, 0.0f, 0.0f)); body()->setWorldTransform(t); motionstate()->setWorldTransform(t); if (entity_state == Docked) { - body()->setLinearFactor(btVector3(0.0f, 0.0f, 0.0f)); - body()->setAngularFactor(btVector3(0.0f, 0.0f, 0.0f)); + //body()->setLinearFactor(btVector3(0.0f, 0.0f, 0.0f)); + //body()->setAngularFactor(btVector3(0.0f, 0.0f, 0.0f)); + entity_body->setActivationState(DISABLE_SIMULATION); } else { - body()->setLinearFactor(btVector3(1.0f, 1.0f, 1.0f)); - body()->setAngularFactor(btVector3(1.0f, 1.0f, 1.0f)); + //body()->setLinearFactor(btVector3(1.0f, 1.0f, 1.0f)); + //body()->setAngularFactor(btVector3(1.0f, 1.0f, 1.0f)); + entity_body->setActivationState(DISABLE_DEACTIVATION); } //if (zone()) { |