UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MeshAdapterTransforms.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
7#include "FrameTypes.h"
8#include "MathUtil.h"
9#include "VectorTypes.h"
10
11#include "Async/ParallelFor.h"
12
23{
24 using namespace UE::Geometry;
26
30 template<class TriangleMeshType>
32 {
33 int NumVertices = Mesh.MaxVertexID();
34 ParallelFor(NumVertices, [&](int vid)
35 {
36 if (Mesh.IsVertex(vid))
37 {
38 Mesh.SetVertex(vid, Mesh.GetVertex(vid) + Translation);
39 }
40 });
41 }
42
46 template<class TriangleMeshType>
48 {
49 int NumVertices = Mesh.MaxVertexID();
50 ParallelFor(NumVertices, [&](int vid)
51 {
52 if (Mesh.IsVertex(vid))
53 {
54 FVector3d Position = Mesh.GetVertex(vid);
55 Mesh.SetVertex(vid, Frame.ToFramePoint(Position));
56 }
57 });
58
59 if (Mesh.HasNormals())
60 {
61 int NumNormals = Mesh.MaxNormalID();
63 {
64 if (Mesh.IsNormal(elemid))
65 {
66 FVector3f Normal = Mesh.GetNormal(elemid);
67 Mesh.SetNormal(elemid, (FVector3f)Frame.ToFrameVector((FVector3d)Normal));
68 }
69 });
70 }
71 }
72
76 template<class TriangleMeshType>
78 {
79 int NumVertices = Mesh.MaxVertexID();
80 ParallelFor(NumVertices, [&](int vid)
81 {
82 if (Mesh.IsVertex(vid))
83 {
84 FVector3d Position = Mesh.GetVertex(vid);
85 Mesh.SetVertex(vid, Frame.FromFramePoint(Position));
86 }
87 });
88
89 if (Mesh.HasNormals())
90 {
91 int NumNormals = Mesh.MaxNormalID();
93 {
94 if (Mesh.IsNormal(elemid))
95 {
96 FVector3f Normal = Mesh.GetNormal(elemid);
97 Mesh.SetNormal(elemid, (FVector3f)Frame.FromFrameVector((FVector3d)Normal));
98 }
99 });
100 }
101 }
102
103
108 template<class TriangleMeshType>
110 {
111 int NumVertices = Mesh.MaxVertexID();
112 ParallelFor(NumVertices, [&](int vid)
113 {
114 if (Mesh.IsVertex(vid))
115 {
116 FVector3d Position = Mesh.GetVertex(vid);
117 Position = Transform.TransformPosition(Position);
118 Mesh.SetVertex(vid, Position);
119 }
120 });
121
122 if (Mesh.HasNormals())
123 {
124 int NumNormals = Mesh.MaxNormalID();
126 {
127 if (Mesh.IsNormal(elemid))
128 {
129 FVector3f Normal = Mesh.GetNormal(elemid);
130 Mesh.SetNormal(elemid, (FVector3f)Transform.TransformNormal((FVector3d)Normal));
131 }
132 });
133 }
134 }
135
136
141 template<class TriangleMeshType>
143 {
144 int NumVertices = Mesh.MaxVertexID();
145 ParallelFor(NumVertices, [&](int vid)
146 {
147 if (Mesh.IsVertex(vid))
148 {
149 FVector3d Position = Mesh.GetVertex(vid);
150 Position = Transform.InverseTransformPosition(Position);
151 Mesh.SetVertex(vid, Position);
152 }
153 });
154
155 if (Mesh.HasNormals())
156 {
157 int NumNormals = Mesh.MaxNormalID();
159 {
160 if (Mesh.IsNormal(elemid))
161 {
162 FVector3f Normal = Mesh.GetNormal(elemid);
163 Mesh.SetNormal(elemid, (FVector3f)Transform.InverseTransformNormal((FVector3d)Normal));
164 }
165 });
166 }
167 }
168
169
174 template<class TriangleMeshType>
178 {
179 int NumVertices = Mesh.MaxVertexID();
180 ParallelFor(NumVertices, [&](int vid)
181 {
182 if (Mesh.IsVertex(vid))
183 {
184 FVector3d Position = Mesh.GetVertex(vid);
185 Position = PositionTransform(Position);
186 Mesh.SetVertex(vid, Position);
187 }
188 });
189
190 if (Mesh.HasNormals())
191 {
192 int NumNormals = Mesh.MaxNormalID();
194 {
195 if (Mesh.IsNormal(elemid))
196 {
197 FVector3f Normal = Mesh.GetNormal(elemid);
198 Normal = NormalTransform(Normal);
199 Mesh.SetNormal(elemid, UE::Geometry::Normalized(Normal));
200 }
201 });
202 }
203 }
204
205};
void ParallelFor(int32 Num, TFunctionRef< void(int32)> Body, bool bForceSingleThread, bool bPumpRenderingThread=false)
Definition ParallelFor.h:481
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::Math::TVector< float > FVector3f
Definition MathFwd.h:73
UE::Math::TVector< double > FVector3d
Definition MathFwd.h:60
Definition AssetRegistryState.h:50
Definition MeshAdapterTransforms.h:23
void FrameCoordsToWorld(TriangleMeshType &Mesh, const FFrame3d &Frame)
Definition MeshAdapterTransforms.h:77
void WorldToFrameCoords(TriangleMeshType &Mesh, const FFrame3d &Frame)
Definition MeshAdapterTransforms.h:47
void ApplyTransformInverse(TriangleMeshType &Mesh, const FTransformSRT3d &Transform)
Definition MeshAdapterTransforms.h:142
void ApplyTransform(TriangleMeshType &Mesh, const FTransformSRT3d &Transform)
Definition MeshAdapterTransforms.h:109
void Translate(TriangleMeshType &Mesh, const FVector3d &Translation)
Definition MeshAdapterTransforms.h:31
Definition ParametricSurfaceData.h:18
TFrame3< double > FFrame3d
Definition FrameTypes.h:478