13 DECLARE_CYCLE_STAT(TEXT(
"RML - Calculate Tessellation Indices"), STAT_RuntimeMeshLibrary_CalculateTessellationIndices, STATGROUP_RuntimeMesh);
17 auto* Pos = PosDict.Find(Vert.
Position);
22 else if (Vert.
TexCoord < Pos->TexCoord)
30 TFunction<FVector(int32)> PositionAccessor, TFunction<FVector2D(int32)> UVAccessor, TFunction<int32(int32)> IndexAccessor,
31 TFunction<
void(int32)> OutIndicesSizeSetter, TFunction<int32()> OutIndicesSizeGetter, TFunction<
void(int32, int32)> OutIndicesWriter, TFunction<int32(int32)> OutIndicesReader)
33 SCOPE_CYCLE_COUNTER(STAT_RuntimeMeshLibrary_CalculateTessellationIndices);
36 EdgeDict.Reserve(NumIndices);
38 PosDict.Reserve(NumIndices);
42 ExpandIB(NumVertices, NumIndices, PositionAccessor, UVAccessor, IndexAccessor, OutIndicesSizeSetter, OutIndicesSizeGetter, OutIndicesWriter, OutIndicesReader, EdgeDict, PosDict);
44 ReplacePlaceholderIndices(NumVertices, NumIndices, PositionAccessor, UVAccessor, IndexAccessor, OutIndicesSizeSetter, OutIndicesSizeGetter, OutIndicesWriter, OutIndicesReader, EdgeDict, PosDict);
49 TFunction<FVector(int32)> PositionAccessor, TFunction<FVector2D(int32)> UVAccessor, TFunction<int32(int32)> IndexAccessor,
50 TFunction<
void(int32)> OutIndicesSizeSetter, TFunction<int32()> OutIndicesSizeGetter, TFunction<
void(int32, int32)> OutIndicesWriter, TFunction<int32(int32)> OutIndicesReader,
55 for (uint32 U = 0; U < TriangleCount; U++)
60 const uint32 Index0 = IndexAccessor(U * 3 + 0);
61 const uint32 Index1 = IndexAccessor(U * 3 + 1);
62 const uint32 Index2 = IndexAccessor(U * 3 + 2);
64 const Vertex Vertex0(PositionAccessor(Index0), UVAccessor(Index0));
65 const Vertex Vertex1(PositionAccessor(Index1), UVAccessor(Index1));
66 const Vertex Vertex2(PositionAccessor(Index2), UVAccessor(Index2));
68 Triangle Tri(Index0, Index1, Index2, Vertex0, Vertex1, Vertex2);
70 if ((uint32)OutIndicesSizeGetter() <= (StartOutIndex + PnAenDomCorner_IndicesPerPatch))
72 OutIndicesSizeSetter((StartOutIndex + PnAenDomCorner_IndicesPerPatch) + 1);
75 OutIndicesWriter(StartOutIndex + 0, Tri.
GetIndex(0));
76 OutIndicesWriter(StartOutIndex + 1, Tri.
GetIndex(1));
77 OutIndicesWriter(StartOutIndex + 2, Tri.
GetIndex(2));
79 OutIndicesWriter(StartOutIndex + 3, Tri.
GetIndex(0));
80 OutIndicesWriter(StartOutIndex + 4, Tri.
GetIndex(1));
82 OutIndicesWriter(StartOutIndex + 5, Tri.
GetIndex(1));
83 OutIndicesWriter(StartOutIndex + 6, Tri.
GetIndex(2));
85 OutIndicesWriter(StartOutIndex + 7, Tri.
GetIndex(2));
86 OutIndicesWriter(StartOutIndex + 8, Tri.
GetIndex(0));
88 OutIndicesWriter(StartOutIndex + 9, Tri.
GetIndex(0));
89 OutIndicesWriter(StartOutIndex + 10, Tri.
GetIndex(1));
90 OutIndicesWriter(StartOutIndex + 11, Tri.
GetIndex(2));
97 OutEdgeDict.Add(Rev0, Rev0);
98 OutEdgeDict.Add(Rev1, Rev1);
99 OutEdgeDict.Add(Rev2, Rev2);
110 TFunction<FVector(int32)> PositionAccessor, TFunction<FVector2D(int32)> UVAccessor, TFunction<int32(int32)> IndexAccessor,
111 TFunction<
void(int32)> OutIndicesSizeSetter, TFunction<int32()> OutIndicesSizeGetter, TFunction<
void(int32, int32)> OutIndicesWriter, TFunction<int32(int32)> OutIndicesReader,
116 for (uint32 U = 0; U < TriangleCount; U++)
120 const uint32 Index0 = OutIndicesReader(StartOutIndex + 0);
121 const uint32 Index1 = OutIndicesReader(StartOutIndex + 1);
122 const uint32 Index2 = OutIndicesReader(StartOutIndex + 2);
124 const Vertex Vertex0(PositionAccessor(Index0), UVAccessor(Index0));
125 const Vertex Vertex1(PositionAccessor(Index1), UVAccessor(Index1));
126 const Vertex Vertex2(PositionAccessor(Index2), UVAccessor(Index2));
128 Triangle Tri(Index0, Index1, Index2, Vertex0, Vertex1, Vertex2);
133 OutIndicesWriter(StartOutIndex + 3, Ed->
GetIndex(0));
134 OutIndicesWriter(StartOutIndex + 4, Ed->
GetIndex(1));
137 Ed = EdgeDict.Find(Tri.
GetEdge(1));
140 OutIndicesWriter(StartOutIndex + 5, Ed->GetIndex(0));
141 OutIndicesWriter(StartOutIndex + 6, Ed->GetIndex(1));
144 Ed = EdgeDict.Find(Tri.
GetEdge(2));
147 OutIndicesWriter(StartOutIndex + 7, Ed->GetIndex(0));
148 OutIndicesWriter(StartOutIndex + 8, Ed->GetIndex(1));
157 OutIndicesWriter(StartOutIndex + 9 +
V, Corn->
Index);
const uint32 DuplicateIndexCount
const uint32 EdgesPerTriangle
static void CalculateTessellationIndices(int32 NumVertices, int32 NumIndices, TFunction< FVector(int32)> PositionAccessor, TFunction< FVector2D(int32)> UVAccessor, TFunction< int32(int32)> IndexAccessor, TFunction< void(int32)> OutIndicesSizeSetter, TFunction< int32()> OutIndicesSizeGetter, TFunction< void(int32, int32)> OutIndicesWriter, TFunction< int32(int32)> OutIndicesReader)
static void ReplacePlaceholderIndices(int32 NumVertices, int32 NumIndices, TFunction< FVector(int32)> PositionAccessor, TFunction< FVector2D(int32)> UVAccessor, TFunction< int32(int32)> IndexAccessor, TFunction< void(int32)> OutIndicesSizeSetter, TFunction< int32()> OutIndicesSizeGetter, TFunction< void(int32, int32)> OutIndicesWriter, TFunction< int32(int32)> OutIndicesReader, EdgeDictionary &EdgeDict, PositionDictionary &PosDict)
DECLARE_CYCLE_STAT(TEXT("RML - Calculate Tessellation Indices"), STAT_RuntimeMeshLibrary_CalculateTessellationIndices, STATGROUP_RuntimeMesh)
const uint32 IndicesPerTriangle
TMap< Edge, Edge > EdgeDictionary
Vertex GetVertex(uint32 I) const
TMap< FVector, Corner > PositionDictionary
FORCEINLINE uint32 GetIndex(uint32 I)
const uint32 VerticesPerTriangle
const uint32 PnAenDomCorner_IndicesPerPatch
static void AddIfLeastUV(PositionDictionary &PosDict, const Vertex &Vert, uint32 Index)
uint32 GetIndex(uint32 I) const
static void ExpandIB(int32 NumVertices, int32 NumIndices, TFunction< FVector(int32)> PositionAccessor, TFunction< FVector2D(int32)> UVAccessor, TFunction< int32(int32)> IndexAccessor, TFunction< void(int32)> OutIndicesSizeSetter, TFunction< int32()> OutIndicesSizeGetter, TFunction< void(int32, int32)> OutIndicesWriter, TFunction< int32(int32)> OutIndicesReader, EdgeDictionary &OutEdgeDict, PositionDictionary &OutPosDict)
FORCEINLINE const Edge & GetEdge(uint32 I)