move IRcTool.SetSample to ISampleTool.SetSample

This commit is contained in:
ikpil 2023-06-13 01:19:05 +09:00
parent a8aafc8491
commit ca51085826
15 changed files with 141 additions and 74 deletions

View File

@ -35,7 +35,6 @@ namespace DotRecast.Recast.Demo.Tools;
public class ConvexVolumeTool : IRcTool public class ConvexVolumeTool : IRcTool
{ {
private readonly ConvexVolumeToolImpl _impl; private readonly ConvexVolumeToolImpl _impl;
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;
@ -54,14 +53,14 @@ public class ConvexVolumeTool : IRcTool
return _impl; return _impl;
} }
public void SetSample(Sample sample) public void OnSampleChanged()
{ {
_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 = _impl.GetSample().GetInputGeom();
if (geom == null) if (geom == null)
{ {
return; return;
@ -229,7 +228,7 @@ public class ConvexVolumeTool : IRcTool
hull.Clear(); hull.Clear();
pts.Clear(); pts.Clear();
DemoInputGeomProvider geom = _sample.GetInputGeom(); DemoInputGeomProvider geom = _impl.GetSample().GetInputGeom();
if (geom != null) if (geom != null)
{ {
geom.ClearConvexVolumes(); geom.ClearConvexVolumes();

View File

@ -39,7 +39,6 @@ public class CrowdTool : IRcTool
{ {
private readonly CrowdToolImpl _impl; private readonly CrowdToolImpl _impl;
private readonly CrowdToolParams toolParams = new CrowdToolParams(); private readonly CrowdToolParams toolParams = new CrowdToolParams();
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;
@ -64,16 +63,15 @@ public class CrowdTool : IRcTool
return _impl; return _impl;
} }
public void SetSample(Sample sample) public void OnSampleChanged()
{ {
_sample = sample; DtNavMesh nav = _impl.GetSample().GetNavMesh();
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(_impl.GetSample().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 }));
@ -111,7 +109,7 @@ public class CrowdTool : IRcTool
crowd.SetObstacleAvoidanceParams(3, option); crowd.SetObstacleAvoidanceParams(3, option);
profilingTool.Setup(_sample.GetSettings().agentRadius, m_nav); profilingTool.Setup(_impl.GetSample().GetSettings().agentRadius, m_nav);
} }
} }
@ -156,8 +154,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 = _impl.GetSample().GetNavMesh();
DtNavMeshQuery navquery = _sample.GetNavMeshQuery(); DtNavMeshQuery navquery = _impl.GetSample().GetNavMeshQuery();
if (nav != null && navquery != null) if (nav != null && navquery != null)
{ {
IDtQueryFilter filter = new DtQueryDefaultFilter(); IDtQueryFilter filter = new DtQueryDefaultFilter();
@ -214,8 +212,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 = _impl.GetSample().GetSettings().agentRadius;
ap.height = _sample.GetSettings().agentHeight; ap.height = _impl.GetSample().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;
@ -264,11 +262,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 (_impl.GetSample() == 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 = _impl.GetSample().GetNavMeshQuery();
IDtQueryFilter filter = crowd.GetFilter(0); IDtQueryFilter filter = crowd.GetFilter(0);
RcVec3f halfExtents = crowd.GetQueryExtents(); RcVec3f halfExtents = crowd.GetQueryExtents();
@ -323,8 +321,8 @@ public class CrowdTool : IRcTool
} }
RecastDebugDraw dd = renderer.GetDebugDraw(); RecastDebugDraw dd = renderer.GetDebugDraw();
float rad = _sample.GetSettings().agentRadius; float rad = _impl.GetSample().GetSettings().agentRadius;
DtNavMesh nav = _sample.GetNavMesh(); DtNavMesh nav = _impl.GetSample().GetNavMesh();
if (nav == null || crowd == null) if (nav == null || crowd == null)
return; return;
@ -636,7 +634,7 @@ public class CrowdTool : IRcTool
if (crowd == null) if (crowd == null)
return; return;
DtNavMesh nav = _sample.GetNavMesh(); DtNavMesh nav = _impl.GetSample().GetNavMesh();
if (nav == null) if (nav == null)
return; return;

View File

@ -41,7 +41,6 @@ namespace DotRecast.Recast.Demo.Tools;
public class DynamicUpdateTool : IRcTool public class DynamicUpdateTool : IRcTool
{ {
private readonly DynamicUpdateToolImpl _impl; private readonly DynamicUpdateToolImpl _impl;
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;
@ -99,12 +98,13 @@ public class DynamicUpdateTool : IRcTool
{ {
return _impl; return _impl;
} }
public void SetSample(Sample sample) public void OnSampleChanged()
{ {
_sample = sample; // ..
} }
public void HandleClick(RcVec3f s, RcVec3f p, bool shift) public void HandleClick(RcVec3f s, RcVec3f p, bool shift)
{ {
if (mode == DynamicUpdateToolMode.COLLIDERS) if (mode == DynamicUpdateToolMode.COLLIDERS)
@ -439,9 +439,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 = _impl.GetSample().GetSettings().agentRadius;
float h = _sample.GetSettings().agentHeight; float h = _impl.GetSample().GetSettings().agentHeight;
float c = _sample.GetSettings().agentMaxClimb; float c = _impl.GetSample().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);
@ -475,8 +475,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()); _impl.GetSample().Update(null, dynaMesh.RecastResults(), dynaMesh.NavMesh());
_sample.SetChanged(false); _impl.GetSample().SetChanged(false);
} }
} }
catch (Exception e) catch (Exception e)
@ -607,7 +607,7 @@ public class DynamicUpdateTool : IRcTool
if (dynaMesh != null) if (dynaMesh != null)
{ {
BuildDynaMesh(); BuildDynaMesh();
_sample.SetChanged(false); _impl.GetSample().SetChanged(false);
} }
} }
} }
@ -708,7 +708,7 @@ public class DynamicUpdateTool : IRcTool
} }
buildTime = (RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond; buildTime = (RcFrequency.Ticks - t) / TimeSpan.TicksPerMillisecond;
_sample.Update(null, dynaMesh.RecastResults(), dynaMesh.NavMesh()); _impl.GetSample().Update(null, dynaMesh.RecastResults(), dynaMesh.NavMesh());
} }
private void ConfigDynaMesh() private void ConfigDynaMesh()

