5 #include "CoreMinimal.h" 16 template<
typename VertexType,
typename TriangleType>
25 Vertices = InVertices;
26 Triangles = InTriangles;
31 for (int32
i = 0;
i < Triangles.Num();
i += 3) {
39 template<
typename Datastruct,
typename VertexType,
typename TriangleType>
59 return DataMap.contains(
id);
76 FORCEINLINE MeshType
GetMesh(Datastruct
id)
78 int32
index = DataMap.find(
id);
79 return GetMeshAtIndex(index);
87 submesh.
Vertices.SetNum(VertLengths[index]);
88 submesh.
Triangles.SetNum(TrisLengths[index]);
89 int32 vertstart, trisstart;
90 getStart(index, vertstart, trisstart);
91 for (int32
i = 0;
i < VertLengths[
index];
i++)
95 for (int32
i = 0;
i < TrisLengths[
index];
i++)
106 if (DataMap.Contains(
id)) {
131 VertLengths.Add(vertlen);
132 TrisLengths.Add(trislen);
135 for (
int i = 0;
i < trislen;
i++)
144 if (!DataMap.Contains(
id)) {
147 int index = DataMap.Find(
id);
148 int32 vertstart = 0, vertlen = VertLengths[
index], trisstart = 0, trislen = TrisLengths[
index];
150 getStart(index, vertstart, trisstart);
153 removeTris(trisstart, trislen);
154 removeVerts(vertstart, vertlen, trisstart);
157 DataMap.RemoveAt(index);
158 VertLengths.RemoveAt(index);
159 TrisLengths.RemoveAt(index);
166 VertStart = 0; TrisStart = 0;
170 VertStart += VertLengths[
i];
171 TrisStart += TrisLengths[
i];
183 Mesh.
Vertices.RemoveAt(start, len,
true);
188 Mesh.
Triangles.RemoveAt(start, len,
true);
197 for (
int i = 0;
i < DataMap.Num();
i++)
199 trisnum += TrisLengths[
i];
200 if (tris * 3 < trisnum) {
211 for (
int i = 0;
i < DataMap.Num();
i++)
213 trisnum += TrisLengths[
i];
214 if (tris * 3 < trisnum) {
FRuntimeMeshDataStruct< VertexType, TriangleType > FlipNormals()
FORCEINLINE void RemoveMesh(Datastruct id)
FRuntimeMeshDataStruct< VertexType, TriangleType > Mesh
FORCEINLINE void removeTris(int32 start, int32 len)
FRuntimeMeshDataStruct(TArray< VertexType > InVertices, TArray< TriangleType > InTriangles)
FORCEINLINE MeshType GetMesh(Datastruct id)
FORCEINLINE int32 GetMeshIndexHit(TriangleType tris)
FORCEINLINE bool HasMesh(Datastruct id)
TArray< VertexType > Vertices
FORCEINLINE void getStart(int32 index, int32 &VertStart, int32 &TrisStart)
TArray< TriangleType > Triangles
TArray< int32 > VertLengths
FORCEINLINE void AddMesh(Datastruct id, MeshType mesh)
TArray< Datastruct > DataMap
FORCEINLINE TArray< Datastruct > GetMeshData()
TArray< int32 > TrisLengths
FORCEINLINE void removeVerts(int32 start, int32 len, int32 trisStart)
FRuntimeMeshDataStruct< VertexType, TriangleType > MeshType
FORCEINLINE Datastruct GetMeshHit(TriangleType tris)
FORCEINLINE MeshType GetMeshAtIndex(int32 index)
FORCEINLINE MeshType GetMesh()