poly.GetType -> poly.GetPolyType

This commit is contained in:
ikpil 2023-07-04 00:09:07 +09:00
parent db64fbd047
commit 86ad3c4148
4 changed files with 42 additions and 42 deletions

View File

@ -40,7 +40,7 @@ namespace DotRecast.Detour.Extras.Unity.Astar
startTile.polys[poly] = new DtPoly(poly, 2); startTile.polys[poly] = new DtPoly(poly, 2);
startTile.polys[poly].verts[0] = startTile.header.vertCount; startTile.polys[poly].verts[0] = startTile.header.vertCount;
startTile.polys[poly].verts[1] = startTile.header.vertCount + 1; startTile.polys[poly].verts[1] = startTile.header.vertCount + 1;
startTile.polys[poly].SetType(DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION); startTile.polys[poly].SetPolyType(DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION);
startTile.verts = RcArrayUtils.CopyOf(startTile.verts, startTile.verts.Length + 6); startTile.verts = RcArrayUtils.CopyOf(startTile.verts, startTile.verts.Length + 6);
startTile.header.polyCount++; startTile.header.polyCount++;
startTile.header.vertCount += 2; startTile.header.vertCount += 2;

View File

@ -64,7 +64,7 @@ namespace DotRecast.Detour
} }
/** Sets the polygon type. (See: #dtPolyTypes.) */ /** Sets the polygon type. (See: #dtPolyTypes.) */
public void SetType(int t) public void SetPolyType(int t)
{ {
areaAndtype = (areaAndtype & 0x3f) | (t << 6); areaAndtype = (areaAndtype & 0x3f) | (t << 6);
} }

View File

@ -487,7 +487,7 @@ namespace DotRecast.Detour
p.vertCount = 0; p.vertCount = 0;
p.flags = option.polyFlags[i]; p.flags = option.polyFlags[i];
p.SetArea(option.polyAreas[i]); p.SetArea(option.polyAreas[i]);
p.SetType(DtPoly.DT_POLYTYPE_GROUND); p.SetPolyType(DtPoly.DT_POLYTYPE_GROUND);
for (int j = 0; j < nvp; ++j) for (int j = 0; j < nvp; ++j)
{ {
if (option.polys[src + j] == MESH_NULL_IDX) if (option.polys[src + j] == MESH_NULL_IDX)
@ -534,7 +534,7 @@ namespace DotRecast.Detour
p.verts[1] = offMeshVertsBase + n * 2 + 1; p.verts[1] = offMeshVertsBase + n * 2 + 1;
p.flags = option.offMeshConFlags[i]; p.flags = option.offMeshConFlags[i];
p.SetArea(option.offMeshConAreas[i]); p.SetArea(option.offMeshConAreas[i]);
p.SetType(DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION); p.SetPolyType(DtPoly.DT_POLYTYPE_OFFMESH_CONNECTION);
n++; n++;
} }
} }

View File

