Add NavMesh BVTree debug overlay

navmesh_draw_bvtree > -1 enables the overlay, with this cvar you can also shift through tiles.
navmesh_debug_type [0 - 4] selects the NavMesh (small, med_short, medium, large, extra_large).
This commit is contained in:
Kawe Mazidjatari 2022-07-20 21:23:56 +02:00
parent be42e98197
commit 2998953600
4 changed files with 48 additions and 14 deletions

View File

@ -16,6 +16,7 @@
#include "materialsystem/cmaterialsystem.h"
#include "mathlib/mathlib.h"
#ifndef CLIENT_DLL
#include "game/server/ai_utility.h"
#include "game/server/ai_network.h"
#include "game/server/ai_networkmanager.h"
#endif // !CLIENT_DLL
@ -271,24 +272,45 @@ void DrawAIScriptNodes()
#endif // !CLIENT_DLL
}
void DrawNavMeshTiles()
//------------------------------------------------------------------------------
// Purpose : draw NavMesh BVTree
//------------------------------------------------------------------------------
void DrawNavMeshBVTree()
{
#ifndef CLIENT_DLL
dtNavMesh* mesh = g_pNavMesh[0];
dtNavMesh* mesh = GetNavMeshForHull(navmesh_debug_type->GetInt());
if (!mesh)
return;
for (int i = 0; i < mesh->getTileCount(); ++i)
OverlayBox_t::Transforms vTransforms;
for (int i = navmesh_draw_bvtree->GetInt(); i < mesh->getTileCount(); ++i)
{
const dtMeshTile* tile = &mesh->m_tiles[i];
if (!tile->header) continue;
OverlayBox_t::Transforms vTransforms;
if (!tile->header)
continue;
vTransforms.xmm[0] = _mm_set_ps(tile->polys[0].org[0] - 50.f, 0.0f, 0.0f, 1.0f);
vTransforms.xmm[1] = _mm_set_ps(tile->polys[0].org[1] - 50.f, 0.0f, 1.0f, 0.0f);
vTransforms.xmm[2] = _mm_set_ps(tile->polys[0].org[2] - 50.f, 1.0f, 0.0f, 0.0f);
const float cs = 1.0f / tile->header->bvQuantFactor;
for (int j = 0; j < tile->header->bvNodeCount; ++j)
{
const dtBVNode* node = &tile->bvTree[j];
if (node->i < 0) // Leaf indices are positive.
continue;
v_RenderBox(vTransforms, { 0, 0, 0 }, { 100, 100, 100 }, Color(0, 255, 0, 255), r_debug_overlay_zbuffer->GetBool());
vTransforms.xmm[0] = _mm_set_ps(0.0f, 0.0f, 0.0f, 1.0f);
vTransforms.xmm[1] = _mm_set_ps(0.0f, 0.0f, 1.0f, 0.0f);
vTransforms.xmm[2] = _mm_set_ps(0.0f, 1.0f, 0.0f, 0.0f);
Vector3D vMins(
tile->header->bmin[0] + node->bmin[0] * cs,
tile->header->bmin[1] + node->bmin[1] * cs,
tile->header->bmin[2] + node->bmin[2] * cs);
Vector3D vMaxs(
tile->header->bmin[0] + node->bmax[0] * cs,
tile->header->bmin[1] + node->bmax[1] * cs,
tile->header->bmin[2] + node->bmax[2] * cs);
v_RenderBox(vTransforms, vMins, vMaxs, Color(255, 255, 255, 255), r_debug_overlay_zbuffer->GetBool());
}
}
#endif
}
@ -307,8 +329,10 @@ void DrawAllOverlays(bool bDraw)
{
DrawAIScriptNodes();
}
//DrawNavMeshTiles();
if (navmesh_draw_bvtree->GetInt() > -1)
{
DrawNavMeshBVTree();
}
EnterCriticalSection(&*s_OverlayMutex);

View File

