0.2.0-dev Download ZIP
39 lines ·2.1 KB Raw
| 1 | // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics) |
| 2 | // SPDX-FileCopyrightText: 2021 Jorrit Rouwe |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | |
| 5 | #pragma once |
| 6 | |
| 7 | #include <Jolt/ObjectStream/SerializableObject.h> |
| 8 | #include <Jolt/Core/StreamIn.h> |
| 9 | #include <Jolt/Core/StreamOut.h> |
| 10 | |
| 11 | JPH_NAMESPACE_BEGIN |
| 12 | |
| 13 | class JPH_EXPORT VehicleDifferentialSettings |
| 14 | { |
| 15 | JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(JPH_EXPORT, VehicleDifferentialSettings) |
| 16 | |
| 17 | public: |
| 18 | /// Saves the contents in binary form to inStream. |
| 19 | void SaveBinaryState(StreamOut &inStream) const; |
| 20 | |
| 21 | /// Restores the contents in binary form to inStream. |
| 22 | void RestoreBinaryState(StreamIn &inStream); |
| 23 | |
| 24 | /// Calculate the torque ratio between left and right wheel |
| 25 | /// @param inLeftAngularVelocity Angular velocity of left wheel (rad / s) |
| 26 | /// @param inRightAngularVelocity Angular velocity of right wheel (rad / s) |
| 27 | /// @param outLeftTorqueFraction Fraction of torque that should go to the left wheel |
| 28 | /// @param outRightTorqueFraction Fraction of torque that should go to the right wheel |
| 29 | void CalculateTorqueRatio(float inLeftAngularVelocity, float inRightAngularVelocity, float &outLeftTorqueFraction, float &outRightTorqueFraction) const; |
| 30 | |
| 31 | int mLeftWheel = -1; ///< Index (in mWheels) that represents the left wheel of this differential (can be -1 to indicate no wheel) |
| 32 | int mRightWheel = -1; ///< Index (in mWheels) that represents the right wheel of this differential (can be -1 to indicate no wheel) |
| 33 | float mDifferentialRatio = 3.42f; ///< Ratio between rotation speed of gear box and wheels |
| 34 | float mLeftRightSplit = 0.5f; ///< Defines how the engine torque is split across the left and right wheel (0 = left, 0.5 = center, 1 = right) |
| 35 | float mLimitedSlipRatio = 1.4f; ///< Ratio max / min wheel speed. When this ratio is exceeded, all torque gets distributed to the slowest moving wheel. This allows implementing a limited slip differential. Set to FLT_MAX for an open differential. Value should be > 1. |
| 36 | float mEngineTorqueRatio = 1.0f; ///< How much of the engines torque is applied to this differential (0 = none, 1 = full), make sure the sum of all differentials is 1. |
| 37 | }; |
| 38 | |
| 39 | JPH_NAMESPACE_END |