mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Recast: move surface area quantization into its own function
Avoid potential mistakes in the future by using the wrong quant factor.
This commit is contained in:
parent
4f72c9aee8
commit
f9fb1c6c64
@ -273,6 +273,7 @@ struct dtPoly
|
||||
/// @param[in] verts The polygon vertices.
|
||||
/// @return The total surface are of the polygon.
|
||||
float dtCalcPolySurfaceArea(const dtPoly* poly, const float* verts);
|
||||
unsigned short dtQuantPolySurfaceArea(const float area);
|
||||
|
||||
/// Defines the location of detail sub-mesh data within a dtMeshTile.
|
||||
struct dtPolyDetail
|
||||
|
@ -1865,7 +1865,7 @@ float dtCalcLinkDistance(const float* spos, const float* epos)
|
||||
unsigned char dtQuantLinkDistance(const float distance)
|
||||
{
|
||||
if (distance > DT_TRAVERSE_DIST_MAX) return (unsigned char)0;
|
||||
return (unsigned char)(distance * DT_TRAVERSE_DIST_QUANT_FACTOR);
|
||||
return (unsigned char)(rdMathRoundf(distance * DT_TRAVERSE_DIST_QUANT_FACTOR));
|
||||
}
|
||||
|
||||
float dtCalcPolySurfaceArea(const dtPoly* poly, const float* verts)
|
||||
@ -1885,6 +1885,11 @@ float dtCalcPolySurfaceArea(const dtPoly* poly, const float* verts)
|
||||
return polyArea;
|
||||
}
|
||||
|
||||
unsigned short dtQuantPolySurfaceArea(const float area)
|
||||
{
|
||||
return (unsigned short)rdMathRoundf(area * DT_POLY_AREA_QUANT_FACTOR);
|
||||
}
|
||||
|
||||
float dtCalcOffMeshRefYaw(const float* spos, const float* epos)
|
||||
{
|
||||
const float dx = epos[0]-spos[0];
|
||||
|
@ -1050,7 +1050,7 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData,
|
||||
p->vertCount++;
|
||||
}
|
||||
rdVscale(p->center, p->center, 1 / (float)(p->vertCount));
|
||||
p->surfaceArea = (unsigned short)rdMathFloorf(dtCalcPolySurfaceArea(p,navVerts) * DT_POLY_AREA_QUANT_FACTOR);
|
||||
p->surfaceArea = dtQuantPolySurfaceArea(dtCalcPolySurfaceArea(p,navVerts));
|
||||
|
||||
src += nvp*2;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user