VehicleAntiRollBar.h 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Jolt/ObjectStream/SerializableObject.h>
  6. #include <Jolt/Core/StreamIn.h>
  7. #include <Jolt/Core/StreamOut.h>
  8. JPH_NAMESPACE_BEGIN
  9. /// An anti rollbar is a stiff spring that connects two wheels to reduce the amount of roll the vehicle makes in sharp corners
  10. /// See: https://en.wikipedia.org/wiki/Anti-roll_bar
  11. class VehicleAntiRollBar
  12. {
  13. public:
  14. JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(VehicleAntiRollBar)
  15. /// Saves the contents in binary form to inStream.
  16. void SaveBinaryState(StreamOut &inStream) const;
  17. /// Restores the contents in binary form to inStream.
  18. void RestoreBinaryState(StreamIn &inStream);
  19. int mLeftWheel = 0; ///< Index (in mWheels) that represents the left wheel of this anti-rollbar
  20. int mRightWheel = 1; ///< Index (in mWheels) that represents the right wheel of this anti-rollbar
  21. float mStiffness = 1000.0f; ///< Stiffness (spring constant in N/m) of anti rollbar, can be 0 to disable the anti-rollbar
  22. };
  23. JPH_NAMESPACE_END