forked from mirror/DotRecast
failed to build navmesh in unity3d
This commit is contained in:
parent
eb8eaa1d36
commit
0ab618bc15
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue