diff --git a/physics.cc b/physics.cc index 0f5cd42..7050a08 100644 --- a/physics.cc +++ b/physics.cc @@ -204,7 +204,7 @@ void Physics::addTriangleMeshBody(Entity entity, std::string path, float mass, f btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(glmQuat.x,glmQuat.y,glmQuat.z,glmQuat.w),btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z))); btVector3 inertia(0,0,0); - if(mass != 0.0 && rotate) //&& rotate lets certain objects get inertia (0,0,0) (not rotateable) + if(mass != 0.0) { shape->calculateLocalInertia((btScalar)mass,inertia); } @@ -219,6 +219,10 @@ void Physics::addTriangleMeshBody(Entity entity, std::string path, float mass, f world->addRigidBody(body,COL_OBJECTS, objectsPhysicsCollision); + if(!rotate)//rotate lets certain objects get inertia (0,0,0) (not rotateable) + { + body->setAngularFactor(btVector3(0,0,0)); + } if(bodies.size() != indice) throw std::invalid_argument( "Bodies out of Sync" ); @@ -237,7 +241,7 @@ void Physics::addButton(float width, float height, float length, Entity entity, btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(glmQuat.x,glmQuat.y,glmQuat.z,glmQuat.w),btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z))); btVector3 inertia(0,0,0); - if(mass != 0.0 && rotate) //&& rotate lets certain objects get inertia (0,0,0) (not rotateable) + if(mass != 0.0) //&& rotate lets certain objects get inertia (0,0,0) (not rotateable) { box->calculateLocalInertia((btScalar)mass,inertia); } @@ -251,6 +255,11 @@ void Physics::addButton(float width, float height, float length, Entity entity, bodies.push_back(body); + if(!rotate) + { + body->setAngularFactor(btVector3(0,0,0)); + } + if(bodies.size() != indice) throw std::invalid_argument( "Bodies out of Sync" ); } @@ -266,11 +275,12 @@ void Physics::addBox(float width, float height, float length, Entity entity, flo btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(glmQuat.x,glmQuat.y,glmQuat.z,glmQuat.w),btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z))); btVector3 inertia(0,0,0); - if(mass != 0.0 && rotate) //&& rotate lets certain objects get inertia (0,0,0) (not rotateable) + if(mass != 0.0) //&& rotate lets certain objects get inertia (0,0,0) (not rotateable) { box->calculateLocalInertia((btScalar)mass,inertia); } + btRigidBody::btRigidBodyConstructionInfo info(mass,motion,box,inertia); btRigidBody* body = new btRigidBody(info); @@ -281,6 +291,11 @@ void Physics::addBox(float width, float height, float length, Entity entity, flo bodies.push_back(body); + if(!rotate) + { + body->setAngularFactor(btVector3(0,0,0)); + } + if(bodies.size() != indice) throw std::invalid_argument( "Bodies out of Sync" ); } @@ -311,6 +326,11 @@ void Physics::addSphere(float rad, Entity entity, float mass, float dampningL, f bodies.push_back(body); + if(!rotate)//rotate lets certain objects get inertia (0,0,0) (not rotateable) + { + body->setAngularFactor(btVector3(0,0,0)); + } + body->setSleepingThresholds(0,0); if(bodies.size() != indice)