updated drawmodes and rendering

DebugDraw for recast now caches the results
We now have a drawmode dropdown selector
drawmode changes come from the gui itself no longer from console values
all recast drawmodes are supported with the exception of drawmodes that add abilities like navqueries until the nav tester tool is imlpemented.
This commit is contained in:
marauder2k7 2025-07-24 14:25:02 +01:00
parent 30b9502e90
commit d1771756c2
12 changed files with 548 additions and 53 deletions

View file

@ -33,6 +33,10 @@ RecastPolyList::RecastPolyList() : mChunkyMesh(0)
verts = NULL;
vertcap = 0;
nnormals = 0;
normals = NULL;
normalcap = 0;
ntris = 0;
tris = NULL;
tricap = 0;
@ -73,6 +77,11 @@ void RecastPolyList::clear()
verts = NULL;
vertcap = 0;
nnormals = 0;
delete[] normals;
normals = NULL;
normalcap = 0;
ntris = 0;
delete[] tris;
tris = NULL;
@ -156,6 +165,39 @@ void RecastPolyList::vertex(U32 vi)
void RecastPolyList::end()
{
// Fetch current triangle indices
const U32 i0 = tris[ntris * 3 + 0];
const U32 i1 = tris[ntris * 3 + 1];
const U32 i2 = tris[ntris * 3 + 2];
// Rebuild vertices
Point3F v0(verts[i0 * 3 + 0], verts[i0 * 3 + 1], verts[i0 * 3 + 2]);
Point3F v1(verts[i1 * 3 + 0], verts[i1 * 3 + 1], verts[i1 * 3 + 2]);
Point3F v2(verts[i2 * 3 + 0], verts[i2 * 3 + 1], verts[i2 * 3 + 2]);
// Compute normal
Point3F edge1 = v1 - v0;
Point3F edge2 = v2 - v0;
Point3F normal = mCross(edge1, edge2);
normal.normalizeSafe();
// Allocate/resize normal buffer if needed
if (nnormals == normalcap)
{
normalcap = (normalcap == 0) ? 16 : normalcap * 2;
F32* newNormals = new F32[normalcap * 3];
if (normals)
dMemcpy(newNormals, normals, nnormals * 3 * sizeof(F32));
delete[] normals;
normals = newNormals;
}
// Store normal
normals[nnormals * 3 + 0] = normal.x;
normals[nnormals * 3 + 1] = normal.y;
normals[nnormals * 3 + 2] = normal.z;
nnormals++;
ntris++;
}
@ -169,6 +211,11 @@ const F32 *RecastPolyList::getVerts() const
return verts;
}
const F32* RecastPolyList::getNormals() const
{
return normals;
}
U32 RecastPolyList::getTriCount() const
{
return ntris;