Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/jolt_physics/Jolt/Renderer/DebugRendererPlayback.h
9906 views
1
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3
// SPDX-License-Identifier: MIT
4
5
#pragma once
6
7
#ifndef JPH_DEBUG_RENDERER
8
#error This file should only be included when JPH_DEBUG_RENDERER is defined
9
#endif // !JPH_DEBUG_RENDERER
10
11
#include <Jolt/Renderer/DebugRendererRecorder.h>
12
#include <Jolt/Core/StreamIn.h>
13
#include <Jolt/Core/UnorderedMap.h>
14
15
JPH_NAMESPACE_BEGIN
16
17
/// Class that can read a recorded stream from DebugRendererRecorder and plays it back trough a DebugRenderer
18
class JPH_DEBUG_RENDERER_EXPORT DebugRendererPlayback
19
{
20
public:
21
/// Constructor
22
DebugRendererPlayback(DebugRenderer &inRenderer) : mRenderer(inRenderer) { }
23
24
/// Parse a stream of frames
25
void Parse(StreamIn &inStream);
26
27
/// Get the number of parsed frames
28
uint GetNumFrames() const { return (uint)mFrames.size(); }
29
30
/// Draw a frame
31
void DrawFrame(uint inFrameNumber) const;
32
33
private:
34
/// The debug renderer we're using to do the actual rendering
35
DebugRenderer & mRenderer;
36
37
/// Mapping of ID to batch
38
UnorderedMap<uint32, DebugRenderer::Batch> mBatches;
39
40
/// Mapping of ID to geometry
41
UnorderedMap<uint32, DebugRenderer::GeometryRef> mGeometries;
42
43
/// The list of parsed frames
44
using Frame = DebugRendererRecorder::Frame;
45
Array<Frame> mFrames;
46
};
47
48
JPH_NAMESPACE_END
49
50