VehicleSixDOFTest.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Tests/Vehicle/VehicleTest.h>
  5. #include <Jolt/Physics/Constraints/SixDOFConstraint.h>
  6. // This test shows how a vehicle could be made with the SixDOF constraint.
  7. class VehicleSixDOFTest : public VehicleTest
  8. {
  9. public:
  10. JPH_DECLARE_RTTI_VIRTUAL(VehicleSixDOFTest)
  11. // See: Test
  12. virtual void Initialize() override;
  13. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  14. virtual void GetInitialCamera(CameraState &ioState) const override;
  15. virtual Mat44 GetCameraPivot(float inCameraHeading, float inCameraPitch) const override;
  16. private:
  17. static constexpr float cMaxSteeringAngle = DegreesToRadians(30);
  18. using EAxis = SixDOFConstraintSettings::EAxis;
  19. enum class EWheel : int
  20. {
  21. LeftFront,
  22. RightFront,
  23. LeftRear,
  24. RightRear,
  25. Num,
  26. };
  27. static inline bool sIsFrontWheel(EWheel inWheel) { return inWheel == EWheel::LeftFront || inWheel == EWheel::RightFront; }
  28. static inline bool sIsLeftWheel(EWheel inWheel) { return inWheel == EWheel::LeftFront || inWheel == EWheel::LeftRear; }
  29. Body * mCarBody;
  30. Ref<SixDOFConstraint> mWheels[int(EWheel::Num)];
  31. };