diff options
author | Stijn Buys <ingar@osirion.org> | 2010-10-17 17:19:03 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-10-17 17:19:03 +0000 |
commit | d6e4c4e7c2b1e28961f1dfe2f25ef96ced60b21b (patch) | |
tree | 63744dff093a8b23f65d9c68b922b678805647d9 /src/core/zone.cc | |
parent | ea6e6bb769d713ac55114c1940626f13e384ebed (diff) |
core bullet physics support,
initial vstrafe support
Diffstat (limited to 'src/core/zone.cc')
-rw-r--r-- | src/core/zone.cc | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/src/core/zone.cc b/src/core/zone.cc index 3791b93..8a8c056 100644 --- a/src/core/zone.cc +++ b/src/core/zone.cc @@ -116,27 +116,46 @@ void Zone ::clear() } /* ---- class Zone ------------------------------------------------- */ -Zone::Zone(std::string const & label) +Zone::Zone(std::string const & label) : Label(label) { - zone_id = 0; - zone_sky.clear(); + zone_id = 0; zone_defaultview = 0; - set_label(label); + btVector3 worldAabbMin(-10000, -10000, -10000); + btVector3 worldAabbMax(10000, 10000, 10000); + const int maxProxies = 1024; + + zone_bullet_cache = new btAxisSweep3(worldAabbMin, worldAabbMax, maxProxies); + zone_bullet_world = new btDiscreteDynamicsWorld(Physics::dispatcher(), zone_bullet_cache, Physics::solver(), Physics::configuration()); + + // disable gravity + zone_bullet_world->setGravity(btVector3(0.0f, 0.0f, 0.0f)); + } -Zone::Zone(std::istream & is) +Zone::Zone(std::istream & is) : Label() { zone_id = 0; + zone_defaultview = 0; + // client side does not setup a bullet physics environment + zone_bullet_cache = 0; + zone_bullet_world = 0; receive_server_update(is); } Zone::~Zone() { for (Content::iterator it = zone_content.begin(); it != zone_content.end(); it++) { + (*it) = 0; } zone_content.clear(); + + if (zone_bullet_world) + delete zone_bullet_world; + + if (zone_bullet_cache) + delete zone_bullet_cache; } void Zone::print() @@ -153,12 +172,19 @@ void Zone::print() void Zone::add(Entity *entity) { zone_content.push_back(entity); + if (physics() && entity->body()) { + physics()->addRigidBody(entity->body()); + entity->reset(); + } } void Zone::remove(Entity *entity) { for (Content::iterator it = zone_content.begin(); it != zone_content.end(); it++) { if ((*it) == entity) { + if (physics() && entity->body()) { + physics()->removeRigidBody(entity->body()); + } zone_content.erase(it); return; } |