Recast: fix compile error

This function was removed in commit 041d02cd654d94bf4b059c212cb6a63a39e5324e but it should've been kept in as it was still used for dtNavMeshQuery::findRandomPointAroundCircle. Only the quantizer should be removed.
This commit is contained in:
Kawe Mazidjatari 2024-08-30 15:54:30 +02:00
parent 77b9d056e8
commit 537f149be3
2 changed files with 23 additions and 0 deletions

View File

@ -265,6 +265,12 @@ struct dtPoly
inline unsigned char getType() const { return areaAndtype >> 6; }
};
/// Calculates the surface area of the polygon.
/// @param[in] poly The polygon.
/// @param[in] verts The polygon vertices.
/// @return The total surface are of the polygon.
float dtCalcPolySurfaceArea(const dtPoly* poly, const float* verts);
/// Defines the location of detail sub-mesh data within a dtMeshTile.
struct dtPolyDetail
{

View File

@ -1868,6 +1868,23 @@ unsigned char dtQuantLinkDistance(const float distance)
return (unsigned char)(rdMathRoundf(distance * DT_TRAVERSE_DIST_QUANT_FACTOR));
}
float dtCalcPolySurfaceArea(const dtPoly* poly, const float* verts)
{
float polyArea = 0.0f;
// Only run if we have more than 2 verts since poly's with 2 verts
// (off-mesh connections) don't have any surface area.
for (int i = 2; i < poly->vertCount; ++i)
{
const float* va = &verts[poly->verts[0]*3];
const float* vb = &verts[poly->verts[i]*3];
const float* vc = &verts[poly->verts[i-1]*3];
polyArea += rdTriArea2D(va,vb,vc);
}
return polyArea;
}
float dtCalcOffMeshRefYaw(const float* spos, const float* epos)
{
const float dx = epos[0]-spos[0];