2020-02-06 14:37:16 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "NavMesh/RecastInternalDebugData.h"
|
2022-07-20 11:31:36 -04:00
|
|
|
|
|
|
|
|
#include "HAL/PlatformCrt.h"
|
|
|
|
|
#include "Misc/AssertionMacros.h"
|
|
|
|
|
#include "NavMesh/RecastHelpers.h"
|
2020-02-06 14:37:16 -05:00
|
|
|
|
2023-08-02 16:01:19 -04:00
|
|
|
#if WITH_RECAST
|
|
|
|
|
|
|
|
|
|
#include "DebugUtils/DebugDraw.h"
|
|
|
|
|
|
2021-10-27 15:14:40 -04:00
|
|
|
void FRecastInternalDebugData::vertex(const FVector::FReal x, const FVector::FReal y, const FVector::FReal z, unsigned int color, const FVector::FReal u, const FVector::FReal v)
|
2020-02-06 14:37:16 -05:00
|
|
|
{
|
2021-10-27 15:14:40 -04:00
|
|
|
FVector::FReal RecastPos[3] = { x,y,z };
|
2020-03-25 08:22:04 -04:00
|
|
|
const FVector Pos = Recast2UnrealPoint(RecastPos);
|
2021-10-25 09:55:19 -04:00
|
|
|
const FColor Color = Recast2UnrealColor(color);
|
2020-03-25 08:22:04 -04:00
|
|
|
switch(CurrentPrim)
|
|
|
|
|
{
|
|
|
|
|
case DU_DRAW_POINTS:
|
|
|
|
|
PointVertices.Push(Pos);
|
2021-10-25 09:55:19 -04:00
|
|
|
PointColors.Push(Color);
|
2020-03-25 08:22:04 -04:00
|
|
|
break;
|
|
|
|
|
case DU_DRAW_LINES:
|
|
|
|
|
LineVertices.Push(Pos);
|
2021-10-25 09:55:19 -04:00
|
|
|
LineColors.Push(Color);
|
2020-03-25 08:22:04 -04:00
|
|
|
break;
|
|
|
|
|
case DU_DRAW_TRIS:
|
|
|
|
|
// Fallthrough
|
|
|
|
|
case DU_DRAW_QUADS:
|
|
|
|
|
TriangleVertices.Push(Pos);
|
2021-10-25 09:55:19 -04:00
|
|
|
TriangleColors.Push(Color);
|
2020-03-25 08:22:04 -04:00
|
|
|
break;
|
|
|
|
|
}
|
2020-02-06 14:37:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FRecastInternalDebugData::end()
|
|
|
|
|
{
|
2020-03-25 08:22:04 -04:00
|
|
|
if (CurrentPrim == DU_DRAW_QUADS)
|
2020-02-06 14:37:16 -05:00
|
|
|
{
|
|
|
|
|
// Turns quads to triangles
|
2020-03-25 08:22:04 -04:00
|
|
|
for (int32 i = FirstVertexIndex; i < TriangleVertices.Num(); i += 4)
|
2020-02-06 14:37:16 -05:00
|
|
|
{
|
2020-03-25 08:22:04 -04:00
|
|
|
ensure(i + 3 < TriangleVertices.Num());
|
|
|
|
|
TriangleIndices.Push(i + 0);
|
|
|
|
|
TriangleIndices.Push(i + 1);
|
|
|
|
|
TriangleIndices.Push(i + 3);
|
2020-02-06 14:37:16 -05:00
|
|
|
|
2020-03-25 08:22:04 -04:00
|
|
|
TriangleIndices.Push(i + 3);
|
|
|
|
|
TriangleIndices.Push(i + 1);
|
|
|
|
|
TriangleIndices.Push(i + 2);
|
2020-02-06 14:37:16 -05:00
|
|
|
}
|
2020-03-25 08:22:04 -04:00
|
|
|
}
|
|
|
|
|
else if (CurrentPrim == DU_DRAW_TRIS)
|
|
|
|
|
{
|
|
|
|
|
// Add indices for triangles.
|
|
|
|
|
for (int32 i = FirstVertexIndex; i < TriangleVertices.Num(); i++)
|
2020-02-06 14:37:16 -05:00
|
|
|
{
|
2020-03-25 08:22:04 -04:00
|
|
|
TriangleIndices.Push(i);
|
2020-02-06 14:37:16 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-02 16:01:19 -04:00
|
|
|
#endif // WITH_RECAST
|