forked from bit/DotRecastNetSim
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);
|
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);
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue