Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-10-20 19:13:46 +0000
committerStijn Buys <ingar@osirion.org>2010-10-20 19:13:46 +0000
commitc2a6f7c2ee6245109c897ee23b093b5277a30594 (patch)
treeb8976c8869ea156c992a7d9d3b6c1355f3730303 /src
parent08f0d0fb6a57f9c398bc03ed9a3cc9537a1f3e18 (diff)
removes Static and Solid entity flags, corrects EntityDynamic motionstate sync
Diffstat (limited to 'src')
-rw-r--r--src/core/entity.cc67
-rw-r--r--src/core/entity.h2
-rw-r--r--src/core/netserver.cc2
-rw-r--r--src/game/base/game.cc10
-rw-r--r--src/game/base/jumppoint.cc1
-rw-r--r--src/game/base/navpoint.cc1
-rw-r--r--src/game/base/planet.cc2
-rw-r--r--src/game/base/ship.cc10
-rw-r--r--src/game/base/star.cc2
9 files changed, 40 insertions, 57 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);
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index d99f80c..9d2dcd0 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -719,9 +719,9 @@ void Game::func_launch(core::Player *player, std::string const &args)
Ship *ship = static_cast<Ship *>(player->control());
if (dock->type() == core::Entity::Globe)
- ship->get_location().assign(dock->location() + (dock->axis().forward() *(planet_safe_distance + ship->radius() + dock->radius())));
+ ship->get_location().assign(dock->location() + (dock->axis().forward() * (planet_safe_distance + ship->radius() + dock->radius())));
else
- ship->get_location().assign(dock->location() + (dock->axis().forward() *(ship->radius() + dock->radius())));
+ ship->get_location().assign(dock->location() + (dock->axis().forward() * (ship->radius() + dock->radius())));
ship->get_axis().assign(dock->axis());
ship->set_state(core::Entity::Normal);
@@ -1065,7 +1065,6 @@ bool Game::load_zone(core::Zone *zone)
} else if (zoneini.got_section("entity")) {
entity = new core::Entity();
- entity->set_flag(core::Entity::Static);
entity->set_zone(zone);
count ++;
@@ -1268,11 +1267,9 @@ bool Game::load_zone(core::Zone *zone)
}
}
}
+
zoneini.close();
-
con_debug << " " << zoneini.name() << " " << zone->content().size() << " entities" << std::endl;
-
-
return true;
}
@@ -1290,7 +1287,6 @@ bool Game::validate_zone(core::Zone *zone)
// validate jump gate
JumpGate *jumpgate = static_cast<JumpGate *>(entity);
jumpgate->validate();
-
} else {
if ((entity->flags() & core::Entity::Dockable) == core::Entity::Dockable) {
generate_entity_menus(entity);
diff --git a/src/game/base/jumppoint.cc b/src/game/base/jumppoint.cc
index 283b607..5b9a75f 100644
--- a/src/game/base/jumppoint.cc
+++ b/src/game/base/jumppoint.cc
@@ -18,7 +18,6 @@ JumpPoint::JumpPoint() : core::EntityDynamic()
get_color().assign(0.0f, 0.8f, 0.8f, 1.0f);
get_color_second().assign(0.6f, 1.0f);
set_radius(0.25f);
- set_flag(core::Entity::Static);
set_flag(core::Entity::Bright);
// FIXME jumppoints should be harder to find
set_flag(core::Entity::ShowOnMap);
diff --git a/src/game/base/navpoint.cc b/src/game/base/navpoint.cc
index 7d0d75c..650473b 100644
--- a/src/game/base/navpoint.cc
+++ b/src/game/base/navpoint.cc
@@ -16,7 +16,6 @@ NavPoint::NavPoint() : core::Entity()
get_color().assign(1.0f, 1.0f);
get_color_second().assign(0.6f, 1.0f);
set_radius(0.25f);
- set_flag(core::Entity::Static);
set_flag(core::Entity::Bright);
//set_flag(core::Entity::ShowOnMap);
diff --git a/src/game/base/planet.cc b/src/game/base/planet.cc
index 1e280c7..8723af4 100644
--- a/src/game/base/planet.cc
+++ b/src/game/base/planet.cc
@@ -14,8 +14,6 @@ namespace game
Planet::Planet() : core::EntityGlobe()
{
set_flag(core::Entity::ShowOnMap);
- set_flag(core::Entity::Static);
- set_flag(core::Entity::Solid);
get_color().assign(1.0f, 1.0f); // white
set_radius(64.0f); // 64 game units
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index d426a0d..0ac7461 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -275,19 +275,21 @@ void Ship::action (btScalar seconds)
{
float maxspeed = 0;
float engine_force = 0;
+ float torque_force = ship_torque_force;
btTransform t;
switch (entity_state) {
case core::Entity::Normal:
engine_force = ship_thrust_force * entity_thrust;
- maxspeed = ship_shipmodel->maxspeed() * entity_thrust;
+ maxspeed = ship_shipmodel->maxspeed() * entity_thrust;
break;
case core::Entity::ImpulseInitiate:
case core::Entity::Impulse:
engine_force = ship_impulse_force;
maxspeed = (Game::g_impulsespeed ? Game::g_impulsespeed->value() * 0.01f : 0.0f);
+ torque_force *= .5f;
break;
case core::Entity::JumpInitiate:
@@ -333,11 +335,11 @@ void Ship::action (btScalar seconds)
}
// apply direction
- body()->applyTorqueImpulse(math::to_btVector3(axis().up() * current_target_direction * ship_torque_force * torque_scale));
+ body()->applyTorqueImpulse(math::to_btVector3(axis().up() * current_target_direction * torque_force * torque_scale));
// apply pitch
- body()->applyTorqueImpulse(math::to_btVector3(axis().left() * -current_target_pitch * ship_torque_force * torque_scale));
+ body()->applyTorqueImpulse(math::to_btVector3(axis().left() * -current_target_pitch * torque_force * torque_scale));
// apply roll
- body()->applyTorqueImpulse(math::to_btVector3(axis().forward() * -current_target_roll * ship_torque_force * roll_scale * torque_scale));
+ body()->applyTorqueImpulse(math::to_btVector3(axis().forward() * -current_target_roll * torque_force * roll_scale * torque_scale));
// limit speed
entity_speed = (float) entity_body->getLinearVelocity().length();
diff --git a/src/game/base/star.cc b/src/game/base/star.cc
index 21fa4af..6327223 100644
--- a/src/game/base/star.cc
+++ b/src/game/base/star.cc
@@ -14,8 +14,6 @@ namespace game
Star::Star() : core::EntityGlobe()
{
set_flag(core::Entity::ShowOnMap);
- set_flag(core::Entity::Static);
- set_flag(core::Entity::Solid);
set_flag(core::Entity::Bright);
get_color().assign(1.0f, 1.0f);