From 14462ac8dfc05f95c11bdaca69193fe248ef0c1b Mon Sep 17 00:00:00 2001 From: Jasper Date: Fri, 23 Jan 2015 12:05:43 +0100 Subject: [PATCH] readding button -> box --- physics.cc | 10 ++++++---- physics.hh | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/physics.cc b/physics.cc index 394cab7..e990551 100644 --- a/physics.cc +++ b/physics.cc @@ -247,21 +247,23 @@ void Physics::addTriangleMeshBody(Entity entity, std::string path, float mass, f throw std::invalid_argument( "Bodies out of Sync" ); } -void Physics::addButton(float radius, float height, Entity entity, float mass, float dampningL, float dampningA, unsigned indice) +void Physics::addButton(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice) { if(bodies.size() == indice) throw std::invalid_argument( "Bodies out of Sync" ); - btCylinderShape* shape = new btCylinderShape(btVector3(height/2, radius,radius)); + + btBoxShape* box = new btBoxShape(btVector3(width/2,height/2,length/2)); + btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z))); btVector3 inertia(0,0,0); if(mass != 0.0) { - shape->calculateLocalInertia((btScalar)mass,inertia); + box->calculateLocalInertia((btScalar)mass,inertia); } - btRigidBody::btRigidBodyConstructionInfo info(mass,motion,shape,inertia); + btRigidBody::btRigidBodyConstructionInfo info(mass,motion,box,inertia); btRigidBody* body = new btRigidBody(info); diff --git a/physics.hh b/physics.hh index 54b1e59..3c87fd7 100644 --- a/physics.hh +++ b/physics.hh @@ -66,7 +66,7 @@ class Physics { void addBox(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice); //this is used to ensuer that the system is synchronized void addPositionConstraint(int bodyIndice, float strength, glm::vec3 position); void removePositionConstraint(int bodyIndice); - void addButton(float radius, float height, Entity entity, float mass, float dampningL, float dampningA, unsigned indice); + void addButton(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice); glm::vec3 getCameraToPlayer(); struct positionConstraint{btRigidBody* body; float strength; btVector3 position;};