-
Notifications
You must be signed in to change notification settings - Fork 1
/
PhysWorld.cpp
40 lines (30 loc) · 1.01 KB
/
PhysWorld.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
38
#include "PhysWorld.h"
#include "cuboid_server.h"
//constructor/destructor
PhysWorld::PhysWorld(CuboidServer* ParentEngine) :
root(ParentEngine)
{
initBullet();
};
PhysWorld::~PhysWorld(){
delete physCollisionConfiguration;
delete physCollisionDispatcher;
delete physPairCache;
delete physConstraintSolver;
delete physDynamicsWorld;
};
//physical control
void PhysWorld::setGravityMagnitude(float Gravity) {
physDynamicsWorld->setGravity(btVector3(0, -Gravity, 0));
}
void PhysWorld::initBullet(){
physCollisionConfiguration = new btDefaultCollisionConfiguration;
physCollisionDispatcher = new btCollisionDispatcher(physCollisionConfiguration);
physPairCache = new btDbvtBroadphase;
physConstraintSolver = new btSequentialImpulseConstraintSolver;
physDynamicsWorld = new btDiscreteDynamicsWorld(physCollisionDispatcher, physPairCache, physConstraintSolver, physCollisionConfiguration);
setGravityMagnitude(9.8f);
}
void PhysWorld::doTick() {
physDynamicsWorld->stepSimulation(1); //TODO wtf is timeStep?
}