@ -64,7 +64,10 @@ void ConVar::Init(void) const
ai_ainDumpOnLoad = new ConVar("ai_ainDumpOnLoad" , "0", FCVAR_DEVELOPMENTONLY, "Dumps AIN data from node graphs loaded from the disk on load.", false, 0.f, false, 0.f, nullptr, nullptr);
ai_ainDebugConnect = new ConVar("ai_ainDebugConnect" , "0", FCVAR_DEVELOPMENTONLY, "Debug AIN node connections.", false, 0.f, false, 0.f, nullptr, nullptr);
ai_script_nodes_draw_index = new ConVar("ai_script_nodes_draw_index", "0", FCVAR_DEVELOPMENTONLY, "Start index for drawing script nodes.", false, 0.f, false, 0.f, nullptr, nullptr);
navmesh_always_reachable = new ConVar("navmesh_always_reachable" , "0", FCVAR_DEVELOPMENTONLY, "Marks poly from agent to target on navmesh as reachable regardless of table data ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
navmesh_always_reachable = new ConVar("navmesh_always_reachable" , "0", FCVAR_DEVELOPMENTONLY, "Marks goal poly from agent poly as reachable regardless of table data ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr);
navmesh_debug_type = new ConVar("navmesh_debug_type" , "0", FCVAR_DEVELOPMENTONLY, "NavMesh hull index for debug draw.", true, 0.f, true, 4.f, nullptr, "0 = small, 1 = med_short, 2 = medium, 3 = large, 4 = extra large");
navmesh_draw_bvtree = new ConVar("navmesh_draw_bvtree" , "-1", FCVAR_DEVELOPMENTONLY, "Draws the BVTree of the NavMesh.", false, 0.f, false, 0.f, nullptr, "Index: > 0 && < tile->header->bvNodeCount");
sv_showconnecting = new ConVar("sv_showconnecting" , "1", FCVAR_RELEASE, "Logs information about the connecting client to the console.", false, 0.f, false, 0.f, nullptr, nullptr);
sv_pylonVisibility = new ConVar("sv_pylonVisibility", "0", FCVAR_RELEASE, "Determines the visiblity to the Pylon master server, 0 = Offline, 1 = Hidden, 2 = Public.", false, 0.f, false, 0.f, nullptr, nullptr);
@ -77,7 +80,7 @@ void ConVar::Init(void) const
sv_rcon_maxfailures = new ConVar("sv_rcon_maxfailures", "10", FCVAR_RELEASE, "Max number of times a user can fail rcon authentication before being banned.", false, 0.f, false, 0.f, nullptr, nullptr);
sv_rcon_maxignores = new ConVar("sv_rcon_maxignores" , "15", FCVAR_RELEASE, "Max number of times a user can ignore the no-auth message before being banned.", false, 0.f, false, 0.f, nullptr, nullptr);
sv_rcon_maxsockets = new ConVar("sv_rcon_maxsockets" , "32", FCVAR_RELEASE, "Max number of accepted sockets before the server starts closing redundant sockets.", false, 0.f, false, 0.f, nullptr, nullptr);
sv_rcon_whitelist_address = new ConVar("sv_rcon_whitelist_address", "", FCVAR_RELEASE, "This address is not considered a 'redundant' socket and will never be banned for failed authentications. Example: '::ffff:127.0.0.1'.", false, 0.f, false, 0.f, nullptr, nullptr);
sv_rcon_whitelist_address = new ConVar("sv_rcon_whitelist_address", "", FCVAR_RELEASE, "This address is not considered a 'redundant' socket and will never be banned for failed authentications.", false, 0.f, false, 0.f, nullptr, "Format: '::ffff:127.0.0.1'.");
#endif // DEDICATED
//-------------------------------------------------------------------------
// CLIENT |

View File

@ -44,7 +44,10 @@ ConVar* ai_ainDumpOnLoad = nullptr;
ConVar* ai_ainDebugConnect = nullptr;
ConVar* ai_script_nodes_draw = nullptr;
ConVar* ai_script_nodes_draw_index = nullptr;
ConVar* navmesh_always_reachable = nullptr;
ConVar* navmesh_debug_type = nullptr;
ConVar* navmesh_draw_bvtree = nullptr;
ConVar* sv_showconnecting = nullptr;
ConVar* sv_pylonVisibility = nullptr;

View File

@ -43,7 +43,11 @@ extern ConVar* ai_ainDumpOnLoad;
extern ConVar* ai_ainDebugConnect;
extern ConVar* ai_script_nodes_draw;
extern ConVar* ai_script_nodes_draw_index;
extern ConVar* navmesh_always_reachable;
extern ConVar* navmesh_debug_type;
extern ConVar* navmesh_draw_bvtree;
extern ConVar* sv_showconnecting;
extern ConVar* sv_pylonVisibility;
extern ConVar* sv_pylonRefreshInterval;