blob: 4dadf07c3c6755e87d9e34dbe6210c0cbd780ecd (
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
|
/*
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
|