forked from mirror/DotRecast
changed m_sample -> _sample
This commit is contained in:
parent
ba1bdb0295
commit
51de2c88f9
|
@ -33,7 +33,7 @@ namespace DotRecast.Recast.Demo.Tools;
|
||||||
|
|
||||||
public class ConvexVolumeTool : IRcTool
|
public class ConvexVolumeTool : IRcTool
|
||||||
{
|
{
|
||||||
private Sample sample;
|
private Sample _sample;
|
||||||
private int areaTypeValue = SampleAreaModifications.SAMPLE_AREAMOD_GRASS.Value;
|
private int areaTypeValue = SampleAreaModifications.SAMPLE_AREAMOD_GRASS.Value;
|
||||||
private AreaModification areaType = SampleAreaModifications.SAMPLE_AREAMOD_GRASS;
|
private AreaModification areaType = SampleAreaModifications.SAMPLE_AREAMOD_GRASS;
|
||||||
private float boxHeight = 6f;
|
private float boxHeight = 6f;
|
||||||
|
@ -42,14 +42,14 @@ public class ConvexVolumeTool : IRcTool
|
||||||
private readonly List<float> pts = new();
|
private readonly List<float> pts = new();
|
||||||
private readonly List<int> hull = new();
|
private readonly List<int> 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)
|
public void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||||
{
|
{
|
||||||
DemoInputGeomProvider geom = sample.GetInputGeom();
|
DemoInputGeomProvider geom = _sample.GetInputGeom();
|
||||||
if (geom == null)
|
if (geom == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -217,7 +217,7 @@ public class ConvexVolumeTool : IRcTool
|
||||||
hull.Clear();
|
hull.Clear();
|
||||||
pts.Clear();
|
pts.Clear();
|
||||||
|
|
||||||
DemoInputGeomProvider geom = sample.GetInputGeom();
|
DemoInputGeomProvider geom = _sample.GetInputGeom();
|
||||||
if (geom != null)
|
if (geom != null)
|
||||||
{
|
{
|
||||||
geom.ClearConvexVolumes();
|
geom.ClearConvexVolumes();
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace DotRecast.Recast.Demo.Tools;
|
||||||
public class CrowdTool : IRcTool
|
public class CrowdTool : IRcTool
|
||||||
{
|
{
|
||||||
private readonly CrowdToolParams toolParams = new CrowdToolParams();
|
private readonly CrowdToolParams toolParams = new CrowdToolParams();
|
||||||
private Sample sample;
|
private Sample _sample;
|
||||||
private DtNavMesh m_nav;
|
private DtNavMesh m_nav;
|
||||||
private DtCrowd crowd;
|
private DtCrowd crowd;
|
||||||
private readonly CrowdProfilingTool profilingTool;
|
private readonly CrowdProfilingTool profilingTool;
|
||||||
|
@ -57,20 +57,16 @@ public class CrowdTool : IRcTool
|
||||||
profilingTool = new CrowdProfilingTool(GetAgentParams);
|
profilingTool = new CrowdProfilingTool(GetAgentParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSample(Sample psample)
|
public void SetSample(Sample sample)
|
||||||
{
|
{
|
||||||
if (sample != psample)
|
_sample = sample;
|
||||||
{
|
DtNavMesh nav = _sample.GetNavMesh();
|
||||||
sample = psample;
|
|
||||||
}
|
|
||||||
|
|
||||||
DtNavMesh nav = sample.GetNavMesh();
|
|
||||||
|
|
||||||
if (nav != null && m_nav != nav)
|
if (nav != null && m_nav != nav)
|
||||||
{
|
{
|
||||||
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,
|
crowd = new DtCrowd(config, nav, __ => new DtQueryDefaultFilter(SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
|
||||||
SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED, new float[] { 1f, 10f, 1f, 1f, 2f, 1.5f }));
|
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);
|
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)
|
else if (m_mode == CrowdToolMode.TOGGLE_POLYS)
|
||||||
{
|
{
|
||||||
DtNavMesh nav = sample.GetNavMesh();
|
DtNavMesh nav = _sample.GetNavMesh();
|
||||||
DtNavMeshQuery navquery = sample.GetNavMeshQuery();
|
DtNavMeshQuery navquery = _sample.GetNavMeshQuery();
|
||||||
if (nav != null && navquery != null)
|
if (nav != null && navquery != null)
|
||||||
{
|
{
|
||||||
IDtQueryFilter filter = new DtQueryDefaultFilter();
|
IDtQueryFilter filter = new DtQueryDefaultFilter();
|
||||||
|
@ -211,8 +207,8 @@ public class CrowdTool : IRcTool
|
||||||
private DtCrowdAgentParams GetAgentParams()
|
private DtCrowdAgentParams GetAgentParams()
|
||||||
{
|
{
|
||||||
DtCrowdAgentParams ap = new DtCrowdAgentParams();
|
DtCrowdAgentParams ap = new DtCrowdAgentParams();
|
||||||
ap.radius = sample.GetSettings().agentRadius;
|
ap.radius = _sample.GetSettings().agentRadius;
|
||||||
ap.height = sample.GetSettings().agentHeight;
|
ap.height = _sample.GetSettings().agentHeight;
|
||||||
ap.maxAcceleration = 8.0f;
|
ap.maxAcceleration = 8.0f;
|
||||||
ap.maxSpeed = 3.5f;
|
ap.maxSpeed = 3.5f;
|
||||||
ap.collisionQueryRange = ap.radius * 12.0f;
|
ap.collisionQueryRange = ap.radius * 12.0f;
|
||||||
|
@ -261,11 +257,11 @@ public class CrowdTool : IRcTool
|
||||||
|
|
||||||
private void SetMoveTarget(RcVec3f p, bool adjust)
|
private void SetMoveTarget(RcVec3f p, bool adjust)
|
||||||
{
|
{
|
||||||
if (sample == null || crowd == null)
|
if (_sample == null || crowd == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Find nearest point on navmesh and set move request to that location.
|
// 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);
|
IDtQueryFilter filter = crowd.GetFilter(0);
|
||||||
RcVec3f halfExtents = crowd.GetQueryExtents();
|
RcVec3f halfExtents = crowd.GetQueryExtents();
|
||||||
|
|
||||||
|
@ -320,8 +316,8 @@ public class CrowdTool : IRcTool
|
||||||
}
|
}
|
||||||
|
|
||||||
RecastDebugDraw dd = renderer.GetDebugDraw();
|
RecastDebugDraw dd = renderer.GetDebugDraw();
|
||||||
float rad = sample.GetSettings().agentRadius;
|
float rad = _sample.GetSettings().agentRadius;
|
||||||
DtNavMesh nav = sample.GetNavMesh();
|
DtNavMesh nav = _sample.GetNavMesh();
|
||||||
if (nav == null || crowd == null)
|
if (nav == null || crowd == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -633,7 +629,7 @@ public class CrowdTool : IRcTool
|
||||||
|
|
||||||
if (crowd == null)
|
if (crowd == null)
|
||||||
return;
|
return;
|
||||||
DtNavMesh nav = sample.GetNavMesh();
|
DtNavMesh nav = _sample.GetNavMesh();
|
||||||
if (nav == null)
|
if (nav == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace DotRecast.Recast.Demo.Tools;
|
||||||
|
|
||||||
public class DynamicUpdateTool : IRcTool
|
public class DynamicUpdateTool : IRcTool
|
||||||
{
|
{
|
||||||
private Sample sample;
|
private Sample _sample;
|
||||||
private int toolModeIdx = DynamicUpdateToolMode.BUILD.Idx;
|
private int toolModeIdx = DynamicUpdateToolMode.BUILD.Idx;
|
||||||
private DynamicUpdateToolMode mode = DynamicUpdateToolMode.BUILD;
|
private DynamicUpdateToolMode mode = DynamicUpdateToolMode.BUILD;
|
||||||
private float cellSize = 0.3f;
|
private float cellSize = 0.3f;
|
||||||
|
@ -95,7 +95,7 @@ public class DynamicUpdateTool : IRcTool
|
||||||
|
|
||||||
public void SetSample(Sample sample)
|
public void SetSample(Sample sample)
|
||||||
{
|
{
|
||||||
this.sample = sample;
|
_sample = sample;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
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)
|
private void DrawAgent(RecastDebugDraw dd, RcVec3f pos, int col)
|
||||||
{
|
{
|
||||||
float r = sample.GetSettings().agentRadius;
|
float r = _sample.GetSettings().agentRadius;
|
||||||
float h = sample.GetSettings().agentHeight;
|
float h = _sample.GetSettings().agentHeight;
|
||||||
float c = sample.GetSettings().agentMaxClimb;
|
float c = _sample.GetSettings().agentMaxClimb;
|
||||||
dd.DepthMask(false);
|
dd.DepthMask(false);
|
||||||
// Agent dimensions.
|
// 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);
|
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)
|
if (updated)
|
||||||
{
|
{
|
||||||
buildTime = (RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond;
|
buildTime = (RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond;
|
||||||
sample.Update(null, dynaMesh.RecastResults(), dynaMesh.NavMesh());
|
_sample.Update(null, dynaMesh.RecastResults(), dynaMesh.NavMesh());
|
||||||
sample.SetChanged(false);
|
_sample.SetChanged(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -600,7 +600,7 @@ public class DynamicUpdateTool : IRcTool
|
||||||
if (dynaMesh != null)
|
if (dynaMesh != null)
|
||||||
{
|
{
|
||||||
BuildDynaMesh();
|
BuildDynaMesh();
|
||||||
sample.SetChanged(false);
|
_sample.SetChanged(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -701,7 +701,7 @@ public class DynamicUpdateTool : IRcTool
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTime = (RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond;
|
buildTime = (RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond;
|
||||||
sample.Update(null, dynaMesh.RecastResults(), dynaMesh.NavMesh());
|
_sample.Update(null, dynaMesh.RecastResults(), dynaMesh.NavMesh());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConfigDynaMesh()
|
private void ConfigDynaMesh()
|
||||||
|
|
|
@ -29,7 +29,7 @@ public interface IRcTool
|
||||||
string GetName();
|
string GetName();
|
||||||
void Layout();
|
void Layout();
|
||||||
|
|
||||||
void SetSample(Sample m_sample);
|
void SetSample(Sample sample);
|
||||||
|
|
||||||
void HandleClick(RcVec3f s, RcVec3f p, bool shift);
|
void HandleClick(RcVec3f s, RcVec3f p, bool shift);
|
||||||
|
|
||||||
|
|
|
@ -33,14 +33,14 @@ namespace DotRecast.Recast.Demo.Tools;
|
||||||
public class JumpLinkBuilderTool : IRcTool
|
public class JumpLinkBuilderTool : IRcTool
|
||||||
{
|
{
|
||||||
private readonly List<JumpLink> links = new();
|
private readonly List<JumpLink> links = new();
|
||||||
private Sample sample;
|
private Sample _sample;
|
||||||
private JumpLinkBuilder annotationBuilder;
|
private JumpLinkBuilder annotationBuilder;
|
||||||
private readonly int selEdge = -1;
|
private readonly int selEdge = -1;
|
||||||
private readonly JumpLinkBuilderToolParams option = new JumpLinkBuilderToolParams();
|
private readonly JumpLinkBuilderToolParams option = new JumpLinkBuilderToolParams();
|
||||||
|
|
||||||
public void SetSample(Sample sample)
|
public void SetSample(Sample sample)
|
||||||
{
|
{
|
||||||
this.sample = sample;
|
_sample = sample;
|
||||||
annotationBuilder = null;
|
annotationBuilder = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ public class JumpLinkBuilderTool : IRcTool
|
||||||
|
|
||||||
public void Layout()
|
public void Layout()
|
||||||
{
|
{
|
||||||
if (0 >= sample.GetRecastResults().Count)
|
if (0 >= _sample.GetRecastResults().Count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGui.Text("Options");
|
ImGui.Text("Options");
|
||||||
|
@ -370,16 +370,16 @@ public class JumpLinkBuilderTool : IRcTool
|
||||||
{
|
{
|
||||||
if (annotationBuilder == null)
|
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();
|
links.Clear();
|
||||||
if (annotationBuilder != null)
|
if (annotationBuilder != null)
|
||||||
{
|
{
|
||||||
var settings = sample.GetSettings();
|
var settings = _sample.GetSettings();
|
||||||
float cellSize = settings.cellSize;
|
float cellSize = settings.cellSize;
|
||||||
float agentHeight = settings.agentHeight;
|
float agentHeight = settings.agentHeight;
|
||||||
float agentRadius = settings.agentRadius;
|
float agentRadius = settings.agentRadius;
|
||||||
|
@ -406,7 +406,7 @@ public class JumpLinkBuilderTool : IRcTool
|
||||||
|
|
||||||
if (buildOffMeshConnections)
|
if (buildOffMeshConnections)
|
||||||
{
|
{
|
||||||
DemoInputGeomProvider geom = sample.GetInputGeom();
|
DemoInputGeomProvider geom = _sample.GetInputGeom();
|
||||||
if (geom != null)
|
if (geom != null)
|
||||||
{
|
{
|
||||||
int area = SampleAreaModifications.SAMPLE_POLYAREA_TYPE_JUMP_AUTO;
|
int area = SampleAreaModifications.SAMPLE_POLYAREA_TYPE_JUMP_AUTO;
|
||||||
|
|
|
@ -31,19 +31,19 @@ namespace DotRecast.Recast.Demo.Tools;
|
||||||
|
|
||||||
public class OffMeshConnectionTool : IRcTool
|
public class OffMeshConnectionTool : IRcTool
|
||||||
{
|
{
|
||||||
private Sample sample;
|
private Sample _sample;
|
||||||
private bool hitPosSet;
|
private bool hitPosSet;
|
||||||
private RcVec3f hitPos;
|
private RcVec3f hitPos;
|
||||||
private int bidir;
|
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)
|
public void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||||
{
|
{
|
||||||
DemoInputGeomProvider geom = sample.GetInputGeom();
|
DemoInputGeomProvider geom = _sample.GetInputGeom();
|
||||||
if (geom == null)
|
if (geom == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -58,7 +58,7 @@ public class OffMeshConnectionTool : IRcTool
|
||||||
foreach (DemoOffMeshConnection offMeshCon in geom.GetOffMeshConnections())
|
foreach (DemoOffMeshConnection offMeshCon in geom.GetOffMeshConnections())
|
||||||
{
|
{
|
||||||
float d = Math.Min(RcVec3f.DistSqr(p, offMeshCon.verts, 0), RcVec3f.DistSqr(p, offMeshCon.verts, 3));
|
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;
|
nearestDist = d;
|
||||||
nearestConnection = offMeshCon;
|
nearestConnection = offMeshCon;
|
||||||
|
@ -82,7 +82,7 @@ public class OffMeshConnectionTool : IRcTool
|
||||||
{
|
{
|
||||||
int area = SampleAreaModifications.SAMPLE_POLYAREA_TYPE_JUMP;
|
int area = SampleAreaModifications.SAMPLE_POLYAREA_TYPE_JUMP;
|
||||||
int flags = SampleAreaModifications.SAMPLE_POLYFLAGS_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;
|
hitPosSet = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,20 +90,20 @@ public class OffMeshConnectionTool : IRcTool
|
||||||
|
|
||||||
public void HandleRender(NavMeshRenderer renderer)
|
public void HandleRender(NavMeshRenderer renderer)
|
||||||
{
|
{
|
||||||
if (sample == null)
|
if (_sample == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RecastDebugDraw dd = renderer.GetDebugDraw();
|
RecastDebugDraw dd = renderer.GetDebugDraw();
|
||||||
float s = sample.GetSettings().agentRadius;
|
float s = _sample.GetSettings().agentRadius;
|
||||||
|
|
||||||
if (hitPosSet)
|
if (hitPosSet)
|
||||||
{
|
{
|
||||||
dd.DebugDrawCross(hitPos.x, hitPos.y + 0.1f, hitPos.z, s, DuRGBA(0, 0, 0, 128), 2.0f);
|
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)
|
if (geom != null)
|
||||||
{
|
{
|
||||||
renderer.DrawOffMeshConnections(geom, true);
|
renderer.DrawOffMeshConnections(geom, true);
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class TestNavmeshTool : IRcTool
|
||||||
private const int MAX_POLYS = 256;
|
private const int MAX_POLYS = 256;
|
||||||
private const int MAX_SMOOTH = 2048;
|
private const int MAX_SMOOTH = 2048;
|
||||||
|
|
||||||
private Sample m_sample;
|
private Sample _sample;
|
||||||
|
|
||||||
private int m_toolModeIdx = TestNavmeshToolMode.PATHFIND_FOLLOW.Idx;
|
private int m_toolModeIdx = TestNavmeshToolMode.PATHFIND_FOLLOW.Idx;
|
||||||
private TestNavmeshToolMode m_toolMode => TestNavmeshToolMode.Values[m_toolModeIdx];
|
private TestNavmeshToolMode m_toolMode => TestNavmeshToolMode.Values[m_toolModeIdx];
|
||||||
|
@ -51,13 +51,16 @@ public class TestNavmeshTool : IRcTool
|
||||||
|
|
||||||
public TestNavmeshTool()
|
public TestNavmeshTool()
|
||||||
{
|
{
|
||||||
m_filter = new DtQueryDefaultFilter(SampleAreaModifications.SAMPLE_POLYFLAGS_ALL,
|
m_filter = new DtQueryDefaultFilter(
|
||||||
SampleAreaModifications.SAMPLE_POLYFLAGS_DISABLED, new float[] { 1f, 1f, 1f, 1f, 2f, 1.5f });
|
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)
|
public void HandleClick(RcVec3f s, RcVec3f p, bool shift)
|
||||||
|
@ -161,12 +164,12 @@ public class TestNavmeshTool : IRcTool
|
||||||
|
|
||||||
private void Recalc()
|
private void Recalc()
|
||||||
{
|
{
|
||||||
if (m_sample.GetNavMesh() == null)
|
if (_sample.GetNavMesh() == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DtNavMeshQuery m_navQuery = m_sample.GetNavMeshQuery();
|
DtNavMeshQuery m_navQuery = _sample.GetNavMeshQuery();
|
||||||
if (m_sposSet)
|
if (m_sposSet)
|
||||||
{
|
{
|
||||||
m_navQuery.FindNearestPoly(m_spos, m_polyPickExt, m_filter, out m_startRef, out var _, out var _);
|
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;
|
m_endRef = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DtNavMesh m_navMesh = m_sample.GetNavMesh();
|
DtNavMesh m_navMesh = _sample.GetNavMesh();
|
||||||
if (m_toolMode == TestNavmeshToolMode.PATHFIND_FOLLOW)
|
if (m_toolMode == TestNavmeshToolMode.PATHFIND_FOLLOW)
|
||||||
{
|
{
|
||||||
if (m_sposSet && m_eposSet && m_startRef != 0 && m_endRef != 0)
|
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);
|
RcVec3f moveTgt = RcVec3f.Mad(iterPos, delta, len);
|
||||||
|
|
||||||
// Move
|
// Move
|
||||||
m_navQuery.MoveAlongSurface(polys[0], iterPos, moveTgt, m_filter, out var result, out var visited);
|
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 nx = (m_epos.z - m_spos.z) * 0.25f;
|
||||||
float nz = -(m_epos.x - m_spos.x) * 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[0] = m_spos.x + nx * 1.2f;
|
||||||
m_queryPoly[1] = m_spos.y + agentHeight / 2;
|
m_queryPoly[1] = m_spos.y + agentHeight / 2;
|
||||||
|
@ -465,7 +468,7 @@ public class TestNavmeshTool : IRcTool
|
||||||
{
|
{
|
||||||
if (m_sposSet && m_startRef != 0)
|
if (m_sposSet && m_startRef != 0)
|
||||||
{
|
{
|
||||||
m_neighbourhoodRadius = m_sample.GetSettings().agentRadius * 20.0f;
|
m_neighbourhoodRadius = _sample.GetSettings().agentRadius * 20.0f;
|
||||||
Result<FindLocalNeighbourhoodResult> result = m_navQuery.FindLocalNeighbourhood(m_startRef, m_spos,
|
Result<FindLocalNeighbourhoodResult> result = m_navQuery.FindLocalNeighbourhood(m_startRef, m_spos,
|
||||||
m_neighbourhoodRadius, m_filter);
|
m_neighbourhoodRadius, m_filter);
|
||||||
if (result.Succeeded())
|
if (result.Succeeded())
|
||||||
|
@ -502,7 +505,7 @@ public class TestNavmeshTool : IRcTool
|
||||||
|
|
||||||
public void HandleRender(NavMeshRenderer renderer)
|
public void HandleRender(NavMeshRenderer renderer)
|
||||||
{
|
{
|
||||||
if (m_sample == null)
|
if (_sample == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -512,9 +515,9 @@ public class TestNavmeshTool : IRcTool
|
||||||
int endCol = DuRGBA(51, 102, 0, 129);
|
int endCol = DuRGBA(51, 102, 0, 129);
|
||||||
int pathCol = DuRGBA(0, 0, 0, 64);
|
int pathCol = DuRGBA(0, 0, 0, 64);
|
||||||
|
|
||||||
float agentRadius = m_sample.GetSettings().agentRadius;
|
float agentRadius = _sample.GetSettings().agentRadius;
|
||||||
float agentHeight = m_sample.GetSettings().agentHeight;
|
float agentHeight = _sample.GetSettings().agentHeight;
|
||||||
float agentClimb = m_sample.GetSettings().agentMaxClimb;
|
float agentClimb = _sample.GetSettings().agentMaxClimb;
|
||||||
|
|
||||||
if (m_sposSet)
|
if (m_sposSet)
|
||||||
{
|
{
|
||||||
|
@ -528,7 +531,7 @@ public class TestNavmeshTool : IRcTool
|
||||||
|
|
||||||
dd.DepthMask(true);
|
dd.DepthMask(true);
|
||||||
|
|
||||||
DtNavMesh m_navMesh = m_sample.GetNavMesh();
|
DtNavMesh m_navMesh = _sample.GetNavMesh();
|
||||||
if (m_navMesh == null)
|
if (m_navMesh == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -831,9 +834,9 @@ public class TestNavmeshTool : IRcTool
|
||||||
}
|
}
|
||||||
|
|
||||||
dd.DepthMask(true);
|
dd.DepthMask(true);
|
||||||
if (m_sample.GetNavMeshQuery() != null)
|
if (_sample.GetNavMeshQuery() != null)
|
||||||
{
|
{
|
||||||
Result<GetPolyWallSegmentsResult> result = m_sample.GetNavMeshQuery()
|
Result<GetPolyWallSegmentsResult> result = _sample.GetNavMeshQuery()
|
||||||
.GetPolyWallSegments(m_polys[i], false, m_filter);
|
.GetPolyWallSegments(m_polys[i], false, m_filter);
|
||||||
if (result.Succeeded())
|
if (result.Succeeded())
|
||||||
{
|
{
|
||||||
|
@ -923,9 +926,9 @@ public class TestNavmeshTool : IRcTool
|
||||||
|
|
||||||
private void DrawAgent(RecastDebugDraw dd, RcVec3f pos, int col)
|
private void DrawAgent(RecastDebugDraw dd, RcVec3f pos, int col)
|
||||||
{
|
{
|
||||||
float r = m_sample.GetSettings().agentRadius;
|
float r = _sample.GetSettings().agentRadius;
|
||||||
float h = m_sample.GetSettings().agentHeight;
|
float h = _sample.GetSettings().agentHeight;
|
||||||
float c = m_sample.GetSettings().agentMaxClimb;
|
float c = _sample.GetSettings().agentMaxClimb;
|
||||||
dd.DepthMask(false);
|
dd.DepthMask(false);
|
||||||
// Agent dimensions.
|
// 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);
|
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
|
// TODO Auto-generated method stub
|
||||||
if (m_toolMode == TestNavmeshToolMode.PATHFIND_SLICED)
|
if (m_toolMode == TestNavmeshToolMode.PATHFIND_SLICED)
|
||||||
{
|
{
|
||||||
DtNavMeshQuery m_navQuery = m_sample.GetNavMeshQuery();
|
DtNavMeshQuery m_navQuery = _sample.GetNavMeshQuery();
|
||||||
if (m_pathFindStatus.InProgress())
|
if (m_pathFindStatus.InProgress())
|
||||||
{
|
{
|
||||||
m_pathFindStatus = m_navQuery.UpdateSlicedFindPath(1).status;
|
m_pathFindStatus = m_navQuery.UpdateSlicedFindPath(1).status;
|
||||||
|
|
Loading…
Reference in New Issue