CharacterTest.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Tests/Character/CharacterBaseTest.h>
  5. #include <Jolt/Physics/Character/Character.h>
  6. // Simple test that test the Character class. Allows the user to move around with the arrow keys and jump with the J button.
  7. class CharacterTest : public CharacterBaseTest
  8. {
  9. public:
  10. JPH_DECLARE_RTTI_VIRTUAL(CharacterTest)
  11. // Destructor
  12. virtual ~CharacterTest() override;
  13. // Initialize the test
  14. virtual void Initialize() override;
  15. // Update the test, called before the physics update
  16. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  17. // Update the test, called after the physics update
  18. virtual void PostPhysicsUpdate(float inDeltaTime) override;
  19. // Saving / restoring state for replay
  20. virtual void SaveState(StateRecorder &inStream) const override;
  21. virtual void RestoreState(StateRecorder &inStream) override;
  22. protected:
  23. // Get position of the character
  24. virtual Vec3 GetCharacterPosition() const override { return mCharacter->GetPosition(); }
  25. // Handle user input to the character
  26. virtual void HandleInput(Vec3Arg inMovementDirection, bool inJump, bool inSwitchStance, float inDeltaTime) override;
  27. private:
  28. // The 'player' character
  29. Ref<Character> mCharacter;
  30. };