mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Recast: many fixes regarding tile numbering
Reducing the tile size to 16 for all types completely eliminated the issue where an NPC in-game fails to find a steer poly after traversal (call to dtNavMeshQuery::findNearestPoly fails). Tile size of 16 causes correct tile numbering for world bmins and bmaxs. Also added 2 new sliders allowing the change of min and max tile bits + some additional cleanup.
This commit is contained in:
parent
34f81f035e
commit
513f4a5297
@ -149,9 +149,6 @@ Editor::Editor() :
|
||||
|
||||
rdVset(m_recastDrawOffset, 0.0f,0.0f,4.0f);
|
||||
rdVset(m_detourDrawOffset, 0.0f,0.0f,8.0f);
|
||||
|
||||
initTraverseMasks();
|
||||
initTraverseTableParams();
|
||||
}
|
||||
|
||||
Editor::~Editor()
|
||||
@ -250,6 +247,14 @@ void Editor::resetCommonSettings()
|
||||
{
|
||||
selectNavMeshType(NAVMESH_SMALL);
|
||||
|
||||
#if DT_NAVMESH_SET_VERSION == 5
|
||||
m_minTileBits 14
|
||||
m_maxTileBits 22
|
||||
#else
|
||||
m_minTileBits = 16;
|
||||
m_maxTileBits = 28;
|
||||
#endif
|
||||
|
||||
m_cellSize = 16.0f;
|
||||
m_cellHeight = 5.85f;
|
||||
m_traverseLinkParams.cellHeight = m_cellHeight;
|
||||
@ -271,6 +276,9 @@ void Editor::resetCommonSettings()
|
||||
m_detailSampleDist = 6.0f;
|
||||
m_detailSampleMaxError = 1.0f;
|
||||
m_partitionType = EDITOR_PARTITION_WATERSHED;
|
||||
|
||||
initTraverseMasks();
|
||||
initTraverseTableParams();
|
||||
}
|
||||
void Editor::handleCommonSettings()
|
||||
{
|
||||
@ -1227,11 +1235,11 @@ void Editor::renderDetourDebugMenu()
|
||||
// NOTE: the climb height should never equal or exceed the agent's height, see https://groups.google.com/g/recastnavigation/c/L5rBamxcOBk/m/5xGLj6YP25kJ
|
||||
// Quote: "you will get into trouble in cases where there is an overhand which is low enough to step over and high enough for the agent to walk under."
|
||||
const hulldef hulls[NAVMESH_COUNT] = {
|
||||
{ g_navMeshNames[NAVMESH_SMALL] , NAI_Hull::Width(HULL_HUMAN) * NAI_Hull::Scale(HULL_HUMAN) , NAI_Hull::Height(HULL_HUMAN) , NAI_Hull::Height(HULL_HUMAN) * NAI_Hull::Scale(HULL_HUMAN) , 32, 8 },
|
||||
{ g_navMeshNames[NAVMESH_MED_SHORT] , NAI_Hull::Width(HULL_PROWLER) * NAI_Hull::Scale(HULL_PROWLER), NAI_Hull::Height(HULL_PROWLER), NAI_Hull::Height(HULL_PROWLER) * NAI_Hull::Scale(HULL_PROWLER), 32, 4 },
|
||||
{ g_navMeshNames[NAVMESH_MEDIUM] , NAI_Hull::Width(HULL_MEDIUM) * NAI_Hull::Scale(HULL_MEDIUM) , NAI_Hull::Height(HULL_MEDIUM) , NAI_Hull::Height(HULL_MEDIUM) * NAI_Hull::Scale(HULL_MEDIUM) , 32, 4 },
|
||||
{ g_navMeshNames[NAVMESH_LARGE] , NAI_Hull::Width(HULL_TITAN) * NAI_Hull::Scale(HULL_TITAN) , NAI_Hull::Height(HULL_TITAN) , NAI_Hull::Height(HULL_TITAN) * NAI_Hull::Scale(HULL_TITAN) , 64, 2 },
|
||||
{ g_navMeshNames[NAVMESH_EXTRA_LARGE], NAI_Hull::Width(HULL_GOLIATH) * NAI_Hull::Scale(HULL_GOLIATH), NAI_Hull::Height(HULL_GOLIATH), NAI_Hull::Height(HULL_GOLIATH) * NAI_Hull::Scale(HULL_GOLIATH), 64, 2 },
|
||||
{ g_navMeshNames[NAVMESH_SMALL] , NAI_Hull::Width(HULL_HUMAN) * NAI_Hull::Scale(HULL_HUMAN) , NAI_Hull::Height(HULL_HUMAN) , NAI_Hull::Height(HULL_HUMAN) * NAI_Hull::Scale(HULL_HUMAN) , 16, 4 },
|
||||
{ g_navMeshNames[NAVMESH_MED_SHORT] , NAI_Hull::Width(HULL_PROWLER) * NAI_Hull::Scale(HULL_PROWLER), NAI_Hull::Height(HULL_PROWLER), NAI_Hull::Height(HULL_PROWLER) * NAI_Hull::Scale(HULL_PROWLER), 16, 2 },
|
||||
{ g_navMeshNames[NAVMESH_MEDIUM] , NAI_Hull::Width(HULL_MEDIUM) * NAI_Hull::Scale(HULL_MEDIUM) , NAI_Hull::Height(HULL_MEDIUM) , NAI_Hull::Height(HULL_MEDIUM) * NAI_Hull::Scale(HULL_MEDIUM) , 16, 2 },
|
||||
{ g_navMeshNames[NAVMESH_LARGE] , NAI_Hull::Width(HULL_TITAN) * NAI_Hull::Scale(HULL_TITAN) , NAI_Hull::Height(HULL_TITAN) , NAI_Hull::Height(HULL_TITAN) * NAI_Hull::Scale(HULL_TITAN) , 16, 1 },
|
||||
{ g_navMeshNames[NAVMESH_EXTRA_LARGE], NAI_Hull::Width(HULL_GOLIATH) * NAI_Hull::Scale(HULL_GOLIATH), NAI_Hull::Height(HULL_GOLIATH), NAI_Hull::Height(HULL_GOLIATH) * NAI_Hull::Scale(HULL_GOLIATH), 16, 1 },
|
||||
};
|
||||
|
||||
void Editor::selectNavMeshType(const NavMeshType_e navMeshType)
|
||||
|
@ -70,15 +70,8 @@ static void EditorCommon_DrawTilingGrid(duDebugDraw* const dd, const InputGeom*
|
||||
duDebugDrawGridXY(dd, bmax[0], bmin[1], bmin[2], tw, th, s, duRGBA(0, 0, 0, 64), 1.0f, nullptr);
|
||||
}
|
||||
|
||||
#if DT_NAVMESH_SET_VERSION == 5
|
||||
#define MIN_TILE_BITS 14
|
||||
#define MAX_TILE_BITS 22
|
||||
#else
|
||||
#define MIN_TILE_BITS 16
|
||||
#define MAX_TILE_BITS 28
|
||||
#endif
|
||||
|
||||
int EditorCommon_SetAndRenderTileProperties(const InputGeom* const geom, const int tileSize,
|
||||
int EditorCommon_SetAndRenderTileProperties(const InputGeom* const geom,
|
||||
const int minTilebits, const int maxTileBits, const int tileSize,
|
||||
const float cellSize, int& maxTiles, int& maxPolysPerTile)
|
||||
{
|
||||
int gridSize = 1;
|
||||
@ -94,12 +87,12 @@ int EditorCommon_SetAndRenderTileProperties(const InputGeom* const geom, const i
|
||||
const int th = (gh + ts-1) / ts;
|
||||
|
||||
ImGui::Text("Tiles: %d x %d", tw, th);
|
||||
ImGui::Text("Tile Sizes: %g x %g (%g)", tw* cellSize, th*cellSize, tileSize*cellSize);
|
||||
ImGui::Text("Tile Sizes: %g x %g (%g)", tw*cellSize, th*cellSize, tileSize*cellSize);
|
||||
|
||||
// Max tiles and max polys affect how the tile IDs are calculated.
|
||||
// There are MAX_TILE_BITS bits available for identifying a tile and a polygon.
|
||||
const int tileBits = rdMin((int)rdIlog2(rdNextPow2(tw*th)), MIN_TILE_BITS);
|
||||
const int polyBits = MAX_TILE_BITS - tileBits;
|
||||
const int tileBits = rdMin((int)rdIlog2(rdNextPow2(tw*th)), minTilebits);
|
||||
const int polyBits = maxTileBits - tileBits;
|
||||
|
||||
maxTiles = 1 << tileBits;
|
||||
maxPolysPerTile = 1 << polyBits;
|
||||
|
@ -814,7 +814,7 @@ void Editor_TempObstacles::handleSettings()
|
||||
|
||||
ImGui::Checkbox("Keep Intermediate Results", &m_keepInterResults);
|
||||
|
||||
const int gridSize = EditorCommon_SetAndRenderTileProperties(m_geom, m_tileSize, m_cellSize, m_maxTiles, m_maxPolysPerTile);
|
||||
const int gridSize = EditorCommon_SetAndRenderTileProperties(m_geom, m_minTileBits, m_maxTileBits, m_tileSize, m_cellSize, m_maxTiles, m_maxPolysPerTile);
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("Tile Cache");
|
||||
|
@ -349,9 +349,6 @@ Editor_TileMesh::Editor_TileMesh() :
|
||||
m_tileMemUsage(0),
|
||||
m_tileTriCount(0)
|
||||
{
|
||||
resetCommonSettings();
|
||||
selectNavMeshType(NAVMESH_SMALL);
|
||||
|
||||
memset(m_lastBuiltTileBmin, 0, sizeof(m_lastBuiltTileBmin));
|
||||
memset(m_lastBuiltTileBmax, 0, sizeof(m_lastBuiltTileBmax));
|
||||
|
||||
@ -372,12 +369,14 @@ void Editor_TileMesh::handleSettings()
|
||||
Editor::handleCommonSettings();
|
||||
|
||||
ImGui::Text("Tiling");
|
||||
ImGui::SliderInt("Min Tile Bits", &m_minTileBits, 14, 32);
|
||||
ImGui::SliderInt("Max Tile Bits", &m_maxTileBits, 22, 32);
|
||||
ImGui::SliderInt("Tile Size", &m_tileSize, 8, 2048);
|
||||
|
||||
ImGui::Checkbox("Build All Tiles", &m_buildAll);
|
||||
ImGui::Checkbox("Keep Intermediate Results", &m_keepInterResults);
|
||||
|
||||
EditorCommon_SetAndRenderTileProperties(m_geom, m_tileSize, m_cellSize, m_maxTiles, m_maxPolysPerTile);
|
||||
EditorCommon_SetAndRenderTileProperties(m_geom, m_minTileBits, m_maxTileBits, m_tileSize, m_cellSize, m_maxTiles, m_maxPolysPerTile);
|
||||
|
||||
ImGui::Separator();
|
||||
Editor_StaticTileMeshCommon::renderIntermediateTileMeshOptions();
|
||||
|
@ -241,6 +241,8 @@ protected:
|
||||
bool m_filterLedgeSpans;
|
||||
bool m_filterWalkableLowHeightSpans;
|
||||
|
||||
int m_minTileBits;
|
||||
int m_maxTileBits;
|
||||
int m_tileSize;
|
||||
float m_cellSize;
|
||||
float m_cellHeight;
|
||||
|
@ -107,7 +107,8 @@ protected:
|
||||
bool m_keepInterResults;
|
||||
};
|
||||
|
||||
int EditorCommon_SetAndRenderTileProperties(const InputGeom* const geom, const int tileSize,
|
||||
int EditorCommon_SetAndRenderTileProperties(const InputGeom* const geom,
|
||||
const int minTilebits, const int maxTileBits, const int tileSize,
|
||||
const float cellSize, int& maxTiles, int& maxPolysPerTile);
|
||||
|
||||
#endif // RECASTEDITORCOMMON_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user