refactor: OffMeshConnectionSampleTool

This commit is contained in:
ikpil 2023-09-10 11:58:31 +09:00
parent 8d6c693e05
commit cd0d096c2c
1 changed files with 13 additions and 13 deletions

View File

@ -37,10 +37,10 @@ public class OffMeshConnectionSampleTool : ISampleTool
private DemoSample _sample; private DemoSample _sample;
private readonly RcOffMeshConnectionTool _tool; private readonly RcOffMeshConnectionTool _tool;
public int bidir; private int _bidir;
private bool hitPosSet; private bool _hasStartPt;
private RcVec3f hitPos; private RcVec3f _startPt;
public OffMeshConnectionSampleTool() public OffMeshConnectionSampleTool()
{ {
@ -49,8 +49,8 @@ public class OffMeshConnectionSampleTool : ISampleTool
public void Layout() public void Layout()
{ {
ImGui.RadioButton("One Way", ref bidir, 0); ImGui.RadioButton("One Way", ref _bidir, 0);
ImGui.RadioButton("Bidirectional", ref bidir, 1); ImGui.RadioButton("Bidirectional", ref _bidir, 1);
} }
public void HandleRender(NavMeshRenderer renderer) public void HandleRender(NavMeshRenderer renderer)
@ -60,9 +60,9 @@ public class OffMeshConnectionSampleTool : ISampleTool
var settings = _sample.GetSettings(); var settings = _sample.GetSettings();
float s = settings.agentRadius; float s = settings.agentRadius;
if (hitPosSet) if (_hasStartPt)
{ {
dd.DebugDrawCross(hitPos.x, hitPos.y + 0.1f, hitPos.z, s, DuRGBA(0, 0, 0, 128), 2.0f); dd.DebugDrawCross(_startPt.x, _startPt.y + 0.1f, _startPt.z, s, DuRGBA(0, 0, 0, 128), 2.0f);
} }
DemoInputGeomProvider geom = _sample.GetInputGeom(); DemoInputGeomProvider geom = _sample.GetInputGeom();
@ -105,15 +105,15 @@ public class OffMeshConnectionSampleTool : ISampleTool
else else
{ {
// Create // Create
if (!hitPosSet) if (!_hasStartPt)
{ {
hitPos = p; _startPt = p;
hitPosSet = true; _hasStartPt = true;
} }
else else
{ {
_tool.Add(geom, settings, hitPos, p, 1 == bidir); _tool.Add(geom, settings, _startPt, p, 1 == _bidir);
hitPosSet = false; _hasStartPt = false;
} }
} }
} }