@ -73,7 +73,7 @@ public class RecastDemo : IRecastDemoChannel
private readonly TileNavMeshBuilder tileNavMeshBuilder = new TileNavMeshBuilder(); private readonly TileNavMeshBuilder tileNavMeshBuilder = new TileNavMeshBuilder();
private string _lastGeomFileName; private string _lastGeomFileName;
private Sample sample; private Sample _sample;
private bool processHitTest = false; private bool processHitTest = false;
private bool processHitTestShift; private bool processHitTestShift;
@ -324,7 +324,7 @@ public class RecastDemo : IRecastDemoChannel
if (null != mesh) if (null != mesh)
{ {
sample.Update(sample.GetInputGeom(), ImmutableArray<RecastBuilderResult>.Empty, mesh); _sample.Update(_sample.GetInputGeom(), ImmutableArray<RecastBuilderResult>.Empty, mesh);
toolset.SetEnabled(true); toolset.SetEnabled(true);
} }
} }
@ -375,10 +375,10 @@ public class RecastDemo : IRecastDemoChannel
_imgui = new ImGuiController(_gl, window, _input, imGuiFontConfig); _imgui = new ImGuiController(_gl, window, _input, imGuiFontConfig);
DemoInputGeomProvider geom = LoadInputMesh("nav_test.obj"); DemoInputGeomProvider geom = LoadInputMesh("nav_test.obj");
sample = new Sample(geom, ImmutableArray<RecastBuilderResult>.Empty, null); _sample = new Sample(geom, ImmutableArray<RecastBuilderResult>.Empty, null);
settingsView = new RcSettingsView(this); settingsView = new RcSettingsView(this);
settingsView.SetSample(sample); settingsView.SetSample(_sample);
toolset = new RcToolsetView( toolset = new RcToolsetView(
new TestNavmeshTool(), new TestNavmeshTool(),
@ -444,16 +444,16 @@ public class RecastDemo : IRecastDemoChannel
* try (MemoryStack stack = StackPush()) { int[] w = stack.MallocInt(1); int[] h = * try (MemoryStack stack = StackPush()) { int[] w = stack.MallocInt(1); int[] h =
* stack.MallocInt(1); GlfwGetWindowSize(win, w, h); width = w.x; height = h.x; } * stack.MallocInt(1); GlfwGetWindowSize(win, w, h); width = w.x; height = h.x; }
*/ */
if (sample.GetInputGeom() != null) if (_sample.GetInputGeom() != null)
{ {
var settings = sample.GetSettings(); var settings = _sample.GetSettings();
RcVec3f bmin = sample.GetInputGeom().GetMeshBoundsMin(); RcVec3f bmin = _sample.GetInputGeom().GetMeshBoundsMin();
RcVec3f bmax = sample.GetInputGeom().GetMeshBoundsMax(); RcVec3f bmax = _sample.GetInputGeom().GetMeshBoundsMax();
Recast.CalcGridSize(bmin, bmax, settings.cellSize, out var gw, out var gh); Recast.CalcGridSize(bmin, bmax, settings.cellSize, out var gw, out var gh);
settingsView.SetVoxels(gw, gh); settingsView.SetVoxels(gw, gh);
settingsView.SetTiles(tileNavMeshBuilder.GetTiles(sample.GetInputGeom(), settings.cellSize, settings.tileSize)); settingsView.SetTiles(tileNavMeshBuilder.GetTiles(_sample.GetInputGeom(), settings.cellSize, settings.tileSize));
settingsView.SetMaxTiles(tileNavMeshBuilder.GetMaxTiles(sample.GetInputGeom(), settings.cellSize, settings.tileSize)); settingsView.SetMaxTiles(tileNavMeshBuilder.GetMaxTiles(_sample.GetInputGeom(), settings.cellSize, settings.tileSize));
settingsView.SetMaxPolys(tileNavMeshBuilder.GetMaxPolysPerTile(sample.GetInputGeom(), settings.cellSize, settings.tileSize)); settingsView.SetMaxPolys(tileNavMeshBuilder.GetMaxPolysPerTile(_sample.GetInputGeom(), settings.cellSize, settings.tileSize));
} }
UpdateKeyboard((float)dt); UpdateKeyboard((float)dt);
@ -490,7 +490,7 @@ public class RecastDemo : IRecastDemoChannel
while (timeAcc > DELTA_TIME) while (timeAcc > DELTA_TIME)
{ {
timeAcc -= DELTA_TIME; timeAcc -= DELTA_TIME;
if (simIter < 5 && sample != null) if (simIter < 5 && _sample != null)
{ {
toolset.HandleUpdate(DELTA_TIME); toolset.HandleUpdate(DELTA_TIME);
} }
@ -515,24 +515,24 @@ public class RecastDemo : IRecastDemoChannel
}); });
} }
if (sample.IsChanged()) if (_sample.IsChanged())
{ {
RcVec3f? bminN = null; RcVec3f? bminN = null;
RcVec3f? bmaxN = null; RcVec3f? bmaxN = null;
if (sample.GetInputGeom() != null) if (_sample.GetInputGeom() != null)
{ {
bminN = sample.GetInputGeom().GetMeshBoundsMin(); bminN = _sample.GetInputGeom().GetMeshBoundsMin();
bmaxN = sample.GetInputGeom().GetMeshBoundsMax(); bmaxN = _sample.GetInputGeom().GetMeshBoundsMax();
} }
else if (sample.GetNavMesh() != null) else if (_sample.GetNavMesh() != null)
{ {
RcVec3f[] bounds = NavMeshUtils.GetNavMeshBounds(sample.GetNavMesh()); RcVec3f[] bounds = NavMeshUtils.GetNavMeshBounds(_sample.GetNavMesh());
bminN = bounds[0]; bminN = bounds[0];
bmaxN = bounds[1]; bmaxN = bounds[1];
} }
else if (0 < sample.GetRecastResults().Count) else if (0 < _sample.GetRecastResults().Count)
{ {
foreach (RecastBuilderResult result in sample.GetRecastResults()) foreach (RecastBuilderResult result in _sample.GetRecastResults())
{ {
if (result.GetSolidHeightfield() != null) if (result.GetSolidHeightfield() != null)
{ {
@ -573,8 +573,8 @@ public class RecastDemo : IRecastDemoChannel
cameraEulers[1] = -45; cameraEulers[1] = -45;
} }
sample.SetChanged(false); _sample.SetChanged(false);
toolset.SetSample(sample); toolset.SetSample(_sample);
} }
if (_messages.TryDequeue(out var msg)) if (_messages.TryDequeue(out var msg))
@ -601,7 +601,7 @@ public class RecastDemo : IRecastDemoChannel
modelviewMatrix = dd.ViewMatrix(cameraPos, cameraEulers); modelviewMatrix = dd.ViewMatrix(cameraPos, cameraEulers);
dd.Fog(camr * 0.1f, camr * 1.25f); dd.Fog(camr * 0.1f, camr * 1.25f);
renderer.Render(sample, settingsView.GetDrawMode()); renderer.Render(_sample, settingsView.GetDrawMode());
IRcTool tool = toolset.GetTool(); IRcTool tool = toolset.GetTool();
if (tool != null) if (tool != null)
@ -652,18 +652,18 @@ public class RecastDemo : IRecastDemoChannel
{ {
var geom = LoadInputMesh(args.FilePath); var geom = LoadInputMesh(args.FilePath);
sample.Update(geom, ImmutableArray<RecastBuilderResult>.Empty, null); _sample.Update(geom, ImmutableArray<RecastBuilderResult>.Empty, null);
} }
private void OnNavMeshBuildBegan(NavMeshBuildBeganEvent args) private void OnNavMeshBuildBegan(NavMeshBuildBeganEvent args)
{ {
if (null == sample.GetInputGeom()) if (null == _sample.GetInputGeom())
{ {
Logger.Information($"not found source geom"); Logger.Information($"not found source geom");
return; return;
} }
var settings = sample.GetSettings(); var settings = _sample.GetSettings();
var partitioning = settings.partitioning; var partitioning = settings.partitioning;
var cellSize = settings.cellSize; var cellSize = settings.cellSize;
var cellHeight = settings.cellHeight; var cellHeight = settings.cellHeight;
@ -691,7 +691,7 @@ public class RecastDemo : IRecastDemoChannel
if (settings.tiled) if (settings.tiled)
{ {
buildResult = tileNavMeshBuilder.Build( buildResult = tileNavMeshBuilder.Build(
sample.GetInputGeom(), _sample.GetInputGeom(),
partitioning, partitioning,
cellSize, cellSize,
cellHeight, cellHeight,
@ -715,7 +715,7 @@ public class RecastDemo : IRecastDemoChannel
else else
{ {
buildResult = soloNavMeshBuilder.Build( buildResult = soloNavMeshBuilder.Build(
sample.GetInputGeom(), _sample.GetInputGeom(),
partitioning, partitioning,
cellSize, cellSize,
cellHeight, cellHeight,
@ -736,11 +736,11 @@ public class RecastDemo : IRecastDemoChannel
); );
} }
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);
//settingsUI.SetBuildTelemetry(buildResult.Item1.Select(x => x.GetTelemetry()).ToList()); //settingsUI.SetBuildTelemetry(buildResult.Item1.Select(x => x.GetTelemetry()).ToList());
toolset.SetSample(sample); toolset.SetSample(_sample);
Logger.Information($"build times"); Logger.Information($"build times");
Logger.Information($"-----------------------------------------"); Logger.Information($"-----------------------------------------");
@ -758,7 +758,7 @@ public class RecastDemo : IRecastDemoChannel
private void OnNavMeshSaveBegan(NavMeshSaveBeganEvent args) private void OnNavMeshSaveBegan(NavMeshSaveBeganEvent args)
{ {
var navMesh = sample.GetNavMesh(); var navMesh = _sample.GetNavMesh();
if (null == navMesh) if (null == navMesh)
{ {
Logger.Error("navmesh is null"); Logger.Error("navmesh is null");
@ -809,8 +809,8 @@ public class RecastDemo : IRecastDemoChannel
var rayEnd = args.End; var rayEnd = args.End;
// Hit test mesh. // Hit test mesh.
DemoInputGeomProvider inputGeom = sample.GetInputGeom(); DemoInputGeomProvider inputGeom = _sample.GetInputGeom();
if (sample == null) if (_sample == null)
return; return;
float? hit = null; float? hit = null;
@ -819,14 +819,14 @@ public class RecastDemo : IRecastDemoChannel
hit = inputGeom.RaycastMesh(rayStart, rayEnd); hit = inputGeom.RaycastMesh(rayStart, rayEnd);
} }
if (!hit.HasValue && sample.GetNavMesh() != null) if (!hit.HasValue && _sample.GetNavMesh() != null)
{ {
hit = NavMeshRaycast.Raycast(sample.GetNavMesh(), rayStart, rayEnd); hit = NavMeshRaycast.Raycast(_sample.GetNavMesh(), rayStart, rayEnd);
} }
if (!hit.HasValue && sample.GetRecastResults() != null) if (!hit.HasValue && _sample.GetRecastResults() != null)
{ {
hit = PolyMeshRaycast.Raycast(sample.GetRecastResults(), rayStart, rayEnd); hit = PolyMeshRaycast.Raycast(_sample.GetRecastResults(), rayStart, rayEnd);
} }
RcVec3f rayDir = RcVec3f.Of(rayEnd.x - rayStart.x, rayEnd.y - rayStart.y, rayEnd.z - rayStart.z); RcVec3f rayDir = RcVec3f.Of(rayEnd.x - rayStart.x, rayEnd.y - rayStart.y, rayEnd.z - rayStart.z);