mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Recast: fix crash in prune tool when initiating NavMesh flood algorithm
dtNavMeshQuery::findNearestPoly can return an error flag, and the function cal also succeed while returning a NULL polyref. Both need to be checked before the algorithm is called. Also moved the memory allocation for flags inside this new check to avoid allocating for nothing.
This commit is contained in:
parent
dabedb2c8b
commit
b4b0e22d61
@ -294,18 +294,20 @@ void NavMeshPruneTool::handleClick(const float* s, const float* p, const int /*v
|
||||
rdVcopy(m_hitPos, p);
|
||||
m_hitPosSet = true;
|
||||
|
||||
if (!m_flags)
|
||||
{
|
||||
m_flags = new NavmeshFlags;
|
||||
m_flags->init(nav);
|
||||
}
|
||||
|
||||
const float halfExtents[3] = { 2, 2, 4 };
|
||||
dtQueryFilter filter;
|
||||
dtPolyRef ref = 0;
|
||||
query->findNearestPoly(p, halfExtents, &filter, &ref, 0);
|
||||
|
||||
floodNavmesh(nav, m_flags, ref, 1);
|
||||
if (dtStatusSucceed(query->findNearestPoly(p, halfExtents, &filter, &ref, 0)) && ref)
|
||||
{
|
||||
if (!m_flags)
|
||||
{
|
||||
m_flags = new NavmeshFlags;
|
||||
m_flags->init(nav);
|
||||
}
|
||||
|
||||
floodNavmesh(nav, m_flags, ref, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void NavMeshPruneTool::handleToggle()
|
||||
|
Loading…
x
Reference in New Issue
Block a user