Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/zone.cc')
-rw-r--r--src/core/zone.cc36
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;
}