mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Recast: fix several bugs related to off-mesh connections
- Off-mesh connections should always be linked to target poly's first. Also set the linked flag on titanfall navmeshes as this is necessary during the pruning stage. - When connecting off-mesh links, we need to iterate over tiles using m_maxTiles, not m_tileCount as m_tileCount counts the number of added tiles, while m_maxTiles contains the maximum tiles in the lookup array, there can be empties in between. - Radians to degrees and visa versa has been moved to a simple inline function, but during this, a regression was made where it was accidentally inverted in dtCalcOffMeshRefYaw and dtCalcOffMeshRefPos.
This commit is contained in:
parent
49907272fb
commit
e62051eff3
@ -620,8 +620,12 @@ dtStatus dtNavMesh::connectOffMeshLinks(const dtTileRef tileRef)
|
|||||||
con->setTraverseType(traverseType, 0);
|
con->setTraverseType(traverseType, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Link off-mesh connection to target poly.
|
||||||
|
if (!connectOffMeshLink(tile, conPoly, basePolyRef, 0xff, 0, DT_NULL_TRAVERSE_TYPE, 0))
|
||||||
|
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||||
|
|
||||||
// Start end-point is always connect back to off-mesh connection.
|
// Start end-point is always connect back to off-mesh connection.
|
||||||
const unsigned short basePolyIdx = (unsigned short)decodePolyIdPoly(basePolyRef);
|
const unsigned int basePolyIdx = decodePolyIdPoly(basePolyRef);
|
||||||
dtPoly* basePoly = &tile->polys[basePolyIdx];
|
dtPoly* basePoly = &tile->polys[basePolyIdx];
|
||||||
|
|
||||||
const dtPolyRef conPolyRef = base | (dtPolyRef)(con->poly);
|
const dtPolyRef conPolyRef = base | (dtPolyRef)(con->poly);
|
||||||
@ -630,10 +634,6 @@ dtStatus dtNavMesh::connectOffMeshLinks(const dtTileRef tileRef)
|
|||||||
invertVertLookup ? DT_OFFMESH_CON_TRAVERSE_ON_VERT : DT_OFFMESH_CON_TRAVERSE_ON_POLY))
|
invertVertLookup ? DT_OFFMESH_CON_TRAVERSE_ON_VERT : DT_OFFMESH_CON_TRAVERSE_ON_POLY))
|
||||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||||
|
|
||||||
// Link off-mesh connection to target poly.
|
|
||||||
if (!connectOffMeshLink(tile, conPoly, basePolyRef, 0xff, 0, DT_NULL_TRAVERSE_TYPE, 0))
|
|
||||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
// connect to land points.
|
// connect to land points.
|
||||||
const float halfExtents[3] = { con->rad, con->rad, header->walkableClimb };
|
const float halfExtents[3] = { con->rad, con->rad, header->walkableClimb };
|
||||||
float bmin[3], bmax[3];
|
float bmin[3], bmax[3];
|
||||||
@ -679,10 +679,9 @@ dtStatus dtNavMesh::connectOffMeshLinks(const dtTileRef tileRef)
|
|||||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DT_NAVMESH_SET_VERSION >= 7
|
|
||||||
// Off-mesh link is fully linked, mark it.
|
// Off-mesh link is fully linked, mark it.
|
||||||
conPoly->flags |= DT_POLYFLAGS_JUMP_LINKED;
|
conPoly->flags |= DT_POLYFLAGS_JUMP_LINKED;
|
||||||
#endif
|
|
||||||
// All links have been established, break out entirely.
|
// All links have been established, break out entirely.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1743,7 +1742,7 @@ dtStatus dtNavMesh::removeTile(dtTileRef ref, unsigned char** data, int* dataSiz
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Disconnect from off-mesh links originating from other tiles.
|
// Disconnect from off-mesh links originating from other tiles.
|
||||||
for (int i = 0; i < m_tileCount; ++i)
|
for (int i = 0; i < m_maxTiles; ++i)
|
||||||
{
|
{
|
||||||
dtMeshTile* offTile = &m_tiles[i];
|
dtMeshTile* offTile = &m_tiles[i];
|
||||||
|
|
||||||
@ -2182,16 +2181,16 @@ float dtCalcOffMeshRefYaw(const float* spos, const float* epos)
|
|||||||
const float dx = epos[0]-spos[0];
|
const float dx = epos[0]-spos[0];
|
||||||
const float dy = epos[1]-spos[1];
|
const float dy = epos[1]-spos[1];
|
||||||
|
|
||||||
const float yawDeg = rdMathAtan2f(dy, dx);
|
const float yawRad = rdMathAtan2f(dy, dx);
|
||||||
return rdDegToRad(yawDeg);
|
return rdRadToDeg(yawRad);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dtCalcOffMeshRefPos(const float* spos, float yawRad, float offset, float* res)
|
void dtCalcOffMeshRefPos(const float* spos, float yawDeg, float offset, float* res)
|
||||||
{
|
{
|
||||||
const float yawDeg = rdRadToDeg(yawRad);
|
const float yawRad = rdDegToRad(yawDeg);
|
||||||
|
|
||||||
const float dx = offset*rdMathCosf(yawDeg);
|
const float dx = offset*rdMathCosf(yawRad);
|
||||||
const float dy = offset*rdMathSinf(yawDeg);
|
const float dy = offset*rdMathSinf(yawRad);
|
||||||
|
|
||||||
res[0] = spos[0]+dx;
|
res[0] = spos[0]+dx;
|
||||||
res[1] = spos[1]+dy;
|
res[1] = spos[1]+dy;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user