mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Recast: improve naming consistency for the traverse system
Traversal and traverse were mixed in variable/function naming. Forced consistency. No logic was changed this patch.
This commit is contained in:
parent
7cacc8ee03
commit
b63cb1d52c
@ -67,11 +67,11 @@ bool Detour_IsGoalPolyReachable(dtNavMesh* const nav, const dtPolyRef fromRef,
|
||||
return true;
|
||||
|
||||
const bool hasAnimType = animType != ANIMTYPE_NONE;
|
||||
const int traversalTableIndex = hasAnimType
|
||||
? NavMesh_GetTraversalTableIndexForAnimType(animType)
|
||||
const int traverseTableIndex = hasAnimType
|
||||
? NavMesh_GetTraverseTableIndexForAnimType(animType)
|
||||
: NULL;
|
||||
|
||||
return nav->isGoalPolyReachable(fromRef, goalRef, !hasAnimType, traversalTableIndex);
|
||||
return nav->isGoalPolyReachable(fromRef, goalRef, !hasAnimType, traverseTableIndex);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -993,9 +993,9 @@ void CrowdTool::handleMenu()
|
||||
{
|
||||
const NavMeshType_e loadedNavMeshType = m_editor->getLoadedNavMeshType();
|
||||
|
||||
// TODO: perhaps clamp with m_nav->m_params.traversalTableCount? Technically a navmesh should
|
||||
// TODO: perhaps clamp with m_nav->m_params.traverseTableCount? Technically a navmesh should
|
||||
// contain all the traversal tables it supports, so if we crash the navmesh is technically corrupt.
|
||||
const int traverseTableCount = NavMesh_GetTraversalTableCountForNavMeshType(loadedNavMeshType);
|
||||
const int traverseTableCount = NavMesh_GetTraverseTableCountForNavMeshType(loadedNavMeshType);
|
||||
const TraverseAnimType_e baseType = NavMesh_GetFirstTraverseAnimTypeForType(loadedNavMeshType);
|
||||
|
||||
for (int i = ANIMTYPE_NONE; i < traverseTableCount; i++)
|
||||
|
@ -370,9 +370,9 @@ void Editor::buildStaticPathingData()
|
||||
m_ctx->log(RC_LOG_ERROR, "buildStaticPathingData: Failed to build traverse links.");
|
||||
}
|
||||
|
||||
if (!dtCreateTraversalTableData(m_navMesh, data, NavMesh_GetTraversalTableCountForNavMeshType(m_selectedNavMeshType)))
|
||||
if (!dtCreateTraverseTableData(m_navMesh, data, NavMesh_GetTraverseTableCountForNavMeshType(m_selectedNavMeshType)))
|
||||
{
|
||||
m_ctx->log(RC_LOG_ERROR, "buildStaticPathingData: Failed to build traversal table data.");
|
||||
m_ctx->log(RC_LOG_ERROR, "buildStaticPathingData: Failed to build traverse table data.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -641,23 +641,23 @@ bool Editor::loadAll(std::string path, const bool fullPath)
|
||||
// Read read static pathing data.
|
||||
if (header.params.polyGroupCount >= DT_MIN_POLY_GROUP_COUNT)
|
||||
{
|
||||
for (int i = 0; i < header.params.traversalTableCount; i++)
|
||||
for (int i = 0; i < header.params.traverseTableCount; i++)
|
||||
{
|
||||
int* traversalTable = (int*)rdAlloc(header.params.traversalTableSize, RD_ALLOC_PERM);
|
||||
if (!traversalTable)
|
||||
int* traverseTable = (int*)rdAlloc(header.params.traverseTableSize, RD_ALLOC_PERM);
|
||||
if (!traverseTable)
|
||||
break;
|
||||
|
||||
memset(traversalTable, 0, header.params.traversalTableSize);
|
||||
readLen = fread(traversalTable, header.params.traversalTableSize, 1, fp);
|
||||
memset(traverseTable, 0, header.params.traverseTableSize);
|
||||
readLen = fread(traverseTable, header.params.traverseTableSize, 1, fp);
|
||||
|
||||
if (readLen != 1)
|
||||
{
|
||||
rdFree(traversalTable);
|
||||
rdFree(traverseTable);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
mesh->setTraverseTable(i, traversalTable);
|
||||
mesh->setTraverseTable(i, traverseTable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -727,12 +727,12 @@ void Editor::saveAll(std::string path, const dtNavMesh* mesh)
|
||||
|
||||
rdAssert(traverseTables);
|
||||
|
||||
for (int i = 0; i < header.params.traversalTableCount; i++)
|
||||
for (int i = 0; i < header.params.traverseTableCount; i++)
|
||||
{
|
||||
const int* const tableData = traverseTables[i];
|
||||
rdAssert(tableData);
|
||||
|
||||
fwrite(tableData, sizeof(int), (header.params.traversalTableSize/4), fp);
|
||||
fwrite(tableData, sizeof(int), (header.params.traverseTableSize/4), fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,8 +425,8 @@ void Editor_StaticTileMeshCommon::renderIntermediateTileMeshOptions()
|
||||
//ImGui::Text("Mesh Origin: \n\tX: %g \n\tY: %g \n\tZ: %g", origin[0], origin[1], origin[2]);
|
||||
ImGui::Text("Tile Dimensions: %g x %g", params.tileWidth, params.tileHeight);
|
||||
ImGui::Text("Poly Group Count: %d", params.polyGroupCount);
|
||||
ImGui::Text("Traversal Table Size: %d", params.traversalTableSize);
|
||||
ImGui::Text("Traversal Table Count: %d", params.traversalTableCount);
|
||||
ImGui::Text("Traversal Table Size: %d", params.traverseTableSize);
|
||||
ImGui::Text("Traversal Table Count: %d", params.traverseTableCount);
|
||||
ImGui::Text("Max Tiles: %d", params.maxTiles);
|
||||
ImGui::Text("Max Polys: %d", params.maxPolys);
|
||||
|
||||
|
@ -435,7 +435,7 @@ bool Editor_SoloMesh::handleBuild()
|
||||
// The GUI may allow more max points per polygon than Detour can handle.
|
||||
// Only build the detour navmesh if we do not exceed the limit.
|
||||
|
||||
const int traversalTableCount = NavMesh_GetTraversalTableCountForNavMeshType(m_selectedNavMeshType);
|
||||
const int traverseTableCount = NavMesh_GetTraverseTableCountForNavMeshType(m_selectedNavMeshType);
|
||||
|
||||
if (m_cfg.maxVertsPerPoly <= DT_VERTS_PER_POLYGON)
|
||||
{
|
||||
@ -514,7 +514,7 @@ bool Editor_SoloMesh::handleBuild()
|
||||
|
||||
dtStatus status;
|
||||
|
||||
status = m_navMesh->init(navData, navDataSize, traversalTableCount, DT_TILE_FREE_DATA);
|
||||
status = m_navMesh->init(navData, navDataSize, traverseTableCount, DT_TILE_FREE_DATA);
|
||||
if (dtStatusFailed(status))
|
||||
{
|
||||
rdFree(navData);
|
||||
@ -537,7 +537,7 @@ bool Editor_SoloMesh::handleBuild()
|
||||
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Failed to build disjoint poly groups.");
|
||||
}
|
||||
|
||||
if (!dtCreateTraversalTableData(m_navMesh, data, traversalTableCount))
|
||||
if (!dtCreateTraverseTableData(m_navMesh, data, traverseTableCount))
|
||||
{
|
||||
m_ctx->log(RC_LOG_ERROR, "buildNavigation: Failed to build traversal table data.");
|
||||
}
|
||||
|
@ -852,8 +852,8 @@ void Editor_TempObstacles::handleSettings()
|
||||
//ImGui::Text("Mesh Origin: \n\tX: %g \n\tY: %g \n\tZ: %g", origin[0], origin[1], origin[2]);
|
||||
ImGui::Text("Tile Dimensions: %g x %g", params.tileWidth, params.tileHeight);
|
||||
ImGui::Text("Poly Group Count: %d", params.polyGroupCount);
|
||||
ImGui::Text("Traversal Table Size: %d", params.traversalTableSize);
|
||||
ImGui::Text("Traversal Table Count: %d", params.traversalTableCount);
|
||||
ImGui::Text("Traversal Table Size: %d", params.traverseTableSize);
|
||||
ImGui::Text("Traversal Table Count: %d", params.traverseTableCount);
|
||||
ImGui::Text("Max Tiles: %d", params.maxTiles);
|
||||
ImGui::Text("Max Polys: %d", params.maxPolys);
|
||||
|
||||
|
@ -472,8 +472,8 @@ bool Editor_TileMesh::handleBuild()
|
||||
params.maxTiles = m_maxTiles;
|
||||
params.maxPolys = m_maxPolysPerTile;
|
||||
params.polyGroupCount = 0;
|
||||
params.traversalTableSize = 0;
|
||||
params.traversalTableCount = NavMesh_GetTraversalTableCountForNavMeshType(m_selectedNavMeshType);
|
||||
params.traverseTableSize = 0;
|
||||
params.traverseTableCount = NavMesh_GetTraverseTableCountForNavMeshType(m_selectedNavMeshType);
|
||||
#if DT_NAVMESH_SET_VERSION >= 8
|
||||
params.magicDataCount = 0;
|
||||
#endif
|
||||
|
@ -466,9 +466,9 @@ void NavMeshTesterTool::handleMenu()
|
||||
|
||||
const NavMeshType_e loadedNavMeshType = m_editor->getLoadedNavMeshType();
|
||||
|
||||
// TODO: perhaps clamp with m_nav->m_params.traversalTableCount? Technically a navmesh should
|
||||
// TODO: perhaps clamp with m_nav->m_params.traverseTableCount? Technically a navmesh should
|
||||
// contain all the traversal tables it supports, so if we crash the navmesh is technically corrupt.
|
||||
const int traverseTableCount = NavMesh_GetTraversalTableCountForNavMeshType(loadedNavMeshType);
|
||||
const int traverseTableCount = NavMesh_GetTraverseTableCountForNavMeshType(loadedNavMeshType);
|
||||
const TraverseAnimType_e baseType = NavMesh_GetFirstTraverseAnimTypeForType(loadedNavMeshType);
|
||||
|
||||
for (int i = ANIMTYPE_NONE; i < traverseTableCount; i++)
|
||||
@ -519,11 +519,11 @@ void NavMeshTesterTool::handleToggle()
|
||||
return;
|
||||
|
||||
const bool hasAnimType = m_traverseAnimType != ANIMTYPE_NONE;
|
||||
const int traversalTableIndex = hasAnimType
|
||||
? NavMesh_GetTraversalTableIndexForAnimType(m_traverseAnimType)
|
||||
const int traverseTableIndex = hasAnimType
|
||||
? NavMesh_GetTraverseTableIndexForAnimType(m_traverseAnimType)
|
||||
: NULL;
|
||||
|
||||
if (!m_navMesh->isGoalPolyReachable(m_startRef, m_endRef, !hasAnimType, traversalTableIndex))
|
||||
if (!m_navMesh->isGoalPolyReachable(m_startRef, m_endRef, !hasAnimType, traverseTableIndex))
|
||||
{
|
||||
printf("%s: end poly '%d' is unreachable from start poly '%d'\n", "m_navMesh->isGoalPolyReachable", m_startRef, m_endRef);
|
||||
|
||||
@ -739,11 +739,11 @@ void NavMeshTesterTool::recalc()
|
||||
if (m_startRef && m_endRef)
|
||||
{
|
||||
const bool hasAnimType = m_traverseAnimType != ANIMTYPE_NONE;
|
||||
const int traversalTableIndex = hasAnimType
|
||||
? NavMesh_GetTraversalTableIndexForAnimType(m_traverseAnimType)
|
||||
const int traverseTableIndex = hasAnimType
|
||||
? NavMesh_GetTraverseTableIndexForAnimType(m_traverseAnimType)
|
||||
: NULL;
|
||||
|
||||
isReachable = m_navMesh->isGoalPolyReachable(m_startRef, m_endRef, !hasAnimType, traversalTableIndex);
|
||||
isReachable = m_navMesh->isGoalPolyReachable(m_startRef, m_endRef, !hasAnimType, traverseTableIndex);
|
||||
|
||||
if (!isReachable)
|
||||
printf("%s: end poly '%d' is unreachable from start poly '%d'\n", "m_navMesh->isGoalPolyReachable", m_startRef, m_endRef);
|
||||
|
@ -43,7 +43,7 @@ inline const int g_navMeshTraverseTableCountIndicesPerType[NAVMESH_COUNT] = {
|
||||
1, 1, 1, 1
|
||||
};
|
||||
|
||||
inline int NavMesh_GetTraversalTableCountForNavMeshType(const NavMeshType_e navMeshType)
|
||||
inline int NavMesh_GetTraverseTableCountForNavMeshType(const NavMeshType_e navMeshType)
|
||||
{
|
||||
Assert(navMeshType >= 0 && navMeshType < NAVMESH_COUNT);
|
||||
return g_navMeshTraverseTableCountIndicesPerType[navMeshType];
|
||||
@ -59,7 +59,7 @@ inline const int g_navMeshTraverseTableIndicesPerType[ANIMTYPE_COUNT] = {
|
||||
-5, -6, -7, -8
|
||||
};
|
||||
|
||||
inline int NavMesh_GetTraversalTableIndexForAnimType(const TraverseAnimType_e animType)
|
||||
inline int NavMesh_GetTraverseTableIndexForAnimType(const TraverseAnimType_e animType)
|
||||
{
|
||||
Assert(animType >= 0 && animType < ANIMTYPE_COUNT);
|
||||
return animType + g_navMeshTraverseTableIndicesPerType[animType];
|
||||
|
@ -89,7 +89,7 @@ static const int DT_MIN_POLY_GROUP_COUNT = 3;
|
||||
static const float DT_POLY_AREA_QUANT_FACTOR = 0.01f;
|
||||
|
||||
/// The maximum number of traversal tables per navmesh that will be used for static pathing.
|
||||
static const int DT_MAX_TRAVERSAL_TABLES = 5;
|
||||
static const int DT_MAX_TRAVERSE_TABLES = 5;
|
||||
|
||||
/// A value that indicates the link doesn't require a traverse action. (Jumping, climbing, etc.)
|
||||
static const unsigned char DT_NULL_TRAVERSE_TYPE = 0xff;
|
||||
@ -475,12 +475,12 @@ struct dtNavMeshParams
|
||||
int maxTiles; ///< The maximum number of tiles the navigation mesh can contain. This and maxPolys are used to calculate how many bits are needed to identify tiles and polygons uniquely.
|
||||
int maxPolys; ///< The maximum number of polygons each tile can contain. This and maxTiles are used to calculate how many bits are needed to identify tiles and polygons uniquely.
|
||||
int polyGroupCount; ///< The total number of disjoint polygon groups.
|
||||
int traversalTableSize; ///< The total size of the static traversal table. This is computed using calcTraversalTableSize(polyGroupcount).
|
||||
int traversalTableCount; ///< The total number of traversal tables in this navmesh. Each TraverseAnimType uses its own table as their available jump links should match their behavior and abilities.
|
||||
int traverseTableSize; ///< The total size of the static traverse table. This is computed using calcTraverseTableSize(polyGroupcount).
|
||||
int traverseTableCount; ///< The total number of traverse tables in this navmesh. Each TraverseAnimType uses its own table as their available jump links should match their behavior and abilities.
|
||||
|
||||
#if DT_NAVMESH_SET_VERSION >= 7
|
||||
// NOTE: this seems to be used for some wallrunning code. This allocates a buffer of size 0x30 * magicDataCount,
|
||||
// then copies in the data 0x30 * magicDataCount at the end of the navmesh file (past the traversal tables).
|
||||
// then copies in the data 0x30 * magicDataCount at the end of the navmesh file (past the traverse tables).
|
||||
// See [r5apex_ds + F43600] for buffer allocation and data copy, see note at dtNavMesh::m_someMagicData for usage.
|
||||
int magicDataCount;
|
||||
#endif
|
||||
@ -505,7 +505,7 @@ public:
|
||||
/// Initializes the navigation mesh for single tile use.
|
||||
/// @param[in] data Data of the new tile. (See: #dtCreateNavMeshData)
|
||||
/// @param[in] dataSize The data size of the new tile.
|
||||
/// @param[in] tableCount The number of traversal tables this navmesh will use.
|
||||
/// @param[in] tableCount The number of traverse tables this navmesh will use.
|
||||
/// @param[in] flags The tile flags. (See: #dtTileFlags)
|
||||
/// @return The status flags for the operation.
|
||||
/// @see dtCreateNavMeshData
|
||||
@ -612,10 +612,10 @@ public:
|
||||
/// @param[in] fromRef The reference to the start poly.
|
||||
/// @param[in] goalRef The reference to the goal poly.
|
||||
/// @param[in] checkDisjointGroupsOnly Whether to only check disjoint poly groups.
|
||||
/// @param[in] traversalTableIndex Traversal table to use for checking if islands are linked together.
|
||||
/// @param[in] traverseTableIndex Traverse table to use for checking if islands are linked together.
|
||||
/// @return True if goal polygon is reachable from start polygon.
|
||||
bool isGoalPolyReachable(const dtPolyRef fromRef, const dtPolyRef goalRef,
|
||||
const bool checkDisjointGroupsOnly, const int traversalTableIndex) const;
|
||||
const bool checkDisjointGroupsOnly, const int traverseTableIndex) const;
|
||||
|
||||
/// Checks the validity of a polygon reference.
|
||||
/// @param[in] ref The polygon reference to check.
|
||||
@ -640,8 +640,8 @@ public:
|
||||
/// @return The specified off-mesh connection, or null if the polygon reference is not valid.
|
||||
const dtOffMeshConnection* getOffMeshConnectionByRef(dtPolyRef ref) const;
|
||||
|
||||
/// The navigation mesh traversal tables.
|
||||
int** getTraverseTables() const { return m_traversalTables; }
|
||||
/// The navigation mesh traverse tables.
|
||||
int** getTraverseTables() const { return m_traverseTables; }
|
||||
|
||||
/// Sets the traverse table slot.
|
||||
/// @param[in] index The index of the traverse table.
|
||||
@ -650,7 +650,7 @@ public:
|
||||
|
||||
/// Sets the size of the traverse table.
|
||||
/// @param[in] size The size of the traverse table.
|
||||
void setTraverseTableSize(const int size) { m_params.traversalTableSize = size; }
|
||||
void setTraverseTableSize(const int size) { m_params.traverseTableSize = size; }
|
||||
|
||||
/// @}
|
||||
|
||||
@ -853,7 +853,7 @@ private:
|
||||
dtMeshTile** m_posLookup; ///< Tile hash lookup.
|
||||
dtMeshTile* m_nextFree; ///< Freelist of tiles.
|
||||
dtMeshTile* m_tiles; ///< List of tiles.
|
||||
int** m_traversalTables; ///< Array of set tables.
|
||||
int** m_traverseTables; ///< Array of traverse tables.
|
||||
|
||||
///< FIXME: unknown structure pointer, used for some wallrunning code, see [r5apex_ds + F12687] for usage.
|
||||
///< See note at dtNavMeshParams::magicDataCount for buffer allocation.
|
||||
@ -879,20 +879,20 @@ private:
|
||||
friend class dtNavMeshQuery;
|
||||
};
|
||||
|
||||
/// Returns the cell index for the static traversal table.
|
||||
/// Returns the cell index for the static traverse table.
|
||||
/// @param[in] numPolyGroups The total number of poly groups.
|
||||
/// @param[in] polyGroup1 The poly group ID of the first island.
|
||||
/// @param[in] polyGroup2 The poly group ID of the second island.
|
||||
/// @return The cell index for the static traversal table.
|
||||
/// @return The cell index for the static traverse table.
|
||||
/// @ingroup detour
|
||||
int dtCalcTraversalTableCellIndex(const int numPolyGroups,
|
||||
int dtCalcTraverseTableCellIndex(const int numPolyGroups,
|
||||
const unsigned short polyGroup1, const unsigned short polyGroup2);
|
||||
|
||||
/// Returns the total size needed for the static traversal table.
|
||||
/// Returns the total size needed for the static traverse table.
|
||||
/// @param[in] numPolyGroups The total number of poly groups.
|
||||
/// @return the total size needed for the static traversal table.
|
||||
/// @return the total size needed for the static traverse table.
|
||||
/// @ingroup detour
|
||||
int dtCalcTraversalTableSize(const int numPolyGroups);
|
||||
int dtCalcTraverseTableSize(const int numPolyGroups);
|
||||
|
||||
/// Defines a navigation mesh tile data block.
|
||||
/// @ingroup detour
|
||||
|
@ -188,12 +188,12 @@ bool dtCreateDisjointPolyGroups(dtNavMesh* nav, dtDisjointSet& disjoint);
|
||||
/// @return True if the traverse links were successfully created.
|
||||
bool dtCreateTraverseLinks(dtNavMesh* nav);
|
||||
|
||||
/// Builds navigation mesh static traversal table from the provided navmesh.
|
||||
/// Builds navigation mesh static traverse table from the provided navmesh.
|
||||
/// @ingroup detour
|
||||
/// @param[in] nav The navigation mesh to use.
|
||||
/// @param[in] disjoint The disjoint set data.
|
||||
/// @return True if the static traversal table was successfully created.
|
||||
bool dtCreateTraversalTableData(dtNavMesh* nav, const dtDisjointSet& disjoint, const int tableCount);
|
||||
/// @return True if the static traverse table was successfully created.
|
||||
bool dtCreateTraverseTableData(dtNavMesh* nav, const dtDisjointSet& disjoint, const int tableCount);
|
||||
|
||||
/// Builds navigation mesh tile data from the provided tile creation data.
|
||||
/// @ingroup detour
|
||||
|
@ -533,10 +533,10 @@ public:
|
||||
/// @param[in] fromRef The reference to the start poly.
|
||||
/// @param[in] goalRef The reference to the goal poly.
|
||||
/// @param[in] checkDisjointGroupsOnly Whether to only check disjoint poly groups.
|
||||
/// @param[in] traversalTableIndex Traversal table to use for checking if islands are linked together.
|
||||
/// @param[in] traverseTableIndex Traverse table to use for checking if islands are linked together.
|
||||
/// @return True if goal polygon is reachable from start polygon.
|
||||
bool isGoalPolyReachable(const dtPolyRef fromRef, const dtPolyRef goalRef,
|
||||
const bool checkDisjointGroupsOnly, const int traversalTableIndex) const;
|
||||
const bool checkDisjointGroupsOnly, const int traverseTableIndex) const;
|
||||
|
||||
/// Returns true if the polygon reference is valid and passes the filter restrictions.
|
||||
/// @param[in] ref The polygon reference to check.
|
||||
|
@ -130,13 +130,13 @@ void dtMeshTile::freeLink(unsigned int link)
|
||||
linksFreeList = link;
|
||||
}
|
||||
|
||||
int dtCalcTraversalTableCellIndex(const int numPolyGroups,
|
||||
int dtCalcTraverseTableCellIndex(const int numPolyGroups,
|
||||
const unsigned short polyGroup1, const unsigned short polyGroup2)
|
||||
{
|
||||
return polyGroup1*((numPolyGroups+(RD_BITS_PER_BIT_CELL-1))/RD_BITS_PER_BIT_CELL)+(polyGroup2/RD_BITS_PER_BIT_CELL);
|
||||
}
|
||||
|
||||
int dtCalcTraversalTableSize(const int numPolyGroups)
|
||||
int dtCalcTraverseTableSize(const int numPolyGroups)
|
||||
{
|
||||
return sizeof(int)*(numPolyGroups*((numPolyGroups+(RD_BITS_PER_BIT_CELL-1))/RD_BITS_PER_BIT_CELL));
|
||||
}
|
||||
@ -201,7 +201,7 @@ dtNavMesh::dtNavMesh() :
|
||||
m_posLookup(0),
|
||||
m_nextFree(0),
|
||||
m_tiles(0),
|
||||
m_traversalTables(0),
|
||||
m_traverseTables(0),
|
||||
m_someMagicData(0),
|
||||
m_meshFlags(0),
|
||||
m_tileFlags(0),
|
||||
@ -231,15 +231,15 @@ dtNavMesh::~dtNavMesh() // TODO: see [r5apex_ds + F43720] to re-implement this c
|
||||
rdFree(m_posLookup);
|
||||
rdFree(m_tiles);
|
||||
|
||||
for (int i = 0; i < m_params.traversalTableCount; i++)
|
||||
for (int i = 0; i < m_params.traverseTableCount; i++)
|
||||
{
|
||||
int* traversalTable = m_traversalTables[i];
|
||||
int* traverseTable = m_traverseTables[i];
|
||||
|
||||
if (traversalTable)
|
||||
rdFree(traversalTable);
|
||||
if (traverseTable)
|
||||
rdFree(traverseTable);
|
||||
}
|
||||
|
||||
rdFree(m_traversalTables);
|
||||
rdFree(m_traverseTables);
|
||||
}
|
||||
|
||||
dtStatus dtNavMesh::init(const dtNavMeshParams* params)
|
||||
@ -265,17 +265,17 @@ dtStatus dtNavMesh::init(const dtNavMeshParams* params)
|
||||
memset(m_tiles, 0, sizeof(dtMeshTile) * m_maxTiles);
|
||||
memset(m_posLookup, 0, sizeof(dtMeshTile*) * m_tileLutSize);
|
||||
|
||||
const int traversalTableCount = params->traversalTableCount;
|
||||
if (traversalTableCount)
|
||||
const int traverseTableCount = params->traverseTableCount;
|
||||
if (traverseTableCount)
|
||||
{
|
||||
rdAssert(traversalTableCount > 0 && traversalTableCount <= DT_MAX_TRAVERSAL_TABLES);
|
||||
const int setTableBufSize = sizeof(int**)*traversalTableCount;
|
||||
rdAssert(traverseTableCount > 0 && traverseTableCount <= DT_MAX_TRAVERSE_TABLES);
|
||||
const int setTableBufSize = sizeof(int**)*traverseTableCount;
|
||||
|
||||
m_traversalTables = (int**)rdAlloc(setTableBufSize, RD_ALLOC_PERM);
|
||||
if (!m_traversalTables)
|
||||
m_traverseTables = (int**)rdAlloc(setTableBufSize, RD_ALLOC_PERM);
|
||||
if (!m_traverseTables)
|
||||
return DT_FAILURE | DT_OUT_OF_MEMORY;
|
||||
|
||||
memset(m_traversalTables, 0, setTableBufSize);
|
||||
memset(m_traverseTables, 0, setTableBufSize);
|
||||
}
|
||||
|
||||
m_nextFree = 0;
|
||||
@ -313,8 +313,8 @@ dtStatus dtNavMesh::init(unsigned char* data, const int dataSize, const int tabl
|
||||
params.maxTiles = 1;
|
||||
params.maxPolys = header->polyCount;
|
||||
params.polyGroupCount = 0;
|
||||
params.traversalTableSize = 0;
|
||||
params.traversalTableCount = tableCount;
|
||||
params.traverseTableSize = 0;
|
||||
params.traverseTableCount = tableCount;
|
||||
#if DT_NAVMESH_SET_VERSION >= 7
|
||||
params.magicDataCount = 0;
|
||||
#endif
|
||||
@ -1323,7 +1323,7 @@ void dtNavMesh::getTileAndPolyByRefUnsafe(const dtPolyRef ref, const dtMeshTile*
|
||||
}
|
||||
|
||||
bool dtNavMesh::isGoalPolyReachable(const dtPolyRef fromRef, const dtPolyRef goalRef,
|
||||
const bool checkDisjointGroupsOnly, const int traversalTableIndex) const
|
||||
const bool checkDisjointGroupsOnly, const int traverseTableIndex) const
|
||||
{
|
||||
// Same poly is always reachable.
|
||||
if (fromRef == goalRef)
|
||||
@ -1340,26 +1340,26 @@ bool dtNavMesh::isGoalPolyReachable(const dtPolyRef fromRef, const dtPolyRef goa
|
||||
const unsigned short fromPolyGroupId = fromPoly->groupId;
|
||||
const unsigned short goalPolyGroupId = goalPoly->groupId;
|
||||
|
||||
// If we don't have an anim type, then we shouldn't use the traversal tables
|
||||
// If we don't have an anim type, then we shouldn't use the traverse tables
|
||||
// since these are used for linking isolated poly islands together (which
|
||||
// requires jumping or some form of animation). So instead, check if we are
|
||||
// on the same poly island.
|
||||
if (checkDisjointGroupsOnly)
|
||||
return fromPolyGroupId == goalPolyGroupId;
|
||||
|
||||
rdAssert(traversalTableIndex >= 0 && traversalTableIndex < m_params.traversalTableCount);
|
||||
const int* const traversalTable = m_traversalTables[traversalTableIndex];
|
||||
rdAssert(traverseTableIndex >= 0 && traverseTableIndex < m_params.traverseTableCount);
|
||||
const int* const traverseTable = m_traverseTables[traverseTableIndex];
|
||||
|
||||
// Traversal table doesn't exist, attempt the path finding anyways (this is
|
||||
// Traverse table doesn't exist, attempt the path finding anyways (this is
|
||||
// a bug in the NavMesh, rebuild it!).
|
||||
if (!traversalTable)
|
||||
if (!traverseTable)
|
||||
return true;
|
||||
|
||||
const int polyGroupCount = m_params.polyGroupCount;
|
||||
const int fromPolyBitCell = traversalTable[dtCalcTraversalTableCellIndex(polyGroupCount, fromPolyGroupId, goalPolyGroupId)];
|
||||
const int fromPolyBitCell = traverseTable[dtCalcTraverseTableCellIndex(polyGroupCount, fromPolyGroupId, goalPolyGroupId)];
|
||||
|
||||
// Check if the bit corresponding to our goal poly is set, if it isn't then
|
||||
// there are no available traversal links from the current poly to the goal.
|
||||
// there are no available traverse links from the current poly to the goal.
|
||||
return fromPolyBitCell & rdBitCellBit(goalPolyGroupId);
|
||||
}
|
||||
|
||||
@ -1677,10 +1677,10 @@ const dtOffMeshConnection* dtNavMesh::getOffMeshConnectionByRef(dtPolyRef ref) c
|
||||
|
||||
void dtNavMesh::setTraverseTable(const int index, int* const table)
|
||||
{
|
||||
rdAssert(index >= 0 && index < m_params.traversalTableCount);
|
||||
rdAssert(m_traversalTables);
|
||||
rdAssert(index >= 0 && index < m_params.traverseTableCount);
|
||||
rdAssert(m_traverseTables);
|
||||
|
||||
m_traversalTables[index] = table;
|
||||
m_traverseTables[index] = table;
|
||||
}
|
||||
|
||||
dtStatus dtNavMesh::setPolyFlags(dtPolyRef ref, unsigned short flags)
|
||||
|
@ -267,7 +267,7 @@ static unsigned char classifyOffMeshPoint(const float* pt, const float* bmin, co
|
||||
static void setPolyGroupsTraversalReachability(int* const tableData, const int numPolyGroups,
|
||||
const unsigned short polyGroup1, const unsigned short polyGroup2, const bool isReachable)
|
||||
{
|
||||
const int index = dtCalcTraversalTableCellIndex(numPolyGroups, polyGroup1, polyGroup2);
|
||||
const int index = dtCalcTraverseTableCellIndex(numPolyGroups, polyGroup1, polyGroup2);
|
||||
const int value = 1<<(polyGroup2 & 31);
|
||||
|
||||
if (isReachable)
|
||||
@ -322,7 +322,7 @@ bool dtCreateDisjointPolyGroups(dtNavMesh* nav, dtDisjointSet& disjoint)
|
||||
// under the same group id.
|
||||
// NOTE: when we implement jump links, we will have to check on
|
||||
// these here as well! They also shouldn't merge 2 islands together.
|
||||
// Ultimately, the jump links should only be used during traversal
|
||||
// Ultimately, the jump links should only be used during traverse
|
||||
// table building to mark linked islands as reachable.
|
||||
if (poly.getType() != DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
@ -586,13 +586,13 @@ bool dtCreateTraverseLinks(dtNavMesh* nav)
|
||||
return true;
|
||||
}
|
||||
|
||||
// todo(amos): remove param 'tableCount' and make struct 'dtTraversalTableCreateParams'
|
||||
bool dtCreateTraversalTableData(dtNavMesh* nav, const dtDisjointSet& disjoint, const int tableCount)
|
||||
// todo(amos): remove param 'tableCount' and make struct 'dtTraverseTableCreateParams'
|
||||
bool dtCreateTraverseTableData(dtNavMesh* nav, const dtDisjointSet& disjoint, const int tableCount)
|
||||
{
|
||||
const int polyGroupCount = nav->getPolyGroupCount();
|
||||
const int tableSize = dtCalcTraversalTableSize(polyGroupCount);
|
||||
const int tableSize = dtCalcTraverseTableSize(polyGroupCount);
|
||||
|
||||
// TODO: currently we allocate 5 buffers and just copy the same traversal
|
||||
// TODO: currently we allocate 5 buffers and just copy the same traverse
|
||||
// tables in, this works fine since we don't generate jump links and
|
||||
// therefore all poly islands should be marked unreachable from each other.
|
||||
// But when we generate jump links, we need to take into consideration that
|
||||
@ -605,19 +605,19 @@ bool dtCreateTraversalTableData(dtNavMesh* nav, const dtDisjointSet& disjoint, c
|
||||
// table. The 'dtLink::jumpType' field probably determines what belongs to
|
||||
// what TraverseAnimType, which we could use to set the traversability.
|
||||
// More reasearch is needed for the jump links and flags... For other
|
||||
// navmeshes, e.g. the '_large' one, they all contain only 1 traversal
|
||||
// navmeshes, e.g. the '_large' one, they all contain only 1 traverse
|
||||
// table as they only support one TraverseAnimType each. but also here
|
||||
// we have to "reverse" the properties from existing Titanfall 2 single
|
||||
// player navmeshes and determine the traversability in this loop below.
|
||||
for (int i = 0; i < tableCount; i++)
|
||||
{
|
||||
int* const traversalTable = (int*)rdAlloc(sizeof(int)*tableSize, RD_ALLOC_PERM);
|
||||
int* const traverseTable = (int*)rdAlloc(sizeof(int)*tableSize, RD_ALLOC_PERM);
|
||||
|
||||
if (!traversalTable)
|
||||
if (!traverseTable)
|
||||
return false;
|
||||
|
||||
nav->setTraverseTable(i, traversalTable);
|
||||
memset(traversalTable, 0, sizeof(int)*tableSize);
|
||||
nav->setTraverseTable(i, traverseTable);
|
||||
memset(traverseTable, 0, sizeof(int)*tableSize);
|
||||
|
||||
for (unsigned short j = 0; j < polyGroupCount; j++)
|
||||
{
|
||||
@ -625,7 +625,7 @@ bool dtCreateTraversalTableData(dtNavMesh* nav, const dtDisjointSet& disjoint, c
|
||||
{
|
||||
// Only reachable if its the same polygroup or if they are linked!
|
||||
const bool isReachable = j == k || disjoint.find(j) == disjoint.find(k);
|
||||
setPolyGroupsTraversalReachability(traversalTable, polyGroupCount, j, k, isReachable);
|
||||
setPolyGroupsTraversalReachability(traverseTable, polyGroupCount, j, k, isReachable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3634,10 +3634,10 @@ dtStatus dtNavMeshQuery::findDistanceToWall(dtPolyRef startRef, const float* cen
|
||||
}
|
||||
|
||||
bool dtNavMeshQuery::isGoalPolyReachable(const dtPolyRef fromRef, const dtPolyRef goalRef,
|
||||
const bool checkDisjointGroupsOnly, const int traversalTableIndex) const
|
||||
const bool checkDisjointGroupsOnly, const int traverseTableIndex) const
|
||||
{
|
||||
rdAssert(m_nav);
|
||||
return m_nav->isGoalPolyReachable(fromRef, goalRef, checkDisjointGroupsOnly, traversalTableIndex);
|
||||
return m_nav->isGoalPolyReachable(fromRef, goalRef, checkDisjointGroupsOnly, traverseTableIndex);
|
||||
}
|
||||
|
||||
bool dtNavMeshQuery::isValidPolyRef(dtPolyRef ref, const dtQueryFilter* filter) const
|
||||
|
@ -92,8 +92,8 @@ struct dtCrowdAgentParams
|
||||
/// How aggressive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
|
||||
float separationWeight;
|
||||
|
||||
/// The traversal animation type, which is used to determine which traversal table this agent will use.
|
||||
/// [Limit: ANIMTYPE_NONE >= value <= #dtNavMeshParams::traversalTableCount]
|
||||
/// The traverse animation type, which is used to determine which traversal table this agent will use.
|
||||
/// [Limit: ANIMTYPE_NONE >= value <= #dtNavMeshParams::traverseTableCount]
|
||||
TraverseAnimType_e traverseAnimType;
|
||||
|
||||
/// Flags that impact steering behavior. (See: #UpdateFlags)
|
||||
|
@ -458,12 +458,12 @@ void dtCrowd::updateMoveRequest(const float /*dt*/)
|
||||
const TraverseAnimType_e animType = ag->params.traverseAnimType;
|
||||
|
||||
const bool hasAnimType = animType != ANIMTYPE_NONE;
|
||||
const int traversalTableIndex = hasAnimType
|
||||
? NavMesh_GetTraversalTableIndexForAnimType(animType)
|
||||
const int traverseTableIndex = hasAnimType
|
||||
? NavMesh_GetTraverseTableIndexForAnimType(animType)
|
||||
: NULL;
|
||||
|
||||
// Don't fire off the request if the goal is unreachable.
|
||||
if (!m_navquery->isGoalPolyReachable(path[0], ag->targetRef, !hasAnimType, traversalTableIndex))
|
||||
if (!m_navquery->isGoalPolyReachable(path[0], ag->targetRef, !hasAnimType, traverseTableIndex))
|
||||
continue;
|
||||
|
||||
if (ag->targetState == DT_CROWDAGENT_TARGET_REQUESTING)
|
||||
|
Loading…
x
Reference in New Issue
Block a user