-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhysics.cpp
37 lines (32 loc) · 995 Bytes
/
Physics.cpp
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
/*
Physics.cpp
Adds physics to the Ogre nodes
@author Matthew Clark
@date 09/02/2016
*/
#include "Physics.h"
Physics::Physics() {
//create physics world
initObjects();
}
Physics::~Physics() {
//removes objects to clear RAM
delete dynamicsWorld;
delete solver;
delete collisionConfiguration;
delete dispatcher;
delete overlappingPairCache;
}
void Physics::initObjects() {
// These are just needed to set up a basic world
collisionConfiguration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionConfiguration);
overlappingPairCache = new btDbvtBroadphase();
solver = new btSequentialImpulseConstraintSolver();
dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, overlappingPairCache, solver, collisionConfiguration);
//sets the gravity (should be default -9.8, but I exlicitly set it)
dynamicsWorld->setGravity(btVector3(0, -9.8f, 0));
}
btDiscreteDynamicsWorld* Physics::getDynamicsWorld() {
return dynamicsWorld;
}