View File

@ -27,10 +27,10 @@ namespace DotRecast.Recast.Demo.Tools;
public interface IRcTool public interface IRcTool
{ {
ISampleTool GetTool(); ISampleTool GetTool();
void OnSampleChanged();
void Layout(); void Layout();
void SetSample(Sample sample);
void HandleClick(RcVec3f s, RcVec3f p, bool shift); void HandleClick(RcVec3f s, RcVec3f p, bool shift);
void HandleRender(NavMeshRenderer renderer); void HandleRender(NavMeshRenderer renderer);

View File

@ -34,7 +34,6 @@ public class JumpLinkBuilderTool : IRcTool
{ {
private readonly JumpLinkBuilderToolImpl _impl; private readonly JumpLinkBuilderToolImpl _impl;
private readonly List<JumpLink> links = new(); private readonly List<JumpLink> links = new();
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();
@ -50,9 +49,8 @@ public class JumpLinkBuilderTool : IRcTool
return _impl; return _impl;
} }
public void SetSample(Sample sample) public void OnSampleChanged()
{ {
_sample = sample;
annotationBuilder = null; annotationBuilder = null;
} }
@ -337,7 +335,7 @@ public class JumpLinkBuilderTool : IRcTool
public void Layout() public void Layout()
{ {
if (0 >= _sample.GetRecastResults().Count) if (0 >= _impl.GetSample().GetRecastResults().Count)
return; return;
ImGui.Text("Options"); ImGui.Text("Options");
@ -382,16 +380,16 @@ public class JumpLinkBuilderTool : IRcTool
{ {
if (annotationBuilder == null) if (annotationBuilder == null)
{ {
if (_sample != null && 0 < _sample.GetRecastResults().Count) if (_impl.GetSample() != null && 0 < _impl.GetSample().GetRecastResults().Count)
{ {
annotationBuilder = new JumpLinkBuilder(_sample.GetRecastResults()); annotationBuilder = new JumpLinkBuilder(_impl.GetSample().GetRecastResults());
} }
} }
links.Clear(); links.Clear();
if (annotationBuilder != null) if (annotationBuilder != null)
{ {
var settings = _sample.GetSettings(); var settings = _impl.GetSample().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;
@ -418,7 +416,7 @@ public class JumpLinkBuilderTool : IRcTool
if (buildOffMeshConnections) if (buildOffMeshConnections)
{ {
DemoInputGeomProvider geom = _sample.GetInputGeom(); DemoInputGeomProvider geom = _impl.GetSample().GetInputGeom();
if (geom != null) if (geom != null)
{ {
int area = SampleAreaModifications.SAMPLE_POLYAREA_TYPE_JUMP_AUTO; int area = SampleAreaModifications.SAMPLE_POLYAREA_TYPE_JUMP_AUTO;

View File

@ -33,7 +33,6 @@ namespace DotRecast.Recast.Demo.Tools;
public class OffMeshConnectionTool : IRcTool public class OffMeshConnectionTool : IRcTool
{ {
private readonly OffMeshConnectionToolImpl _impl; private readonly OffMeshConnectionToolImpl _impl;
private Sample _sample;
private bool hitPosSet; private bool hitPosSet;
private RcVec3f hitPos; private RcVec3f hitPos;
private int bidir; private int bidir;
@ -47,15 +46,15 @@ public class OffMeshConnectionTool : IRcTool
{ {
return _impl; return _impl;
} }
public void SetSample(Sample sample) public void OnSampleChanged()
{ {
_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 = _impl.GetSample().GetInputGeom();
if (geom == null) if (geom == null)
{ {
return; return;
@ -70,7 +69,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) < _impl.GetSample().GetSettings().agentRadius)
{ {
nearestDist = d; nearestDist = d;
nearestConnection = offMeshCon; nearestConnection = offMeshCon;
@ -94,7 +93,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, _impl.GetSample().GetSettings().agentRadius, 0 == bidir, area, flags);
hitPosSet = false; hitPosSet = false;
} }
} }
@ -102,20 +101,20 @@ public class OffMeshConnectionTool : IRcTool
public void HandleRender(NavMeshRenderer renderer) public void HandleRender(NavMeshRenderer renderer)
{ {
if (_sample == null) if (_impl.GetSample() == null)
{ {
return; return;
} }
RecastDebugDraw dd = renderer.GetDebugDraw(); RecastDebugDraw dd = renderer.GetDebugDraw();
float s = _sample.GetSettings().agentRadius; float s = _impl.GetSample().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 = _impl.GetSample().GetInputGeom();
if (geom != null) if (geom != null)
{ {
renderer.DrawOffMeshConnections(geom, true); renderer.DrawOffMeshConnections(geom, true);

View File

@ -13,15 +13,12 @@ using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives;
namespace DotRecast.Recast.Demo.Tools; namespace DotRecast.Recast.Demo.Tools;
public class TestNavmeshTool : IRcTool 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 readonly TestNavmeshToolImpl _impl; private readonly TestNavmeshToolImpl _impl;
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];
@ -66,12 +63,13 @@ public class TestNavmeshTool : IRcTool
{ {
return _impl; return _impl;
} }
public void SetSample(Sample sample) public void OnSampleChanged()
{ {
_sample = sample; // ..
} }
public void HandleClick(RcVec3f s, RcVec3f p, bool shift) public void HandleClick(RcVec3f s, RcVec3f p, bool shift)
{ {
if (shift) if (shift)
@ -169,12 +167,12 @@ public class TestNavmeshTool : IRcTool
private void Recalc() private void Recalc()
{ {
if (_sample.GetNavMesh() == null) if (_impl.GetSample().GetNavMesh() == null)
{ {
return; return;
} }
DtNavMeshQuery m_navQuery = _sample.GetNavMeshQuery(); DtNavMeshQuery m_navQuery = _impl.GetSample().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 _);
@ -193,7 +191,7 @@ public class TestNavmeshTool : IRcTool
m_endRef = 0; m_endRef = 0;
} }
DtNavMesh m_navMesh = _sample.GetNavMesh(); DtNavMesh m_navMesh = _impl.GetSample().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)
@ -443,7 +441,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 = _sample != null ? _sample.GetSettings().agentHeight : 0; float agentHeight = _impl.GetSample() != null ? _impl.GetSample().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;
@ -473,7 +471,7 @@ public class TestNavmeshTool : IRcTool
{ {
if (m_sposSet && m_startRef != 0) if (m_sposSet && m_startRef != 0)
{ {
m_neighbourhoodRadius = _sample.GetSettings().agentRadius * 20.0f; m_neighbourhoodRadius = _impl.GetSample().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())
@ -510,7 +508,7 @@ public class TestNavmeshTool : IRcTool
public void HandleRender(NavMeshRenderer renderer) public void HandleRender(NavMeshRenderer renderer)
{ {
if (_sample == null) if (_impl.GetSample() == null)
{ {
return; return;
} }
@ -520,9 +518,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 = _sample.GetSettings().agentRadius; float agentRadius = _impl.GetSample().GetSettings().agentRadius;
float agentHeight = _sample.GetSettings().agentHeight; float agentHeight = _impl.GetSample().GetSettings().agentHeight;
float agentClimb = _sample.GetSettings().agentMaxClimb; float agentClimb = _impl.GetSample().GetSettings().agentMaxClimb;
if (m_sposSet) if (m_sposSet)
{ {
@ -536,7 +534,7 @@ public class TestNavmeshTool : IRcTool
dd.DepthMask(true); dd.DepthMask(true);
DtNavMesh m_navMesh = _sample.GetNavMesh(); DtNavMesh m_navMesh = _impl.GetSample().GetNavMesh();
if (m_navMesh == null) if (m_navMesh == null)
{ {
return; return;
@ -839,9 +837,9 @@ public class TestNavmeshTool : IRcTool
} }
dd.DepthMask(true); dd.DepthMask(true);
if (_sample.GetNavMeshQuery() != null) if (_impl.GetSample().GetNavMeshQuery() != null)
{ {
Result<GetPolyWallSegmentsResult> result = _sample.GetNavMeshQuery() Result<GetPolyWallSegmentsResult> result = _impl.GetSample().GetNavMeshQuery()
.GetPolyWallSegments(m_polys[i], false, m_filter); .GetPolyWallSegments(m_polys[i], false, m_filter);
if (result.Succeeded()) if (result.Succeeded())
{ {
@ -931,9 +929,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 = _sample.GetSettings().agentRadius; float r = _impl.GetSample().GetSettings().agentRadius;
float h = _sample.GetSettings().agentHeight; float h = _impl.GetSample().GetSettings().agentHeight;
float c = _sample.GetSettings().agentMaxClimb; float c = _impl.GetSample().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);
@ -979,7 +977,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 = _sample.GetNavMeshQuery(); DtNavMeshQuery m_navQuery = _impl.GetSample().GetNavMeshQuery();
if (m_pathFindStatus.InProgress()) if (m_pathFindStatus.InProgress())
{ {
m_pathFindStatus = m_navQuery.UpdateSlicedFindPath(1).status; m_pathFindStatus = m_navQuery.UpdateSlicedFindPath(1).status;

View File

@ -95,7 +95,8 @@ public class RcToolsetView : IRcView
public void SetSample(Sample sample) public void SetSample(Sample sample)
{ {
tools.ForEach(t => t.SetSample(sample)); tools.ForEach(t => t.GetTool().SetSample(sample));
tools.ForEach(t => t.OnSampleChanged());
} }
public void HandleUpdate(float dt) public void HandleUpdate(float dt)

View File

@ -3,5 +3,7 @@
public interface ISampleTool public interface ISampleTool
{ {
string GetName(); string GetName();
void SetSample(Sample sample);
Sample GetSample();
} }
} }

View File

@ -2,9 +2,22 @@
{ {
public class ConvexVolumeToolImpl : ISampleTool public class ConvexVolumeToolImpl : ISampleTool
{ {
public string GetName() public string GetName()
{ {
return "Create Convex Volumes"; return "Create Convex Volumes";
} }
private Sample _sample;
public void SetSample(Sample sample)
{
_sample = sample;
}
public Sample GetSample()
{
return _sample;
}
} }
} }

View File

@ -6,5 +6,16 @@
{ {
return "Crowd"; return "Crowd";
} }
private Sample _sample;
public void SetSample(Sample sample)
{
_sample = sample;
}
public Sample GetSample()
{
return _sample;
}
} }
} }

View File

@ -6,5 +6,17 @@
{ {
return "Dynamic Updates"; return "Dynamic Updates";
} }
private Sample _sample;
public void SetSample(Sample sample)
{
_sample = sample;
}
public Sample GetSample()
{
return _sample;
}
} }
} }

View File

@ -6,5 +6,17 @@
{ {
return "Annotation Builder"; return "Annotation Builder";
} }
private Sample _sample;
public void SetSample(Sample sample)
{
_sample = sample;
}
public Sample GetSample()
{
return _sample;
}
} }
} }

View File

@ -6,5 +6,17 @@
{ {
return "Create Off-Mesh Links"; return "Create Off-Mesh Links";
} }
private Sample _sample;
public void SetSample(Sample sample)
{
_sample = sample;
}
public Sample GetSample()
{
return _sample;
}
} }
} }

View File

@ -6,5 +6,17 @@
{ {
return "Test Navmesh"; return "Test Navmesh";
} }
private Sample _sample;
public void SetSample(Sample sample)
{
_sample = sample;
}
public Sample GetSample()
{
return _sample;
}
} }
} }