mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Recast: always start from north during traverse linkage
During new tests, not starting from the neighboring tile at north caused some smaller links to not establish, which is roughly 30 links in angel_city.bsp. This patch makes it always start from north without any alternation and yields the best results during all tests.
This commit is contained in:
parent
065150158a
commit
98ed726cb4
@ -868,8 +868,6 @@ dtStatus dtNavMesh::connectTraverseLinks(const dtTileRef tileRef, const dtTraver
|
|||||||
float basePolyEdgeMid[3];
|
float basePolyEdgeMid[3];
|
||||||
rdVsad(basePolyEdgeMid, baseDetailPolyEdgeSpos, baseDetailPolyEdgeEpos, 0.5f);
|
rdVsad(basePolyEdgeMid, baseDetailPolyEdgeSpos, baseDetailPolyEdgeEpos, 0.5f);
|
||||||
|
|
||||||
const unsigned char startSide = rdClassifyPointInsideBounds(basePolyEdgeMid, baseHeader->bmin, baseHeader->bmax);
|
|
||||||
|
|
||||||
const int MAX_NEIS = 32; // Max neighbors
|
const int MAX_NEIS = 32; // Max neighbors
|
||||||
dtMeshTile* neis[MAX_NEIS];
|
dtMeshTile* neis[MAX_NEIS];
|
||||||
|
|
||||||
@ -877,28 +875,17 @@ dtStatus dtNavMesh::connectTraverseLinks(const dtTileRef tileRef, const dtTraver
|
|||||||
|
|
||||||
if (params.linkToNeighbor) // Retrieve the neighboring tiles.
|
if (params.linkToNeighbor) // Retrieve the neighboring tiles.
|
||||||
{
|
{
|
||||||
// Start with the tile our edge is facing first, as this has the highest
|
// Get the neighboring tiles starting from north in the compass rose.
|
||||||
// chance for the best connection.
|
// It is possible we don't end up linking to some of these tiles if
|
||||||
nneis = getNeighbourTilesAt(baseHeader->x, baseHeader->y, startSide, neis, nneis);
|
// we happen to run out of links on the base tile.
|
||||||
bool getOpposite = true;
|
for (int n = 0; n < 8; ++n)
|
||||||
|
|
||||||
// Get the other tiles starting from the opposite of the base side in the
|
|
||||||
// compass rose, and alternate between the next side and its opposite. It
|
|
||||||
// is possible we don't end up linking to these if we happen to run out
|
|
||||||
// of links on the base tile.
|
|
||||||
for (int n = 1; n < 8; ++n, getOpposite ^= true)
|
|
||||||
{
|
{
|
||||||
const unsigned char side = getOpposite
|
|
||||||
? rdOppositeTile(startSide+n)
|
|
||||||
: rdWrapTileSide(startSide+n);
|
|
||||||
|
|
||||||
rdAssert(side != startSide);
|
|
||||||
const int numSlotsLeft = MAX_NEIS-nneis;
|
const int numSlotsLeft = MAX_NEIS-nneis;
|
||||||
|
|
||||||
if (!numSlotsLeft)
|
if (!numSlotsLeft)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
nneis += getNeighbourTilesAt(baseHeader->x, baseHeader->y, side, &neis[nneis], numSlotsLeft);
|
nneis += getNeighbourTilesAt(baseHeader->x, baseHeader->y, n, &neis[nneis], numSlotsLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No neighbors, nothing to link to.
|
// No neighbors, nothing to link to.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user