UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
LineSegmentGenerators.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 "VectorTypes.h"
7#include "FrameTypes.h"
8#include "TransformTypes.h"
9
10namespace UE
11{
12 namespace Geometry
13 {
14 using namespace UE::Math;
15
25 template<typename RealType>
34
44 template<typename RealType>
46 int32 NumSteps,
47 RealType Radius,
53
64 template<typename RealType>
66 int32 NumSteps,
67 RealType Radius,
68 RealType StartAngle,
69 RealType EndAngle,
75 }
76}
77
78
79
80
81
82template<typename RealType>
91{
92 // B is box max/min, P and Q are used to store the start and endpoints of the segments we create
93 TVector<RealType> B[2], P, Q;
94 B[0] = Center + HalfDimensions; // max
95 B[1] = Center - HalfDimensions; // min
96
97 // Iterate across the four corners of top/side/front and create segments along the Z axis
98 for (int32 i = 0; i < 2; i++)
99 {
100 for (int32 j = 0; j < 2; j++)
101 {
102 P.X = B[i].X; Q.X = B[i].X;
103 P.Y = B[j].Y; Q.Y = B[j].Y;
104 P.Z = B[0].Z; Q.Z = B[1].Z;
105 EmitLineFunc(Transform.TransformPosition(P), Transform.TransformPosition(Q));
106
107 P.Y = B[i].Y; Q.Y = B[i].Y;
108 P.Z = B[j].Z; Q.Z = B[j].Z;
109 P.X = B[0].X; Q.X = B[1].X;
110 EmitLineFunc(Transform.TransformPosition(P), Transform.TransformPosition(Q));
111
112 P.Z = B[i].Z; Q.Z = B[i].Z;
113 P.X = B[j].X; Q.X = B[j].X;
114 P.Y = B[0].Y; Q.Y = B[1].Y;
115 EmitLineFunc(Transform.TransformPosition(P), Transform.TransformPosition(Q));
116 }
117 }
118}
119
120
121
122template<typename RealType>
124 int32 NumSteps, RealType Radius,
130{
132 for (int32 i = 0; i <= NumSteps; ++i)
133 {
134 RealType t = (RealType)i / (RealType)NumSteps;
135 RealType Angle = (RealType)2.0 * TMathUtil<RealType>::Pi * t;
136 RealType PlaneX = Radius * TMathUtil<RealType>::Cos(Angle);
137 RealType PlaneY = Radius * TMathUtil<RealType>::Sin(Angle);
138 TVector<RealType> CurPos = Transform.TransformPosition(Center + PlaneX * AxisX + PlaneY * AxisY);
139 if (i > 0)
140 {
141 EmitLineFunc(PrevPos, CurPos);
142 }
143 PrevPos = CurPos;
144 }
145}
146
147
148
149template<typename RealType>
151 int32 NumSteps,
152 RealType Radius,
153 RealType StartAngle,
154 RealType EndAngle,
160{
162 for (int32 i = 0; i <= NumSteps; ++i)
163 {
164 RealType t = (RealType)i / (RealType)NumSteps;
165 RealType Angle = ((RealType)1 - t) * StartAngle + (t)*EndAngle;
166 RealType PlaneX = Radius * TMathUtil<RealType>::Cos(Angle);
167 RealType PlaneY = Radius * TMathUtil<RealType>::Sin(Angle);
168 TVector<RealType> CurPos = Transform.TransformPosition(Center + PlaneX * AxisX + PlaneY * AxisY);
169 if (i > 0)
170 {
171 EmitLineFunc(PrevPos, CurPos);
172 }
173 PrevPos = CurPos;
174 }
175}
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
Definition AssetRegistryState.h:50
Definition MathUtil.h:150
static RealType Cos(const RealType Value)
Definition MathUtil.h:372
static RealType Sin(const RealType Value)
Definition MathUtil.h:366
Definition TransformTypes.h:30
void GenerateArcSegments(int32 NumSteps, RealType Radius, RealType StartAngle, RealType EndAngle, const TVector< RealType > &Center, const TVector< RealType > &AxisX, const TVector< RealType > &AxisY, const TTransformSRT3< RealType > &Transform, TFunctionRef< void(const TVector< RealType > &A, const TVector< RealType > &B)> EmitLineFunc)
Definition LineSegmentGenerators.h:150
void GenerateBoxSegments(const TVector< RealType > &HalfDimensions, const TVector< RealType > &Center, const TVector< RealType > &AxisX, const TVector< RealType > &AxisY, const TVector< RealType > &AxisZ, const TTransformSRT3< RealType > &Transform, TFunctionRef< void(const TVector< RealType > &A, const TVector< RealType > &B)> EmitLineFunc)
Definition LineSegmentGenerators.h:83
void GenerateCircleSegments(int32 NumSteps, RealType Radius, const TVector< RealType > &Center, const TVector< RealType > &AxisX, const TVector< RealType > &AxisY, const TTransformSRT3< RealType > &Transform, TFunctionRef< void(const TVector< RealType > &A, const TVector< RealType > &B)> EmitLineFunc)
Definition LineSegmentGenerators.h:123
Definition Sphere.cpp:10
Definition AdvancedWidgetsModule.cpp:13
Definition Vector.h:51
T Z
Definition Vector.h:68
T Y
Definition Vector.h:65
T X
Definition Vector.h:62