Fixed non rotating objects
This commit is contained in:
parent
9049458ad5
commit
98718b517e
26
physics.cc
26
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)));
|
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);
|
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);
|
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);
|
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)
|
if(bodies.size() != indice)
|
||||||
throw std::invalid_argument( "Bodies out of Sync" );
|
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)));
|
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);
|
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);
|
box->calculateLocalInertia((btScalar)mass,inertia);
|
||||||
}
|
}
|
||||||
@ -251,6 +255,11 @@ void Physics::addButton(float width, float height, float length, Entity entity,
|
|||||||
|
|
||||||
bodies.push_back(body);
|
bodies.push_back(body);
|
||||||
|
|
||||||
|
if(!rotate)
|
||||||
|
{
|
||||||
|
body->setAngularFactor(btVector3(0,0,0));
|
||||||
|
}
|
||||||
|
|
||||||
if(bodies.size() != indice)
|
if(bodies.size() != indice)
|
||||||
throw std::invalid_argument( "Bodies out of Sync" );
|
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)));
|
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);
|
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);
|
box->calculateLocalInertia((btScalar)mass,inertia);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
btRigidBody::btRigidBodyConstructionInfo info(mass,motion,box,inertia);
|
btRigidBody::btRigidBodyConstructionInfo info(mass,motion,box,inertia);
|
||||||
|
|
||||||
btRigidBody* body = new btRigidBody(info);
|
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);
|
bodies.push_back(body);
|
||||||
|
|
||||||
|
if(!rotate)
|
||||||
|
{
|
||||||
|
body->setAngularFactor(btVector3(0,0,0));
|
||||||
|
}
|
||||||
|
|
||||||
if(bodies.size() != indice)
|
if(bodies.size() != indice)
|
||||||
throw std::invalid_argument( "Bodies out of Sync" );
|
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);
|
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);
|
body->setSleepingThresholds(0,0);
|
||||||
|
|
||||||
if(bodies.size() != indice)
|
if(bodies.size() != indice)
|
||||||
|
Loading…
Reference in New Issue
Block a user