Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-11-12 19:50:04 +0000
committerStijn Buys <ingar@osirion.org>2010-11-12 19:50:04 +0000
commite6516fb9999ae47a828e032f0908d2f2ae4b2434 (patch)
tree80aaed66e95541d93bd56de6fb8cad997e078856 /src/core
parentb460b3193e54b7364bb75ff26ce6f999887e454b (diff)
enables entity model scaling, Entity::radius() gets precedence over Model::radius(),
corrected bullet motionstate transfer bug in Entity::reset(), minor cleanups
Diffstat (limited to 'src/core')
-rw-r--r--src/core/entity.cc37
-rw-r--r--src/core/gameserver.cc1
2 files changed, 21 insertions, 17 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc
index 9e467fe..fe33d2a 100644
--- a/src/core/entity.cc
+++ b/src/core/entity.cc
@@ -316,9 +316,6 @@ void Entity::set_model(model::Model *model)
// server-side property should not clear modelname
entity_model = model;
if (entity_model) {
-
- //entity_radius = entity_model->radius();
-
entity_modelname.assign(entity_model->name());
}
@@ -394,8 +391,6 @@ void Entity::receive_server_create(std::istream &is)
entity_shape = (Shape) s;
is >> entity_radius;
- if (entity_model)
- entity_radius = model()->radius();
is >> entity_axis[0];
is >> entity_axis[1];
@@ -519,8 +514,9 @@ void Entity::reset()
// construct physics body if necessary
if (!entity_body) {
// create collision shape
- if (model()) {
- entity_collision_shape = new btBoxShape(to_btVector3(model()->box().max()));
+ if (model() && model()->radius()) {
+ const float modelscale = radius() / model()->radius();
+ entity_collision_shape = new btBoxShape(to_btVector3(model()->box().max() * modelscale));
} else {
entity_collision_shape = new btSphereShape(radius());
}
@@ -542,12 +538,13 @@ void Entity::reset()
}
// transfer entity location to motion state
- body()->setWorldTransform(t);
body()->setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f));
- body()->setAngularVelocity(btVector3(0.0f, 0.0f, 0.0f));
+ body()->setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f));
+ body()->setWorldTransform(t);
+ motionstate()->setWorldTransform(t);
- if (zone())
- zone()->physics()->synchronizeSingleMotionState(entity_body);
+ //if (zone())
+ // zone()->physics()->synchronizeSingleMotionState(entity_body);
set_dirty();
}
@@ -936,6 +933,9 @@ void EntityControlable::set_zone(Zone *zone)
void EntityControlable::reset()
{
+ if (!radius())
+ return;
+
// location and orientation
btTransform t;
t.setIdentity();
@@ -945,8 +945,10 @@ void EntityControlable::reset()
// construct physics body if necessary
if (!entity_body) {
// create collision shape
- if (model()) {
- entity_collision_shape = new btBoxShape(to_btVector3(model()->box().max()));
+ // create collision shape
+ if (model() && model()->radius()) {
+ const float modelscale = radius() / model()->radius();
+ entity_collision_shape = new btBoxShape(to_btVector3(model()->box().max() * modelscale));
} else {
entity_collision_shape = new btSphereShape(radius());
}
@@ -973,6 +975,7 @@ void EntityControlable::reset()
body()->setLinearVelocity(btVector3(0.0f, 0.0f, 0.0f));
body()->setLinearVelocity(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));
@@ -982,10 +985,10 @@ void EntityControlable::reset()
body()->setAngularFactor(btVector3(1.0f, 1.0f, 1.0f));
}
- if (zone()) {
- // transfer entity location to motion state
- zone()->physics()->synchronizeSingleMotionState(entity_body);
- }
+ //if (zone()) {
+ // // transfer entity location to motion state
+ // zone()->physics()->synchronizeSingleMotionState(entity_body);
+ //}
set_dirty();
}
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 7d6fc96..e07774d 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -546,6 +546,7 @@ void GameServer::frame(unsigned long timestamp)
Entity *entity = (*it).second;
Zone *zone = entity->zone();
if (zone && entity->flag_is_set(Entity::KeepAlive)) {
+
if (zone->keepalive_run() && zone->keepalive_box().inside(entity->location())) {
entity->set_keepalive(server_timestamp);
}