mirror of
https://github.com/recastnavigation/recastnavigation.git
synced 2026-09-30 05:56:08 +00:00
Off-Mesh link progress (not fully working).
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
#include "DetourNavMeshBuilder.h"
|
||||
#include "DetourDebugDraw.h"
|
||||
#include "NavMeshTesterTool.h"
|
||||
#include "ExtraLinkTool.h"
|
||||
#include "OffMeshLinkTool.h"
|
||||
|
||||
#ifdef WIN32
|
||||
# define snprintf _snprintf
|
||||
@@ -110,9 +110,9 @@ void Sample_SoloMeshTiled::handleTools()
|
||||
{
|
||||
setTool(new NavMeshTesterTool);
|
||||
}
|
||||
if (imguiCheck("Create Extra Links", type == TOOL_EXTRA_LINK))
|
||||
if (imguiCheck("Create Off-Mesh Links", type == TOOL_OFFMESH_LINK))
|
||||
{
|
||||
setTool(new ExtraLinkTool);
|
||||
setTool(new OffMeshLinkTool);
|
||||
}
|
||||
|
||||
imguiSeparator();
|
||||
@@ -220,8 +220,6 @@ void Sample_SoloMeshTiled::handleRender()
|
||||
if (!m_geom || !m_geom->getMesh())
|
||||
return;
|
||||
|
||||
float col[4];
|
||||
|
||||
DebugDrawGL dd;
|
||||
|
||||
glEnable(GL_FOG);
|
||||
@@ -233,12 +231,14 @@ void Sample_SoloMeshTiled::handleRender()
|
||||
duDebugDrawTriMeshSlope(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
|
||||
m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(),
|
||||
m_agentMaxSlope);
|
||||
m_geom->drawLinks(&dd, m_agentRadius);
|
||||
}
|
||||
else if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
|
||||
{
|
||||
// Draw mesh
|
||||
duDebugDrawTriMesh(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
|
||||
m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(), 0);
|
||||
m_geom->drawLinks(&dd, m_agentRadius);
|
||||
}
|
||||
|
||||
glDisable(GL_FOG);
|
||||
@@ -247,46 +247,15 @@ void Sample_SoloMeshTiled::handleRender()
|
||||
// Draw bounds
|
||||
const float* bmin = m_geom->getMeshBoundsMin();
|
||||
const float* bmax = m_geom->getMeshBoundsMax();
|
||||
col[0] = 1; col[1] = 1; col[2] = 1; col[3] = 0.5f;
|
||||
duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], col);
|
||||
duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
|
||||
|
||||
// Tiling grid.
|
||||
const int ts = (int)m_tileSize;
|
||||
int gw = 0, gh = 0;
|
||||
rcCalcGridSize(bmin, bmax, m_cellSize, &gw, &gh);
|
||||
int tw = (gw + ts-1) / ts;
|
||||
int th = (gh + ts-1) / ts;
|
||||
const float s = ts*m_cellSize;
|
||||
glBegin(GL_LINES);
|
||||
glColor4ub(0,0,0,64);
|
||||
for (int y = 0; y < th; ++y)
|
||||
{
|
||||
for (int x = 0; x < tw; ++x)
|
||||
{
|
||||
float fx, fy, fz;
|
||||
fx = bmin[0] + x*s;
|
||||
fy = bmin[1];
|
||||
fz = bmin[2] + y*s;
|
||||
|
||||
glVertex3f(fx,fy,fz);
|
||||
glVertex3f(fx+s,fy,fz);
|
||||
glVertex3f(fx,fy,fz);
|
||||
glVertex3f(fx,fy,fz+s);
|
||||
|
||||
if (x+1 >= tw)
|
||||
{
|
||||
glVertex3f(fx+s,fy,fz);
|
||||
glVertex3f(fx+s,fy,fz+s);
|
||||
}
|
||||
if (y+1 >= th)
|
||||
{
|
||||
glVertex3f(fx,fy,fz+s);
|
||||
glVertex3f(fx+s,fy,fz+s);
|
||||
}
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
const int tw = (gw + (int)m_tileSize-1) / (int)m_tileSize;
|
||||
const int th = (gh + (int)m_tileSize-1) / (int)m_tileSize;
|
||||
const float s = m_tileSize*m_cellSize;
|
||||
duDebugDrawGridXZ(&dd, bmin[0],bmin[1],bmin[2], tw,th, s, duRGBA(0,0,0,64), 1.0f);
|
||||
|
||||
if (m_navMesh &&
|
||||
(m_drawMode == DRAWMODE_NAVMESH ||
|
||||
@@ -614,7 +583,7 @@ bool Sample_SoloMeshTiled::handleBuild()
|
||||
cleanup();
|
||||
|
||||
const float* bmin = m_geom->getMeshBoundsMin();
|
||||
const float* bmax = m_geom->getMeshBoundsMin();
|
||||
const float* bmax = m_geom->getMeshBoundsMax();
|
||||
const float* verts = m_geom->getMesh()->getVerts();
|
||||
const int nverts = m_geom->getMesh()->getVertCount();
|
||||
const int ntris = m_geom->getMesh()->getTriCount();
|
||||
@@ -957,6 +926,7 @@ bool Sample_SoloMeshTiled::handleBuild()
|
||||
m_pmesh->polys, m_pmesh->npolys, m_pmesh->nvp,
|
||||
m_dmesh->meshes, m_dmesh->verts, m_dmesh->nverts,
|
||||
m_dmesh->tris, m_dmesh->ntris,
|
||||
0, 0,
|
||||
m_pmesh->bmin, m_pmesh->bmax, m_cfg.cs, m_cfg.ch, 0, m_cfg.walkableClimb,
|
||||
&navData, &navDataSize))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user