From ec74d700be55565beac8aa27dca5e96dc2b42d10 Mon Sep 17 00:00:00 2001 From: ViktorLjung Date: Mon, 19 May 2014 21:57:13 +0200 Subject: [PATCH] fix --- src/Systems/PhysicsSystem.cpp | 9 ++------- src/Systems/TankSteeringSystem.cpp | 11 +++++------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/Systems/PhysicsSystem.cpp b/src/Systems/PhysicsSystem.cpp index f4de197..03aade8 100644 --- a/src/Systems/PhysicsSystem.cpp +++ b/src/Systems/PhysicsSystem.cpp @@ -166,8 +166,8 @@ void Systems::PhysicsSystem::Update(double dt) m_Accumulator += dt; while (m_Accumulator >= timestep) { - //hkpStepResult stepresult = m_PhysicsWorld->stepMultithreaded(m_JobQueue, m_ThreadPool, timestep); - m_PhysicsWorld->stepDeltaTime(timestep); + m_PhysicsWorld->stepMultithreaded(m_JobQueue, m_ThreadPool, timestep); + //m_PhysicsWorld->stepDeltaTime(timestep); m_Accumulator -= timestep; @@ -541,7 +541,6 @@ bool Systems::PhysicsSystem::OnTankSteer(const Events::TankSteer &event) auto vehicleComponent = m_World->GetComponent(event.Entity); if (vehicleComponent && m_Vehicles.find(event.Entity) != m_Vehicles.end() && m_RigidBodies.find(event.Entity) != m_RigidBodies.end()) { - m_PhysicsWorld->markForWrite(); hkpVehicleDriverInputAnalogStatus* deviceStatus = (hkpVehicleDriverInputAnalogStatus*)m_Vehicles[event.Entity]->m_deviceStatus; deviceStatus->m_positionX = event.PositionX; deviceStatus->m_positionY = event.PositionY; @@ -550,7 +549,6 @@ bool Systems::PhysicsSystem::OnTankSteer(const Events::TankSteer &event) deviceStatus->m_reverseButtonPressed = true; } deviceStatus->m_handbrakeButtonPressed = event.Handbrake; - m_PhysicsWorld->unmarkForWrite(); } return true; @@ -561,7 +559,6 @@ bool Systems::PhysicsSystem::OnSetVelocity( const Events::SetVelocity &event ) m_PhysicsWorld->markForWrite(); m_RigidBodies[event.Entity]->setLinearVelocity(GLMVEC3_TO_HKVECTOR4(event.Velocity)); m_PhysicsWorld->unmarkForWrite(); - return true; } @@ -570,7 +567,6 @@ bool Systems::PhysicsSystem::OnApplyForce(const Events::ApplyForce &event) m_PhysicsWorld->markForWrite(); m_RigidBodies[event.Entity]->applyForce(event.DeltaTime, GLMVEC3_TO_HKVECTOR4(event.Force)); m_PhysicsWorld->unmarkForWrite(); - return true; } @@ -579,6 +575,5 @@ bool Systems::PhysicsSystem::OnApplyPointImpulse( const Events::ApplyPointImpuls m_PhysicsWorld->markForWrite(); m_RigidBodies[event.Entity]->applyPointImpulse(GLMVEC3_TO_HKVECTOR4(event.Impulse), GLMVEC3_TO_HKVECTOR4(event.Position)); m_PhysicsWorld->unmarkForWrite(); - return true; } diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index 99cd4bd..11c48fe 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -24,6 +24,9 @@ void Systems::TankSteeringSystem::Update(double dt) void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, EntityID parent) { auto tankSteeringComponent = m_World->GetComponent(entity); + auto towerSteeringComponent = m_World->GetComponent(entity); + auto barrelSteeringComponent = m_World->GetComponent(entity); + if(tankSteeringComponent) { Events::TankSteer e; @@ -33,17 +36,13 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit e.Handbrake = m_TankInputController->Handbrake; EventBroker->Publish(e); } - - auto towerSteeringComponent = m_World->GetComponent(entity); - if(towerSteeringComponent) + else if(towerSteeringComponent) { auto transformComponent = m_World->GetComponent(entity); glm::quat orientation = glm::angleAxis(towerSteeringComponent->TurnSpeed * m_TowerInputController->TowerDirection * (float)dt, towerSteeringComponent->Axis); transformComponent->Orientation *= orientation; } - - auto barrelSteeringComponent = m_World->GetComponent(entity); - if(barrelSteeringComponent) + else if(barrelSteeringComponent) { auto transformComponent = m_World->GetComponent(entity); auto absoluteTransform = m_World->GetSystem()->AbsoluteTransform(entity);