JoltViewer.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 <Application/Application.h>
  6. #ifdef JPH_DEBUG_RENDERER
  7. #include <Jolt/Renderer/DebugRendererPlayback.h>
  8. #else
  9. // Hack to still compile DebugRenderer inside the test framework when Jolt is compiled without
  10. #define JPH_DEBUG_RENDERER
  11. // Make sure the debug renderer symbols don't get imported or exported
  12. #define JPH_DEBUG_RENDERER_EXPORT
  13. #include <Jolt/Renderer/DebugRendererPlayback.h>
  14. #undef JPH_DEBUG_RENDERER
  15. #undef JPH_DEBUG_RENDERER_EXPORT
  16. #endif
  17. using namespace std;
  18. // Application that views recordings produced by DebugRendererRecorder
  19. class JoltViewer : public Application
  20. {
  21. public:
  22. // Constructor / destructor
  23. JoltViewer();
  24. // Render the frame
  25. virtual bool RenderFrame(float inDeltaTime) override;
  26. private:
  27. enum class EPlaybackMode
  28. {
  29. Rewind,
  30. StepBack,
  31. Stop,
  32. StepForward,
  33. Play
  34. };
  35. DebugRendererPlayback mRendererPlayback { *mDebugRenderer };
  36. EPlaybackMode mPlaybackMode = EPlaybackMode::Play; // Current playback state. Indicates if we're playing or scrubbing back/forward.
  37. uint mCurrentFrame = 0;
  38. };