failed to build navmesh in unity3d

This commit is contained in:
ikpil 2023-07-29 12:01:38 +09:00
parent eb8eaa1d36
commit 0ab618bc15
3 changed files with 27 additions and 1 deletions

View File

@ -687,6 +687,12 @@ public class RecastDemo : IRecastDemoChannel
buildResult = soloNavMeshBuilder.Build(_sample.GetInputGeom(), settings);
}
if (!buildResult.Success)
{
Logger.Error("failed to build");
return;
}
_sample.Update(_sample.GetInputGeom(), buildResult.RecastBuilderResults, buildResult.NavMesh);
_sample.SetChanged(false);
settingsView.SetBuildTime((RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond);

View File

@ -1,15 +1,25 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using DotRecast.Detour;
namespace DotRecast.Recast.DemoTool.Builder
{
public class NavMeshBuildResult
{
public readonly bool Success;
public readonly IList<RecastBuilderResult> RecastBuilderResults;
public readonly DtNavMesh NavMesh;
public NavMeshBuildResult()
{
Success = false;
RecastBuilderResults = Array.Empty<RecastBuilderResult>();
NavMesh = null;
}
public NavMeshBuildResult(IList<RecastBuilderResult> recastBuilderResults, DtNavMesh navMesh)
{
Success = true;
RecastBuilderResults = recastBuilderResults;
NavMesh = navMesh;
}

View File

@ -49,6 +49,11 @@ namespace DotRecast.Recast.DemoTool.Builder
filterWalkableLowHeightSpans);
var meshData = BuildMeshData(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, rcResult);
if (null == meshData)
{
return new NavMeshBuildResult();
}
var navMesh = BuildNavMesh(meshData, vertsPerPoly);
return new NavMeshBuildResult(ImmutableArray.Create(rcResult), navMesh);
}
@ -79,6 +84,11 @@ namespace DotRecast.Recast.DemoTool.Builder
DtNavMeshCreateParams option = DemoNavMeshBuilder
.GetNavMeshCreateParams(geom, cellSize, cellHeight, agentHeight, agentRadius, agentMaxClimb, result);
var meshData = NavMeshBuilder.CreateNavMeshData(option);
if (null == meshData)
{
return null;
}
return DemoNavMeshBuilder.UpdateAreaAndFlags(meshData);
}
}