Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-10-18 23:41:41 +0000
committerStijn Buys <ingar@osirion.org>2010-10-18 23:41:41 +0000
commit7a373c3f1fb8ea9dbef7690154bbe332fc386eca (patch)
treee56652c9b6197017d7eb8e86e5cd431bf9861d57 /src/core/entity.cc
parent4c5b00221c9405c5af06143974fbc6296ebe46b5 (diff)
bullet ActionInterface for controlable entities, KeepAlive flag and g_keepalive
Diffstat (limited to 'src/core/entity.cc')
-rw-r--r--src/core/entity.cc92
1 files changed, 63 insertions, 29 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc
index a1db040..1438466 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -520,7 +520,7 @@ void Entity::reset()
entity_body_info = new btRigidBody::btRigidBodyConstructionInfo(entity_mass, entity_motionstate, entity_collision_shape, inertia);
entity_body = new btRigidBody(*entity_body_info);
- //entity_body->setActivationState(ISLAND_SLEEPING);
+ entity_body->setActivationState(ISLAND_SLEEPING);
if (zone())
zone()->physics()->addRigidBody(entity_body);
@@ -540,12 +540,16 @@ EntityDynamic::EntityDynamic() : Entity()
{
entity_state = Normal;
entity_timer = 0;
+ entity_keepalive_time = 0.0f;
+ entity_keepalive_timeout = 0.0f;
}
EntityDynamic::EntityDynamic(std::istream & is) : Entity(is)
{
entity_state = Normal;
entity_timer = 0;
+ entity_keepalive_time = 0.0f;
+ entity_keepalive_timeout = 0.0f;
}
EntityDynamic::~EntityDynamic()
@@ -560,6 +564,16 @@ void EntityDynamic::set_state(int state)
}
}
+void EntityDynamic::set_keepalive_time(float time)
+{
+ entity_keepalive_time = time;
+}
+
+void EntityDynamic::set_keepalive_timeout(float timeout)
+{
+ entity_keepalive_timeout = timeout;
+}
+
void EntityDynamic::reset()
{
Entity::reset();
@@ -577,7 +591,6 @@ void EntityDynamic::frame(float seconds)
return;
// transfer bullet state to entity state
- // FIXME disable physics when docked
if (entity_body) {
// this makes sure an update is sent if speed goes to 0 in the next step
if (entity_speed > 0) {
@@ -672,6 +685,27 @@ void EntityDynamic::receive_server_update(std::istream &is)
}
}
+/*----- EntityControlable::ActionInterface ------------------------- */
+
+EntityControlable::ActionInterface::ActionInterface(EntityControlable *entity)
+{
+ actioninterface_entity = entity;
+}
+
+EntityControlable::ActionInterface::~ActionInterface()
+{
+ actioninterface_entity = 0;
+}
+
+void EntityControlable::ActionInterface::updateAction(btCollisionWorld* collisionWorld, btScalar deltaTimeStep)
+{
+ actioninterface_entity->action(deltaTimeStep);
+}
+
+void EntityControlable::ActionInterface::debugDraw(btIDebugDraw* debugDrawer)
+{
+}
+
/*----- EntityControlable ------------------------------------------ */
EntityControlable::EntityControlable() : EntityDynamic()
@@ -688,7 +722,7 @@ EntityControlable::EntityControlable() : EntityDynamic()
entity_owner = 0;
- entity_vehicle = 0;
+ entity_actioninterface = 0;
}
EntityControlable::EntityControlable(std::istream & is) :
@@ -706,7 +740,7 @@ EntityControlable::EntityControlable(std::istream & is) :
entity_owner = 0;
- entity_vehicle = 0;
+ entity_actioninterface = 0;
}
@@ -800,14 +834,6 @@ void EntityControlable::receive_server_update(std::istream &is)
entity_movement /= 100.0f;
}
-void EntityControlable::frame(float seconds)
-{
- //entity_direction = target_direction;
- //entity_thrust = target_thrust;
- //entity_dirty = true;
- EntityDynamic::frame(seconds);
-}
-
void EntityControlable::set_thrust(float thrust)
{
if ((flags() & Static) == Static)
@@ -892,11 +918,9 @@ void EntityControlable::set_zone(Zone *zone)
if (entity_zone) {
entity_zone->remove(this);
- if (vehicle() && entity_zone->physics()) {
- entity_zone->physics()->removeAction(entity_vehicle);
+ if (body() && entity_zone->physics()) {
+ entity_zone->physics()->removeAction(entity_actioninterface);
entity_zone->physics()->removeRigidBody(body());
- delete entity_vehicle;
- entity_vehicle = 0;
}
}
@@ -909,10 +933,9 @@ void EntityControlable::set_zone(Zone *zone)
if (entity_zone) {
entity_zone->add(this);
- if (body() && entity_zone->physics()) {
- entity_vehicle = new btRaycastVehicle(entity_vehicletuning, body(), entity_zone->raycaster());
+ if (body() && entity_zone->physics()) {
entity_zone->physics()->addRigidBody(body());
- entity_zone->physics()->addAction(entity_vehicle);
+ entity_zone->physics()->addAction(entity_actioninterface);
reset();
}
}
@@ -945,20 +968,19 @@ void EntityControlable::reset()
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->setWorldTransform(t);
- if (zone()) {
- if (!entity_vehicle) {
- entity_vehicle = new btRaycastVehicle(entity_vehicletuning, body(), entity_zone->raycaster());
+
+ entity_actioninterface = new ActionInterface(this);
+
+ if (zone()) {
entity_zone->physics()->addRigidBody(body());
- entity_zone->physics()->addAction(entity_vehicle);
- }
+ entity_zone->physics()->addAction(entity_actioninterface);
- // transfer entity location to motion state
- zone()->physics()->synchronizeSingleMotionState(entity_body);
+ // 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);
} else {
@@ -968,6 +990,18 @@ void EntityControlable::reset()
set_dirty();
}
+// bullet physics frame (runs at bullet framerate)
+void EntityControlable::action(btScalar seconds)
+{
+}
+
+// osirion game frame (runs at osirion server framerate)
+void EntityControlable::frame(float seconds)
+{
+ EntityDynamic::frame(seconds);
+}
+
+
/*----- EntityGlobe ------------------------------------------------ */
EntityGlobe::EntityGlobe() : Entity()