From 486922a7c5d29a03d26ed5a921f363b6263e23a9 Mon Sep 17 00:00:00 2001 From: ViktorLjung Date: Tue, 3 Jun 2014 18:54:08 +0200 Subject: [PATCH] Tank tuning --- src/Components/Vehicle.h | 7 +++---- src/Systems/PhysicsSystem.cpp | 18 ++++++++++++++++-- src/Systems/PhysicsSystem.h | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/Components/Vehicle.h b/src/Components/Vehicle.h index 5dfed54..9f6cfac 100644 --- a/src/Components/Vehicle.h +++ b/src/Components/Vehicle.h @@ -10,10 +10,9 @@ namespace Components struct Vehicle : Component { Vehicle() - : MaxTorque(1000.0f), MinRPM(0.0f), OptimalRPM(2000.0f), MaxRPM(3000.0f), MaxSteeringAngle(35), TopSpeed(70.0f), - MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f), UpshiftRPM(2500.0f), DownshiftRPM(500.0f), - gearsRatio0(4.5f), gearsRatio1(2.5f), gearsRatio2(1.0f), gearsRatio3(0.5f){ } - //gearsRatio0(3.0f), gearsRatio1(2.25f), gearsRatio2(1.5f), gearsRatio3(1.0f) + : MaxTorque(1000.0f), MinRPM(200.0f), OptimalRPM(3000.0f), MaxRPM(6000.0f), MaxSteeringAngle(35), TopSpeed(90.0f), + MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f), UpshiftRPM(5500.0f), DownshiftRPM(1000.0f), + gearsRatio0(3.0f), gearsRatio1(2.25f), gearsRatio2(1.5f), gearsRatio3(1.0f){ } float MaxTorque; float MinRPM; float OptimalRPM; diff --git a/src/Systems/PhysicsSystem.cpp b/src/Systems/PhysicsSystem.cpp index d696b78..cba6c39 100644 --- a/src/Systems/PhysicsSystem.cpp +++ b/src/Systems/PhysicsSystem.cpp @@ -237,6 +237,19 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p if(m_Vehicles.find(car) != m_Vehicles.end()) { m_PhysicsWorld->markForWrite(); + + /*auto player = m_World->GetComponent(car); + if(player) + { + if(player->ID == 1) + { + LOG_INFO("Speed: %f, Gear: %i, RPM: %f", m_Vehicles[car]->calcKMPH(), m_Vehicles[car]->m_currentGear, m_Vehicles[car]->m_rpm); + + } + }*/ + + + m_Vehicles[car]->getChassis()->activate(); hkVector4 hardPoint = m_Vehicles[car]->m_suspension->m_wheelParams[wheelComponent->ID].m_hardpointChassisSpace; @@ -409,7 +422,6 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity ) } } - VehicleSetup vehicleSetup; // Create the basic vehicle. m_Vehicles[entity] = new hkpVehicleInstance(m_RigidBodies[entity]); @@ -638,6 +650,8 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity ) std::vector* vertices = new std::vector; std::vector* vertexIndices = new std::vector; auto meshShape = ResourceManager->Load("OBJ", meshShapeComponent->ResourceName); + if(!meshShape) + return; for (auto &vertex : meshShape->Vertices) { @@ -749,7 +763,7 @@ bool Systems::PhysicsSystem::OnTankSteer(const Events::TankSteer &event) } else { - deviceStatus->m_positionX = steeringX; + deviceStatus->m_positionX = event.PositionX; deviceStatus->m_positionY = event.PositionY; } diff --git a/src/Systems/PhysicsSystem.h b/src/Systems/PhysicsSystem.h index a14481b..a1df46a 100644 --- a/src/Systems/PhysicsSystem.h +++ b/src/Systems/PhysicsSystem.h @@ -23,6 +23,7 @@ #include "Components/HingeConstraint.h" #include "Components/WheelPair.h" #include "Components/TowerSteering.h" +#include "Components/Player.h" #include "Events/TankSteer.h" #include "Events/SetVelocity.h" #include "Events/ApplyForce.h"