VehicleConstraintTest.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Tests/Vehicle/VehicleTest.h>
  5. #include <Jolt/Physics/Vehicle/VehicleConstraint.h>
  6. // This test shows how a vehicle could be made with the vehicle constraint.
  7. class VehicleConstraintTest : public VehicleTest
  8. {
  9. public:
  10. JPH_DECLARE_RTTI_VIRTUAL(VehicleConstraintTest)
  11. // Destructor
  12. virtual ~VehicleConstraintTest() override;
  13. // See: Test
  14. virtual void Initialize() override;
  15. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  16. virtual void GetInitialCamera(CameraState &ioState) const override;
  17. virtual Mat44 GetCameraPivot(float inCameraHeading, float inCameraPitch) const override;
  18. virtual void CreateSettingsMenu(DebugUI *inUI, UIElement *inSubMenu) override;
  19. private:
  20. static inline int sCollisionMode = 1;
  21. static inline bool sFourWheelDrive = false;
  22. static inline bool sAntiRollbar = true;
  23. static inline bool sLimitedSlipDifferentials = true;
  24. static inline float sMaxEngineTorque = 500.0f;
  25. static inline float sClutchStrength = 10.0f;
  26. Body * mCarBody; ///< The vehicle
  27. Ref<VehicleConstraint> mVehicleConstraint; ///< The vehicle constraint
  28. Ref<VehicleCollisionTester> mTesters[2]; ///< Collision testers for the wheel
  29. float mPreviousForward = 1.0f; ///< Keeps track of last car direction so we know when to brake and when to accelerate
  30. };