blob: 9ffe13c2adc07686370d5238c1229ad2917747ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*
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 "model/collisionmesh.h"
#include "core/physics.h"
#include "core/zone.h"
#include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h"
namespace core {
btDefaultCollisionConfiguration *Physics::physics_configuration = 0;
btCollisionDispatcher *Physics::physics_dispatcher = 0;
btSequentialImpulseConstraintSolver *Physics::physics_solver = 0;
void Physics::init()
{
con_print << "^BInitializing physics engine..." << std::endl;
model::CollisionModel::init();
physics_configuration = new btDefaultCollisionConfiguration();
physics_dispatcher = new btCollisionDispatcher(physics_configuration);
btGImpactCollisionAlgorithm::registerAlgorithm(physics_dispatcher);
physics_solver = new btSequentialImpulseConstraintSolver;
}
void Physics::done()
{
con_print << "^BShutting down physics engine..." << std::endl;
model::CollisionModel::shutdown();
delete physics_solver;
delete physics_dispatcher;
delete physics_configuration;
physics_configuration = 0;
physics_dispatcher = 0;
physics_solver = 0;
}
void Physics::frame(const unsigned long elapsed)
{
const float seconds = (float) elapsed / 1000.0f;
for (core::Zone::Registry::iterator it = core::Zone::registry().begin(); it != core::Zone::registry().end(); it++) {
(*it).second->physics()->stepSimulation(seconds, 8);
}
}
} // namespace core
|