fix
This commit is contained in:
@@ -166,8 +166,8 @@ void Systems::PhysicsSystem::Update(double dt)
|
|||||||
m_Accumulator += dt;
|
m_Accumulator += dt;
|
||||||
while (m_Accumulator >= timestep)
|
while (m_Accumulator >= timestep)
|
||||||
{
|
{
|
||||||
//hkpStepResult stepresult = m_PhysicsWorld->stepMultithreaded(m_JobQueue, m_ThreadPool, timestep);
|
m_PhysicsWorld->stepMultithreaded(m_JobQueue, m_ThreadPool, timestep);
|
||||||
m_PhysicsWorld->stepDeltaTime(timestep);
|
//m_PhysicsWorld->stepDeltaTime(timestep);
|
||||||
|
|
||||||
m_Accumulator -= timestep;
|
m_Accumulator -= timestep;
|
||||||
|
|
||||||
@@ -541,7 +541,6 @@ bool Systems::PhysicsSystem::OnTankSteer(const Events::TankSteer &event)
|
|||||||
auto vehicleComponent = m_World->GetComponent<Components::Vehicle>(event.Entity);
|
auto vehicleComponent = m_World->GetComponent<Components::Vehicle>(event.Entity);
|
||||||
if (vehicleComponent && m_Vehicles.find(event.Entity) != m_Vehicles.end() && m_RigidBodies.find(event.Entity) != m_RigidBodies.end())
|
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;
|
hkpVehicleDriverInputAnalogStatus* deviceStatus = (hkpVehicleDriverInputAnalogStatus*)m_Vehicles[event.Entity]->m_deviceStatus;
|
||||||
deviceStatus->m_positionX = event.PositionX;
|
deviceStatus->m_positionX = event.PositionX;
|
||||||
deviceStatus->m_positionY = event.PositionY;
|
deviceStatus->m_positionY = event.PositionY;
|
||||||
@@ -550,7 +549,6 @@ bool Systems::PhysicsSystem::OnTankSteer(const Events::TankSteer &event)
|
|||||||
deviceStatus->m_reverseButtonPressed = true;
|
deviceStatus->m_reverseButtonPressed = true;
|
||||||
}
|
}
|
||||||
deviceStatus->m_handbrakeButtonPressed = event.Handbrake;
|
deviceStatus->m_handbrakeButtonPressed = event.Handbrake;
|
||||||
m_PhysicsWorld->unmarkForWrite();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -561,7 +559,6 @@ bool Systems::PhysicsSystem::OnSetVelocity( const Events::SetVelocity &event )
|
|||||||
m_PhysicsWorld->markForWrite();
|
m_PhysicsWorld->markForWrite();
|
||||||
m_RigidBodies[event.Entity]->setLinearVelocity(GLMVEC3_TO_HKVECTOR4(event.Velocity));
|
m_RigidBodies[event.Entity]->setLinearVelocity(GLMVEC3_TO_HKVECTOR4(event.Velocity));
|
||||||
m_PhysicsWorld->unmarkForWrite();
|
m_PhysicsWorld->unmarkForWrite();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,7 +567,6 @@ bool Systems::PhysicsSystem::OnApplyForce(const Events::ApplyForce &event)
|
|||||||
m_PhysicsWorld->markForWrite();
|
m_PhysicsWorld->markForWrite();
|
||||||
m_RigidBodies[event.Entity]->applyForce(event.DeltaTime, GLMVEC3_TO_HKVECTOR4(event.Force));
|
m_RigidBodies[event.Entity]->applyForce(event.DeltaTime, GLMVEC3_TO_HKVECTOR4(event.Force));
|
||||||
m_PhysicsWorld->unmarkForWrite();
|
m_PhysicsWorld->unmarkForWrite();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,6 +575,5 @@ bool Systems::PhysicsSystem::OnApplyPointImpulse( const Events::ApplyPointImpuls
|
|||||||
m_PhysicsWorld->markForWrite();
|
m_PhysicsWorld->markForWrite();
|
||||||
m_RigidBodies[event.Entity]->applyPointImpulse(GLMVEC3_TO_HKVECTOR4(event.Impulse), GLMVEC3_TO_HKVECTOR4(event.Position));
|
m_RigidBodies[event.Entity]->applyPointImpulse(GLMVEC3_TO_HKVECTOR4(event.Impulse), GLMVEC3_TO_HKVECTOR4(event.Position));
|
||||||
m_PhysicsWorld->unmarkForWrite();
|
m_PhysicsWorld->unmarkForWrite();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ void Systems::TankSteeringSystem::Update(double dt)
|
|||||||
void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
{
|
{
|
||||||
auto tankSteeringComponent = m_World->GetComponent<Components::TankSteering>(entity);
|
auto tankSteeringComponent = m_World->GetComponent<Components::TankSteering>(entity);
|
||||||
|
auto towerSteeringComponent = m_World->GetComponent<Components::TowerSteering>(entity);
|
||||||
|
auto barrelSteeringComponent = m_World->GetComponent<Components::BarrelSteering>(entity);
|
||||||
|
|
||||||
if(tankSteeringComponent)
|
if(tankSteeringComponent)
|
||||||
{
|
{
|
||||||
Events::TankSteer e;
|
Events::TankSteer e;
|
||||||
@@ -33,17 +36,13 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
|||||||
e.Handbrake = m_TankInputController->Handbrake;
|
e.Handbrake = m_TankInputController->Handbrake;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
else if(towerSteeringComponent)
|
||||||
auto towerSteeringComponent = m_World->GetComponent<Components::TowerSteering>(entity);
|
|
||||||
if(towerSteeringComponent)
|
|
||||||
{
|
{
|
||||||
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
|
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
|
||||||
glm::quat orientation = glm::angleAxis(towerSteeringComponent->TurnSpeed * m_TowerInputController->TowerDirection * (float)dt, towerSteeringComponent->Axis);
|
glm::quat orientation = glm::angleAxis(towerSteeringComponent->TurnSpeed * m_TowerInputController->TowerDirection * (float)dt, towerSteeringComponent->Axis);
|
||||||
transformComponent->Orientation *= orientation;
|
transformComponent->Orientation *= orientation;
|
||||||
}
|
}
|
||||||
|
else if(barrelSteeringComponent)
|
||||||
auto barrelSteeringComponent = m_World->GetComponent<Components::BarrelSteering>(entity);
|
|
||||||
if(barrelSteeringComponent)
|
|
||||||
{
|
{
|
||||||
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
|
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
|
||||||
auto absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(entity);
|
auto absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(entity);
|
||||||
|
|||||||
Reference in New Issue
Block a user