Add differential settings to WheeledVehicle
This commit is contained in:
@@ -88,6 +88,16 @@ void WheeledVehicle::SetEngine(const EngineSettings& value)
|
||||
_engine = value;
|
||||
}
|
||||
|
||||
WheeledVehicle::DifferentialSettings WheeledVehicle::GetDifferential() const
|
||||
{
|
||||
return _differential;
|
||||
}
|
||||
|
||||
void WheeledVehicle::SetDifferential(const DifferentialSettings& value)
|
||||
{
|
||||
_differential = value;
|
||||
}
|
||||
|
||||
WheeledVehicle::GearboxSettings WheeledVehicle::GetGearbox() const
|
||||
{
|
||||
return _gearbox;
|
||||
@@ -399,8 +409,13 @@ void WheeledVehicle::Setup()
|
||||
|
||||
// Differential
|
||||
PxVehicleDifferential4WData diff;
|
||||
// TODO: expose Differential options
|
||||
diff.mType = PxVehicleDifferential4WData::eDIFF_TYPE_LS_4WD;
|
||||
diff.mType = (PxVehicleDifferential4WData::Enum)_differential.Type;
|
||||
diff.mFrontRearSplit = _differential.FrontRearSplit;
|
||||
diff.mFrontLeftRightSplit = _differential.FrontLeftRightSplit;
|
||||
diff.mRearLeftRightSplit = _differential.RearLeftRightSplit;
|
||||
diff.mCentreBias = _differential.CentreBias;
|
||||
diff.mFrontBias = _differential.FrontBias;
|
||||
diff.mRearBias = _differential.RearBias;
|
||||
driveSimData.setDiffData(diff);
|
||||
|
||||
// Engine
|
||||
@@ -450,7 +465,6 @@ void WheeledVehicle::Setup()
|
||||
|
||||
// Differential
|
||||
PxVehicleDifferentialNWData diff;
|
||||
// TODO: expose Differential options
|
||||
for (int32 i = 0; i < wheels.Count(); i++)
|
||||
diff.setDrivenWheel(i, true);
|
||||
driveSimData.setDiffData(diff);
|
||||
@@ -554,6 +568,7 @@ void WheeledVehicle::Serialize(SerializeStream& stream, const void* otherObj)
|
||||
SERIALIZE_MEMBER(Wheels, _wheels);
|
||||
SERIALIZE(UseReverseAsBrake);
|
||||
SERIALIZE_MEMBER(Engine, _engine);
|
||||
SERIALIZE_MEMBER(Differential, _differential);
|
||||
SERIALIZE_MEMBER(Gearbox, _gearbox);
|
||||
}
|
||||
|
||||
@@ -565,6 +580,7 @@ void WheeledVehicle::Deserialize(DeserializeStream& stream, ISerializeModifier*
|
||||
DESERIALIZE_MEMBER(Wheels, _wheels);
|
||||
DESERIALIZE(UseReverseAsBrake);
|
||||
DESERIALIZE_MEMBER(Engine, _engine);
|
||||
DESERIALIZE_MEMBER(Differential, _differential);
|
||||
DESERIALIZE_MEMBER(Gearbox, _gearbox);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,69 @@ public:
|
||||
API_FIELD() float MaxRotationSpeed = 6000.0f;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Vehicle differential types.
|
||||
/// </summary>
|
||||
API_ENUM() enum class DifferentialTypes
|
||||
{
|
||||
// Limited slip differential for car with 4 driven wheels.
|
||||
LimitedSlip4W,
|
||||
// Limited slip differential for car with front-wheel drive.
|
||||
LimitedSlipFrontDrive,
|
||||
// Limited slip differential for car with rear-wheel drive.
|
||||
LimitedSlipRearDrive,
|
||||
// Open differential for car with 4 driven wheels.
|
||||
Open4W,
|
||||
// Open differential for car with front-wheel drive.
|
||||
OpenFrontDrive,
|
||||
// Open differential for car with rear-wheel drive.
|
||||
OpenRearDrive,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Vehicle differential settings.
|
||||
/// </summary>
|
||||
API_STRUCT() struct DifferentialSettings : ISerializable
|
||||
{
|
||||
DECLARE_SCRIPTING_TYPE_MINIMAL(DifferentialSettings);
|
||||
API_AUTO_SERIALIZATION();
|
||||
|
||||
/// <summary>
|
||||
/// Type of differential.
|
||||
/// </summary>
|
||||
API_FIELD() DifferentialTypes Type = DifferentialTypes::LimitedSlip4W;
|
||||
|
||||
/// <summary>
|
||||
/// Ratio of torque split between front and rear (higher then 0.5 means more to front, smaller than 0.5 means more to rear). Only applied to LimitedSlip4W and Open4W.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="LimitAttribute(0, 1)") float FrontRearSplit = 0.45f;
|
||||
|
||||
/// <summary>
|
||||
/// Ratio of torque split between front-left and front-right (higher then 0.5 means more to front-left, smaller than 0.5 means more to front-right). Only applied to LimitedSlip4W and Open4W and LimitedSlipFrontDrive.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="LimitAttribute(0, 1)") float FrontLeftRightSplit = 0.5f;
|
||||
|
||||
/// <summary>
|
||||
/// Ratio of torque split between rear-left and rear-right (higher then 0.5 means more to rear-left, smaller than 0.5 means more to rear-right). Only applied to LimitedSlip4W and Open4W and LimitedSlipRearDrive.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="LimitAttribute(0, 1)") float RearLeftRightSplit = 0.5f;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum allowed ratio of average front wheel rotation speed and rear wheel rotation speeds. The differential will divert more torque to the slower wheels when the bias is exceeded. Only applied to LimitedSlip4W.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="LimitAttribute(1)") float CentreBias = 1.3f;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum allowed ratio of front-left and front-right wheel rotation speeds. The differential will divert more torque to the slower wheel when the bias is exceeded. Only applied to LimitedSlip4W and LimitedSlipFrontDrive.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="LimitAttribute(1)") float FrontBias = 1.3f;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum allowed ratio of rear-left and rear-right wheel rotation speeds. The differential will divert more torque to the slower wheel when the bias is exceeded. Only applied to LimitedSlip4W and LimitedSlipRearDrive.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="LimitAttribute(1)") float RearBias = 1.3f;
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Vehicle wheel types.
|
||||
/// </summary>
|
||||
@@ -172,8 +235,9 @@ private:
|
||||
Array<WheelData, FixedAllocation<20>> _wheelsData;
|
||||
float _throttle = 0.0f, _steering = 0.0f, _brake = 0.0f, _handBrake = 0.0f;
|
||||
Array<Wheel> _wheels;
|
||||
GearboxSettings _gearbox;
|
||||
EngineSettings _engine;
|
||||
DifferentialSettings _differential;
|
||||
GearboxSettings _gearbox;
|
||||
|
||||
public:
|
||||
|
||||
@@ -213,6 +277,16 @@ public:
|
||||
/// </summary>
|
||||
API_PROPERTY() void SetEngine(const EngineSettings& value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vehicle differential settings.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(4), EditorDisplay(\"Vehicle\")") DifferentialSettings GetDifferential() const;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the vehicle differential settings.
|
||||
/// </summary>
|
||||
API_PROPERTY() void SetDifferential(const DifferentialSettings& value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vehicle gearbox settings.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user