Skip to content

Commit

Permalink
Traktor: Able to query VehicleComponent about applied engine torque.
Browse files Browse the repository at this point in the history
  • Loading branch information
apistol78 committed Apr 16, 2024
1 parent 2519e24 commit 3de757c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions code/Physics/PhysicsClassFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ void PhysicsClassFactory::createClasses(IRuntimeClassRegistrar* registrar) const
classVehicleComponent->addProperty("steerAngleFiltered", &VehicleComponent::getSteerAngleFiltered);
classVehicleComponent->addProperty("engineThrottle", &VehicleComponent::setEngineThrottle, &VehicleComponent::getEngineThrottle);
classVehicleComponent->addProperty("engineBoost", &VehicleComponent::setEngineBoost, &VehicleComponent::getEngineBoost);
classVehicleComponent->addProperty("engineTorque", &VehicleComponent::getEngineTorque);
classVehicleComponent->addProperty("breaking", &VehicleComponent::setBreaking, &VehicleComponent::getBreaking);
classVehicleComponent->addProperty("wheels", &VehicleComponent::getWheels);
registrar->registerClass(classVehicleComponent);
Expand Down
9 changes: 9 additions & 0 deletions code/Physics/World/Vehicle/VehicleComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ VehicleComponent::VehicleComponent(
, m_steerAngleTarget(0.0f)
, m_engineThrottle(0.0f)
, m_engineBoost(0.0f)
, m_engineTorque(0.0f)
, m_breaking(0.0f)
, m_airBorn(true)
{
Expand Down Expand Up @@ -151,6 +152,11 @@ float VehicleComponent::getEngineBoost() const
return m_engineBoost;
}

float VehicleComponent::getEngineTorque() const
{
return m_engineTorque;
}

void VehicleComponent::setBreaking(float breaking)
{
m_breaking = breaking;
Expand Down Expand Up @@ -477,6 +483,9 @@ void VehicleComponent::updateEngine(Body* body, float /*dT*/)
true
);
}

// Save engine force so user can query momentus force.
m_engineTorque = engineForce;
}

void VehicleComponent::updateWheels(Body* body, float dT)
Expand Down
3 changes: 3 additions & 0 deletions code/Physics/World/Vehicle/VehicleComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class T_DLLCLASS VehicleComponent : public world::IEntityComponent

float getEngineBoost() const;

float getEngineTorque() const;

void setBreaking(float breaking);

float getBreaking() const;
Expand All @@ -96,6 +98,7 @@ class T_DLLCLASS VehicleComponent : public world::IEntityComponent
float m_steerAngleTarget;
float m_engineThrottle;
float m_engineBoost;
float m_engineTorque;
float m_breaking;
bool m_airBorn;

Expand Down

0 comments on commit 3de757c

Please sign in to comment.