From a7a75bfaad69f0809f4b3a7b195c5c22e505a7f9 Mon Sep 17 00:00:00 2001 From: Jasper Date: Fri, 21 Nov 2014 12:56:30 +0100 Subject: [PATCH] Modified adders in physics to no longer accept float x,y,z but entity/object instead. --- level.cc | 2 +- physics.cc | 10 +++++----- physics.hh | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/level.cc b/level.cc index 22d8161..82bd5b6 100644 --- a/level.cc +++ b/level.cc @@ -29,7 +29,7 @@ void Level::load(ACGL::OpenGL::SharedShaderProgram shader) { Object object = Object(model, material, glm::vec3(0.0f, 10.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), shader); //add player to phy - this->physics.addPlayer(1.25f,0.0f,10.0f,0.0f,1.0f,0); + this->physics.addPlayer(1.25f,object,1.0f,0); objects.push_back(object); Model skyboxModel = Model("skybox.obj", skyboxSize); diff --git a/physics.cc b/physics.cc index 5805d4a..74429e9 100644 --- a/physics.cc +++ b/physics.cc @@ -75,7 +75,7 @@ void Physics::addStaticGroundPlane() world->addRigidBody(staticGroundBody); } -void Physics::addPlayer(float rad, float x, float y, float z, float mass, unsigned indice) +void Physics::addPlayer(float rad, Entity entity, float mass, unsigned indice) { if(bodies.size() != indice) throw std::invalid_argument( "Bodies out of Sync" ); @@ -87,7 +87,7 @@ void Physics::addPlayer(float rad, float x, float y, float z, float mass, unsign sphere->calculateLocalInertia((btScalar)mass,inertia); } - btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(x,y,z))); + btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z))); btRigidBody::btRigidBodyConstructionInfo info(mass,motion,sphere,inertia); @@ -138,7 +138,7 @@ void Physics::addBox(float width, float height, float length, Entity entity, flo throw std::invalid_argument( "Bodies out of Sync" ); } -void Physics::addSphere(float rad, float x, float y, float z, float mass, unsigned indice) +void Physics::addSphere(float rad, Entity entity, float mass, unsigned indice) { if(bodies.size() != indice) throw std::invalid_argument( "Bodies out of Sync" ); @@ -150,8 +150,8 @@ void Physics::addSphere(float rad, float x, float y, float z, float mass, unsign sphere->calculateLocalInertia((btScalar)mass,inertia); } - btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(x,y,z))); - + btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z))); + btRigidBody::btRigidBodyConstructionInfo info(mass,motion,sphere,inertia); //info. diff --git a/physics.hh b/physics.hh index efb0c31..fa69442 100644 --- a/physics.hh +++ b/physics.hh @@ -48,8 +48,8 @@ class Physics { void rollForward(glm::vec3 camPos); void addStaticGroundPlane(); void addTerrain(int width, int length, float** heightData); - void addPlayer(float rad, float x, float y, float z, float mass, unsigned indice); - void addSphere(float rad, float x, float y, float z, float mass, unsigned indice); + void addPlayer(float rad, Entity entity, float mass, unsigned indice); + void addSphere(float rad, Entity entity, float mass, unsigned indice); void addBox(float width, float height, float length, Entity entity, float mass, unsigned indice); private: