Recast: create method for getting actual tile bounds

Properly calculate the height of the tile bounding.
This commit is contained in:
Kawe Mazidjatari 2024-08-16 20:38:09 +02:00
parent 12e370e630
commit 7ec6ab5b3f
2 changed files with 36 additions and 0 deletions

View File

@ -425,6 +425,8 @@ public:
bool linkCountAvailable(const int count) const;
void getTightBounds(float* bminOut, float* bmaxOut) const;
unsigned int salt; ///Counter describing modifications to the tile.
unsigned int linksFreeList; ///Index to the next free link.

View File

@ -149,6 +149,40 @@ bool dtMeshTile::linkCountAvailable(const int count) const
return true;
}
void dtMeshTile::getTightBounds(float* bminOut, float* bmaxOut) const
{
float hmin = FLT_MAX;
float hmax = -FLT_MAX;
if (detailVerts && header->detailVertCount)
{
for (int i = 0; i < header->detailVertCount; ++i)
{
const float h = detailVerts[i*3+2];
hmin = rdMin(hmin, h);
hmax = rdMax(hmax, h);
}
}
else
{
for (int i = 0; i < header->vertCount; ++i)
{
const float h = verts[i*3+2];
hmin = rdMin(hmin, h);
hmax = rdMax(hmax, h);
}
}
hmin -= header->walkableClimb;
hmax += header->walkableClimb;
rdVcopy(bminOut, header->bmin);
rdVcopy(bmaxOut, header->bmax);
bminOut[2] = hmin;
bmaxOut[2] = hmax;
}
int dtCalcTraverseTableCellIndex(const int numPolyGroups,
const unsigned short polyGroup1, const unsigned short polyGroup2)
{