forked from mirror/DotRecast
view active tile box wire
This commit is contained in:
parent
1968d90609
commit
d5f1b4be54
|
@ -63,17 +63,41 @@ public class TileTool : IRcTool
|
||||||
|
|
||||||
public void HandleRender(NavMeshRenderer renderer)
|
public void HandleRender(NavMeshRenderer renderer)
|
||||||
{
|
{
|
||||||
|
var sample = _impl.GetSample();
|
||||||
|
if (null == sample)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var geom = sample.GetInputGeom();
|
||||||
|
if (null == geom)
|
||||||
|
return;
|
||||||
|
|
||||||
var dd = renderer.GetDebugDraw();
|
var dd = renderer.GetDebugDraw();
|
||||||
if (_hitPosSet)
|
if (_hitPosSet)
|
||||||
{
|
{
|
||||||
var s = _impl.GetSample().GetSettings().agentRadius;
|
var bmin = geom.GetMeshBoundsMin();
|
||||||
RcVec3f m_lastBuiltTileBmin = _hitPos - RcVec3f.One;
|
var bmax = geom.GetMeshBoundsMax();
|
||||||
RcVec3f m_lastBuiltTileBmax = _hitPos + RcVec3f.One;
|
|
||||||
|
|
||||||
|
var settings = sample.GetSettings();
|
||||||
|
var s = settings.agentRadius;
|
||||||
|
float ts = settings.tileSize * settings.cellSize;
|
||||||
|
int tx = (int)((_hitPos.x - bmin[0]) / ts);
|
||||||
|
int ty = (int)((_hitPos.z - bmin[2]) / ts);
|
||||||
|
|
||||||
|
RcVec3f lastBuiltTileBmin = RcVec3f.Zero;
|
||||||
|
RcVec3f lastBuiltTileBmax = RcVec3f.Zero;
|
||||||
|
|
||||||
|
lastBuiltTileBmin[0] = bmin[0] + tx*ts;
|
||||||
|
lastBuiltTileBmin[1] = bmin[1];
|
||||||
|
lastBuiltTileBmin[2] = bmin[2] + ty*ts;
|
||||||
|
|
||||||
|
lastBuiltTileBmax[0] = bmin[0] + (tx+1)*ts;
|
||||||
|
lastBuiltTileBmax[1] = bmax[1];
|
||||||
|
lastBuiltTileBmax[2] = bmin[2] + (ty+1)*ts;
|
||||||
|
|
||||||
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);
|
||||||
dd.DebugDrawBoxWire(
|
dd.DebugDrawBoxWire(
|
||||||
m_lastBuiltTileBmin.x, m_lastBuiltTileBmin.y, m_lastBuiltTileBmin.z,
|
lastBuiltTileBmin.x, lastBuiltTileBmin.y, lastBuiltTileBmin.z,
|
||||||
m_lastBuiltTileBmax.x, m_lastBuiltTileBmax.y, m_lastBuiltTileBmax.z,
|
lastBuiltTileBmax.x, lastBuiltTileBmax.y, lastBuiltTileBmax.z,
|
||||||
DuRGBA(255, 255, 255, 64), 1.0f);
|
DuRGBA(255, 255, 255, 64), 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue