From 9381b5b8ffab91601f7db0c21e9e8147d199fa8e Mon Sep 17 00:00:00 2001 From: ikpil Date: Thu, 27 Jul 2023 00:30:01 +0900 Subject: [PATCH] tile selecting --- src/DotRecast.Recast.Demo/Tools/TileTool.cs | 25 +++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/DotRecast.Recast.Demo/Tools/TileTool.cs b/src/DotRecast.Recast.Demo/Tools/TileTool.cs index a106594..390a5b8 100644 --- a/src/DotRecast.Recast.Demo/Tools/TileTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/TileTool.cs @@ -4,6 +4,7 @@ using DotRecast.Recast.Demo.Draw; using DotRecast.Recast.DemoTool; using DotRecast.Recast.DemoTool.Tools; using ImGuiNET; +using Silk.NET.Vulkan; using static DotRecast.Recast.Demo.Draw.DebugDraw; using static DotRecast.Recast.Demo.Draw.DebugDrawPrimitives; @@ -64,19 +65,29 @@ public class TileTool : IRcTool public void HandleRender(NavMeshRenderer renderer) { + var dd = renderer.GetDebugDraw(); if (_hitPosSet) { - RecastDebugDraw dd = renderer.GetDebugDraw(); var s = _impl.GetSample().GetSettings().agentRadius; dd.Begin(LINES, 2.0f); - dd.Vertex(_hitPos[0] - s, _hitPos[1] + 0.1f, _hitPos[2], DuRGBA(0, 0, 0, 128)); - dd.Vertex(_hitPos[0] + s, _hitPos[1] + 0.1f, _hitPos[2], DuRGBA(0, 0, 0, 128)); - dd.Vertex(_hitPos[0], _hitPos[1] - s + 0.1f, _hitPos[2], DuRGBA(0, 0, 0, 128)); - dd.Vertex(_hitPos[0], _hitPos[1] + s + 0.1f, _hitPos[2], DuRGBA(0, 0, 0, 128)); - dd.Vertex(_hitPos[0], _hitPos[1] + 0.1f, _hitPos[2] - s, DuRGBA(0, 0, 0, 128)); - dd.Vertex(_hitPos[0], _hitPos[1] + 0.1f, _hitPos[2] + s, DuRGBA(0, 0, 0, 128)); + dd.Vertex(_hitPos.x - s, _hitPos.y + 0.1f, _hitPos.z, DuRGBA(0, 0, 0, 128)); + dd.Vertex(_hitPos.x + s, _hitPos.y + 0.1f, _hitPos.z, DuRGBA(0, 0, 0, 128)); + dd.Vertex(_hitPos.x, _hitPos.y - s + 0.1f, _hitPos.z, DuRGBA(0, 0, 0, 128)); + dd.Vertex(_hitPos.x, _hitPos.y + s + 0.1f, _hitPos.z, DuRGBA(0, 0, 0, 128)); + dd.Vertex(_hitPos.x, _hitPos.y + 0.1f, _hitPos.z - s, DuRGBA(0, 0, 0, 128)); + dd.Vertex(_hitPos.x, _hitPos.y + 0.1f, _hitPos.z + s, DuRGBA(0, 0, 0, 128)); dd.End(); } + + if (_hitPosSet) + { + RcVec3f m_lastBuiltTileBmin = _hitPos - RcVec3f.One; + RcVec3f m_lastBuiltTileBmax = _hitPos + RcVec3f.One; + dd.DebugDrawBoxWire( + m_lastBuiltTileBmin.x, m_lastBuiltTileBmin.y, m_lastBuiltTileBmin.z, + m_lastBuiltTileBmax.x, m_lastBuiltTileBmax.y, m_lastBuiltTileBmax.z, + DuRGBA(255, 255, 255, 64), 1.0f); + } } public void HandleUpdate(float dt)