Skip to content

Commit

Permalink
h8man#130 added option to call non-async versions of rebuild (also re…
Browse files Browse the repository at this point in the history
…named async one to include suffix async, so breaking change there...)
  • Loading branch information
mikaelhogstrom committed Mar 23, 2023
1 parent c7ea1f1 commit 87bcfa1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion NavMeshComponents/Editor/NavMeshAssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void StartBakingSurfaces(UnityEngine.Object[] surfaces)
var oper = new AsyncBakeOperation();

oper.bakeData = InitializeBakeData(surf);
oper.bakeOperation = surf.UpdateNavMesh(oper.bakeData);
oper.bakeOperation = surf.UpdateNavMeshAsync(oper.bakeData);
oper.surface = surf;

m_BakeOperations.Add(oper);
Expand Down
30 changes: 28 additions & 2 deletions NavMeshComponents/Scripts/NavMeshSurface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,36 @@ public AsyncOperation BuildNavMeshAsync()
AddData();
}

return UpdateNavMesh(m_NavMeshData);
return UpdateNavMeshAsync(m_NavMeshData);
}

public AsyncOperation UpdateNavMesh(NavMeshData data)
public void UpdateNavMesh()
{
UpdateNavMesh(navMeshData);
}

public void UpdateNavMesh(NavMeshData data)
{
using var builderState = new NavMeshBuilderState() { };

var sources = CollectSources(builderState);

// Use unscaled bounds - this differs in behaviour from e.g. collider components.
// But is similar to reflection probe - and since navmesh data has no scaling support - it is the right choice here.
var sourcesBounds = new Bounds(m_Center, Abs(m_Size));
if (m_CollectObjects == CollectObjects.All || m_CollectObjects == CollectObjects.Children)
{
sourcesBounds = CalculateWorldBounds(sources);
}
builderState.worldBounds = sourcesBounds;
for (int i = 0; i < NevMeshExtensions.Count; ++i)
{
NevMeshExtensions[i].PostCollectSources(this, sources, builderState);
}
NavMeshBuilder.UpdateNavMeshData(data, GetBuildSettings(), sources, sourcesBounds);
}

public AsyncOperation UpdateNavMeshAsync(NavMeshData data)
{
using var builderState = new NavMeshBuilderState() { };

Expand Down

0 comments on commit 87bcfa1

Please sign in to comment.