Serialized navmesh props

This commit is contained in:
Antoine Pilote
2024-08-09 21:21:41 -04:00
parent 279588cad8
commit 275aad82b9
2 changed files with 43 additions and 8 deletions

View File

@@ -101,7 +101,7 @@ namespace Nuake {
float* verts = reinterpret_cast<float*>(vertices.data());
int* tris = reinterpret_cast<int*>(indices.data());
rcMarkWalkableTriangles(m_RecastContext.get(), 45.0f, verts, std::size(vertices), tris, std::size(indices) / 3, m_triareas);
rcMarkWalkableTriangles(m_RecastContext.get(), config.WalkableSlopeAngle, verts, std::size(vertices), tris, std::size(indices) / 3, m_triareas);
if (!rcRasterizeTriangles(m_RecastContext.get(), verts, std::size(vertices), tris, m_triareas, std::size(indices) / 3, *voxelHeightField, recastConfig.walkableClimb))
{
Logger::Log("buildNavigation: Could not rasterize triangles.", "NavManager", CRITICAL);
@@ -218,7 +218,6 @@ namespace Nuake {
params.detailVertsCount = detailMesh->nverts;
params.detailTris = detailMesh->tris;
params.detailTriCount = detailMesh->ntris;
// Off connection, might be useful for user defined jump points?
// Maybe useful for ziplines, scripted jumppad, idk
// See sample OffMeshConnectionTool.cpp in RecastDemo project.
@@ -231,12 +230,9 @@ namespace Nuake {
//params.offMeshConUserID = m_geom->getOffMeshConnectionId();
//params.offMeshConCount = m_geom->getOffMeshConnectionCount();
const float agentHeight = 0.5f;
const float agentRadius = 0.1f;
const float agentMaxClimb = 0.01f;
params.walkableHeight = agentHeight;
params.walkableRadius = agentRadius;
params.walkableClimb = agentMaxClimb;
params.walkableHeight = config.WalkableHeight;
params.walkableRadius = config.WalkableRadius;
params.walkableClimb = config.WalkableClimb;
rcVcopy(params.bmin, polygonMesh->bmin);
rcVcopy(params.bmax, polygonMesh->bmax);

View File

@@ -26,6 +26,10 @@ namespace Nuake
float DetailSampleDistance = 2.0f;
float DetailsampleMaxError = 1.0f;
float AgentHeight = 0.5f;
float AgentRadius = 0.1f;
float AgentMaxClimb = 0.01f;
Ref<NavMesh> NavMeshData;
json Serialize()
@@ -34,6 +38,24 @@ namespace Nuake
SERIALIZE_VEC3(VolumeSize);
SERIALIZE_VAL(OnlyIncludeMapGeometry);
SERIALIZE_VAL(CellSize);
SERIALIZE_VAL(CellHeight);
SERIALIZE_VAL(TileSize);
SERIALIZE_VAL(WalkableSlopeAngle);
SERIALIZE_VAL(MaxEdgeLength);
SERIALIZE_VAL(MaxVertsPerPoly);
SERIALIZE_VAL(WalkableHeight);
SERIALIZE_VAL(WalkableClimb);
SERIALIZE_VAL(WalkableRadius);
SERIALIZE_VAL(MaxSimplificationError);
SERIALIZE_VAL(MinRegionArea);
SERIALIZE_VAL(DetailSampleDistance);
SERIALIZE_VAL(DetailsampleMaxError);
SERIALIZE_VAL(AgentHeight);
SERIALIZE_VAL(AgentRadius);
SERIALIZE_VAL(AgentMaxClimb);
if (NavMeshData != nullptr)
{
SERIALIZE_OBJECT(NavMeshData);
@@ -55,6 +77,23 @@ namespace Nuake
DESERIALIZE_VAL(OnlyIncludeMapGeometry);
}
DESERIALIZE_VAL(CellSize);
DESERIALIZE_VAL(CellHeight);
DESERIALIZE_VAL(TileSize);
DESERIALIZE_VAL(WalkableSlopeAngle);
DESERIALIZE_VAL(MaxEdgeLength);
DESERIALIZE_VAL(MaxVertsPerPoly);
DESERIALIZE_VAL(WalkableHeight);
DESERIALIZE_VAL(WalkableClimb);
DESERIALIZE_VAL(WalkableRadius);
DESERIALIZE_VAL(MaxSimplificationError);
DESERIALIZE_VAL(MinRegionArea);
DESERIALIZE_VAL(DetailSampleDistance);
DESERIALIZE_VAL(DetailsampleMaxError);
DESERIALIZE_VAL(AgentHeight);
DESERIALIZE_VAL(AgentRadius);
DESERIALIZE_VAL(AgentMaxClimb);
if (j.contains("NavMeshData"))
{
NavMeshData = CreateRef<NavMesh>();