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-17 17:19:03 +0000
committerStijn Buys <ingar@osirion.org>2010-10-17 17:19:03 +0000
commitd6e4c4e7c2b1e28961f1dfe2f25ef96ced60b21b (patch)
tree63744dff093a8b23f65d9c68b922b678805647d9 /src/core/physics.cc
parentea6e6bb769d713ac55114c1940626f13e384ebed (diff)
core bullet physics support,
initial vstrafe support
Diffstat (limited to 'src/core/physics.cc')
-rw-r--r--src/core/physics.cc54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/core/physics.cc b/src/core/physics.cc
new file mode 100644
index 0000000..a8577b3
--- /dev/null
+++ b/src/core/physics.cc
@@ -0,0 +1,54 @@
+/*
+ core/physics.cc
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
+*/
+
+#include "core/physics.h"
+#include "core/zone.h"
+
+namespace core {
+
+btDefaultCollisionConfiguration *Physics::physics_configuration;
+btCollisionDispatcher *Physics::physics_dispatcher;
+btSequentialImpulseConstraintSolver *Physics::physics_solver;
+unsigned long Physics::physics_timestamp;
+
+void Physics::init()
+{
+ con_print << "^BInitializing physics engine..." << std::endl;
+
+ physics_configuration = new btDefaultCollisionConfiguration();
+ physics_dispatcher = new btCollisionDispatcher(physics_configuration);
+ physics_solver = new btSequentialImpulseConstraintSolver;
+
+ physics_timestamp = 0;
+}
+
+void Physics::done()
+{
+ con_print << "^Bshutting down physics engine..." << std::endl;
+ delete physics_solver;
+ delete physics_dispatcher;
+ delete physics_configuration;
+
+ physics_configuration = 0;
+ physics_dispatcher = 0;
+ physics_solver = 0;
+}
+
+void Physics::frame(const unsigned long timestamp)
+{
+ if (!timestamp)
+ return;
+
+ const float seconds = (float) (timestamp - physics_timestamp) / 1000.0f;
+
+ for (core::Zone::Registry::iterator it = core::Zone::registry().begin(); it != core::Zone::registry().end(); it++) {
+ (*it).second->physics()->stepSimulation(seconds);
+ }
+
+ physics_timestamp = timestamp;
+}
+
+} // namespace core \ No newline at end of file