Added cost per poly. Added API to change poly flags. Optimized pathfinder.
This commit is contained in:
parent
1eaf28c548
commit
f6236c133d
@ -379,6 +379,15 @@ public:
|
||||
// area - (in) area ID (0-63).
|
||||
float getAreaCost(const int area) const;
|
||||
|
||||
// Sets polygon flags.
|
||||
void setPolyFlags(dtPolyRef ref, unsigned short flags);
|
||||
|
||||
// Return polygon flags.
|
||||
unsigned short getPolyFlags(dtPolyRef ref);
|
||||
|
||||
// Return polygon type.
|
||||
unsigned char getPolyType(dtPolyRef ref);
|
||||
|
||||
// Returns pointer to a polygon based on ref.
|
||||
const dtPoly* getPolyByRef(dtPolyRef ref) const;
|
||||
|
||||
@ -448,18 +457,18 @@ private:
|
||||
// Returns closest point on polygon.
|
||||
bool closestPointOnPolyInTile(const dtMeshTile* tile, unsigned int ip, const float* pos, float* closest) const;
|
||||
|
||||
unsigned short getPolyFlags(dtPolyRef ref);
|
||||
unsigned char getPolyType(dtPolyRef ref);
|
||||
float getCost(dtPolyRef prev, dtPolyRef from, dtPolyRef to) const;
|
||||
float getFirstCost(const float* pos, dtPolyRef from, dtPolyRef to) const;
|
||||
float getLastCost(dtPolyRef from, dtPolyRef to, const float* pos) const;
|
||||
float getHeuristic(const float* from, const float* to) const;
|
||||
|
||||
// Returns portal points between two polygons.
|
||||
bool getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float* right,
|
||||
unsigned char& fromType, unsigned char& toType) const;
|
||||
bool getPortalPoints(dtPolyRef from, const dtPoly* fromPoly, const dtMeshHeader* fromHeader,
|
||||
dtPolyRef to, const dtPoly* toPoly, const dtMeshHeader* toHeader,
|
||||
float* left, float* right) const;
|
||||
|
||||
// Returns edge mid point between two polygons.
|
||||
bool getEdgeMidPoint(dtPolyRef from, dtPolyRef to, float* mid) const;
|
||||
bool getEdgeMidPoint(dtPolyRef from, const dtPoly* fromPoly, const dtMeshHeader* fromHeader,
|
||||
dtPolyRef to, const dtPoly* toPoly, const dtMeshHeader* toHeader,
|
||||
float* mid) const;
|
||||
|
||||
float m_orig[3]; // Origin of the tile (0,0)
|
||||
float m_tileWidth, m_tileHeight; // Dimensions of each tile.
|
||||
|
@ -116,6 +116,9 @@ dtNavMesh::dtNavMesh() :
|
||||
m_orig[0] = 0;
|
||||
m_orig[1] = 0;
|
||||
m_orig[2] = 0;
|
||||
|
||||
for (int i = 0; i < DT_MAX_AREAS; ++i)
|
||||
m_areaCost[i] = 1.0f;
|
||||
}
|
||||
|
||||
dtNavMesh::~dtNavMesh()
|
||||
@ -905,13 +908,13 @@ bool dtNavMesh::getPolyHeight(dtPolyRef ref, const float* pos, float* height) co
|
||||
|
||||
void dtNavMesh::setAreaCost(const int area, float cost)
|
||||
{
|
||||
if (area >= 0 && area > DT_MAX_AREAS)
|
||||
if (area >= 0 && area < DT_MAX_AREAS)
|
||||
m_areaCost[area] = cost;
|
||||
}
|
||||
|
||||
float dtNavMesh::getAreaCost(const int area) const
|
||||
{
|
||||
if (area >= 0 && area > DT_MAX_AREAS)
|
||||
if (area >= 0 && area < DT_MAX_AREAS)
|
||||
return m_areaCost[area];
|
||||
return -1;
|
||||
}
|
||||
@ -1130,6 +1133,9 @@ int dtNavMesh::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
|
||||
dtNode* lastBestNode = startNode;
|
||||
float lastBestNodeCost = startNode->total;
|
||||
|
||||
unsigned int it, ip;
|
||||
|
||||
while (!m_openList->empty())
|
||||
{
|
||||
dtNode* bestNode = m_openList->pop();
|
||||
@ -1140,47 +1146,83 @@ int dtNavMesh::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
break;
|
||||
}
|
||||
|
||||
// Get poly and tile.
|
||||
unsigned int salt, it, ip;
|
||||
decodePolyId(bestNode->id, salt, it, ip);
|
||||
float previousEdgeMidPoint[3];
|
||||
|
||||
// Get current poly and tile.
|
||||
// The API input has been cheked already, skip checking internal data.
|
||||
const dtMeshHeader* header = m_tiles[it].header;
|
||||
const dtPoly* poly = &header->polys[ip];
|
||||
const dtPolyRef bestRef = bestNode->id;
|
||||
it = decodePolyIdTile(bestRef);
|
||||
ip = decodePolyIdPoly(bestRef);
|
||||
const dtMeshHeader* bestHeader = m_tiles[it].header;
|
||||
const dtPoly* bestPoly = &bestHeader->polys[ip];
|
||||
|
||||
for (unsigned int i = poly->firstLink; i != DT_NULL_LINK; i = header->links[i].next)
|
||||
// Get parent poly and tile.
|
||||
dtPolyRef parentRef = 0;
|
||||
const dtMeshHeader* parentHeader = 0;
|
||||
const dtPoly* parentPoly = 0;
|
||||
if (bestNode->pidx)
|
||||
parentRef = m_nodePool->getNodeAtIdx(bestNode->pidx)->id;
|
||||
if (parentRef)
|
||||
{
|
||||
dtPolyRef neighbour = header->links[i].ref;
|
||||
if (neighbour)
|
||||
it = decodePolyIdTile(parentRef);
|
||||
ip = decodePolyIdPoly(parentRef);
|
||||
parentHeader = m_tiles[it].header;
|
||||
parentPoly = &parentHeader->polys[ip];
|
||||
|
||||
getEdgeMidPoint(parentRef, parentPoly, parentHeader,
|
||||
bestRef, bestPoly, bestHeader, previousEdgeMidPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Skip parent node.
|
||||
if (bestNode->pidx && m_nodePool->getNodeAtIdx(bestNode->pidx)->id == neighbour)
|
||||
vcopy(previousEdgeMidPoint, startPos);
|
||||
}
|
||||
|
||||
for (unsigned int i = bestPoly->firstLink; i != DT_NULL_LINK; i = bestHeader->links[i].next)
|
||||
{
|
||||
dtPolyRef neighbourRef = bestHeader->links[i].ref;
|
||||
// Skip invalid ids and do not expand back to parent node.
|
||||
if (!neighbourRef || parentRef == neighbourRef)
|
||||
continue;
|
||||
|
||||
// TODO: Avoid digging the polygon (done in getEdgeMidPoint too).
|
||||
if (!passFilter(filter, getPolyFlags(neighbour)))
|
||||
// Get neighbour poly and tile.
|
||||
// The API input has been cheked already, skip checking internal data.
|
||||
it = decodePolyIdTile(neighbourRef);
|
||||
ip = decodePolyIdPoly(neighbourRef);
|
||||
const dtMeshHeader* neighbourHeader = m_tiles[it].header;
|
||||
const dtPoly* neighbourPoly = &neighbourHeader->polys[ip];
|
||||
|
||||
if (!passFilter(filter, neighbourPoly->flags))
|
||||
continue;
|
||||
|
||||
dtNode* parent = bestNode;
|
||||
dtNode newNode;
|
||||
newNode.pidx = m_nodePool->getNodeIdx(parent);
|
||||
newNode.id = neighbour;
|
||||
newNode.pidx = m_nodePool->getNodeIdx(bestNode);
|
||||
newNode.id = neighbourRef;
|
||||
|
||||
// Calculate cost.
|
||||
float p0[3], p1[3];
|
||||
if (!parent->pidx)
|
||||
vcopy(p0, startPos);
|
||||
else
|
||||
getEdgeMidPoint(m_nodePool->getNodeAtIdx(parent->pidx)->id, parent->id, p0);
|
||||
float edgeMidPoint[3];
|
||||
|
||||
getEdgeMidPoint(parent->id, newNode.id, p1);
|
||||
getEdgeMidPoint(bestRef, bestPoly, bestHeader,
|
||||
neighbourRef, neighbourPoly, neighbourHeader, edgeMidPoint);
|
||||
|
||||
newNode.cost = parent->cost + vdist(p0,p1);
|
||||
// Special case for last node.
|
||||
if (newNode.id == endRef)
|
||||
newNode.cost += vdist(p1, endPos);
|
||||
|
||||
float h = 0;
|
||||
if (neighbourRef == endRef)
|
||||
{
|
||||
// Cost
|
||||
newNode.cost = bestNode->cost +
|
||||
vdist(previousEdgeMidPoint,edgeMidPoint) * m_areaCost[bestPoly->area] +
|
||||
vdist(edgeMidPoint, endPos) * m_areaCost[neighbourPoly->area];
|
||||
// Heuristic
|
||||
const float h = vdist(p1,endPos)*H_SCALE;
|
||||
h = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cost
|
||||
newNode.cost = bestNode->cost +
|
||||
vdist(previousEdgeMidPoint,edgeMidPoint) * m_areaCost[bestPoly->area];
|
||||
// Heuristic
|
||||
h = vdist(edgeMidPoint,endPos)*H_SCALE;
|
||||
}
|
||||
newNode.total = newNode.cost + h;
|
||||
|
||||
dtNode* actualNode = m_nodePool->getNode(newNode.id);
|
||||
@ -1212,7 +1254,7 @@ int dtNavMesh::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bestNode->flags |= DT_NODE_CLOSED;
|
||||
}
|
||||
|
||||
@ -1550,7 +1592,6 @@ int dtNavMesh::moveAlongPathCorridor(const float* startPos, const float* endPos,
|
||||
return n;
|
||||
}
|
||||
|
||||
// Returns portal points between two polygons.
|
||||
bool dtNavMesh::getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float* right,
|
||||
unsigned char& fromType, unsigned char& toType) const
|
||||
{
|
||||
@ -1563,12 +1604,6 @@ bool dtNavMesh::getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float
|
||||
const dtPoly* fromPoly = &fromHeader->polys[ip];
|
||||
fromType = fromPoly->type;
|
||||
|
||||
for (unsigned int i = fromPoly->firstLink; i != DT_NULL_LINK; i = fromHeader->links[i].next)
|
||||
{
|
||||
const dtLink* link = &fromHeader->links[i];
|
||||
if (link->ref != to)
|
||||
continue;
|
||||
|
||||
decodePolyId(to, salt, it, ip);
|
||||
if (it >= (unsigned int)m_maxTiles) return false;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return false;
|
||||
@ -1577,6 +1612,30 @@ bool dtNavMesh::getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float
|
||||
const dtPoly* toPoly = &toHeader->polys[ip];
|
||||
toType = toPoly->type;
|
||||
|
||||
return getPortalPoints(from, fromPoly, fromHeader,
|
||||
to, toPoly, toHeader,
|
||||
left, right);
|
||||
}
|
||||
|
||||
// Returns portal points between two polygons.
|
||||
bool dtNavMesh::getPortalPoints(dtPolyRef from, const dtPoly* fromPoly, const dtMeshHeader* fromHeader,
|
||||
dtPolyRef to, const dtPoly* toPoly, const dtMeshHeader* toHeader,
|
||||
float* left, float* right) const
|
||||
{
|
||||
// Find the link that points to the 'to' polygon.
|
||||
const dtLink* link = 0;
|
||||
for (unsigned int i = fromPoly->firstLink; i != DT_NULL_LINK; i = fromHeader->links[i].next)
|
||||
{
|
||||
if (fromHeader->links[i].ref == to)
|
||||
{
|
||||
link = &fromHeader->links[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!link)
|
||||
return false;
|
||||
|
||||
// Handle off-mesh connections.
|
||||
if (fromPoly->type == DT_POLYTYPE_OFFMESH_CONNECTION)
|
||||
{
|
||||
// Find link that points to first vertex.
|
||||
@ -1613,6 +1672,7 @@ bool dtNavMesh::getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float
|
||||
const int v1 = fromPoly->verts[(link->edge+1) % (int)fromPoly->vertCount];
|
||||
vcopy(left, &fromHeader->verts[v0*3]);
|
||||
vcopy(right, &fromHeader->verts[v1*3]);
|
||||
|
||||
// If the link is at tile boundary, clamp the vertices to
|
||||
// the link width.
|
||||
if (link->side == 0 || link->side == 4)
|
||||
@ -1641,10 +1701,9 @@ bool dtNavMesh::getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float
|
||||
right[0] = max(right[0],lmin);
|
||||
right[0] = min(right[0],lmax);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns edge mid point between two polygons.
|
||||
bool dtNavMesh::getEdgeMidPoint(dtPolyRef from, dtPolyRef to, float* mid) const
|
||||
@ -1658,6 +1717,32 @@ bool dtNavMesh::getEdgeMidPoint(dtPolyRef from, dtPolyRef to, float* mid) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dtNavMesh::getEdgeMidPoint(dtPolyRef from, const dtPoly* fromPoly, const dtMeshHeader* fromHeader,
|
||||
dtPolyRef to, const dtPoly* toPoly, const dtMeshHeader* toHeader,
|
||||
float* mid) const
|
||||
{
|
||||
float left[3], right[3];
|
||||
if (!getPortalPoints(from, fromPoly, fromHeader, to, toPoly, toHeader, left, right))
|
||||
return false;
|
||||
mid[0] = (left[0]+right[0])*0.5f;
|
||||
mid[1] = (left[1]+right[1])*0.5f;
|
||||
mid[2] = (left[2]+right[2])*0.5f;
|
||||
return true;
|
||||
}
|
||||
|
||||
void dtNavMesh::setPolyFlags(dtPolyRef ref, unsigned short flags)
|
||||
{
|
||||
unsigned int salt, it, ip;
|
||||
decodePolyId(ref, salt, it, ip);
|
||||
if (it >= (unsigned int)m_maxTiles) return;
|
||||
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return;
|
||||
if (ip >= (unsigned int)m_tiles[it].header->polyCount) return;
|
||||
dtMeshHeader* header = m_tiles[it].header;
|
||||
dtPoly* poly = &header->polys[ip];
|
||||
// Change flags.
|
||||
poly->flags = flags;
|
||||
}
|
||||
|
||||
unsigned short dtNavMesh::getPolyFlags(dtPolyRef ref)
|
||||
{
|
||||
unsigned int salt, it, ip;
|
||||
@ -1846,30 +1931,54 @@ int dtNavMesh::findPolysAround(dtPolyRef centerRef, const float* centerPos, floa
|
||||
|
||||
const float radiusSqr = sqr(radius);
|
||||
|
||||
unsigned int it, ip;
|
||||
|
||||
while (!m_openList->empty())
|
||||
{
|
||||
dtNode* bestNode = m_openList->pop();
|
||||
|
||||
float previousEdgeMidPoint[3];
|
||||
|
||||
// Get poly and tile.
|
||||
// The API input has been cheked already, skip checking internal data.
|
||||
unsigned int it = decodePolyIdTile(bestNode->id);
|
||||
unsigned int ip = decodePolyIdPoly(bestNode->id);
|
||||
const dtMeshHeader* header = m_tiles[it].header;
|
||||
const dtPoly* poly = &header->polys[ip];
|
||||
const dtPolyRef bestRef = bestNode->id;
|
||||
it = decodePolyIdTile(bestRef);
|
||||
ip = decodePolyIdPoly(bestRef);
|
||||
const dtMeshHeader* bestHeader = m_tiles[it].header;
|
||||
const dtPoly* bestPoly = &bestHeader->polys[ip];
|
||||
|
||||
for (unsigned int i = poly->firstLink; i != DT_NULL_LINK; i = header->links[i].next)
|
||||
// Get parent poly and tile.
|
||||
dtPolyRef parentRef = 0;
|
||||
const dtMeshHeader* parentHeader = 0;
|
||||
const dtPoly* parentPoly = 0;
|
||||
if (bestNode->pidx)
|
||||
parentRef = m_nodePool->getNodeAtIdx(bestNode->pidx)->id;
|
||||
if (parentRef)
|
||||
{
|
||||
const dtLink* link = &header->links[i];
|
||||
dtPolyRef neighbour = link->ref;
|
||||
if (neighbour)
|
||||
it = decodePolyIdTile(parentRef);
|
||||
ip = decodePolyIdPoly(parentRef);
|
||||
parentHeader = m_tiles[it].header;
|
||||
parentPoly = &parentHeader->polys[ip];
|
||||
|
||||
getEdgeMidPoint(parentRef, parentPoly, parentHeader,
|
||||
bestRef, bestPoly, bestHeader, previousEdgeMidPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Skip parent node.
|
||||
if (bestNode->pidx && m_nodePool->getNodeAtIdx(bestNode->pidx)->id == neighbour)
|
||||
vcopy(previousEdgeMidPoint, centerPos);
|
||||
}
|
||||
|
||||
for (unsigned int i = bestPoly->firstLink; i != DT_NULL_LINK; i = bestHeader->links[i].next)
|
||||
{
|
||||
const dtLink* link = &bestHeader->links[i];
|
||||
dtPolyRef neighbourRef = link->ref;
|
||||
// Skip invalid neighbours and do not follow back to parent.
|
||||
if (!neighbourRef || neighbourRef == parentRef)
|
||||
continue;
|
||||
|
||||
// Calc distance to the edge.
|
||||
const float* va = &header->verts[poly->verts[link->edge]*3];
|
||||
const float* vb = &header->verts[poly->verts[(link->edge+1) % poly->vertCount]*3];
|
||||
const float* va = &bestHeader->verts[bestPoly->verts[link->edge]*3];
|
||||
const float* vb = &bestHeader->verts[bestPoly->verts[(link->edge+1) % bestPoly->vertCount]*3];
|
||||
float tseg;
|
||||
float distSqr = distancePtSegSqr2D(centerPos, va, vb, tseg);
|
||||
|
||||
@ -1877,22 +1986,25 @@ int dtNavMesh::findPolysAround(dtPolyRef centerRef, const float* centerPos, floa
|
||||
if (distSqr > radiusSqr)
|
||||
continue;
|
||||
|
||||
if (!passFilter(filter, getPolyFlags(neighbour)))
|
||||
// Expand to neighbour
|
||||
it = decodePolyIdTile(neighbourRef);
|
||||
ip = decodePolyIdPoly(neighbourRef);
|
||||
const dtMeshHeader* neighbourHeader = m_tiles[it].header;
|
||||
const dtPoly* neighbourPoly = &neighbourHeader->polys[ip];
|
||||
|
||||
if (!passFilter(filter, neighbourPoly->flags))
|
||||
continue;
|
||||
|
||||
dtNode* parent = bestNode;
|
||||
dtNode newNode;
|
||||
newNode.pidx = m_nodePool->getNodeIdx(parent);
|
||||
newNode.id = neighbour;
|
||||
newNode.pidx = m_nodePool->getNodeIdx(bestNode);
|
||||
newNode.id = neighbourRef;
|
||||
|
||||
// Cost
|
||||
float p0[3], p1[3];
|
||||
if (!parent->pidx)
|
||||
vcopy(p0, centerPos);
|
||||
else
|
||||
getEdgeMidPoint(m_nodePool->getNodeAtIdx(parent->pidx)->id, parent->id, p0);
|
||||
getEdgeMidPoint(parent->id, newNode.id, p1);
|
||||
newNode.total = parent->total + vdist(p0,p1);
|
||||
float edgeMidPoint[3];
|
||||
getEdgeMidPoint(bestRef, bestPoly, bestHeader,
|
||||
neighbourRef, neighbourPoly, neighbourHeader, edgeMidPoint);
|
||||
|
||||
newNode.total = bestNode->total + vdist(previousEdgeMidPoint, edgeMidPoint);
|
||||
|
||||
dtNode* actualNode = m_nodePool->getNode(newNode.id);
|
||||
if (!actualNode)
|
||||
@ -1927,7 +2039,6 @@ int dtNavMesh::findPolysAround(dtPolyRef centerRef, const float* centerPos, floa
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
@ -1952,45 +2063,72 @@ float dtNavMesh::findDistanceToWall(dtPolyRef centerRef, const float* centerPos,
|
||||
|
||||
float radiusSqr = sqr(maxRadius);
|
||||
|
||||
unsigned int it, ip;
|
||||
|
||||
while (!m_openList->empty())
|
||||
{
|
||||
dtNode* bestNode = m_openList->pop();
|
||||
|
||||
float previousEdgeMidPoint[3];
|
||||
|
||||
// Get poly and tile.
|
||||
// The API input has been cheked already, skip checking internal data.
|
||||
unsigned int it = decodePolyIdTile(bestNode->id);
|
||||
unsigned int ip = decodePolyIdPoly(bestNode->id);
|
||||
const dtMeshHeader* header = m_tiles[it].header;
|
||||
const dtPoly* poly = &header->polys[ip];
|
||||
const dtPolyRef bestRef = bestNode->id;
|
||||
it = decodePolyIdTile(bestRef);
|
||||
ip = decodePolyIdPoly(bestRef);
|
||||
const dtMeshHeader* bestHeader = m_tiles[it].header;
|
||||
const dtPoly* bestPoly = &bestHeader->polys[ip];
|
||||
|
||||
// Get parent poly and tile.
|
||||
dtPolyRef parentRef = 0;
|
||||
const dtMeshHeader* parentHeader = 0;
|
||||
const dtPoly* parentPoly = 0;
|
||||
if (bestNode->pidx)
|
||||
parentRef = m_nodePool->getNodeAtIdx(bestNode->pidx)->id;
|
||||
if (parentRef)
|
||||
{
|
||||
it = decodePolyIdTile(parentRef);
|
||||
ip = decodePolyIdPoly(parentRef);
|
||||
parentHeader = m_tiles[it].header;
|
||||
parentPoly = &parentHeader->polys[ip];
|
||||
|
||||
getEdgeMidPoint(parentRef, parentPoly, parentHeader,
|
||||
bestRef, bestPoly, bestHeader, previousEdgeMidPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
vcopy(previousEdgeMidPoint, centerPos);
|
||||
}
|
||||
|
||||
// Hit test walls.
|
||||
for (int i = 0, j = (int)poly->vertCount-1; i < (int)poly->vertCount; j = i++)
|
||||
for (int i = 0, j = (int)bestPoly->vertCount-1; i < (int)bestPoly->vertCount; j = i++)
|
||||
{
|
||||
// Skip non-solid edges.
|
||||
if (poly->neis[j] & DT_EXT_LINK)
|
||||
if (bestPoly->neis[j] & DT_EXT_LINK)
|
||||
{
|
||||
// Tile border.
|
||||
bool solid = true;
|
||||
for (unsigned int k = poly->firstLink; k != DT_NULL_LINK; k = header->links[k].next)
|
||||
for (unsigned int k = bestPoly->firstLink; k != DT_NULL_LINK; k = bestHeader->links[k].next)
|
||||
{
|
||||
const dtLink* link = &header->links[k];
|
||||
if (link->edge == j && link->ref != 0 && passFilter(filter, getPolyFlags(link->ref)))
|
||||
const dtLink* link = &bestHeader->links[k];
|
||||
if (link->edge == j)
|
||||
{
|
||||
if (link->ref != 0 && passFilter(filter, getPolyFlags(link->ref)))
|
||||
solid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!solid) continue;
|
||||
}
|
||||
else if (poly->neis[j] && passFilter(filter, header->polys[poly->neis[j]].flags))
|
||||
else if (bestPoly->neis[j] && passFilter(filter, bestHeader->polys[bestPoly->neis[j]].flags))
|
||||
{
|
||||
// Internal edge
|
||||
continue;
|
||||
}
|
||||
|
||||
// Calc distance to the edge.
|
||||
const float* vj = &header->verts[poly->verts[j]*3];
|
||||
const float* vi = &header->verts[poly->verts[i]*3];
|
||||
const float* vj = &bestHeader->verts[bestPoly->verts[j]*3];
|
||||
const float* vi = &bestHeader->verts[bestPoly->verts[i]*3];
|
||||
float tseg;
|
||||
float distSqr = distancePtSegSqr2D(centerPos, vj, vi, tseg);
|
||||
|
||||
@ -2006,19 +2144,17 @@ float dtNavMesh::findDistanceToWall(dtPolyRef centerRef, const float* centerPos,
|
||||
hitPos[2] = vj[2] + (vi[2] - vj[2])*tseg;
|
||||
}
|
||||
|
||||
for (unsigned int i = poly->firstLink; i != DT_NULL_LINK; i = header->links[i].next)
|
||||
for (unsigned int i = bestPoly->firstLink; i != DT_NULL_LINK; i = bestHeader->links[i].next)
|
||||
{
|
||||
const dtLink* link = &header->links[i];
|
||||
dtPolyRef neighbour = link->ref;
|
||||
if (neighbour)
|
||||
{
|
||||
// Skip parent node.
|
||||
if (bestNode->pidx && m_nodePool->getNodeAtIdx(bestNode->pidx)->id == neighbour)
|
||||
const dtLink* link = &bestHeader->links[i];
|
||||
dtPolyRef neighbourRef = link->ref;
|
||||
// Skip invalid neighbours and do not follow back to parent.
|
||||
if (!neighbourRef || neighbourRef == parentRef)
|
||||
continue;
|
||||
|
||||
// Calc distance to the edge.
|
||||
const float* va = &header->verts[poly->verts[link->edge]*3];
|
||||
const float* vb = &header->verts[poly->verts[(link->edge+1) % poly->vertCount]*3];
|
||||
const float* va = &bestHeader->verts[bestPoly->verts[link->edge]*3];
|
||||
const float* vb = &bestHeader->verts[bestPoly->verts[(link->edge+1) % bestPoly->vertCount]*3];
|
||||
float tseg;
|
||||
float distSqr = distancePtSegSqr2D(centerPos, va, vb, tseg);
|
||||
|
||||
@ -2026,21 +2162,25 @@ float dtNavMesh::findDistanceToWall(dtPolyRef centerRef, const float* centerPos,
|
||||
if (distSqr > radiusSqr)
|
||||
continue;
|
||||
|
||||
if (!passFilter(filter, getPolyFlags(neighbour)))
|
||||
// Expand to neighbour.
|
||||
it = decodePolyIdTile(neighbourRef);
|
||||
ip = decodePolyIdPoly(neighbourRef);
|
||||
const dtMeshHeader* neighbourHeader = m_tiles[it].header;
|
||||
const dtPoly* neighbourPoly = &neighbourHeader->polys[ip];
|
||||
|
||||
if (!passFilter(filter, neighbourPoly->flags))
|
||||
continue;
|
||||
|
||||
dtNode* parent = bestNode;
|
||||
dtNode newNode;
|
||||
newNode.pidx = m_nodePool->getNodeIdx(parent);
|
||||
newNode.id = neighbour;
|
||||
newNode.pidx = m_nodePool->getNodeIdx(bestNode);
|
||||
newNode.id = neighbourRef;
|
||||
|
||||
float p0[3], p1[3];
|
||||
if (!parent->pidx)
|
||||
vcopy(p0, centerPos);
|
||||
else
|
||||
getEdgeMidPoint(m_nodePool->getNodeAtIdx(parent->pidx)->id, parent->id, p0);
|
||||
getEdgeMidPoint(parent->id, newNode.id, p1);
|
||||
newNode.total = parent->total + vdist(p0,p1);
|
||||
// Cost
|
||||
float edgeMidPoint[3];
|
||||
getEdgeMidPoint(bestRef, bestPoly, bestHeader,
|
||||
neighbourRef, neighbourPoly, neighbourHeader, edgeMidPoint);
|
||||
|
||||
newNode.total = bestNode->total + vdist(previousEdgeMidPoint, edgeMidPoint);
|
||||
|
||||
dtNode* actualNode = m_nodePool->getNode(newNode.id);
|
||||
if (!actualNode)
|
||||
@ -2065,7 +2205,6 @@ float dtNavMesh::findDistanceToWall(dtPolyRef centerRef, const float* centerPos,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calc hit normal.
|
||||
vsub(hitNormal, centerPos, hitPos);
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -281,14 +281,14 @@
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
<array>
|
||||
<integer>45</integer>
|
||||
<integer>44</integer>
|
||||
<integer>36</integer>
|
||||
<integer>35</integer>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
||||
<string>{{0, 293}, {358, 643}}</string>
|
||||
<string>{{0, 295}, {358, 643}}</string>
|
||||
</dict>
|
||||
<key>PBXTopSmartGroupGIDs</key>
|
||||
<array/>
|
||||
@ -323,7 +323,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>ConvexVolumeTool.cpp</string>
|
||||
<string>DetourNavMesh.cpp</string>
|
||||
<key>PBXSplitModuleInNavigatorKey</key>
|
||||
<dict>
|
||||
<key>Split0</key>
|
||||
@ -331,11 +331,11 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A40F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>ConvexVolumeTool.cpp</string>
|
||||
<string>DetourNavMesh.cpp</string>
|
||||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>6B324D0D111C7C1700EBD2FD</string>
|
||||
<string>6B324E231125568100EBD2FD</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>6B8DE70D10B01BBF00DF20FB</string>
|
||||
@ -350,8 +350,6 @@
|
||||
<string>6BF7C2441111DAC1002B3F46</string>
|
||||
<string>6BF7C2761112BE4F002B3F46</string>
|
||||
<string>6BF7C2851112C348002B3F46</string>
|
||||
<string>6BF7C3211112DB82002B3F46</string>
|
||||
<string>6BF7C3431112E74B002B3F46</string>
|
||||
<string>6BF7C36E1112EB25002B3F46</string>
|
||||
<string>6BF7C37D1113026E002B3F46</string>
|
||||
<string>6BF7C394111316AD002B3F46</string>
|
||||
@ -361,13 +359,11 @@
|
||||
<string>6BF7C4831115C7C4002B3F46</string>
|
||||
<string>6BF7C5F91116F346002B3F46</string>
|
||||
<string>6BF7C6591117142A002B3F46</string>
|
||||
<string>6BF7C67C1117163B002B3F46</string>
|
||||
<string>6BF7C67D1117163B002B3F46</string>
|
||||
<string>6BF7C69B11172159002B3F46</string>
|
||||
<string>6BF7C6AA11172278002B3F46</string>
|
||||
<string>6B324A7C111BF65400EBD2FD</string>
|
||||
<string>6B324AC3111C00D700EBD2FD</string>
|
||||
<string>6B324AC5111C00D700EBD2FD</string>
|
||||
<string>6B324ACA111C00D700EBD2FD</string>
|
||||
<string>6B324AE6111C07AB00EBD2FD</string>
|
||||
<string>6B324AEA111C0D9700EBD2FD</string>
|
||||
@ -380,24 +376,29 @@
|
||||
<string>6B324B52111C1AC800EBD2FD</string>
|
||||
<string>6B324B71111C1C4F00EBD2FD</string>
|
||||
<string>6B324B7A111C1C8200EBD2FD</string>
|
||||
<string>6B324B8A111C1DE600EBD2FD</string>
|
||||
<string>6B324BB8111C4C2B00EBD2FD</string>
|
||||
<string>6B324BBB111C4C2B00EBD2FD</string>
|
||||
<string>6B324C45111C5C5A00EBD2FD</string>
|
||||
<string>6B324C51111C5D1400EBD2FD</string>
|
||||
<string>6B324C92111C604500EBD2FD</string>
|
||||
<string>6B324C9E111C6DD400EBD2FD</string>
|
||||
<string>6B324CB5111C6EEA00EBD2FD</string>
|
||||
<string>6B324CC3111C6F6300EBD2FD</string>
|
||||
<string>6B324CF2111C7A9800EBD2FD</string>
|
||||
<string>6B324CF9111C7B0900EBD2FD</string>
|
||||
<string>6B324CFA111C7B0900EBD2FD</string>
|
||||
<string>6B324CFB111C7B0900EBD2FD</string>
|
||||
<string>6B324CFC111C7B0900EBD2FD</string>
|
||||
<string>6B324CFD111C7B0900EBD2FD</string>
|
||||
<string>6B324D09111C7C1700EBD2FD</string>
|
||||
<string>6B324D0A111C7C1700EBD2FD</string>
|
||||
<string>6B324CDA111C789800EBD2FD</string>
|
||||
<string>6B324D0F1121C78000EBD2FD</string>
|
||||
<string>6B324D101121C78000EBD2FD</string>
|
||||
<string>6B324D501121D61A00EBD2FD</string>
|
||||
<string>6B324D511121D61A00EBD2FD</string>
|
||||
<string>6B324D631121DE7A00EBD2FD</string>
|
||||
<string>6B324D641121DE7A00EBD2FD</string>
|
||||
<string>6B324D651121DE7A00EBD2FD</string>
|
||||
<string>6B324D661121DE7A00EBD2FD</string>
|
||||
<string>6B324DC911254B2E00EBD2FD</string>
|
||||
<string>6B324E071125554800EBD2FD</string>
|
||||
<string>6B324E181125566A00EBD2FD</string>
|
||||
<string>6B324E191125566A00EBD2FD</string>
|
||||
<string>6B324E201125568100EBD2FD</string>
|
||||
<string>6B324E211125568100EBD2FD</string>
|
||||
</array>
|
||||
<key>prevStack</key>
|
||||
<array>
|
||||
@ -435,7 +436,6 @@
|
||||
<string>6BF7C39C111316AD002B3F46</string>
|
||||
<string>6BB7FDD910F37703006DA0A6</string>
|
||||
<string>6BF7C16711119C69002B3F46</string>
|
||||
<string>6BF7C4661115C514002B3F46</string>
|
||||
<string>6BF7C46A1115C514002B3F46</string>
|
||||
<string>6BF7C52F1115FA3B002B3F46</string>
|
||||
<string>6BF7C6081116F61A002B3F46</string>
|
||||
@ -461,7 +461,6 @@
|
||||
<string>6B324AEE111C0D9700EBD2FD</string>
|
||||
<string>6B324AEF111C0D9700EBD2FD</string>
|
||||
<string>6B324AF0111C0D9700EBD2FD</string>
|
||||
<string>6B324B01111C0F2700EBD2FD</string>
|
||||
<string>6B324B02111C0F2700EBD2FD</string>
|
||||
<string>6B324B03111C0F2700EBD2FD</string>
|
||||
<string>6B324B04111C0F2700EBD2FD</string>
|
||||
@ -474,7 +473,6 @@
|
||||
<string>6B324B14111C103600EBD2FD</string>
|
||||
<string>6B324B15111C103600EBD2FD</string>
|
||||
<string>6B324B18111C103600EBD2FD</string>
|
||||
<string>6B324B21111C10C700EBD2FD</string>
|
||||
<string>6B324B23111C10C700EBD2FD</string>
|
||||
<string>6B324B33111C153D00EBD2FD</string>
|
||||
<string>6B324B35111C153D00EBD2FD</string>
|
||||
@ -485,13 +483,9 @@
|
||||
<string>6B324B55111C1AC800EBD2FD</string>
|
||||
<string>6B324B56111C1AC800EBD2FD</string>
|
||||
<string>6B324B57111C1AC800EBD2FD</string>
|
||||
<string>6B324B5A111C1AC800EBD2FD</string>
|
||||
<string>6B324B5B111C1AC800EBD2FD</string>
|
||||
<string>6B324B5C111C1AC800EBD2FD</string>
|
||||
<string>6B324B5D111C1AC800EBD2FD</string>
|
||||
<string>6B324B5E111C1AC800EBD2FD</string>
|
||||
<string>6B324B5F111C1AC800EBD2FD</string>
|
||||
<string>6B324B60111C1AC800EBD2FD</string>
|
||||
<string>6B324B61111C1AC800EBD2FD</string>
|
||||
<string>6B324B62111C1AC800EBD2FD</string>
|
||||
<string>6B324B63111C1AC800EBD2FD</string>
|
||||
@ -504,10 +498,7 @@
|
||||
<string>6B324B75111C1C4F00EBD2FD</string>
|
||||
<string>6B324B7D111C1C8200EBD2FD</string>
|
||||
<string>6B324B82111C1CF000EBD2FD</string>
|
||||
<string>6B324B87111C1D9700EBD2FD</string>
|
||||
<string>6B324B8C111C1DE600EBD2FD</string>
|
||||
<string>6B324BBD111C4C2B00EBD2FD</string>
|
||||
<string>6B324BBE111C4C2B00EBD2FD</string>
|
||||
<string>6B324BC1111C4C2B00EBD2FD</string>
|
||||
<string>6B324C21111C5B8D00EBD2FD</string>
|
||||
<string>6B324C23111C5B8D00EBD2FD</string>
|
||||
@ -517,25 +508,18 @@
|
||||
<string>6B324C2B111C5B8D00EBD2FD</string>
|
||||
<string>6B324C2D111C5B8D00EBD2FD</string>
|
||||
<string>6B324C2F111C5B8D00EBD2FD</string>
|
||||
<string>6B324C30111C5B8D00EBD2FD</string>
|
||||
<string>6B324C31111C5B8D00EBD2FD</string>
|
||||
<string>6B324C33111C5B8D00EBD2FD</string>
|
||||
<string>6B324C34111C5B8D00EBD2FD</string>
|
||||
<string>6B324C49111C5C5A00EBD2FD</string>
|
||||
<string>6B324C58111C5D1400EBD2FD</string>
|
||||
<string>6B324C59111C5D1400EBD2FD</string>
|
||||
<string>6B324C5D111C5D1400EBD2FD</string>
|
||||
<string>6B324C5F111C5D1400EBD2FD</string>
|
||||
<string>6B324C61111C5D1400EBD2FD</string>
|
||||
<string>6B324C70111C5DDC00EBD2FD</string>
|
||||
<string>6B324C71111C5DDC00EBD2FD</string>
|
||||
<string>6B324C79111C5E7C00EBD2FD</string>
|
||||
<string>6B324C7A111C5E7C00EBD2FD</string>
|
||||
<string>6B324C7B111C5E7C00EBD2FD</string>
|
||||
<string>6B324C80111C5EF800EBD2FD</string>
|
||||
<string>6B324CA4111C6DD400EBD2FD</string>
|
||||
<string>6B324CA5111C6DD400EBD2FD</string>
|
||||
<string>6B324CAE111C6E0100EBD2FD</string>
|
||||
<string>6B324CB7111C6EEA00EBD2FD</string>
|
||||
<string>6B324CB8111C6EEA00EBD2FD</string>
|
||||
<string>6B324CB9111C6EEA00EBD2FD</string>
|
||||
@ -545,7 +529,6 @@
|
||||
<string>6B324CD0111C759F00EBD2FD</string>
|
||||
<string>6B324CD1111C759F00EBD2FD</string>
|
||||
<string>6B324CDE111C789800EBD2FD</string>
|
||||
<string>6B324CDF111C789800EBD2FD</string>
|
||||
<string>6B324CE0111C789800EBD2FD</string>
|
||||
<string>6B324CE1111C789800EBD2FD</string>
|
||||
<string>6B324CE5111C78DA00EBD2FD</string>
|
||||
@ -554,12 +537,51 @@
|
||||
<string>6B324CF5111C7A9800EBD2FD</string>
|
||||
<string>6B324CFF111C7B0900EBD2FD</string>
|
||||
<string>6B324D00111C7B0900EBD2FD</string>
|
||||
<string>6B324D01111C7B0900EBD2FD</string>
|
||||
<string>6B324D02111C7B0900EBD2FD</string>
|
||||
<string>6B324D03111C7B0900EBD2FD</string>
|
||||
<string>6B324D04111C7B0900EBD2FD</string>
|
||||
<string>6B324D0B111C7C1700EBD2FD</string>
|
||||
<string>6B324D0C111C7C1700EBD2FD</string>
|
||||
<string>6B324D121121C78000EBD2FD</string>
|
||||
<string>6B324D131121C78000EBD2FD</string>
|
||||
<string>6B324D141121C78000EBD2FD</string>
|
||||
<string>6B324D151121C78000EBD2FD</string>
|
||||
<string>6B324D231121CD0C00EBD2FD</string>
|
||||
<string>6B324D281121CD2000EBD2FD</string>
|
||||
<string>6B324D321121CDAF00EBD2FD</string>
|
||||
<string>6B324D3B1121CFCF00EBD2FD</string>
|
||||
<string>6B324D3C1121CFCF00EBD2FD</string>
|
||||
<string>6B324D531121D61A00EBD2FD</string>
|
||||
<string>6B324D541121D61A00EBD2FD</string>
|
||||
<string>6B324B5A111C1AC800EBD2FD</string>
|
||||
<string>6B324D5E1121D71800EBD2FD</string>
|
||||
<string>6B324D691121DE7A00EBD2FD</string>
|
||||
<string>6B324D6A1121DE7A00EBD2FD</string>
|
||||
<string>6B324D6B1121DE7A00EBD2FD</string>
|
||||
<string>6B324D6C1121DE7A00EBD2FD</string>
|
||||
<string>6B324D6D1121DE7A00EBD2FD</string>
|
||||
<string>6B324D6F1121DE7A00EBD2FD</string>
|
||||
<string>6B324D711121DE7A00EBD2FD</string>
|
||||
<string>6B324D731121DE7A00EBD2FD</string>
|
||||
<string>6B324D751121DE7A00EBD2FD</string>
|
||||
<string>6B324D771121DE7A00EBD2FD</string>
|
||||
<string>6B324D791121DE7A00EBD2FD</string>
|
||||
<string>6B324D7B1121DE7A00EBD2FD</string>
|
||||
<string>6B324D7D1121DE7A00EBD2FD</string>
|
||||
<string>6B324D7F1121DE7A00EBD2FD</string>
|
||||
<string>6B324D8411253B8E00EBD2FD</string>
|
||||
<string>6B324D95112542DA00EBD2FD</string>
|
||||
<string>6B324D97112542DA00EBD2FD</string>
|
||||
<string>6B324DD011254E0400EBD2FD</string>
|
||||
<string>6B324DE51125511B00EBD2FD</string>
|
||||
<string>6B324E0B1125554800EBD2FD</string>
|
||||
<string>6B324E0C1125554800EBD2FD</string>
|
||||
<string>6B324E0D1125554800EBD2FD</string>
|
||||
<string>6B324E0E1125554800EBD2FD</string>
|
||||
<string>6B324E0F1125554800EBD2FD</string>
|
||||
<string>6B324E101125554800EBD2FD</string>
|
||||
<string>6B324E14112555CF00EBD2FD</string>
|
||||
<string>6B324E1B1125566A00EBD2FD</string>
|
||||
<string>6B324E221125568100EBD2FD</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
@ -573,18 +595,18 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {876, 545}}</string>
|
||||
<string>{{0, 0}, {876, 426}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>11 76 1256 702 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXNavigatorGroup</string>
|
||||
<key>Proportion</key>
|
||||
<string>545pt</string>
|
||||
<string>426pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Proportion</key>
|
||||
<string>111pt</string>
|
||||
<string>230pt</string>
|
||||
<key>Tabs</key>
|
||||
<array>
|
||||
<dict>
|
||||
@ -614,7 +636,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {876, 197}}</string>
|
||||
<string>{{10, 27}, {876, 72}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXProjectFindModule</string>
|
||||
@ -652,7 +674,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {876, 84}}</string>
|
||||
<string>{{10, 27}, {876, 203}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>11 76 1256 702 0 0 1280 778 </string>
|
||||
</dict>
|
||||
@ -737,12 +759,12 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {1256, 260}}</string>
|
||||
<string>{{0, 0}, {1256, 55}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXDebugCLIModule</string>
|
||||
<key>Proportion</key>
|
||||
<string>260pt</string>
|
||||
<string>55pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>ContentConfiguration</key>
|
||||
@ -761,8 +783,8 @@
|
||||
<string>yes</string>
|
||||
<key>sizes</key>
|
||||
<array>
|
||||
<string>{{0, 0}, {625, 125}}</string>
|
||||
<string>{{625, 0}, {631, 125}}</string>
|
||||
<string>{{0, 0}, {628, 157}}</string>
|
||||
<string>{{628, 0}, {628, 157}}</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>VerticalSplitView</key>
|
||||
@ -777,8 +799,8 @@
|
||||
<string>yes</string>
|
||||
<key>sizes</key>
|
||||
<array>
|
||||
<string>{{0, 0}, {1256, 125}}</string>
|
||||
<string>{{0, 125}, {1256, 271}}</string>
|
||||
<string>{{0, 0}, {1256, 157}}</string>
|
||||
<string>{{0, 157}, {1256, 444}}</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
@ -798,7 +820,7 @@
|
||||
<key>DebugSTDIOWindowFrame</key>
|
||||
<string>{{200, 200}, {500, 300}}</string>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 265}, {1256, 396}}</string>
|
||||
<string>{{0, 60}, {1256, 601}}</string>
|
||||
<key>PBXDebugSessionStackFrameViewKey</key>
|
||||
<dict>
|
||||
<key>DebugVariablesTableConfiguration</key>
|
||||
@ -808,16 +830,16 @@
|
||||
<string>Value</string>
|
||||
<real>85</real>
|
||||
<string>Summary</string>
|
||||
<real>401</real>
|
||||
<real>398</real>
|
||||
</array>
|
||||
<key>Frame</key>
|
||||
<string>{{625, 0}, {631, 125}}</string>
|
||||
<string>{{628, 0}, {628, 157}}</string>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXDebugSessionModule</string>
|
||||
<key>Proportion</key>
|
||||
<string>396pt</string>
|
||||
<string>601pt</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Name</key>
|
||||
|
@ -36,11 +36,13 @@
|
||||
#endif
|
||||
|
||||
// Quick and dirty convex hull.
|
||||
|
||||
// Returns true if 'c' is left of line 'a'-'b'.
|
||||
inline bool left(const float* a, const float* b, const float* c)
|
||||
{
|
||||
return (b[0] - a[0]) * (c[2] - a[2]) - (c[0] - a[0]) * (b[2] - a[2]) < 0;
|
||||
}
|
||||
|
||||
// Returns true if 'a' is more lower-left than 'b'.
|
||||
inline bool cmppt(const float* a, const float* b)
|
||||
{
|
||||
if (a[0] < b[0]) return true;
|
||||
@ -49,15 +51,17 @@ inline bool cmppt(const float* a, const float* b)
|
||||
if (a[2] > b[2]) return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Calculates convex hull on xz-plane of points on 'pts',
|
||||
// stores the indices of the resulting hull in 'out' and
|
||||
// returns number of points on hull.
|
||||
static int convexhull(const float* pts, int npts, int* out)
|
||||
{
|
||||
// Find leftmost point.
|
||||
// Find lower-leftmost point.
|
||||
int hull = 0;
|
||||
for (int i = 1; i < npts; ++i)
|
||||
if (cmppt(&pts[i*3], &pts[hull*3]))
|
||||
hull = i;
|
||||
// Gif wrap hull.
|
||||
// Gift wrap hull.
|
||||
int endpt = 0;
|
||||
int i = 0;
|
||||
do
|
||||
@ -224,7 +228,6 @@ void ConvexVolumeTool::handleClick(const float* p, bool shift)
|
||||
void ConvexVolumeTool::handleRender()
|
||||
{
|
||||
DebugDrawGL dd;
|
||||
const float s = m_sample->getAgentRadius();
|
||||
|
||||
// Find height extents of the shape.
|
||||
float minh = FLT_MAX, maxh = 0;
|
||||
|
@ -85,6 +85,17 @@ void NavMeshTesterTool::init(Sample* sample)
|
||||
m_navMesh = sample->getNavMesh();
|
||||
recalc();
|
||||
|
||||
if (m_navMesh)
|
||||
{
|
||||
// Change costs.
|
||||
m_navMesh->setAreaCost(SAMPLE_POLYAREA_GROUND, 1.0f);
|
||||
m_navMesh->setAreaCost(SAMPLE_POLYAREA_WATER, 10.0f);
|
||||
m_navMesh->setAreaCost(SAMPLE_POLYAREA_ROAD, 1.0f);
|
||||
m_navMesh->setAreaCost(SAMPLE_POLYAREA_DOOR, 1.0f);
|
||||
m_navMesh->setAreaCost(SAMPLE_POLYAREA_GRASS, 2.0f);
|
||||
m_navMesh->setAreaCost(SAMPLE_POLYAREA_JUMP, 1.5f);
|
||||
}
|
||||
|
||||
if (m_toolMode == TOOLMODE_PATHFIND_ITER || m_toolMode == TOOLMODE_PATHFIND_STRAIGHT)
|
||||
{
|
||||
unsigned char flags = DU_DRAWNAVMESH_CLOSEDLIST;
|
||||
@ -282,6 +293,7 @@ void NavMeshTesterTool::recalc()
|
||||
m_spos[0],m_spos[1],m_spos[2], m_epos[0],m_epos[1],m_epos[2],
|
||||
m_filter.includeFlags, m_filter.excludeFlags);
|
||||
#endif
|
||||
|
||||
m_npolys = m_navMesh->findPath(m_startRef, m_endRef, m_spos, m_epos, &m_filter, m_polys, MAX_POLYS);
|
||||
|
||||
m_nsmoothPath = 0;
|
||||
|
@ -321,6 +321,7 @@ void Sample_SoloMeshSimple::handleMeshChanged(class InputGeom* geom)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Sample_SoloMeshSimple::handleBuild()
|
||||
{
|
||||
if (!m_geom || !m_geom->getMesh())
|
||||
|
Loading…
x
Reference in New Issue
Block a user