Fixed hadling of negative tile indices. Made findStraightPath a tiny bit simpler.
This commit is contained in:
parent
d9d9fa85a5
commit
21f76bc0a5
@ -1078,10 +1078,10 @@ int dtNavMesh::queryPolygons(const float* center, const float* extents, dtQueryF
|
||||
vadd(bmax, center, extents);
|
||||
|
||||
// Find tiles the query touches.
|
||||
const int minx = (int)((bmin[0]-m_orig[0]) / m_tileWidth);
|
||||
const int maxx = (int)((bmax[0]-m_orig[0]) / m_tileWidth);
|
||||
const int miny = (int)((bmin[2]-m_orig[2]) / m_tileHeight);
|
||||
const int maxy = (int)((bmax[2]-m_orig[2]) / m_tileHeight);
|
||||
const int minx = (int)floorf((bmin[0]-m_orig[0]) / m_tileWidth);
|
||||
const int maxx = (int)floorf((bmax[0]-m_orig[0]) / m_tileWidth);
|
||||
const int miny = (int)floorf((bmin[2]-m_orig[2]) / m_tileHeight);
|
||||
const int maxy = (int)floorf((bmax[2]-m_orig[2]) / m_tileHeight);
|
||||
|
||||
int n = 0;
|
||||
for (int y = miny; y <= maxy; ++y)
|
||||
@ -1385,18 +1385,9 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
}
|
||||
|
||||
// Right vertex.
|
||||
if (vequal(portalApex, portalRight))
|
||||
{
|
||||
vcopy(portalRight, right);
|
||||
rightPolyRef = (i+1 < pathSize) ? path[i+1] : 0;
|
||||
rightPolyType = toType;
|
||||
rightIndex = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (triArea2D(portalApex, portalRight, right) <= 0.0f)
|
||||
{
|
||||
if (triArea2D(portalApex, portalLeft, right) > 0.0f)
|
||||
if (vequal(portalApex, portalRight) || triArea2D(portalApex, portalLeft, right) > 0.0f)
|
||||
{
|
||||
vcopy(portalRight, right);
|
||||
rightPolyRef = (i+1 < pathSize) ? path[i+1] : 0;
|
||||
@ -1443,21 +1434,11 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Left vertex.
|
||||
if (vequal(portalApex, portalLeft))
|
||||
{
|
||||
vcopy(portalLeft, left);
|
||||
leftPolyRef = (i+1 < pathSize) ? path[i+1] : 0;
|
||||
leftPolyType = toType;
|
||||
leftIndex = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (triArea2D(portalApex, portalLeft, left) >= 0.0f)
|
||||
{
|
||||
if (triArea2D(portalApex, portalRight, left) < 0.0f)
|
||||
if (vequal(portalApex, portalLeft) || triArea2D(portalApex, portalRight, left) < 0.0f)
|
||||
{
|
||||
vcopy(portalLeft, left);
|
||||
leftPolyRef = (i+1 < pathSize) ? path[i+1] : 0;
|
||||
@ -1506,7 +1487,6 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add end point.
|
||||
vcopy(&straightPath[straightPathSize*3], closestEndPos);
|
||||
|
Loading…
x
Reference in New Issue
Block a user