Fix for Issue 107
This commit is contained in:
parent
07ec6dfa08
commit
47ba806fef
@ -182,6 +182,8 @@ inline unsigned int dtIlog2(unsigned int v)
|
||||
|
||||
inline int dtAlign4(int x) { return (x+3) & ~3; }
|
||||
|
||||
inline int dtOppositeTile(int side) { return (side+4) & 0x7; }
|
||||
|
||||
inline float dtVdot2D(const float* u, const float* v)
|
||||
{
|
||||
return u[0]*v[0] + u[2]*v[2];
|
||||
@ -201,8 +203,8 @@ inline float dtTriArea2D(const float* a, const float* b, const float* c)
|
||||
return acx*abz - abx*acz;
|
||||
}
|
||||
|
||||
inline bool dtCheckOverlapBox(const unsigned short amin[3], const unsigned short amax[3],
|
||||
const unsigned short bmin[3], const unsigned short bmax[3])
|
||||
inline bool dtOverlapQuantBounds(const unsigned short amin[3], const unsigned short amax[3],
|
||||
const unsigned short bmin[3], const unsigned short bmax[3])
|
||||
{
|
||||
bool overlap = true;
|
||||
overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap;
|
||||
@ -211,7 +213,8 @@ inline bool dtCheckOverlapBox(const unsigned short amin[3], const unsigned short
|
||||
return overlap;
|
||||
}
|
||||
|
||||
inline bool dtOverlapBounds(const float* amin, const float* amax, const float* bmin, const float* bmax)
|
||||
inline bool dtOverlapBounds(const float* amin, const float* amax,
|
||||
const float* bmin, const float* bmax)
|
||||
{
|
||||
bool overlap = true;
|
||||
overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap;
|
||||
|
@ -28,27 +28,6 @@
|
||||
#include <new>
|
||||
|
||||
|
||||
inline int opposite(int side) { return (side+4) & 0x7; }
|
||||
|
||||
inline bool overlapBoxes(const float* amin, const float* amax,
|
||||
const float* bmin, const float* bmax)
|
||||
{
|
||||
bool overlap = true;
|
||||
overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap;
|
||||
overlap = (amin[1] > bmax[1] || amax[1] < bmin[1]) ? false : overlap;
|
||||
overlap = (amin[2] > bmax[2] || amax[2] < bmin[2]) ? false : overlap;
|
||||
return overlap;
|
||||
}
|
||||
|
||||
inline bool overlapRects(const float* amin, const float* amax,
|
||||
const float* bmin, const float* bmax)
|
||||
{
|
||||
bool overlap = true;
|
||||
overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap;
|
||||
overlap = (amin[1] > bmax[1] || amax[1] < bmin[1]) ? false : overlap;
|
||||
return overlap;
|
||||
}
|
||||
|
||||
inline bool overlapSlabs(const float* amin, const float* amax,
|
||||
const float* bmin, const float* bmax,
|
||||
const float px, const float py)
|
||||
@ -358,7 +337,7 @@ void dtNavMesh::connectExtLinks(dtMeshTile* tile, dtMeshTile* target, int side)
|
||||
const float* vb = &tile->verts[poly->verts[(j+1) % nv]*3];
|
||||
dtPolyRef nei[4];
|
||||
float neia[4*2];
|
||||
int nnei = findConnectingPolys(va,vb, target, opposite(side), nei,neia,4);
|
||||
int nnei = findConnectingPolys(va,vb, target, dtOppositeTile(side), nei,neia,4);
|
||||
for (int k = 0; k < nnei; ++k)
|
||||
{
|
||||
unsigned int idx = allocLink(tile);
|
||||
@ -403,7 +382,7 @@ void dtNavMesh::connectExtOffMeshLinks(dtMeshTile* tile, dtMeshTile* target, int
|
||||
|
||||
// Connect off-mesh links.
|
||||
// We are interested on links which land from target tile to this tile.
|
||||
const unsigned char oppositeSide = (unsigned char)opposite(side);
|
||||
const unsigned char oppositeSide = (unsigned char)dtOppositeTile(side);
|
||||
|
||||
for (int i = 0; i < target->header->offMeshConCount; ++i)
|
||||
{
|
||||
@ -671,7 +650,7 @@ int dtNavMesh::queryPolygonsInTile(const dtMeshTile* tile, const float* qmin, co
|
||||
int n = 0;
|
||||
while (node < end)
|
||||
{
|
||||
const bool overlap = dtCheckOverlapBox(bmin, bmax, node->bmin, node->bmax);
|
||||
const bool overlap = dtOverlapQuantBounds(bmin, bmax, node->bmin, node->bmax);
|
||||
const bool isLeafNode = node->i >= 0;
|
||||
|
||||
if (isLeafNode && overlap)
|
||||
@ -709,7 +688,7 @@ int dtNavMesh::queryPolygonsInTile(const dtMeshTile* tile, const float* qmin, co
|
||||
dtVmin(bmin, v);
|
||||
dtVmax(bmax, v);
|
||||
}
|
||||
if (overlapBoxes(qmin,qmax, bmin,bmax))
|
||||
if (dtOverlapBounds(qmin,qmax, bmin,bmax))
|
||||
{
|
||||
if (n < maxPolys)
|
||||
polys[n++] = base | (dtPolyRef)i;
|
||||
@ -825,9 +804,9 @@ dtTileRef dtNavMesh::addTile(unsigned char* data, int dataSize, int flags, dtTil
|
||||
if (nei)
|
||||
{
|
||||
connectExtLinks(tile, nei, i);
|
||||
connectExtLinks(nei, tile, opposite(i));
|
||||
connectExtLinks(nei, tile, dtOppositeTile(i));
|
||||
connectExtOffMeshLinks(tile, nei, i);
|
||||
connectExtOffMeshLinks(nei, tile, opposite(i));
|
||||
connectExtOffMeshLinks(nei, tile, dtOppositeTile(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -984,7 +963,7 @@ bool dtNavMesh::removeTile(dtTileRef ref, unsigned char** data, int* dataSize)
|
||||
{
|
||||
dtMeshTile* nei = getNeighbourTileAt(tile->header->x,tile->header->y,i);
|
||||
if (!nei) continue;
|
||||
unconnectExtLinks(nei, opposite(i));
|
||||
unconnectExtLinks(nei, dtOppositeTile(i));
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,18 +71,6 @@ inline float dtQueryFilter::getCost(const float* pa, const float* pb,
|
||||
static const float H_SCALE = 0.999f; // Search heuristic scale.
|
||||
|
||||
|
||||
inline int opposite(int side) { return (side+4) & 0x7; }
|
||||
|
||||
inline bool overlapBoxes(const float* amin, const float* amax,
|
||||
const float* bmin, const float* bmax)
|
||||
{
|
||||
bool overlap = true;
|
||||
overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap;
|
||||
overlap = (amin[1] > bmax[1] || amax[1] < bmin[1]) ? false : overlap;
|
||||
overlap = (amin[2] > bmax[2] || amax[2] < bmin[2]) ? false : overlap;
|
||||
return overlap;
|
||||
}
|
||||
|
||||
dtNavMeshQuery* dtAllocNavMeshQuery()
|
||||
{
|
||||
return new(dtAlloc(sizeof(dtNavMeshQuery), DT_ALLOC_PERM)) dtNavMeshQuery;
|
||||
@ -428,7 +416,7 @@ int dtNavMeshQuery::queryPolygonsInTile(const dtMeshTile* tile, const float* qmi
|
||||
int n = 0;
|
||||
while (node < end)
|
||||
{
|
||||
const bool overlap = dtCheckOverlapBox(bmin, bmax, node->bmin, node->bmax);
|
||||
const bool overlap = dtOverlapQuantBounds(bmin, bmax, node->bmin, node->bmax);
|
||||
const bool isLeafNode = node->i >= 0;
|
||||
|
||||
if (isLeafNode && overlap)
|
||||
@ -470,7 +458,7 @@ int dtNavMeshQuery::queryPolygonsInTile(const dtMeshTile* tile, const float* qmi
|
||||
dtVmin(bmin, v);
|
||||
dtVmax(bmax, v);
|
||||
}
|
||||
if (overlapBoxes(qmin,qmax, bmin,bmax))
|
||||
if (dtOverlapBounds(qmin,qmax, bmin,bmax))
|
||||
{
|
||||
const dtPolyRef ref = base | (dtPolyRef)i;
|
||||
if (filter->passFilter(ref, tile, p))
|
||||
|
Loading…
x
Reference in New Issue
Block a user