From 51de2c88f979b8f042df009e14ad287b74dace27 Mon Sep 17 00:00:00 2001 From: ikpil Date: Tue, 13 Jun 2023 00:40:03 +0900 Subject: [PATCH] changed m_sample -> _sample --- .../Tools/ConvexVolumeTool.cs | 10 ++-- src/DotRecast.Recast.Demo/Tools/CrowdTool.cs | 34 ++++++-------- .../Tools/DynamicUpdateTool.cs | 18 +++---- src/DotRecast.Recast.Demo/Tools/IRcTool.cs | 2 +- .../Tools/JumpLinkBuilderTool.cs | 14 +++--- .../Tools/OffMeshConnectionTool.cs | 18 +++---- .../Tools/TestNavmeshTool.cs | 47 ++++++++++--------- 7 files changed, 71 insertions(+), 72 deletions(-) diff --git a/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs b/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs index 70230be..dddc834 100644 --- a/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/ConvexVolumeTool.cs @@ -33,7 +33,7 @@ namespace DotRecast.Recast.Demo.Tools; public class ConvexVolumeTool : IRcTool { - private Sample sample; + private Sample _sample; private int areaTypeValue = SampleAreaModifications.SAMPLE_AREAMOD_GRASS.Value; private AreaModification areaType = SampleAreaModifications.SAMPLE_AREAMOD_GRASS; private float boxHeight = 6f; @@ -42,14 +42,14 @@ public class ConvexVolumeTool : IRcTool private readonly List pts = new(); private readonly List hull = new(); - public void SetSample(Sample m_sample) + public void SetSample(Sample sample) { - sample = m_sample; + _sample = sample; } public void HandleClick(RcVec3f s, RcVec3f p, bool shift) { - DemoInputGeomProvider geom = sample.GetInputGeom(); + DemoInputGeomProvider geom = _sample.GetInputGeom(); if (geom == null) { return; @@ -217,7 +217,7 @@ public class ConvexVolumeTool : IRcTool hull.Clear(); pts.Clear(); - DemoInputGeomProvider geom = sample.GetInputGeom(); + DemoInputGeomProvider geom = _sample.GetInputGeom(); if (geom != null) { geom.ClearConvexVolumes(); diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs index dfca2a8..5080fc1 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdTool.cs @@ -38,7 +38,7 @@ namespace DotRecast.Recast.Demo.Tools; public class CrowdTool : IRcTool { private readonly CrowdToolParams toolParams = new CrowdToolParams(); - private Sample sample; + private Sample _sample; private DtNavMesh m_nav; private DtCrowd crowd; private readonly CrowdProfilingTool profilingTool; @@ -57,20 +57,16 @@ public class CrowdTool : IRcTool profilingTool = new CrowdProfilingTool(GetAgentParams); } - public void SetSample(Sample psample) + public void SetSample(Sample sample) { - if (sample != psample) - { - sample = psample; - } - - DtNavMesh nav = sample.GetNavMesh(); + _sample = sample; + DtNavMesh nav = _sample.GetNavMesh(); if (nav != null && m_nav != nav) { m_nav = nav; - DtCrowdConfig config = new DtCrowdConfig(sample.GetSettings().agentRadius); + DtCrowdConfig config = new DtCrowdConfig(_sample.GetSettings().agentRadius); crowd = new DtCrowd(config, nav, __ => new DtQueryDefaultFilter(SampleAreaModifications.SAMPLE_POLYFLAGS_ALL, SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED, new float[] { 1f, 10f, 1f, 1f, 2f, 1.5f })); @@ -108,7 +104,7 @@ public class CrowdTool : IRcTool crowd.SetObstacleAvoidanceParams(3, option); - profilingTool.Setup(sample.GetSettings().agentRadius, m_nav); + profilingTool.Setup(_sample.GetSettings().agentRadius, m_nav); } } @@ -153,8 +149,8 @@ public class CrowdTool : IRcTool } else if (m_mode == CrowdToolMode.TOGGLE_POLYS) { - DtNavMesh nav = sample.GetNavMesh(); - DtNavMeshQuery navquery = sample.GetNavMeshQuery(); + DtNavMesh nav = _sample.GetNavMesh(); + DtNavMeshQuery navquery = _sample.GetNavMeshQuery(); if (nav != null && navquery != null) { IDtQueryFilter filter = new DtQueryDefaultFilter(); @@ -211,8 +207,8 @@ public class CrowdTool : IRcTool private DtCrowdAgentParams GetAgentParams() { DtCrowdAgentParams ap = new DtCrowdAgentParams(); - ap.radius = sample.GetSettings().agentRadius; - ap.height = sample.GetSettings().agentHeight; + ap.radius = _sample.GetSettings().agentRadius; + ap.height = _sample.GetSettings().agentHeight; ap.maxAcceleration = 8.0f; ap.maxSpeed = 3.5f; ap.collisionQueryRange = ap.radius * 12.0f; @@ -261,11 +257,11 @@ public class CrowdTool : IRcTool private void SetMoveTarget(RcVec3f p, bool adjust) { - if (sample == null || crowd == null) + if (_sample == null || crowd == null) return; // Find nearest point on navmesh and set move request to that location. - DtNavMeshQuery navquery = sample.GetNavMeshQuery(); + DtNavMeshQuery navquery = _sample.GetNavMeshQuery(); IDtQueryFilter filter = crowd.GetFilter(0); RcVec3f halfExtents = crowd.GetQueryExtents(); @@ -320,8 +316,8 @@ public class CrowdTool : IRcTool } RecastDebugDraw dd = renderer.GetDebugDraw(); - float rad = sample.GetSettings().agentRadius; - DtNavMesh nav = sample.GetNavMesh(); + float rad = _sample.GetSettings().agentRadius; + DtNavMesh nav = _sample.GetNavMesh(); if (nav == null || crowd == null) return; @@ -633,7 +629,7 @@ public class CrowdTool : IRcTool if (crowd == null) return; - DtNavMesh nav = sample.GetNavMesh(); + DtNavMesh nav = _sample.GetNavMesh(); if (nav == null) return; diff --git a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs index 26ca8aa..968cae8 100644 --- a/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/DynamicUpdateTool.cs @@ -40,7 +40,7 @@ namespace DotRecast.Recast.Demo.Tools; public class DynamicUpdateTool : IRcTool { - private Sample sample; + private Sample _sample; private int toolModeIdx = DynamicUpdateToolMode.BUILD.Idx; private DynamicUpdateToolMode mode = DynamicUpdateToolMode.BUILD; private float cellSize = 0.3f; @@ -95,7 +95,7 @@ public class DynamicUpdateTool : IRcTool public void SetSample(Sample sample) { - this.sample = sample; + _sample = sample; } public void HandleClick(RcVec3f s, RcVec3f p, bool shift) @@ -432,9 +432,9 @@ public class DynamicUpdateTool : IRcTool private void DrawAgent(RecastDebugDraw dd, RcVec3f pos, int col) { - float r = sample.GetSettings().agentRadius; - float h = sample.GetSettings().agentHeight; - float c = sample.GetSettings().agentMaxClimb; + float r = _sample.GetSettings().agentRadius; + float h = _sample.GetSettings().agentHeight; + float c = _sample.GetSettings().agentMaxClimb; dd.DepthMask(false); // Agent dimensions. dd.DebugDrawCylinderWire(pos.x - r, pos.y + 0.02f, pos.z - r, pos.x + r, pos.y + h, pos.z + r, col, 2.0f); @@ -468,8 +468,8 @@ public class DynamicUpdateTool : IRcTool if (updated) { buildTime = (RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond; - sample.Update(null, dynaMesh.RecastResults(), dynaMesh.NavMesh()); - sample.SetChanged(false); + _sample.Update(null, dynaMesh.RecastResults(), dynaMesh.NavMesh()); + _sample.SetChanged(false); } } catch (Exception e) @@ -600,7 +600,7 @@ public class DynamicUpdateTool : IRcTool if (dynaMesh != null) { BuildDynaMesh(); - sample.SetChanged(false); + _sample.SetChanged(false); } } } @@ -701,7 +701,7 @@ public class DynamicUpdateTool : IRcTool } buildTime = (RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond; - sample.Update(null, dynaMesh.RecastResults(), dynaMesh.NavMesh()); + _sample.Update(null, dynaMesh.RecastResults(), dynaMesh.NavMesh()); } private void ConfigDynaMesh() diff --git a/src/DotRecast.Recast.Demo/Tools/IRcTool.cs b/src/DotRecast.Recast.Demo/Tools/IRcTool.cs index 3b946fd..60072b6 100644 --- a/src/DotRecast.Recast.Demo/Tools/IRcTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/IRcTool.cs @@ -29,7 +29,7 @@ public interface IRcTool string GetName(); void Layout(); - void SetSample(Sample m_sample); + void SetSample(Sample sample); void HandleClick(RcVec3f s, RcVec3f p, bool shift); diff --git a/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs b/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs index d5bbd20..df06c4b 100644 --- a/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/JumpLinkBuilderTool.cs @@ -33,14 +33,14 @@ namespace DotRecast.Recast.Demo.Tools; public class JumpLinkBuilderTool : IRcTool { private readonly List links = new(); - private Sample sample; + private Sample _sample; private JumpLinkBuilder annotationBuilder; private readonly int selEdge = -1; private readonly JumpLinkBuilderToolParams option = new JumpLinkBuilderToolParams(); public void SetSample(Sample sample) { - this.sample = sample; + _sample = sample; annotationBuilder = null; } @@ -325,7 +325,7 @@ public class JumpLinkBuilderTool : IRcTool public void Layout() { - if (0 >= sample.GetRecastResults().Count) + if (0 >= _sample.GetRecastResults().Count) return; ImGui.Text("Options"); @@ -370,16 +370,16 @@ public class JumpLinkBuilderTool : IRcTool { if (annotationBuilder == null) { - if (sample != null && 0 < sample.GetRecastResults().Count) + if (_sample != null && 0 < _sample.GetRecastResults().Count) { - annotationBuilder = new JumpLinkBuilder(sample.GetRecastResults()); + annotationBuilder = new JumpLinkBuilder(_sample.GetRecastResults()); } } links.Clear(); if (annotationBuilder != null) { - var settings = sample.GetSettings(); + var settings = _sample.GetSettings(); float cellSize = settings.cellSize; float agentHeight = settings.agentHeight; float agentRadius = settings.agentRadius; @@ -406,7 +406,7 @@ public class JumpLinkBuilderTool : IRcTool if (buildOffMeshConnections) { - DemoInputGeomProvider geom = sample.GetInputGeom(); + DemoInputGeomProvider geom = _sample.GetInputGeom(); if (geom != null) { int area = SampleAreaModifications.SAMPLE_POLYAREA_TYPE_JUMP_AUTO; diff --git a/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs b/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs index de5d117..1c0837b 100644 --- a/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/OffMeshConnectionTool.cs @@ -31,19 +31,19 @@ namespace DotRecast.Recast.Demo.Tools; public class OffMeshConnectionTool : IRcTool { - private Sample sample; + private Sample _sample; private bool hitPosSet; private RcVec3f hitPos; private int bidir; - public void SetSample(Sample m_sample) + public void SetSample(Sample sample) { - sample = m_sample; + _sample = sample; } public void HandleClick(RcVec3f s, RcVec3f p, bool shift) { - DemoInputGeomProvider geom = sample.GetInputGeom(); + DemoInputGeomProvider geom = _sample.GetInputGeom(); if (geom == null) { return; @@ -58,7 +58,7 @@ public class OffMeshConnectionTool : IRcTool foreach (DemoOffMeshConnection offMeshCon in geom.GetOffMeshConnections()) { float d = Math.Min(RcVec3f.DistSqr(p, offMeshCon.verts, 0), RcVec3f.DistSqr(p, offMeshCon.verts, 3)); - if (d < nearestDist && Math.Sqrt(d) < sample.GetSettings().agentRadius) + if (d < nearestDist && Math.Sqrt(d) < _sample.GetSettings().agentRadius) { nearestDist = d; nearestConnection = offMeshCon; @@ -82,7 +82,7 @@ public class OffMeshConnectionTool : IRcTool { int area = SampleAreaModifications.SAMPLE_POLYAREA_TYPE_JUMP; int flags = SampleAreaModifications.SAMPLE_POLYFLAGS_JUMP; - geom.AddOffMeshConnection(hitPos, p, sample.GetSettings().agentRadius, 0 == bidir, area, flags); + geom.AddOffMeshConnection(hitPos, p, _sample.GetSettings().agentRadius, 0 == bidir, area, flags); hitPosSet = false; } } @@ -90,20 +90,20 @@ public class OffMeshConnectionTool : IRcTool public void HandleRender(NavMeshRenderer renderer) { - if (sample == null) + if (_sample == null) { return; } RecastDebugDraw dd = renderer.GetDebugDraw(); - float s = sample.GetSettings().agentRadius; + float s = _sample.GetSettings().agentRadius; if (hitPosSet) { dd.DebugDrawCross(hitPos.x, hitPos.y + 0.1f, hitPos.z, s, DuRGBA(0, 0, 0, 128), 2.0f); } - DemoInputGeomProvider geom = sample.GetInputGeom(); + DemoInputGeomProvider geom = _sample.GetInputGeom(); if (geom != null) { renderer.DrawOffMeshConnections(geom, true); diff --git a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs index cc5bae4..cf4dde3 100644 --- a/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/TestNavmeshTool.cs @@ -18,7 +18,7 @@ public class TestNavmeshTool : IRcTool private const int MAX_POLYS = 256; private const int MAX_SMOOTH = 2048; - private Sample m_sample; + private Sample _sample; private int m_toolModeIdx = TestNavmeshToolMode.PATHFIND_FOLLOW.Idx; private TestNavmeshToolMode m_toolMode => TestNavmeshToolMode.Values[m_toolModeIdx]; @@ -51,13 +51,16 @@ public class TestNavmeshTool : IRcTool public TestNavmeshTool() { - m_filter = new DtQueryDefaultFilter(SampleAreaModifications.SAMPLE_POLYFLAGS_ALL, - SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED, new float[] { 1f, 1f, 1f, 1f, 2f, 1.5f }); + m_filter = new DtQueryDefaultFilter( + SampleAreaModifications.SAMPLE_POLYFLAGS_ALL, + SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED, + new float[] { 1f, 1f, 1f, 1f, 2f, 1.5f } + ); } - public void SetSample(Sample m_sample) + public void SetSample(Sample sample) { - this.m_sample = m_sample; + _sample = sample; } public void HandleClick(RcVec3f s, RcVec3f p, bool shift) @@ -161,12 +164,12 @@ public class TestNavmeshTool : IRcTool private void Recalc() { - if (m_sample.GetNavMesh() == null) + if (_sample.GetNavMesh() == null) { return; } - DtNavMeshQuery m_navQuery = m_sample.GetNavMeshQuery(); + DtNavMeshQuery m_navQuery = _sample.GetNavMeshQuery(); if (m_sposSet) { m_navQuery.FindNearestPoly(m_spos, m_polyPickExt, m_filter, out m_startRef, out var _, out var _); @@ -185,7 +188,7 @@ public class TestNavmeshTool : IRcTool m_endRef = 0; } - DtNavMesh m_navMesh = m_sample.GetNavMesh(); + DtNavMesh m_navMesh = _sample.GetNavMesh(); if (m_toolMode == TestNavmeshToolMode.PATHFIND_FOLLOW) { if (m_sposSet && m_eposSet && m_startRef != 0 && m_endRef != 0) @@ -239,7 +242,7 @@ public class TestNavmeshTool : IRcTool } RcVec3f moveTgt = RcVec3f.Mad(iterPos, delta, len); - + // Move m_navQuery.MoveAlongSurface(polys[0], iterPos, moveTgt, m_filter, out var result, out var visited); @@ -435,7 +438,7 @@ public class TestNavmeshTool : IRcTool { float nx = (m_epos.z - m_spos.z) * 0.25f; float nz = -(m_epos.x - m_spos.x) * 0.25f; - float agentHeight = m_sample != null ? m_sample.GetSettings().agentHeight : 0; + float agentHeight = _sample != null ? _sample.GetSettings().agentHeight : 0; m_queryPoly[0] = m_spos.x + nx * 1.2f; m_queryPoly[1] = m_spos.y + agentHeight / 2; @@ -465,7 +468,7 @@ public class TestNavmeshTool : IRcTool { if (m_sposSet && m_startRef != 0) { - m_neighbourhoodRadius = m_sample.GetSettings().agentRadius * 20.0f; + m_neighbourhoodRadius = _sample.GetSettings().agentRadius * 20.0f; Result result = m_navQuery.FindLocalNeighbourhood(m_startRef, m_spos, m_neighbourhoodRadius, m_filter); if (result.Succeeded()) @@ -502,7 +505,7 @@ public class TestNavmeshTool : IRcTool public void HandleRender(NavMeshRenderer renderer) { - if (m_sample == null) + if (_sample == null) { return; } @@ -512,9 +515,9 @@ public class TestNavmeshTool : IRcTool int endCol = DuRGBA(51, 102, 0, 129); int pathCol = DuRGBA(0, 0, 0, 64); - float agentRadius = m_sample.GetSettings().agentRadius; - float agentHeight = m_sample.GetSettings().agentHeight; - float agentClimb = m_sample.GetSettings().agentMaxClimb; + float agentRadius = _sample.GetSettings().agentRadius; + float agentHeight = _sample.GetSettings().agentHeight; + float agentClimb = _sample.GetSettings().agentMaxClimb; if (m_sposSet) { @@ -528,7 +531,7 @@ public class TestNavmeshTool : IRcTool dd.DepthMask(true); - DtNavMesh m_navMesh = m_sample.GetNavMesh(); + DtNavMesh m_navMesh = _sample.GetNavMesh(); if (m_navMesh == null) { return; @@ -831,9 +834,9 @@ public class TestNavmeshTool : IRcTool } dd.DepthMask(true); - if (m_sample.GetNavMeshQuery() != null) + if (_sample.GetNavMeshQuery() != null) { - Result result = m_sample.GetNavMeshQuery() + Result result = _sample.GetNavMeshQuery() .GetPolyWallSegments(m_polys[i], false, m_filter); if (result.Succeeded()) { @@ -923,9 +926,9 @@ public class TestNavmeshTool : IRcTool private void DrawAgent(RecastDebugDraw dd, RcVec3f pos, int col) { - float r = m_sample.GetSettings().agentRadius; - float h = m_sample.GetSettings().agentHeight; - float c = m_sample.GetSettings().agentMaxClimb; + float r = _sample.GetSettings().agentRadius; + float h = _sample.GetSettings().agentHeight; + float c = _sample.GetSettings().agentMaxClimb; dd.DepthMask(false); // Agent dimensions. dd.DebugDrawCylinderWire(pos.x - r, pos.y + 0.02f, pos.z - r, pos.x + r, pos.y + h, pos.z + r, col, 2.0f); @@ -971,7 +974,7 @@ public class TestNavmeshTool : IRcTool // TODO Auto-generated method stub if (m_toolMode == TestNavmeshToolMode.PATHFIND_SLICED) { - DtNavMeshQuery m_navQuery = m_sample.GetNavMeshQuery(); + DtNavMeshQuery m_navQuery = _sample.GetNavMeshQuery(); if (m_pathFindStatus.InProgress()) { m_pathFindStatus = m_navQuery.UpdateSlicedFindPath(1).status;