Recast: clamp the off-mesh connection positions as well

Allows for parsing zipline positions from BSP entity partitions and placing them whilst also having it clamp the positions correctly to the polygon the zipliner will end up or start from.
This commit is contained in:
Kawe Mazidjatari 2024-09-23 12:11:44 +02:00
parent 5cb0e93766
commit fa1db8f995
2 changed files with 8 additions and 4 deletions

View File

@ -1015,7 +1015,7 @@ public:
/// Builds external polygon links for a tile.
dtStatus connectOffMeshLinks(const dtTileRef tileRef);
dtPolyRef clampOffMeshVertToPoly(const dtOffMeshConnection* con, dtMeshTile* conTile, const dtMeshTile* lookupTile, const bool start);
dtPolyRef clampOffMeshVertToPoly(dtOffMeshConnection* con, dtMeshTile* conTile, const dtMeshTile* lookupTile, const bool start);
private:
/// Returns all polygons in neighbour tile based on portal defined by the segment.

View File

@ -531,7 +531,7 @@ void dtNavMesh::connectExtLinks(dtMeshTile* tile, dtMeshTile* target, int side)
}
}
dtPolyRef dtNavMesh::clampOffMeshVertToPoly(const dtOffMeshConnection* con, dtMeshTile* conTile,
dtPolyRef dtNavMesh::clampOffMeshVertToPoly(dtOffMeshConnection* con, dtMeshTile* conTile,
const dtMeshTile* lookupTile, const bool start)
{
const float* p = start ? &con->pos[0] : &con->pos[3];
@ -548,8 +548,12 @@ dtPolyRef dtNavMesh::clampOffMeshVertToPoly(const dtOffMeshConnection* con, dtMe
const dtPoly* poly = &conTile->polys[con->poly];
// Make sure the location is on current mesh.
float* v = &conTile->verts[poly->verts[start?0:1]*3];
rdVcopy(v, nearestPt);
float* polyVert = &conTile->verts[poly->verts[start?0:1]*3];
rdVcopy(polyVert, nearestPt);
// Update the off-mesh connection positions as well.
float* conPos = &con->pos[start?0:3];
rdVcopy(conPos, nearestPt);
return ref;
}