Recast: add more render options

This commit is contained in:
Kawe Mazidjatari 2024-07-06 09:24:39 +02:00
parent 601d958e14
commit b5afdfe2f3
5 changed files with 36 additions and 19 deletions

View File

@ -377,6 +377,15 @@ void Editor_TileMesh::handleDebugMode()
imguiLabel("Render Options");
if (imguiCheck("Draw Off-Mesh Connections", (getNavMeshDrawFlags() & DU_DRAWNAVMESH_OFFMESHCONS)))
toggleNavMeshDrawFlag(DU_DRAWNAVMESH_OFFMESHCONS);
if (imguiCheck("Draw Closed List", (getNavMeshDrawFlags() & DU_DRAWNAVMESH_CLOSEDLIST)))
toggleNavMeshDrawFlag(DU_DRAWNAVMESH_CLOSEDLIST);
if (imguiCheck("Draw Tile ID Colors", (getNavMeshDrawFlags() & DU_DRAWNAVMESH_COLOR_TILES)))
toggleNavMeshDrawFlag(DU_DRAWNAVMESH_COLOR_TILES);
if (imguiCheck("Draw Vertex Points", (getNavMeshDrawFlags() & DU_DRAWNAVMESH_VERTS)))
toggleNavMeshDrawFlag(DU_DRAWNAVMESH_VERTS);
@ -386,6 +395,12 @@ void Editor_TileMesh::handleDebugMode()
if (imguiCheck("Draw Outer Poly Boundaries", (getNavMeshDrawFlags() & DU_DRAWNAVMESH_OUTERBOUND)))
toggleNavMeshDrawFlag(DU_DRAWNAVMESH_OUTERBOUND);
if (imguiCheck("Draw Poly Centers", (getNavMeshDrawFlags() & DU_DRAWNAVMESH_POLYCENTERS)))
toggleNavMeshDrawFlag(DU_DRAWNAVMESH_POLYCENTERS);
if (imguiCheck("Disable NavMesh Depth Mask", (getNavMeshDrawFlags() & DU_DRAWNAVMESH_NO_DEPTH_MASK)))
toggleNavMeshDrawFlag(DU_DRAWNAVMESH_NO_DEPTH_MASK);
if (imguiCheck("Disable NavMesh Transparency", (getNavMeshDrawFlags() & DU_DRAWNAVMESH_NO_ALPHA)))
toggleNavMeshDrawFlag(DU_DRAWNAVMESH_NO_ALPHA);

View File

@ -113,7 +113,7 @@ protected:
class dtNavMeshQuery* m_navQuery;
class dtCrowd* m_crowd;
unsigned char m_navMeshDrawFlags;
unsigned int m_navMeshDrawFlags;
bool m_filterLowHangingObstacles;
bool m_filterLedgeSpans;
bool m_filterWalkableLowHeightSpans;
@ -179,10 +179,10 @@ public:
virtual float getAgentHeight() { return m_agentHeight; }
virtual float getAgentClimb() { return m_agentMaxClimb; }
inline unsigned char getNavMeshDrawFlags() const { return m_navMeshDrawFlags; }
inline void setNavMeshDrawFlags(unsigned char flags) { m_navMeshDrawFlags = flags; }
inline unsigned int getNavMeshDrawFlags() const { return m_navMeshDrawFlags; }
inline void setNavMeshDrawFlags(unsigned int flags) { m_navMeshDrawFlags = flags; }
inline void toggleNavMeshDrawFlag(unsigned char flag) { m_navMeshDrawFlags ^= flag; }
inline void toggleNavMeshDrawFlag(unsigned int flag) { m_navMeshDrawFlags ^= flag; }
void updateToolStates(const float dt);
void initToolStates(Editor* editor);

View File

@ -29,7 +29,7 @@ class OffMeshConnectionTool : public EditorTool
float m_hitPos[3];
bool m_hitPosSet;
bool m_bidir;
unsigned char m_oldFlags;
unsigned int m_oldFlags;
public:
OffMeshConnectionTool();

View File

