diff options
author | Stijn Buys <ingar@osirion.org> | 2010-10-20 19:13:46 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-10-20 19:13:46 +0000 |
commit | c2a6f7c2ee6245109c897ee23b093b5277a30594 (patch) | |
tree | b8976c8869ea156c992a7d9d3b6c1355f3730303 /src/core | |
parent | 08f0d0fb6a57f9c398bc03ed9a3cc9537a1f3e18 (diff) |
removes Static and Solid entity flags, corrects EntityDynamic motionstate sync
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/entity.cc | 67 | ||||
-rw-r--r-- | src/core/entity.h | 2 | ||||
-rw-r--r-- | src/core/netserver.cc | 2 |
3 files changed, 31 insertions, 40 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc index 2b37d95..c76b23a 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -523,11 +523,14 @@ void Entity::reset() entity_body->setActivationState(ISLAND_SLEEPING); if (zone()) - zone()->physics()->addRigidBody(entity_body); + zone()->physics()->addRigidBody(entity_body); } // transfer entity location to motion state - entity_body->setWorldTransform(t); + body()->setWorldTransform(t); + body()->setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f)); + body()->setAngularVelocity(btVector3(0.0f, 0.0f, 0.0f)); + if (zone()) zone()->physics()->synchronizeSingleMotionState(entity_body); @@ -577,19 +580,22 @@ void EntityDynamic::set_keepalive_timeout(float timeout) void EntityDynamic::reset() { Entity::reset(); - - if ((entity_state == Docked) || (entity_state == Destroyed) || (!visible())){ - entity_body->activate(false); + + if (entity_state == Docked) { + body()->setLinearFactor(btVector3(0.0f, 0.0f, 0.0f)); + body()->setAngularFactor(btVector3(0.0f, 0.0f, 0.0f)); } else { - entity_body->activate(true); + body()->setLinearFactor(btVector3(1.0f, 1.0f, 1.0f)); + body()->setAngularFactor(btVector3(1.0f, 1.0f, 1.0f)); } } void EntityDynamic::frame(float seconds) { - if ((flags() & Static) == Static) + if (entity_state == Docked) { return; - + } + // transfer bullet state to entity state if (entity_body) { // this makes sure an update is sent if speed goes to 0 in the next step @@ -841,9 +847,6 @@ void EntityControlable::receive_server_update(std::istream &is) void EntityControlable::set_thrust(float thrust) { - if ((flags() & Static) == Static) - return; - if (thrust != target_thrust) { target_thrust = thrust; set_dirty(); @@ -852,9 +855,6 @@ void EntityControlable::set_thrust(float thrust) void EntityControlable::set_direction(float direction) { - if ((flags() & Static) == Static) - return; - if (target_direction != direction) { target_direction = direction; set_dirty(); @@ -863,9 +863,6 @@ void EntityControlable::set_direction(float direction) void EntityControlable::set_pitch(float pitch) { - if ((flags() & Static) == Static) - return; - if (target_pitch != pitch) { target_pitch = pitch; set_dirty(); @@ -874,9 +871,6 @@ void EntityControlable::set_pitch(float pitch) void EntityControlable::set_roll(float roll) { - if ((flags() & Static) == Static) - return; - if (target_roll != roll) { target_roll = roll; set_dirty(); @@ -885,9 +879,6 @@ void EntityControlable::set_roll(float roll) void EntityControlable::set_strafe(float strafe) { - if ((flags() & Static) == Static) - return; - if (target_strafe != strafe) { target_strafe = strafe; set_dirty(); @@ -896,9 +887,6 @@ void EntityControlable::set_strafe(float strafe) void EntityControlable::set_vstrafe(float vstrafe) { - if ((flags() & Static) == Static) - return; - if (target_vstrafe != vstrafe) { target_vstrafe = vstrafe; set_dirty(); @@ -907,9 +895,6 @@ void EntityControlable::set_vstrafe(float vstrafe) void EntityControlable::set_afterburner(float afterburner) { - if ((flags() & Static) == Static) - return; - if (target_afterburner != afterburner) { target_afterburner = afterburner; set_dirty(); @@ -979,19 +964,25 @@ void EntityControlable::reset() if (zone()) { entity_zone->physics()->addRigidBody(body()); entity_zone->physics()->addAction(entity_actioninterface); - - // transfer entity location to motion state - zone()->physics()->synchronizeSingleMotionState(entity_body); } } - - entity_body->setWorldTransform(t); - if ((entity_state == Docked) || (entity_state == Destroyed) || (!visible())){ - entity_body->activate(false); + + body()->setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f)); + body()->setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f)); + body()->setWorldTransform(t); + + if (entity_state == Docked) { + body()->setLinearFactor(btVector3(0.0f, 0.0f, 0.0f)); + body()->setAngularFactor(btVector3(0.0f, 0.0f, 0.0f)); } else { - entity_body->activate(true); + body()->setLinearFactor(btVector3(1.0f, 1.0f, 1.0f)); + body()->setAngularFactor(btVector3(1.0f, 1.0f, 1.0f)); + } + + if (zone()) { + // transfer entity location to motion state + zone()->physics()->synchronizeSingleMotionState(entity_body); } - set_dirty(); } diff --git a/src/core/entity.h b/src/core/entity.h index f6ee1d7..8dd5644 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -44,7 +44,7 @@ public: /** * @brief entity flags */ - enum Flags {Static = 1, Solid = 2, Bright = 4, Dockable = 8, ShowOnMap = 16, KeepAlive = 32}; + enum Flags {NonSolid = 2, Bright = 4, Dockable = 8, ShowOnMap = 16, KeepAlive = 32}; /// Entity type constants enum Type {Default = 0, Dynamic = 1, Controlable = 2, Globe = 3}; diff --git a/src/core/netserver.cc b/src/core/netserver.cc index 8d3e762..4769f68 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -366,7 +366,7 @@ void NetServer::client_frame(NetClient *client, unsigned long timestamp) // this entity has entered the zone send_entity_create(client, entity); - } else if (entity->dirty() && !(entity->flags() & Entity::Static)) { + } else if (entity->dirty()) { // FIXME only within visual range send_entity_update(client, entity); |