-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSPhysicsGhostComponent.h
More file actions
41 lines (31 loc) · 1.1 KB
/
SPhysicsGhostComponent.h
File metadata and controls
41 lines (31 loc) · 1.1 KB
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
#ifndef SPHYSICSGHOSTCOMPONENT_H_INCLUDED
#define SPHYSICSGHOSTCOMPONENT_H_INCLUDED
#include <btBulletDynamicsCommon.h>
#include "BulletCollision/CollisionDispatch/btGhostObject.h"
#include <entityx.h>
using namespace entityx;
struct PhysicsGhostComponent : Component<PhysicsGhostComponent>
{
btGhostObject *ghost;
btCollisionShape *ghostshape;
btVector3 position;
PhysicsGhostComponent(btCollisionShape *shape, btVector3 position) : ghostshape(shape), position(position)
{
ghost = new btGhostObject();
ghost->setCollisionShape(ghostshape);
btTransform trans;
trans.setIdentity();
trans.setOrigin(position);
ghost->setWorldTransform(trans);
ghost->setCollisionFlags( ghost->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
//ghost->setActivationState(DISABLE_DEACTIVATION);
}
void setPosition(btVector3 const &btvector )
{
btTransform trans;
trans.setIdentity();
trans.setOrigin(btvector);
ghost->setWorldTransform(trans);
}
};
#endif // SPHYSICSGHOSTCOMPONENT_H_INCLUDED