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); buildResult = soloNavMeshBuilder.Build(_sample.GetInputGeom(), settings);
} }
if (!buildResult.Success)
{
Logger.Error("failed to build");
return;
}
_sample.Update(_sample.GetInputGeom(), buildResult.RecastBuilderResults, buildResult.NavMesh); _sample.Update(_sample.GetInputGeom(), buildResult.RecastBuilderResults, buildResult.NavMesh);
_sample.SetChanged(false); _sample.SetChanged(false);
settingsView.SetBuildTime((RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond); 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; using DotRecast.Detour;
namespace DotRecast.Recast.DemoTool.Builder namespace DotRecast.Recast.DemoTool.Builder
{ {
public class NavMeshBuildResult public class NavMeshBuildResult
{ {
public readonly bool Success;
public readonly IList<RecastBuilderResult> RecastBuilderResults; public readonly IList<RecastBuilderResult> RecastBuilderResults;
public readonly DtNavMesh NavMesh; public readonly DtNavMesh NavMesh;
public NavMeshBuildResult()
{
Success = false;
RecastBuilderResults = Array.Empty<RecastBuilderResult>();
NavMesh = null;
}
public NavMeshBuildResult(IList<RecastBuilderResult> recastBuilderResults, DtNavMesh navMesh) public NavMeshBuildResult(IList<RecastBuilderResult> recastBuilderResults, DtNavMesh navMesh)
{ {
Success = true;
RecastBuilderResults = recastBuilderResults; RecastBuilderResults = recastBuilderResults;
NavMesh = navMesh; NavMesh = navMesh;
} }

View File

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