@ -25,17 +25,19 @@
enum DrawNavMeshFlags
{
DU_DRAWNAVMESH_OFFMESHCONS = 1 << 0,
DU_DRAWNAVMESH_CLOSEDLIST = 1 << 1,
DU_DRAWNAVMESH_COLOR_TILES = 1 << 2,
DU_DRAWNAVMESH_VERTS = 1 << 3, // Render vertex points
DU_DRAWNAVMESH_INNERBOUND = 1 << 4, // Render inner poly boundaries
DU_DRAWNAVMESH_OUTERBOUND = 1 << 5, // Render outer poly boundaries
DU_DRAWNAVMESH_NO_ALPHA = 1 << 6, // Render meshes as opaque.
DU_DRAWNAVMESH_OFFMESHCONS = 1 << 0, // Render off-mesh connections.
DU_DRAWNAVMESH_CLOSEDLIST = 1 << 1, // Render navmesh with closed list.
DU_DRAWNAVMESH_COLOR_TILES = 1 << 2, // Render tiles colored by their ID's.
DU_DRAWNAVMESH_VERTS = 1 << 3, // Render vertex points.
DU_DRAWNAVMESH_INNERBOUND = 1 << 4, // Render inner poly boundaries.
DU_DRAWNAVMESH_OUTERBOUND = 1 << 5, // Render outer poly boundaries.
DU_DRAWNAVMESH_POLYCENTERS = 1 << 6, // Render poly centers.
DU_DRAWNAVMESH_NO_DEPTH_MASK = 1 << 7, // Disable render depth mask.
DU_DRAWNAVMESH_NO_ALPHA = 1 << 8, // Disable navmesh transparency.
};
void duDebugDrawNavMesh(struct duDebugDraw* dd, const dtNavMesh& mesh, unsigned char flags);
void duDebugDrawNavMeshWithClosedList(struct duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMeshQuery& query, unsigned char flags);
void duDebugDrawNavMeshWithClosedList(struct duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMeshQuery& query, unsigned int flags);
void duDebugDrawNavMeshNodes(struct duDebugDraw* dd, const dtNavMeshQuery& query);
void duDebugDrawNavMeshBVTree(struct duDebugDraw* dd, const dtNavMesh& mesh);
void duDebugDrawNavMeshPortals(struct duDebugDraw* dd, const dtNavMesh& mesh);

View File

@ -134,18 +134,17 @@ static void drawPolyCenters(duDebugDraw* dd, const dtMeshTile* tile, const unsig
}
static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMeshQuery* query,
const dtMeshTile* tile, unsigned char flags)
const dtMeshTile* tile, unsigned int flags)
{
dtPolyRef base = mesh.getPolyRefBase(tile);
int tileNum = mesh.decodePolyIdTile(base);
// If "No Alpha" flag is set, force the colour to be opaque instead of semi-transparent.
const int tileAlpha = flags & DU_DRAWNAVMESH_NO_ALPHA ? 255 : 170;
const unsigned int tileColor = duIntToCol(tileNum, tileAlpha);
dd->depthMask(true);
const bool disableDepthTest = flags & DU_DRAWNAVMESH_NO_DEPTH_MASK;
dd->depthMask(!disableDepthTest);
dd->begin(DU_DRAW_TRIS);
for (int i = 0; i < tile->header->polyCount; ++i)
@ -190,7 +189,8 @@ static void drawMeshTile(duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMesh
drawPolyBoundaries(dd, tile, 2.5f, false);
// Draw poly centers
drawPolyCenters(dd, tile, duRGBA(255, 255, 255, 100), 1.0f);
if (flags & DU_DRAWNAVMESH_POLYCENTERS)
drawPolyCenters(dd, tile, duRGBA(255, 255, 255, 100), 1.0f);
if (flags & DU_DRAWNAVMESH_OFFMESHCONS)
{
@ -277,7 +277,7 @@ void duDebugDrawNavMesh(duDebugDraw* dd, const dtNavMesh& mesh, unsigned char fl
}
}
void duDebugDrawNavMeshWithClosedList(struct duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMeshQuery& query, unsigned char flags)
void duDebugDrawNavMeshWithClosedList(struct duDebugDraw* dd, const dtNavMesh& mesh, const dtNavMeshQuery& query, unsigned int flags)
{
if (!dd) return;