UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ToolDataVisualizer.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "ToolContextInterfaces.h" // for FViewCameraState
7
11
19{
20public:
24 float LineThickness = 1.0f;
26 float ArrowHeadSize = 4.0f;
27
31 float PointSize = 1.0f;
32
34 float DepthBias = 0.0f;
36 bool bDepthTested = true;
37
38public:
42
43
44 //
45 // Frame initialization/cleanup
46 //
47
48
51
54
57
58
59 //
60 // Transform support
61 //
62
71
77
83
86 {
87 // transform normal by a safe inverse scale + normalize, and a standard rotation (TODO: move implementation into FTransform)
89 double DetSign = FMath::Sign(S.X*S.Y*S.Z); // we only need to multiply by the sign of the determinant, rather than divide by it, since we normalize later anyway
90 FVector SafeInvS(S.Y*S.Z*DetSign, S.X*S.Z*DetSign, S.X*S.Y*DetSign);
91 return TotalTransform.TransformVectorNoScale((SafeInvS*Normal).GetSafeNormal());
92 }
93
94
95 //
96 // Parameters
97 //
98
99
101 void SetLineParameters(const FLinearColor& Color, float Thickness, float InArrowHeadSize = 4.0f)
102 {
104 LineThickness = Thickness;
106 }
107
110 {
112 PointSize = Size;
113 }
114
115
116 //
117 // Drawing functions
118 //
119
120
122 template<typename PointType>
123 void DrawLine(const PointType& A, const PointType& B)
124 {
126 }
127
129 template<typename PointType>
130 void DrawLine(const PointType& A, const PointType& B, const FLinearColor& Color)
131 {
133 }
134
136 template<typename PointType>
137 void DrawLine(const PointType& A, const PointType& B, const FLinearColor& Color, float LineThicknessIn)
138 {
140 }
141
143 template<typename PointType>
144 void DrawLine(const PointType& A, const PointType& B, const FLinearColor& Color, float LineThicknessIn, bool bDepthTestedIn)
145 {
147 }
148
150 template<typename PointType>
155
157 template<typename PointType>
162
164 template<typename PointType>
169
171 template<typename PointType>
176
177
179 template<typename PointType>
184
186 template<typename PointType>
191
193 template<typename PointType>
198
199
201 template<typename PointType>
202 void DrawCircle(const PointType& Position, const PointType& Normal, float Radius, int Steps, const FLinearColor& Color, float LineThicknessIn, bool bDepthTestedIn)
203 {
205 }
206
208 template<typename PointType>
209 void DrawViewFacingCircle(const PointType& Position, float Radius, int Steps, const FLinearColor& Color, float LineThicknessIn, bool bDepthTestedIn)
210 {
212 }
213
215 template<typename PointType>
216 void DrawArc(const PointType& Position, const PointType& Normal, float Radius, int Steps, float MinAngle, float MaxAngle, const FLinearColor& Color, float LineThicknessIn, bool bDepthTestedIn)
217 {
219 }
220
222 template<typename PointType>
223 void DrawViewFacingArc(const PointType& Position, float Radius, int Steps, float MinAngle, float MaxAngle, const FLinearColor& Color, float LineThicknessIn, bool bDepthTestedIn)
224 {
226 }
227
229 template<typename PointType>
230 void DrawViewFacingX(const PointType& Position, float Width)
231 {
233 }
234
236 template<typename PointType>
237 void DrawViewFacingX(const PointType& Position, float Width, const FLinearColor& Color, float LineThicknessIn, bool bDepthTestedIn)
238 {
240 }
241
243 template<typename PointType>
244 void DrawWireCylinder(const PointType& Position, const PointType& Normal, float Radius, float Height, int Steps, const FLinearColor& Color, float LineThicknessIn, bool bDepthTestedIn)
245 {
247 }
248
250 template<typename PointType>
251 void DrawWireCylinder(const PointType& Position, const PointType& Normal, float Radius, float Height, int Steps)
252 {
254 }
255
261
266
267 template<typename PointType>
268 void DrawSquare(const PointType& Center, const PointType& SideA, const PointType& SideB, const FLinearColor& Color, float LineThicknessIn, bool bDepthTestedIn)
269 {
271 }
272
273 template<typename PointType>
274 void DrawSquare(const PointType& Center, const PointType& SideA, const PointType& SideB)
275 {
277 }
278
279 template<typename PointType>
280 void DrawGrid(const PointType& Center, const PointType& Normal, const PointType& Size, const FLinearColor& Color, float LineThicknessIn, bool bDepthTestedIn)
281 {
283 }
284
285 template<typename PointType>
286 void DrawGrid(const PointType& Center, const PointType& Normal, const PointType& Up, const PointType& Side, const PointType& Size, const FLinearColor& Color, float LineThicknessIn, bool bDepthTestedIn)
287 {
289 }
290
292 template<typename PointType>
293 void DrawDisc(const PointType& Position, const PointType& Normal, float Radius, int Steps, const FColor& Color, FMaterialRenderProxy* RenderProxy, bool bDepthTestedIn)
294 {
296 }
297
298protected:
301
304
305 // screen-space line thicknesses and point sizes are multiplied by this value to try to normalize for variable thickness
306 // that occurs at different FOVs.
307 float PDISizeScale = 1.0;
308
309
312
313 // actually does the line drawing; assumes A and B are already transformed
315 // actually does the arrow drawing; assumes A and B are already transformed
317 // actually does the point drawing; assumes Position is already transformed
319
320
321 // actually does the circle drawing
322 INTERACTIVETOOLSFRAMEWORK_API virtual void InternalDrawCircle(const FVector& Position, const FVector& Normal, float Radius, int Steps, const FLinearColor& Color, float LineThickness, bool bDepthTested);
323 // actually does the circle drawing
324 INTERACTIVETOOLSFRAMEWORK_API virtual void InternalDrawViewFacingCircle(const FVector& Position, float Radius, int Steps, const FLinearColor& Color, float LineThickness, bool bDepthTested);
325 // actually does the arc drawing
326 INTERACTIVETOOLSFRAMEWORK_API virtual void InternalDrawArc(const FVector& InPosition, const FVector& InNormal, const float InRadius, int32 InSteps, const float InMinAngle, const float InMaxAngle, const FLinearColor& Color, float LineThickness, bool bDepthTested);
327 // actually does the arc drawing
329 // actually does the cylinder drawing
330 INTERACTIVETOOLSFRAMEWORK_API virtual void InternalDrawWireCylinder(const FVector& Position, const FVector& Normal, float Radius, float Height, int Steps, const FLinearColor& Color, float LineThickness, bool bDepthTested);
331 // actually does the box drawing
333 // actually does the square drawing
334 INTERACTIVETOOLSFRAMEWORK_API virtual void InternalDrawSquare(const FVector& Center, const FVector& SideA, const FVector& SideB, const FLinearColor& Color, float LineThickness, bool bDepthTested);
335 // actually does the grid drawing
337 // actually does the grid drawing
338 INTERACTIVETOOLSFRAMEWORK_API virtual void InternalDrawGrid(const FVector& Center, const FVector& Normal, const FVector& Up, const FVector& Side, const FVector& Size, const FLinearColor& Color, float LineThickness, bool bDepthTested);
339 // actually does the X drawing
341 // actually does the disc drawing
342 INTERACTIVETOOLSFRAMEWORK_API virtual void InternalDrawDisc(const FVector& Position, const FVector& Normal, float Radius, int Steps, const FColor& Color, FMaterialRenderProxy* RenderProxy, bool bDepthTested);
343};
@ Normal
Definition AndroidInputInterface.h:116
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
uint32 Size
Definition VulkanMemory.cpp:4034
Definition MaterialRenderProxy.h:102
Definition PrimitiveDrawInterface.h:19
Definition ToolDataVisualizer.h:19
FVector TransformV(const FVector &Vector)
Definition ToolDataVisualizer.h:79
INTERACTIVETOOLSFRAMEWORK_API void PopAllTransforms()
Definition ToolDataVisualizer.cpp:79
void DrawGrid(const PointType &Center, const PointType &Normal, const PointType &Size, const FLinearColor &Color, float LineThicknessIn, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:280
FTransform TotalTransform
Definition ToolDataVisualizer.h:311
virtual INTERACTIVETOOLSFRAMEWORK_API ~FToolDataVisualizer()
void DrawDirectionalArrow(const PointType &A, const PointType &B, const FVector &InNormal, const FLinearColor &Color)
Definition ToolDataVisualizer.h:158
virtual INTERACTIVETOOLSFRAMEWORK_API void InternalDrawTransformedLine(const FVector &A, const FVector &B, const FLinearColor &Color, float LineThickness, bool bDepthTested)
Definition ToolDataVisualizer.cpp:88
void DrawDirectionalArrow(const PointType &A, const PointType &B, const FVector &InNormal, const FLinearColor &Color, float InArrowHeadSize, float LineThicknessIn, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:172
FVector TransformN(const FVector &Normal)
Definition ToolDataVisualizer.h:85
float PDISizeScale
Definition ToolDataVisualizer.h:307
virtual INTERACTIVETOOLSFRAMEWORK_API void InternalDrawDisc(const FVector &Position, const FVector &Normal, float Radius, int Steps, const FColor &Color, FMaterialRenderProxy *RenderProxy, bool bDepthTested)
Definition ToolDataVisualizer.cpp:349
void DrawViewFacingArc(const PointType &Position, float Radius, int Steps, float MinAngle, float MaxAngle, const FLinearColor &Color, float LineThicknessIn, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:223
void DrawWireCylinder(const PointType &Position, const PointType &Normal, float Radius, float Height, int Steps, const FLinearColor &Color, float LineThicknessIn, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:244
FPrimitiveDrawInterface * CurrentPDI
Definition ToolDataVisualizer.h:300
virtual INTERACTIVETOOLSFRAMEWORK_API void InternalDrawViewFacingX(const FVector &Position, float Width, const FLinearColor &Color, float LineThickness, bool bDepthTested)
Definition ToolDataVisualizer.cpp:330
void SetLineParameters(const FLinearColor &Color, float Thickness, float InArrowHeadSize=4.0f)
Definition ToolDataVisualizer.h:101
void DrawViewFacingCircle(const PointType &Position, float Radius, int Steps, const FLinearColor &Color, float LineThicknessIn, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:209
FLinearColor PointColor
Definition ToolDataVisualizer.h:29
void DrawGrid(const PointType &Center, const PointType &Normal, const PointType &Up, const PointType &Side, const PointType &Size, const FLinearColor &Color, float LineThicknessIn, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:286
FLinearColor LineColor
Definition ToolDataVisualizer.h:22
void DrawWireBox(const FBox &Box)
Definition ToolDataVisualizer.h:257
virtual INTERACTIVETOOLSFRAMEWORK_API void InternalDrawWireCylinder(const FVector &Position, const FVector &Normal, float Radius, float Height, int Steps, const FLinearColor &Color, float LineThickness, bool bDepthTested)
Definition ToolDataVisualizer.cpp:268
float ArrowHeadSize
Definition ToolDataVisualizer.h:26
float LineThickness
Definition ToolDataVisualizer.h:24
void DrawCircle(const PointType &Position, const PointType &Normal, float Radius, int Steps, const FLinearColor &Color, float LineThicknessIn, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:202
void DrawSquare(const PointType &Center, const PointType &SideA, const PointType &SideB)
Definition ToolDataVisualizer.h:274
virtual INTERACTIVETOOLSFRAMEWORK_API void InternalDrawDirectionalArrow(const FVector &A, const FVector &B, const FVector &InNormal, const FLinearColor &Color, const float InHeadSize, float LineThickness, bool bDepthTested)
Definition ToolDataVisualizer.cpp:95
void DrawLine(const PointType &A, const PointType &B, const FLinearColor &Color)
Definition ToolDataVisualizer.h:130
void DrawPoint(const PointType &Position, const FLinearColor &Color, float PointSizeIn, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:194
void DrawPoint(const PointType &Position, const FLinearColor &Color)
Definition ToolDataVisualizer.h:187
float DepthBias
Definition ToolDataVisualizer.h:34
void DrawLine(const PointType &A, const PointType &B, const FLinearColor &Color, float LineThicknessIn, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:144
void DrawPoint(const PointType &Position)
Definition ToolDataVisualizer.h:180
void DrawWireCylinder(const PointType &Position, const PointType &Normal, float Radius, float Height, int Steps)
Definition ToolDataVisualizer.h:251
void DrawDirectionalArrow(const PointType &A, const PointType &B, const FVector &InNormal, const FLinearColor &Color, float InArrowHeadSize, float LineThicknessIn)
Definition ToolDataVisualizer.h:165
virtual INTERACTIVETOOLSFRAMEWORK_API void InternalDrawGrid(const FVector &Center, const FVector &Normal, const FVector &Size, const FLinearColor &Color, float LineThickness, bool bDepthTested)
Definition ToolDataVisualizer.cpp:223
void DrawArc(const PointType &Position, const PointType &Normal, float Radius, int Steps, float MinAngle, float MaxAngle, const FLinearColor &Color, float LineThicknessIn, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:216
bool bDepthTested
Definition ToolDataVisualizer.h:36
virtual INTERACTIVETOOLSFRAMEWORK_API void InternalDrawArc(const FVector &InPosition, const FVector &InNormal, const float InRadius, int32 InSteps, const float InMinAngle, const float InMaxAngle, const FLinearColor &Color, float LineThickness, bool bDepthTested)
Definition ToolDataVisualizer.cpp:169
void DrawSquare(const PointType &Center, const PointType &SideA, const PointType &SideB, const FLinearColor &Color, float LineThicknessIn, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:268
void DrawViewFacingX(const PointType &Position, float Width)
Definition ToolDataVisualizer.h:230
void DrawLine(const PointType &A, const PointType &B)
Definition ToolDataVisualizer.h:123
void DrawViewFacingX(const PointType &Position, float Width, const FLinearColor &Color, float LineThicknessIn, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:237
FVector TransformP(const FVector &Point)
Definition ToolDataVisualizer.h:73
INTERACTIVETOOLSFRAMEWORK_API void PopTransform()
Definition ToolDataVisualizer.cpp:69
virtual INTERACTIVETOOLSFRAMEWORK_API void InternalDrawCircle(const FVector &Position, const FVector &Normal, float Radius, int Steps, const FLinearColor &Color, float LineThickness, bool bDepthTested)
Definition ToolDataVisualizer.cpp:156
FViewCameraState CameraState
Definition ToolDataVisualizer.h:302
bool bHaveCameraState
Definition ToolDataVisualizer.h:303
INTERACTIVETOOLSFRAMEWORK_API FToolDataVisualizer(const FToolDataVisualizer &)
INTERACTIVETOOLSFRAMEWORK_API void PushTransform(const FTransform &Transform)
Definition ToolDataVisualizer.cpp:63
void DrawWireBox(const FBox &Box, const FLinearColor &Color, float LineThicknessIn, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:262
TArray< FTransform > TransformStack
Definition ToolDataVisualizer.h:310
void DrawDirectionalArrow(const PointType &A, const PointType &B, const FVector &InNormal)
Definition ToolDataVisualizer.h:151
virtual INTERACTIVETOOLSFRAMEWORK_API void InternalDrawWireBox(const FBox &Box, const FLinearColor &Color, float LineThickness, bool bDepthTested)
Definition ToolDataVisualizer.cpp:182
virtual INTERACTIVETOOLSFRAMEWORK_API void InternalDrawViewFacingCircle(const FVector &Position, float Radius, int Steps, const FLinearColor &Color, float LineThickness, bool bDepthTested)
Definition ToolDataVisualizer.cpp:295
virtual INTERACTIVETOOLSFRAMEWORK_API void InternalDrawViewFacingArc(const FVector &InPosition, float InRadius, int32 InSteps, const float InMinAngle, const float InMaxAngle, const FLinearColor &Color, float LineThickness, bool bDepthTested)
Definition ToolDataVisualizer.cpp:313
virtual INTERACTIVETOOLSFRAMEWORK_API void InternalDrawTransformedPoint(const FVector &Position, const FLinearColor &Color, float PointSize, bool bDepthTested)
Definition ToolDataVisualizer.cpp:149
INTERACTIVETOOLSFRAMEWORK_API void SetTransform(const FTransform &Transform)
Definition ToolDataVisualizer.cpp:55
void DrawLine(const PointType &A, const PointType &B, const FLinearColor &Color, float LineThicknessIn)
Definition ToolDataVisualizer.h:137
void DrawDisc(const PointType &Position, const PointType &Normal, float Radius, int Steps, const FColor &Color, FMaterialRenderProxy *RenderProxy, bool bDepthTestedIn)
Definition ToolDataVisualizer.h:293
float PointSize
Definition ToolDataVisualizer.h:31
virtual INTERACTIVETOOLSFRAMEWORK_API void InternalDrawSquare(const FVector &Center, const FVector &SideA, const FVector &SideB, const FLinearColor &Color, float LineThickness, bool bDepthTested)
Definition ToolDataVisualizer.cpp:206
void SetPointParameters(const FLinearColor &Color, float Size)
Definition ToolDataVisualizer.h:109
INTERACTIVETOOLSFRAMEWORK_API FToolDataVisualizer()
Definition ToolDataVisualizer.cpp:20
INTERACTIVETOOLSFRAMEWORK_API void EndFrame()
Definition ToolDataVisualizer.cpp:48
Definition ToolContextInterfaces.h:427
Definition Array.h:670
Definition Color.h:486
Definition Color.h:48
Definition ToolContextInterfaces.h:83
TVector< T > GetScale3D() const
Definition TransformNonVectorized.h:1131
TVector< T > TransformVectorNoScale(const TVector< T > &V) const
Definition TransformNonVectorized.h:1447
UE_FORCEINLINE_HINT TVector< T > TransformVector(const TVector< T > &V) const
Definition TransformNonVectorized.h:1439
UE_FORCEINLINE_HINT TVector< T > TransformPosition(const TVector< T > &V) const
Definition TransformNonVectorized.h:1423