UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MeshCaches.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "DynamicVector.h"
6
7#include "Async/ParallelFor.h"
8#include "MeshQueries.h"
9
10namespace UE
11{
12namespace Geometry
13{
14
15/*
16 * Basic cache of per-triangle information for a mesh
17 */
19{
23
24 void GetTriInfo(int TriangleID, FVector3d& NormalOut, double& AreaOut, FVector3d& CentroidOut) const
25 {
26 NormalOut = Normals[TriangleID];
27 AreaOut = Areas[TriangleID];
28 CentroidOut = Centroids[TriangleID];
29 }
30
31 template<class TriangleMeshType>
33 {
35 int NT = Mesh.MaxTriangleID();
36 Cache.Centroids.Resize(NT);
37 Cache.Normals.Resize(NT);
38 Cache.Areas.Resize(NT);
39
40 ParallelFor(NT, [&](int TID)
41 {
42 if (Mesh.IsTriangle(TID))
43 {
44 TMeshQueries<TriangleMeshType>::GetTriNormalAreaCentroid(Mesh, TID, Cache.Normals[TID], Cache.Areas[TID], Cache.Centroids[TID]);
45 }
46 });
47
48 return Cache;
49 }
50};
51
52
53} // end namespace UE::Geometry
54} // end namespace UE
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
Definition DynamicVector.h:27
Definition AdvancedWidgetsModule.cpp:13
Definition MeshCaches.h:19
TDynamicVector< double > Areas
Definition MeshCaches.h:22
void GetTriInfo(int TriangleID, FVector3d &NormalOut, double &AreaOut, FVector3d &CentroidOut) const
Definition MeshCaches.h:24
TDynamicVector< FVector3d > Centroids
Definition MeshCaches.h:20
static FMeshTriInfoCache BuildTriInfoCache(const TriangleMeshType &Mesh)
Definition MeshCaches.h:32
TDynamicVector< FVector3d > Normals
Definition MeshCaches.h:21