Make RecastDemo colors more meaningful (#254)
Implement a SampleDebugDraw which will color area types meaningfully, for example color water as blue, grass as green and so on.
This commit is contained in:
parent
16a7a30ada
commit
03eb2f92f3
@ -445,7 +445,7 @@ void duDebugDrawNavMeshPoly(duDebugDraw* dd, const dtNavMesh& mesh, dtPolyRef re
|
||||
|
||||
dd->depthMask(false);
|
||||
|
||||
const unsigned int c = (col & 0x00ffffff) | (64 << 24);
|
||||
const unsigned int c = duTransCol(col, 64);
|
||||
const unsigned int ip = (unsigned int)(poly - tile->polys);
|
||||
|
||||
if (poly->getType() == DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
@ -456,7 +456,7 @@ void duDebugDrawNavMeshPoly(duDebugDraw* dd, const dtNavMesh& mesh, dtPolyRef re
|
||||
|
||||
// Connection arc.
|
||||
duAppendArc(dd, con->pos[0],con->pos[1],con->pos[2], con->pos[3],con->pos[4],con->pos[5], 0.25f,
|
||||
(con->flags & 1) ? 0.6f : 0, 0.6f, c);
|
||||
(con->flags & 1) ? 0.6f : 0.0f, 0.6f, c);
|
||||
|
||||
dd->end();
|
||||
}
|
||||
|
@ -59,6 +59,12 @@ enum SamplePolyFlags
|
||||
SAMPLE_POLYFLAGS_ALL = 0xffff // All abilities.
|
||||
};
|
||||
|
||||
class SampleDebugDraw : public DebugDrawGL
|
||||
{
|
||||
public:
|
||||
virtual unsigned int areaToCol(unsigned int area);
|
||||
};
|
||||
|
||||
enum SamplePartitionType
|
||||
{
|
||||
SAMPLE_PARTITION_WATERSHED,
|
||||
@ -123,6 +129,8 @@ protected:
|
||||
SampleToolState* m_toolStates[MAX_TOOLS];
|
||||
|
||||
BuildContext* m_ctx;
|
||||
|
||||
SampleDebugDraw m_dd;
|
||||
|
||||
public:
|
||||
Sample();
|
||||
@ -133,7 +141,9 @@ public:
|
||||
void setTool(SampleTool* tool);
|
||||
SampleToolState* getToolState(int type) { return m_toolStates[type]; }
|
||||
void setToolState(int type, SampleToolState* s) { m_toolStates[type] = s; }
|
||||
|
||||
|
||||
SampleDebugDraw& getDebugDraw() { return m_dd; }
|
||||
|
||||
virtual void handleSettings();
|
||||
virtual void handleTools();
|
||||
virtual void handleDebugMode();
|
||||
|
@ -130,14 +130,18 @@ void ConvexVolumeTool::handleMenu()
|
||||
|
||||
imguiLabel("Area Type");
|
||||
imguiIndent();
|
||||
if (imguiCheck("Grass", m_areaType == SAMPLE_POLYAREA_GRASS))
|
||||
m_areaType = SAMPLE_POLYAREA_GRASS;
|
||||
if (imguiCheck("Road", m_areaType == SAMPLE_POLYAREA_ROAD))
|
||||
m_areaType = SAMPLE_POLYAREA_ROAD;
|
||||
if (imguiCheck("Ground", m_areaType == SAMPLE_POLYAREA_GROUND))
|
||||
m_areaType = SAMPLE_POLYAREA_GROUND;
|
||||
if (imguiCheck("Water", m_areaType == SAMPLE_POLYAREA_WATER))
|
||||
m_areaType = SAMPLE_POLYAREA_WATER;
|
||||
if (imguiCheck("Road", m_areaType == SAMPLE_POLYAREA_ROAD))
|
||||
m_areaType = SAMPLE_POLYAREA_ROAD;
|
||||
if (imguiCheck("Door", m_areaType == SAMPLE_POLYAREA_DOOR))
|
||||
m_areaType = SAMPLE_POLYAREA_DOOR;
|
||||
if (imguiCheck("Grass", m_areaType == SAMPLE_POLYAREA_GRASS))
|
||||
m_areaType = SAMPLE_POLYAREA_GRASS;
|
||||
if (imguiCheck("Jump", m_areaType == SAMPLE_POLYAREA_JUMP))
|
||||
m_areaType = SAMPLE_POLYAREA_JUMP;
|
||||
imguiUnindent();
|
||||
|
||||
imguiSeparator();
|
||||
@ -242,7 +246,7 @@ void ConvexVolumeTool::handleUpdate(const float /*dt*/)
|
||||
|
||||
void ConvexVolumeTool::handleRender()
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
duDebugDraw& dd = m_sample->getDebugDraw();
|
||||
|
||||
// Find height extents of the shape.
|
||||
float minh = FLT_MAX, maxh = 0;
|
||||
|
@ -203,7 +203,7 @@ void CrowdToolState::reset()
|
||||
|
||||
void CrowdToolState::handleRender()
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
duDebugDraw& dd = m_sample->getDebugDraw();
|
||||
const float rad = m_sample->getAgentRadius();
|
||||
|
||||
dtNavMesh* nav = m_sample->getNavMesh();
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "DebugDraw.h"
|
||||
#include "RecastDebugDraw.h"
|
||||
#include "DetourNavMesh.h"
|
||||
#include "Sample.h"
|
||||
|
||||
static bool intersectSegmentTriangle(const float* sp, const float* sq,
|
||||
const float* a, const float* b, const float* c,
|
||||
@ -555,7 +556,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/)
|
||||
for (int i = 0; i < m_volumeCount; ++i)
|
||||
{
|
||||
const ConvexVolume* vol = &m_volumes[i];
|
||||
unsigned int col = duIntToCol(vol->area, 32);
|
||||
unsigned int col = duTransCol(dd->areaToCol(vol->area), 32);
|
||||
for (int j = 0, k = vol->nverts-1; j < vol->nverts; k = j++)
|
||||
{
|
||||
const float* va = &vol->verts[k*3];
|
||||
@ -581,7 +582,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/)
|
||||
for (int i = 0; i < m_volumeCount; ++i)
|
||||
{
|
||||
const ConvexVolume* vol = &m_volumes[i];
|
||||
unsigned int col = duIntToCol(vol->area, 220);
|
||||
unsigned int col = duTransCol(dd->areaToCol(vol->area), 220);
|
||||
for (int j = 0, k = vol->nverts-1; j < vol->nverts; k = j++)
|
||||
{
|
||||
const float* va = &vol->verts[k*3];
|
||||
@ -600,7 +601,7 @@ void InputGeom::drawConvexVolumes(struct duDebugDraw* dd, bool /*hilight*/)
|
||||
for (int i = 0; i < m_volumeCount; ++i)
|
||||
{
|
||||
const ConvexVolume* vol = &m_volumes[i];
|
||||
unsigned int col = duDarkenCol(duIntToCol(vol->area, 255));
|
||||
unsigned int col = duDarkenCol(duTransCol(dd->areaToCol(vol->area), 220));
|
||||
for (int j = 0; j < vol->nverts; ++j)
|
||||
{
|
||||
dd->vertex(vol->verts[j*3+0],vol->verts[j*3+1]+0.1f,vol->verts[j*3+2], col);
|
||||
|
@ -274,7 +274,7 @@ void NavMeshPruneTool::handleUpdate(const float /*dt*/)
|
||||
|
||||
void NavMeshPruneTool::handleRender()
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
duDebugDraw& dd = m_sample->getDebugDraw();
|
||||
|
||||
if (m_hitPosSet)
|
||||
{
|
||||
|
@ -1040,7 +1040,7 @@ static void getPolyCenter(dtNavMesh* navMesh, dtPolyRef ref, float* center)
|
||||
|
||||
void NavMeshTesterTool::handleRender()
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
duDebugDraw& dd = m_sample->getDebugDraw();
|
||||
|
||||
static const unsigned int startCol = duRGBA(128,25,0,192);
|
||||
static const unsigned int endCol = duRGBA(51,102,0,129);
|
||||
@ -1397,7 +1397,7 @@ void NavMeshTesterTool::handleRenderOverlay(double* proj, double* model, int* vi
|
||||
|
||||
void NavMeshTesterTool::drawAgent(const float* pos, float r, float h, float c, const unsigned int col)
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
duDebugDraw& dd = m_sample->getDebugDraw();
|
||||
|
||||
dd.depthMask(false);
|
||||
|
||||
|
@ -142,7 +142,7 @@ void OffMeshConnectionTool::handleUpdate(const float /*dt*/)
|
||||
|
||||
void OffMeshConnectionTool::handleRender()
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
duDebugDraw& dd = m_sample->getDebugDraw();
|
||||
const float s = m_sample->getAgentRadius();
|
||||
|
||||
if (m_hitPosSet)
|
||||
|
@ -35,6 +35,27 @@
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
unsigned int SampleDebugDraw::areaToCol(unsigned int area)
|
||||
{
|
||||
switch(area)
|
||||
{
|
||||
// Ground (0) : brown
|
||||
case SAMPLE_POLYAREA_GROUND: return duRGBA(125, 125, 0, 255);
|
||||
// Water : blue
|
||||
case SAMPLE_POLYAREA_WATER: return duRGBA(0, 0, 255, 255);
|
||||
// Road : dark grey
|
||||
case SAMPLE_POLYAREA_ROAD: return duRGBA(80, 80, 80, 255);
|
||||
// Door : cyan
|
||||
case SAMPLE_POLYAREA_DOOR: return duRGBA(0, 255, 255, 255);
|
||||
// Grass : green
|
||||
case SAMPLE_POLYAREA_GRASS: return duRGBA(0, 255, 0, 255);
|
||||
// Jump : yellow
|
||||
case SAMPLE_POLYAREA_JUMP: return duRGBA(255, 255, 0, 255);
|
||||
// Unexpected : red
|
||||
default: return duRGBA(255, 0, 0, 255);
|
||||
}
|
||||
}
|
||||
|
||||
Sample::Sample() :
|
||||
m_geom(0),
|
||||
m_navMesh(0),
|
||||
@ -90,15 +111,13 @@ void Sample::handleRender()
|
||||
if (!m_geom)
|
||||
return;
|
||||
|
||||
DebugDrawGL dd;
|
||||
|
||||
// Draw mesh
|
||||
duDebugDrawTriMesh(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
|
||||
duDebugDrawTriMesh(&m_dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
|
||||
m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(), 0, 1.0f);
|
||||
// Draw bounds
|
||||
const float* bmin = m_geom->getMeshBoundsMin();
|
||||
const float* bmax = m_geom->getMeshBoundsMax();
|
||||
duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
|
||||
duDebugDrawBoxWire(&m_dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
|
||||
}
|
||||
|
||||
void Sample::handleRenderOverlay(double* /*proj*/, double* /*model*/, int* /*view*/)
|
||||
|
@ -191,19 +191,17 @@ void Sample_Debug::handleDebugMode()
|
||||
|
||||
void Sample_Debug::handleRender()
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
|
||||
if (m_chf)
|
||||
{
|
||||
duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
|
||||
duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf);
|
||||
// duDebugDrawCompactHeightfieldSolid(&dd, *m_chf);
|
||||
}
|
||||
|
||||
if (m_navMesh)
|
||||
duDebugDrawNavMesh(&dd, *m_navMesh, DU_DRAWNAVMESH_OFFMESHCONS);
|
||||
duDebugDrawNavMesh(&m_dd, *m_navMesh, DU_DRAWNAVMESH_OFFMESHCONS);
|
||||
|
||||
if (m_ref && m_navMesh)
|
||||
duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_ref, duRGBA(255,0,0,128));
|
||||
duDebugDrawNavMeshPoly(&m_dd, *m_navMesh, m_ref, duRGBA(255,0,0,128));
|
||||
|
||||
/* float bmin[3], bmax[3];
|
||||
rcVsub(bmin, m_center, m_ext);
|
||||
@ -213,13 +211,13 @@ void Sample_Debug::handleRender()
|
||||
|
||||
if (m_cset)
|
||||
{
|
||||
duDebugDrawRawContours(&dd, *m_cset, 0.25f);
|
||||
duDebugDrawContours(&dd, *m_cset);
|
||||
duDebugDrawRawContours(&m_dd, *m_cset, 0.25f);
|
||||
duDebugDrawContours(&m_dd, *m_cset);
|
||||
}
|
||||
|
||||
if (m_pmesh)
|
||||
{
|
||||
duDebugDrawPolyMesh(&dd, *m_pmesh);
|
||||
duDebugDrawPolyMesh(&m_dd, *m_pmesh);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -215,8 +215,6 @@ void Sample_SoloMesh::handleRender()
|
||||
if (!m_geom || !m_geom->getMesh())
|
||||
return;
|
||||
|
||||
DebugDrawGL dd;
|
||||
|
||||
glEnable(GL_FOG);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
@ -225,10 +223,10 @@ void Sample_SoloMesh::handleRender()
|
||||
if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
|
||||
{
|
||||
// Draw mesh
|
||||
duDebugDrawTriMeshSlope(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
|
||||
duDebugDrawTriMeshSlope(&m_dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
|
||||
m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(),
|
||||
m_agentMaxSlope, texScale);
|
||||
m_geom->drawOffMeshConnections(&dd);
|
||||
m_geom->drawOffMeshConnections(&m_dd);
|
||||
}
|
||||
|
||||
glDisable(GL_FOG);
|
||||
@ -237,10 +235,10 @@ void Sample_SoloMesh::handleRender()
|
||||
// Draw bounds
|
||||
const float* bmin = m_geom->getNavMeshBoundsMin();
|
||||
const float* bmax = m_geom->getNavMeshBoundsMax();
|
||||
duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
|
||||
dd.begin(DU_DRAW_POINTS, 5.0f);
|
||||
dd.vertex(bmin[0],bmin[1],bmin[2],duRGBA(255,255,255,128));
|
||||
dd.end();
|
||||
duDebugDrawBoxWire(&m_dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
|
||||
m_dd.begin(DU_DRAW_POINTS, 5.0f);
|
||||
m_dd.vertex(bmin[0],bmin[1],bmin[2],duRGBA(255,255,255,128));
|
||||
m_dd.end();
|
||||
|
||||
if (m_navMesh && m_navQuery &&
|
||||
(m_drawMode == DRAWMODE_NAVMESH ||
|
||||
@ -250,76 +248,76 @@ void Sample_SoloMesh::handleRender()
|
||||
m_drawMode == DRAWMODE_NAVMESH_INVIS))
|
||||
{
|
||||
if (m_drawMode != DRAWMODE_NAVMESH_INVIS)
|
||||
duDebugDrawNavMeshWithClosedList(&dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags);
|
||||
duDebugDrawNavMeshWithClosedList(&m_dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags);
|
||||
if (m_drawMode == DRAWMODE_NAVMESH_BVTREE)
|
||||
duDebugDrawNavMeshBVTree(&dd, *m_navMesh);
|
||||
duDebugDrawNavMeshBVTree(&m_dd, *m_navMesh);
|
||||
if (m_drawMode == DRAWMODE_NAVMESH_NODES)
|
||||
duDebugDrawNavMeshNodes(&dd, *m_navQuery);
|
||||
duDebugDrawNavMeshPolysWithFlags(&dd, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128));
|
||||
duDebugDrawNavMeshNodes(&m_dd, *m_navQuery);
|
||||
duDebugDrawNavMeshPolysWithFlags(&m_dd, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128));
|
||||
}
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
if (m_chf && m_drawMode == DRAWMODE_COMPACT)
|
||||
duDebugDrawCompactHeightfieldSolid(&dd, *m_chf);
|
||||
duDebugDrawCompactHeightfieldSolid(&m_dd, *m_chf);
|
||||
|
||||
if (m_chf && m_drawMode == DRAWMODE_COMPACT_DISTANCE)
|
||||
duDebugDrawCompactHeightfieldDistance(&dd, *m_chf);
|
||||
duDebugDrawCompactHeightfieldDistance(&m_dd, *m_chf);
|
||||
if (m_chf && m_drawMode == DRAWMODE_COMPACT_REGIONS)
|
||||
duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
|
||||
duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf);
|
||||
if (m_solid && m_drawMode == DRAWMODE_VOXELS)
|
||||
{
|
||||
glEnable(GL_FOG);
|
||||
duDebugDrawHeightfieldSolid(&dd, *m_solid);
|
||||
duDebugDrawHeightfieldSolid(&m_dd, *m_solid);
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
if (m_solid && m_drawMode == DRAWMODE_VOXELS_WALKABLE)
|
||||
{
|
||||
glEnable(GL_FOG);
|
||||
duDebugDrawHeightfieldWalkable(&dd, *m_solid);
|
||||
duDebugDrawHeightfieldWalkable(&m_dd, *m_solid);
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
if (m_cset && m_drawMode == DRAWMODE_RAW_CONTOURS)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
duDebugDrawRawContours(&dd, *m_cset);
|
||||
duDebugDrawRawContours(&m_dd, *m_cset);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_cset && m_drawMode == DRAWMODE_BOTH_CONTOURS)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
duDebugDrawRawContours(&dd, *m_cset, 0.5f);
|
||||
duDebugDrawContours(&dd, *m_cset);
|
||||
duDebugDrawRawContours(&m_dd, *m_cset, 0.5f);
|
||||
duDebugDrawContours(&m_dd, *m_cset);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_cset && m_drawMode == DRAWMODE_CONTOURS)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
duDebugDrawContours(&dd, *m_cset);
|
||||
duDebugDrawContours(&m_dd, *m_cset);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_chf && m_cset && m_drawMode == DRAWMODE_REGION_CONNECTIONS)
|
||||
{
|
||||
duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
|
||||
duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf);
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
duDebugDrawRegionConnections(&dd, *m_cset);
|
||||
duDebugDrawRegionConnections(&m_dd, *m_cset);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_pmesh && m_drawMode == DRAWMODE_POLYMESH)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
duDebugDrawPolyMesh(&dd, *m_pmesh);
|
||||
duDebugDrawPolyMesh(&m_dd, *m_pmesh);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_dmesh && m_drawMode == DRAWMODE_POLYMESH_DETAIL)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
duDebugDrawPolyMeshDetail(&dd, *m_dmesh);
|
||||
duDebugDrawPolyMeshDetail(&m_dd, *m_dmesh);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
m_geom->drawConvexVolumes(&dd);
|
||||
m_geom->drawConvexVolumes(&m_dd);
|
||||
|
||||
if (m_tool)
|
||||
m_tool->handleRender();
|
||||
|
@ -1034,25 +1034,23 @@ void Sample_TempObstacles::handleRender()
|
||||
if (!m_geom || !m_geom->getMesh())
|
||||
return;
|
||||
|
||||
DebugDrawGL dd;
|
||||
|
||||
const float texScale = 1.0f / (m_cellSize * 10.0f);
|
||||
|
||||
// Draw mesh
|
||||
if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
|
||||
{
|
||||
// Draw mesh
|
||||
duDebugDrawTriMeshSlope(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
|
||||
duDebugDrawTriMeshSlope(&m_dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
|
||||
m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(),
|
||||
m_agentMaxSlope, texScale);
|
||||
m_geom->drawOffMeshConnections(&dd);
|
||||
m_geom->drawOffMeshConnections(&m_dd);
|
||||
}
|
||||
|
||||
if (m_tileCache && m_drawMode == DRAWMODE_CACHE_BOUNDS)
|
||||
drawTiles(&dd, m_tileCache);
|
||||
drawTiles(&m_dd, m_tileCache);
|
||||
|
||||
if (m_tileCache)
|
||||
drawObstacles(&dd, m_tileCache);
|
||||
drawObstacles(&m_dd, m_tileCache);
|
||||
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
@ -1060,7 +1058,7 @@ void Sample_TempObstacles::handleRender()
|
||||
// Draw bounds
|
||||
const float* bmin = m_geom->getNavMeshBoundsMin();
|
||||
const float* bmax = m_geom->getNavMeshBoundsMax();
|
||||
duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
|
||||
duDebugDrawBoxWire(&m_dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
|
||||
|
||||
// Tiling grid.
|
||||
int gw = 0, gh = 0;
|
||||
@ -1068,7 +1066,7 @@ void Sample_TempObstacles::handleRender()
|
||||
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);
|
||||
duDebugDrawGridXZ(&m_dd, bmin[0],bmin[1],bmin[2], tw,th, s, duRGBA(0,0,0,64), 1.0f);
|
||||
|
||||
if (m_navMesh && m_navQuery &&
|
||||
(m_drawMode == DRAWMODE_NAVMESH ||
|
||||
@ -1079,20 +1077,20 @@ void Sample_TempObstacles::handleRender()
|
||||
m_drawMode == DRAWMODE_NAVMESH_INVIS))
|
||||
{
|
||||
if (m_drawMode != DRAWMODE_NAVMESH_INVIS)
|
||||
duDebugDrawNavMeshWithClosedList(&dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags/*|DU_DRAWNAVMESH_COLOR_TILES*/);
|
||||
duDebugDrawNavMeshWithClosedList(&m_dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags/*|DU_DRAWNAVMESH_COLOR_TILES*/);
|
||||
if (m_drawMode == DRAWMODE_NAVMESH_BVTREE)
|
||||
duDebugDrawNavMeshBVTree(&dd, *m_navMesh);
|
||||
duDebugDrawNavMeshBVTree(&m_dd, *m_navMesh);
|
||||
if (m_drawMode == DRAWMODE_NAVMESH_PORTALS)
|
||||
duDebugDrawNavMeshPortals(&dd, *m_navMesh);
|
||||
duDebugDrawNavMeshPortals(&m_dd, *m_navMesh);
|
||||
if (m_drawMode == DRAWMODE_NAVMESH_NODES)
|
||||
duDebugDrawNavMeshNodes(&dd, *m_navQuery);
|
||||
duDebugDrawNavMeshPolysWithFlags(&dd, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128));
|
||||
duDebugDrawNavMeshNodes(&m_dd, *m_navQuery);
|
||||
duDebugDrawNavMeshPolysWithFlags(&m_dd, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128));
|
||||
}
|
||||
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
m_geom->drawConvexVolumes(&dd);
|
||||
m_geom->drawConvexVolumes(&m_dd);
|
||||
|
||||
if (m_tool)
|
||||
m_tool->handleRender();
|
||||
@ -1103,9 +1101,8 @@ void Sample_TempObstacles::handleRender()
|
||||
|
||||
void Sample_TempObstacles::renderCachedTile(const int tx, const int ty, const int type)
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
if (m_tileCache)
|
||||
drawDetail(&dd,m_tileCache,tx,ty,type);
|
||||
drawDetail(&m_dd,m_tileCache,tx,ty,type);
|
||||
}
|
||||
|
||||
void Sample_TempObstacles::renderCachedTileOverlay(const int tx, const int ty, double* proj, double* model, int* view)
|
||||
|
@ -550,18 +550,16 @@ void Sample_TileMesh::handleRender()
|
||||
if (!m_geom || !m_geom->getMesh())
|
||||
return;
|
||||
|
||||
DebugDrawGL dd;
|
||||
|
||||
const float texScale = 1.0f / (m_cellSize * 10.0f);
|
||||
|
||||
// Draw mesh
|
||||
if (m_drawMode != DRAWMODE_NAVMESH_TRANS)
|
||||
{
|
||||
// Draw mesh
|
||||
duDebugDrawTriMeshSlope(&dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
|
||||
duDebugDrawTriMeshSlope(&m_dd, m_geom->getMesh()->getVerts(), m_geom->getMesh()->getVertCount(),
|
||||
m_geom->getMesh()->getTris(), m_geom->getMesh()->getNormals(), m_geom->getMesh()->getTriCount(),
|
||||
m_agentMaxSlope, texScale);
|
||||
m_geom->drawOffMeshConnections(&dd);
|
||||
m_geom->drawOffMeshConnections(&m_dd);
|
||||
}
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
@ -569,7 +567,7 @@ void Sample_TileMesh::handleRender()
|
||||
// Draw bounds
|
||||
const float* bmin = m_geom->getNavMeshBoundsMin();
|
||||
const float* bmax = m_geom->getNavMeshBoundsMax();
|
||||
duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
|
||||
duDebugDrawBoxWire(&m_dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
|
||||
|
||||
// Tiling grid.
|
||||
int gw = 0, gh = 0;
|
||||
@ -577,10 +575,10 @@ void Sample_TileMesh::handleRender()
|
||||
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);
|
||||
duDebugDrawGridXZ(&m_dd, bmin[0],bmin[1],bmin[2], tw,th, s, duRGBA(0,0,0,64), 1.0f);
|
||||
|
||||
// Draw active tile
|
||||
duDebugDrawBoxWire(&dd, m_lastBuiltTileBmin[0],m_lastBuiltTileBmin[1],m_lastBuiltTileBmin[2],
|
||||
duDebugDrawBoxWire(&m_dd, m_lastBuiltTileBmin[0],m_lastBuiltTileBmin[1],m_lastBuiltTileBmin[2],
|
||||
m_lastBuiltTileBmax[0],m_lastBuiltTileBmax[1],m_lastBuiltTileBmax[2], m_tileCol, 1.0f);
|
||||
|
||||
if (m_navMesh && m_navQuery &&
|
||||
@ -592,81 +590,81 @@ void Sample_TileMesh::handleRender()
|
||||
m_drawMode == DRAWMODE_NAVMESH_INVIS))
|
||||
{
|
||||
if (m_drawMode != DRAWMODE_NAVMESH_INVIS)
|
||||
duDebugDrawNavMeshWithClosedList(&dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags);
|
||||
duDebugDrawNavMeshWithClosedList(&m_dd, *m_navMesh, *m_navQuery, m_navMeshDrawFlags);
|
||||
if (m_drawMode == DRAWMODE_NAVMESH_BVTREE)
|
||||
duDebugDrawNavMeshBVTree(&dd, *m_navMesh);
|
||||
duDebugDrawNavMeshBVTree(&m_dd, *m_navMesh);
|
||||
if (m_drawMode == DRAWMODE_NAVMESH_PORTALS)
|
||||
duDebugDrawNavMeshPortals(&dd, *m_navMesh);
|
||||
duDebugDrawNavMeshPortals(&m_dd, *m_navMesh);
|
||||
if (m_drawMode == DRAWMODE_NAVMESH_NODES)
|
||||
duDebugDrawNavMeshNodes(&dd, *m_navQuery);
|
||||
duDebugDrawNavMeshPolysWithFlags(&dd, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128));
|
||||
duDebugDrawNavMeshNodes(&m_dd, *m_navQuery);
|
||||
duDebugDrawNavMeshPolysWithFlags(&m_dd, *m_navMesh, SAMPLE_POLYFLAGS_DISABLED, duRGBA(0,0,0,128));
|
||||
}
|
||||
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
if (m_chf && m_drawMode == DRAWMODE_COMPACT)
|
||||
duDebugDrawCompactHeightfieldSolid(&dd, *m_chf);
|
||||
duDebugDrawCompactHeightfieldSolid(&m_dd, *m_chf);
|
||||
|
||||
if (m_chf && m_drawMode == DRAWMODE_COMPACT_DISTANCE)
|
||||
duDebugDrawCompactHeightfieldDistance(&dd, *m_chf);
|
||||
duDebugDrawCompactHeightfieldDistance(&m_dd, *m_chf);
|
||||
if (m_chf && m_drawMode == DRAWMODE_COMPACT_REGIONS)
|
||||
duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
|
||||
duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf);
|
||||
if (m_solid && m_drawMode == DRAWMODE_VOXELS)
|
||||
{
|
||||
glEnable(GL_FOG);
|
||||
duDebugDrawHeightfieldSolid(&dd, *m_solid);
|
||||
duDebugDrawHeightfieldSolid(&m_dd, *m_solid);
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
if (m_solid && m_drawMode == DRAWMODE_VOXELS_WALKABLE)
|
||||
{
|
||||
glEnable(GL_FOG);
|
||||
duDebugDrawHeightfieldWalkable(&dd, *m_solid);
|
||||
duDebugDrawHeightfieldWalkable(&m_dd, *m_solid);
|
||||
glDisable(GL_FOG);
|
||||
}
|
||||
|
||||
if (m_cset && m_drawMode == DRAWMODE_RAW_CONTOURS)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
duDebugDrawRawContours(&dd, *m_cset);
|
||||
duDebugDrawRawContours(&m_dd, *m_cset);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
if (m_cset && m_drawMode == DRAWMODE_BOTH_CONTOURS)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
duDebugDrawRawContours(&dd, *m_cset, 0.5f);
|
||||
duDebugDrawContours(&dd, *m_cset);
|
||||
duDebugDrawRawContours(&m_dd, *m_cset, 0.5f);
|
||||
duDebugDrawContours(&m_dd, *m_cset);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_cset && m_drawMode == DRAWMODE_CONTOURS)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
duDebugDrawContours(&dd, *m_cset);
|
||||
duDebugDrawContours(&m_dd, *m_cset);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_chf && m_cset && m_drawMode == DRAWMODE_REGION_CONNECTIONS)
|
||||
{
|
||||
duDebugDrawCompactHeightfieldRegions(&dd, *m_chf);
|
||||
duDebugDrawCompactHeightfieldRegions(&m_dd, *m_chf);
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
duDebugDrawRegionConnections(&dd, *m_cset);
|
||||
duDebugDrawRegionConnections(&m_dd, *m_cset);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_pmesh && m_drawMode == DRAWMODE_POLYMESH)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
duDebugDrawPolyMesh(&dd, *m_pmesh);
|
||||
duDebugDrawPolyMesh(&m_dd, *m_pmesh);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
if (m_dmesh && m_drawMode == DRAWMODE_POLYMESH_DETAIL)
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
duDebugDrawPolyMeshDetail(&dd, *m_dmesh);
|
||||
duDebugDrawPolyMeshDetail(&m_dd, *m_dmesh);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
m_geom->drawConvexVolumes(&dd);
|
||||
m_geom->drawConvexVolumes(&m_dd);
|
||||
|
||||
if (m_tool)
|
||||
m_tool->handleRender();
|
||||
|
Loading…
x
Reference in New Issue
Block a user