Indentation style changed to Allman

Using Artistic Style (http://astyle.sourceforge.net/)
Options:
--style=allman
--indent=tab
--keep-one-line-blocks
--align-pointer=type
--align-reference=name
This commit is contained in:
2014-04-11 20:56:19 +02:00
parent 34bcfbce08
commit 4c081d0e1c
56 changed files with 599 additions and 438 deletions
+43 -23
View File
@@ -10,7 +10,7 @@ Systems::PhysicsSystem::PhysicsSystem(World* world) : System(world)
m_CollisionConfiguration = new btDefaultCollisionConfiguration();
m_Dispatcher = new btCollisionDispatcher(m_CollisionConfiguration);
m_Solver = new btSequentialImpulseConstraintSolver();
m_DynamicsWorld = new btDiscreteDynamicsWorld(m_Dispatcher, m_Broadphase, m_Solver, m_CollisionConfiguration);
m_DynamicsWorld->setGravity(btVector3(0, -9.82f, 0));
@@ -20,14 +20,16 @@ Systems::PhysicsSystem::PhysicsSystem(World* world) : System(world)
void Systems::PhysicsSystem::Update(double dt)
{
// Update entity transform in physics world
for (auto pair : *m_World->GetEntities()) {
for (auto pair : *m_World->GetEntities())
{
EntityID entity = pair.first;
EntityID parent = pair.second;
if (parent != 0)
continue;
if (m_PhysicsData.find(entity) != m_PhysicsData.end()) {
if (m_PhysicsData.find(entity) != m_PhysicsData.end())
{
PhysicsData* physicsData = &m_PhysicsData[entity];
auto transformComponent = m_World->GetComponent<Components::Transform>(entity, "Transform");
@@ -63,7 +65,8 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
if (physicsComponent || sphereShapeComponent || boxShapeComponent || meshShapeComponent || staticMeshShapeComponent)
{
if (m_PhysicsData.find(entity) == m_PhysicsData.end()) {
if (m_PhysicsData.find(entity) == m_PhysicsData.end())
{
SetUpPhysicsState(entity, parent);
}
@@ -84,10 +87,11 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
}
else
{
if (m_PhysicsData.find(entity) != m_PhysicsData.end()) {
if (m_PhysicsData.find(entity) != m_PhysicsData.end())
{
TearDownPhysicsState(entity, parent);
}
}
}
auto ballSocketComponent = m_World->GetComponent<Components::BallSocketConstraint>(entity, "BallSocketConstraint");
auto sliderComponent = m_World->GetComponent<Components::SliderConstraint>(entity, "SliderConstraint");
@@ -145,7 +149,7 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
btVector3 AxisB = btVector3(hingeComponent->AxisB.x, hingeComponent->AxisB.y, hingeComponent->AxisB.z);
btHingeConstraint *hingeConstraint = new btHingeConstraint(*m_PhysicsData[entityA].RigidBody, *m_PhysicsData[entityB].RigidBody, PivotA, PivotB, AxisA, AxisB, true);
btHingeConstraint* hingeConstraint = new btHingeConstraint(*m_PhysicsData[entityA].RigidBody, *m_PhysicsData[entityB].RigidBody, PivotA, PivotB, AxisA, AxisB, true);
hingeConstraint->setLimit(hingeComponent->LowLimit, hingeComponent->HighLimit, hingeComponent->Softness, hingeComponent->BiasFactor, hingeComponent->RelaxationFactor);
@@ -159,7 +163,7 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
void Systems::PhysicsSystem::OnComponentCreated(std::string type, std::shared_ptr<Component> component)
{
}
void Systems::PhysicsSystem::OnComponentRemoved(std::string type, Component* component)
@@ -170,7 +174,8 @@ void Systems::PhysicsSystem::OnComponentRemoved(std::string type, Component* com
void Systems::PhysicsSystem::SetUpPhysicsState(EntityID entity, EntityID parent)
{
auto transformComponent = m_World->GetComponent<Components::Transform>(entity, "Transform");
if (!transformComponent) {
if (!transformComponent)
{
LOG_WARNING("Physics component missing transform component on entity %i", entity);
return;
}
@@ -182,7 +187,8 @@ void Systems::PhysicsSystem::SetUpPhysicsState(EntityID entity, EntityID parent)
auto meshShapeComponent = m_World->GetComponent<Components::MeshShape>(entity, "MeshShape");
auto staticMeshShapeComponent = m_World->GetComponent<Components::StaticMeshShape>(entity, "StaticMeshShape");
if (compoundShapeComponent && (sphereShapeComponent || boxShapeComponent || meshShapeComponent || staticMeshShapeComponent)) {
if (compoundShapeComponent && (sphereShapeComponent || boxShapeComponent || meshShapeComponent || staticMeshShapeComponent))
{
LOG_WARNING("Entity %i has both compound shape and normal shape! Normal shapes must be children to entity with compound shape.", entity);
}
@@ -192,7 +198,8 @@ void Systems::PhysicsSystem::SetUpPhysicsState(EntityID entity, EntityID parent)
auto baseCompoundShape = m_World->GetComponent<Components::CompoundShape>(baseParent, "CompoundShape");*/
// Set-up compound shape
if (compoundShapeComponent) {
if (compoundShapeComponent)
{
btCompoundShape* compoundShape = new btCompoundShape();
physicsData->CollisionShape = compoundShape;
@@ -201,7 +208,8 @@ void Systems::PhysicsSystem::SetUpPhysicsState(EntityID entity, EntityID parent)
physicsData->MotionState = new btDefaultMotionState(transform);
btVector3 inertia;
if (physicsComponent->Mass != 0) {
if (physicsComponent->Mass != 0)
{
physicsData->CollisionShape->calculateLocalInertia(physicsComponent->Mass, inertia);
}
@@ -210,26 +218,34 @@ void Systems::PhysicsSystem::SetUpPhysicsState(EntityID entity, EntityID parent)
m_DynamicsWorld->addRigidBody(physicsData->RigidBody);
}
// Set-up normal shapes
else if (boxShapeComponent) {
else if (boxShapeComponent)
{
physicsData->CollisionShape = new btBoxShape(btVector3(boxShapeComponent->Width, boxShapeComponent->Height, boxShapeComponent->Depth));
} else if (sphereShapeComponent) {
}
else if (sphereShapeComponent)
{
physicsData->CollisionShape = new btSphereShape(sphereShapeComponent->Radius);
} else if (meshShapeComponent) {
}
else if (meshShapeComponent)
{
// TODO: Collision mesh things go here
//new btConvexTriangleMeshShape()
}
if (boxShapeComponent || sphereShapeComponent || meshShapeComponent || staticMeshShapeComponent) {
if (boxShapeComponent || sphereShapeComponent || meshShapeComponent || staticMeshShapeComponent)
{
btTransform transform;
transform.setFromOpenGLMatrix(glm::value_ptr(glm::translate(glm::mat4(), transformComponent->Position) * glm::toMat4(transformComponent->Orientation)));
// If there's a local physics component
if (physicsComponent) {
if (physicsComponent)
{
physicsData->MotionState = new btDefaultMotionState(transform);
btVector3 inertia;
if (physicsComponent->Mass != 0) {
if (physicsComponent->Mass != 0)
{
physicsData->CollisionShape->calculateLocalInertia(physicsComponent->Mass, inertia);
}
@@ -237,16 +253,20 @@ void Systems::PhysicsSystem::SetUpPhysicsState(EntityID entity, EntityID parent)
physicsData->RigidBody = new btRigidBody(rigidBodyCI);
m_DynamicsWorld->addRigidBody(physicsData->RigidBody);
} else {
}
else
{
// Otherwise, find our base parent and attach to compound shape
EntityID baseParent = m_World->GetEntityBaseParent(entity);
auto basePhysicsComponent = m_World->GetComponent<Components::Physics>(baseParent, "Physics");
if (!basePhysicsComponent) {
if (!basePhysicsComponent)
{
LOG_WARNING("Failed to attach orphan collision shape on entity %i: missing physics component on base parent entity %i", entity, baseParent);
return;
}
auto baseCompoundShapeComponent = m_World->GetComponent<Components::CompoundShape>(baseParent, "CompoundShape");
if (!baseCompoundShapeComponent) {
if (!baseCompoundShapeComponent)
{
LOG_WARNING("Failed to attach orphan collision shape on entity %i: missing compound shape on base parent entity %i", entity, baseParent);
return;
}
@@ -267,7 +287,7 @@ void Systems::PhysicsSystem::SetUpPhysicsState(EntityID entity, EntityID parent)
void Systems::PhysicsSystem::TearDownPhysicsState(EntityID entity, EntityID parent)
{
PhysicsData* physicsData = &m_PhysicsData[entity];
delete physicsData->RigidBody;
delete physicsData->MotionState;
delete physicsData->CollisionShape;