VehicleConstraintTest.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Tests/Vehicle/VehicleTest.h>
  5. #include <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 int sCollisionMode;
  21. Body * mCarBody; ///< The vehicle
  22. Ref<VehicleConstraint> mVehicleConstraint; ///< The vehicle constraint
  23. Ref<VehicleCollisionTester> mTesters[2]; ///< Collision testers for the wheel
  24. float mPreviousForward = 1.0f; ///< Keeps track of last car direction so we know when to brake and when to accelerate
  25. };