UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ChaosDDTimeline.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
7#include "Containers/Map.h"
9#include "Math/Sphere.h"
10#include "Misc/ScopeLock.h"
11
12#if CHAOS_DEBUG_DRAW
13
14namespace ChaosDD::Private
15{
16 //
17 // Holds a sequence of debug draw frames. Every system that runs its own loop
18 // will need a timeline. E.g., Physics Thread, Game Thread, RBANs
19 //
20 // @todo(chaos): Add per-thread buffers to avoid locks
21 //
22 class FChaosDDTimeline : public TSharedFromThis<FChaosDDTimeline>
23 {
24 public:
25 FChaosDDTimeline(const FString& InName, int32 InCommandBudget)
26 : Name(InName)
27 , MaxFrames(1)
28 , NextFrameIndex(0)
32 {
33 }
34
35 const FString& GetName() const
36 {
37 return Name;
38 }
39
41 {
43
45 }
46
48 {
50
52 }
53
54 void BeginFrame(double InTime, double InDt)
55 {
57
58 // Duplicate BeginFrame?
59 check(!ActiveFrame.IsValid());
60
62
63 //UE_LOG(LogChaosDD, VeryVerbose, TEXT("BeginFrame %s %lld"), *GetName(), ActiveFrame->GetFrameIndex());
64 }
65
66 void EndFrame()
67 {
69
70 // Missing BeginFrame?
71 check(ActiveFrame.IsValid());
72
73 //UE_LOG(LogChaosDD, VeryVerbose, TEXT("EndFrame %s %lld (%d Commands)"), *GetName(), ActiveFrame->GetFrameIndex(), ActiveFrame->GetNumCommands());
74
75 // Remeber the queue size to prevent array growth every frame
76 CommandQueueLength = FMath::RoundUpToPowerOfTwo(FMath::Max(CommandQueueLength, ActiveFrame->GetNumCommands()));
77
79 ActiveFrame.Reset();
80
82 }
83
84 const FChaosDDFramePtr& GetActiveFrame() const
85 {
86 return ActiveFrame;
87 }
88
90 {
92
93 for (const FChaosDDFramePtr& Frame : Frames)
94 {
95 InOutFrames.Add(Frame);
96 }
97 }
98
99 private:
100 void PruneFrames()
101 {
102 const int32 NumToRemove = Frames.Num() - MaxFrames;
103 if (NumToRemove > 0)
104 {
106 }
107 }
108
109 FString Name;
113 int64 NextFrameIndex;
118 };
119
120
121 // Here to avoid circular dependency with ChaosDDFrame.h
122 inline void FChaosDDFrame::BuildName()
123 {
125 {
126 Name = FString::Format(TEXT("{0}: {1}"), { PinnedTimeline->GetName(), GetFrameIndex() });
127 }
128 else
129 {
130 Name = FString::Format(TEXT("<Global>: {0}"), { GetFrameIndex()});
131 }
132 }
133
134}
135
136#endif
#define check(expr)
Definition AssertionMacros.h:314
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
FRWLock Lock
Definition UnversionedPropertySerialization.cpp:921
Definition ScopeLock.h:141
Definition Array.h:670
Definition SharedPointer.h:1640
IMAGECORE_API const TCHAR * GetName(Type Format)
Definition ImageCore.cpp:1378