Update path iterator code to cope with off-mesh links. findStraightPath() returns now more info so that off-mesh links can de detected.

This commit is contained in:
Mikko Mononen 2010-01-13 21:25:07 +00:00
parent 4ad8dafa40
commit a81223f3bb
9 changed files with 2335 additions and 9470 deletions

View File

@ -109,6 +109,13 @@ struct dtMeshTile
dtMeshTile* next; // Next free tile or, next tile in spatial grid.
};
// Flags returned by findStraightPath().
enum dtStraightPathFlags
{
DT_STRAIGHTPATH_START = 0x01, // The vertex is the start position.
DT_STRAIGHTPATH_END = 0x02, // The vertex is the end position.
DT_STRAIGHTPATH_OFFMESH_LINK = 0x04, // The vertex is start of an off-mesh link.
};
class dtNavMesh
{
@ -218,17 +225,23 @@ public:
// Finds a straight path from start to end locations within the corridor
// described by the path polygons.
// Start and end locations will be clamped on the corridor.
// The returned polygon references are point to polygon which was entered when
// a path point was added. For the end point, zero will be returned. This allows
// to match for example off-mesh link points to their representative polygons.
// Params:
// startPos - (in) Path start location.
// endPos - (in) Path end location.
// path - (in) Array of connected polygons describing the corridor.
// pathSize - (in) Number of polygons in path array.
// straightPath - (out) Points describing the straight path.
// straightPathFlags - (out, opt) Flags describing each point type, see dtStraightPathFlags.
// straightPathRefs - (out, opt) References to polygons at point locations.
// maxStraightPathSize - (in) The max number of points the straight path array can hold.
// Returns: Number of points in the path.
int findStraightPath(const float* startPos, const float* endPos,
const dtPolyRef* path, const int pathSize,
float* straightPath, const int maxStraightPathSize);
float* straightPath, unsigned char* straightPathFlags, dtPolyRef* straightPathRefs,
const int maxStraightPathSize);
// Moves towards end position a long the path corridor.
// Returns: Index to the result path polygon.
@ -291,6 +304,15 @@ public:
// Returns: true if closest point found.
bool closestPointOnPolyBoundary(dtPolyRef ref, const float* pos, float* closest) const;
// Returns start and end location of an off-mesh link polygon.
// Params:
// prevRef - (in) ref to the polygon before the link (used to select direction).
// polyRef - (in) ref to the off-mesh link polygon.
// startPos - (out) start point of the link.
// endPos - (out) end point of the link.
// Returns: true if link is found.
bool getOffMeshLinkPolyEndPoints(dtPolyRef prevRef, dtPolyRef polyRef, float* startPos, float* endPos) const;
// Returns height of the polygon at specified location.
// Params:
// ref - (in) ref to the polygon.
@ -349,7 +371,8 @@ private:
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) const;
bool getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float* right,
unsigned char& fromFlags, unsigned char& toFlags) const;
// Returns edge mid point between two polygons.
bool getEdgeMidPoint(dtPolyRef from, dtPolyRef to, float* mid) const;

View File

@ -748,6 +748,54 @@ bool dtNavMesh::closestPointOnPolyBoundary(dtPolyRef ref, const float* pos, floa
return true;
}
// Returns start and end location of an off-mesh link polygon.
bool dtNavMesh::getOffMeshLinkPolyEndPoints(dtPolyRef prevRef, dtPolyRef polyRef, float* startPos, float* endPos) const
{
unsigned int salt, it, ip;
// Get previous poly
dtDecodePolyId(prevRef, salt, it, ip);
if (it >= (unsigned int)m_maxTiles) return false;
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return false;
const dtMeshHeader* prevHeader = m_tiles[it].header;
if (ip >= (unsigned int)prevHeader->npolys) return false;
const dtPoly* prevPoly = &prevHeader->polys[ip];
// Get current polygon
dtDecodePolyId(polyRef, salt, it, ip);
if (it >= (unsigned int)m_maxTiles) return false;
if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return false;
const dtMeshHeader* header = m_tiles[it].header;
if (ip >= (unsigned int)header->npolys) return false;
const dtPoly* poly = &header->polys[ip];
// Make sure that the current poly is indeed off-mesh link.
if ((poly->flags & DT_POLY_OFFMESH_LINK) == 0)
return false;
// Figure out which way to hand out the vertices.
int idx0 = 0, idx1 = 1;
for (int i = 0; i < prevPoly->nlinks; ++i)
{
const dtLink* link = &prevHeader->links[prevPoly->links+i];
if (link->ref != polyRef)
continue;
// If first link does not point to the prev, then we need to reverse the order.
if (header->links[poly->links+0].ref != prevRef)
{
idx0 = 1;
idx1 = 0;
break;
}
}
vcopy(startPos, &header->verts[poly->v[idx0]*3]);
vcopy(endPos, &header->verts[poly->v[idx1]*3]);
return true;
}
bool dtNavMesh::getPolyHeight(dtPolyRef ref, const float* pos, float* height) const
{
@ -760,6 +808,19 @@ bool dtNavMesh::getPolyHeight(dtPolyRef ref, const float* pos, float* height) co
if (ip >= (unsigned int)header->npolys) return false;
const dtPoly* poly = &header->polys[ip];
if (poly->flags & DT_POLY_OFFMESH_LINK)
{
const float* v0 = &header->verts[poly->v[0]*3];
const float* v1 = &header->verts[poly->v[1]*3];
const float d0 = vdist(pos, v0);
const float d1 = vdist(pos, v1);
const float u = d0 / (d0+d1);
if (height)
*height = v0[1] + (v1[1] - v0[1]) * u;
return true;
}
else
{
const dtPolyDetail* pd = &header->dmeshes[ip];
for (int j = 0; j < pd->ntris; ++j)
{
@ -780,6 +841,7 @@ bool dtNavMesh::getPolyHeight(dtPolyRef ref, const float* pos, float* height) co
return true;
}
}
}
return false;
}
@ -1070,7 +1132,8 @@ int dtNavMesh::findPath(dtPolyRef startRef, dtPolyRef endRef,
int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
const dtPolyRef* path, const int pathSize,
float* straightPath, const int maxStraightPathSize)
float* straightPath, unsigned char* straightPathFlags, dtPolyRef* straightPathRefs,
const int maxStraightPathSize)
{
if (!maxStraightPathSize)
return 0;
@ -1087,6 +1150,10 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
// Add start point.
vcopy(&straightPath[straightPathSize*3], closestStartPos);
if (straightPathFlags)
straightPathFlags[straightPathSize] = DT_STRAIGHTPATH_START;
if (straightPathRefs)
straightPathRefs[straightPathSize] = path[0];
straightPathSize++;
if (straightPathSize >= maxStraightPathSize)
return straightPathSize;
@ -1095,10 +1162,9 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
if (!closestPointOnPolyBoundary(path[pathSize-1], endPos, closestEndPos))
return 0;
float portalApex[3], portalLeft[3], portalRight[3];
if (pathSize > 1)
{
float portalApex[3], portalLeft[3], portalRight[3];
vcopy(portalApex, closestStartPos);
vcopy(portalLeft, portalApex);
vcopy(portalRight, portalApex);
@ -1106,18 +1172,32 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
int leftIndex = 0;
int rightIndex = 0;
unsigned char leftPolyFlags = 0;
unsigned char rightPolyFlags = 0;
dtPolyRef leftPolyRef = path[0];
dtPolyRef rightPolyRef = path[0];
for (int i = 0; i < pathSize; ++i)
{
float left[3], right[3];
if (i < pathSize-1)
unsigned char fromFlags, toFlags;
if (i+1 < pathSize)
{
// Next portal.
if (!getPortalPoints(path[i], path[i+1], left, right))
if (!getPortalPoints(path[i], path[i+1], left, right, fromFlags, toFlags))
{
if (!closestPointOnPolyBoundary(path[i], endPos, closestEndPos))
return 0;
vcopy(&straightPath[straightPathSize*3], closestEndPos);
if (straightPathFlags)
straightPathFlags[straightPathSize] = 0;
if (straightPathRefs)
straightPathRefs[straightPathSize] = path[i];
straightPathSize++;
return straightPathSize;
}
}
@ -1126,12 +1206,16 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
// End of the path.
vcopy(left, closestEndPos);
vcopy(right, closestEndPos);
fromFlags = toFlags = 0;
}
// Right vertex.
if (vequal(portalApex, portalRight))
{
vcopy(portalRight, right);
rightPolyRef = (i+1 < pathSize) ? path[i+1] : 0;
rightPolyFlags = toFlags;
rightIndex = i;
}
else
@ -1141,6 +1225,8 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
if (triArea2D(portalApex, portalLeft, right) > 0.0f)
{
vcopy(portalRight, right);
rightPolyRef = (i+1 < pathSize) ? path[i+1] : 0;
rightPolyFlags = toFlags;
rightIndex = i;
}
else
@ -1148,13 +1234,29 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
vcopy(portalApex, portalLeft);
apexIndex = leftIndex;
unsigned char flags = (leftPolyFlags & DT_POLY_OFFMESH_LINK) ? DT_STRAIGHTPATH_OFFMESH_LINK : 0;
dtPolyRef ref = leftPolyRef;
if (!vequal(&straightPath[(straightPathSize-1)*3], portalApex))
{
vcopy(&straightPath[straightPathSize*3], portalApex);
if (straightPathFlags)
straightPathFlags[straightPathSize] = flags;
if (straightPathRefs)
straightPathRefs[straightPathSize] = ref;
straightPathSize++;
if (straightPathSize >= maxStraightPathSize)
return straightPathSize;
}
else
{
// The vertices are equal, update flags and poly.
if (straightPathFlags)
straightPathFlags[straightPathSize-1] = flags;
if (straightPathRefs)
straightPathRefs[straightPathSize-1] = ref;
}
vcopy(portalLeft, portalApex);
vcopy(portalRight, portalApex);
@ -1173,6 +1275,8 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
if (vequal(portalApex, portalLeft))
{
vcopy(portalLeft, left);
leftPolyRef = (i+1 < pathSize) ? path[i+1] : 0;
leftPolyFlags = toFlags;
leftIndex = i;
}
else
@ -1182,6 +1286,8 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
if (triArea2D(portalApex, portalRight, left) < 0.0f)
{
vcopy(portalLeft, left);
leftPolyRef = (i+1 < pathSize) ? path[i+1] : 0;
leftPolyFlags = toFlags;
leftIndex = i;
}
else
@ -1189,13 +1295,29 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
vcopy(portalApex, portalRight);
apexIndex = rightIndex;
unsigned char flags = (rightPolyFlags & DT_POLY_OFFMESH_LINK) ? DT_STRAIGHTPATH_OFFMESH_LINK : 0;
dtPolyRef ref = rightPolyRef;
if (!vequal(&straightPath[(straightPathSize-1)*3], portalApex))
{
vcopy(&straightPath[straightPathSize*3], portalApex);
if (straightPathFlags)
straightPathFlags[straightPathSize] = flags;
if (straightPathRefs)
straightPathRefs[straightPathSize] = ref;
straightPathSize++;
if (straightPathSize >= maxStraightPathSize)
return straightPathSize;
}
else
{
// The vertices are equal, update flags and poly.
if (straightPathFlags)
straightPathFlags[straightPathSize-1] = flags;
if (straightPathRefs)
straightPathRefs[straightPathSize-1] = ref;
}
vcopy(portalLeft, portalApex);
vcopy(portalRight, portalApex);
@ -1214,6 +1336,11 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
// Add end point.
vcopy(&straightPath[straightPathSize*3], closestEndPos);
if (straightPathFlags)
straightPathFlags[straightPathSize] = DT_STRAIGHTPATH_END;
if (straightPathRefs)
straightPathRefs[straightPathSize] = 0;
straightPathSize++;
return straightPathSize;
@ -1247,6 +1374,20 @@ int dtNavMesh::moveAlongPathCorridor(const float* startPos, const float* endPos,
const dtMeshHeader* header = m_tiles[it].header;
const dtPoly* poly = &header->polys[ip];
// In case of Off-Mesh link, just snap to the end location and advance over it.
if (poly->flags & DT_POLY_OFFMESH_LINK)
{
if (n+1 < pathSize)
{
float left[3], right[3];
unsigned char fromFlags, toFlags;
if (!getPortalPoints(path[n], path[n+1], left, right, fromFlags, toFlags))
return n;
vcopy(resultPos, endPos);
}
return n+1;
}
// Collect vertices.
int nv = 0;
for (int i = 0; i < (int)poly->nv; ++i)
@ -1283,7 +1424,8 @@ int dtNavMesh::moveAlongPathCorridor(const float* startPos, const float* endPos,
if (n+1 >= pathSize)
return n;
float left[3], right[3];
if (!getPortalPoints(path[n], path[n+1], left, right))
unsigned char fromFlags, toFlags;
if (!getPortalPoints(path[n], path[n+1], left, right, fromFlags, toFlags))
return n;
// If the clamped point is close to the next portal edge, advance to next poly.
float t;
@ -1298,7 +1440,8 @@ int dtNavMesh::moveAlongPathCorridor(const float* startPos, const float* endPos,
}
// Returns portal points between two polygons.
bool dtNavMesh::getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float* right) const
bool dtNavMesh::getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float* right,
unsigned char& fromFlags, unsigned char& toFlags) const
{
unsigned int salt, it, ip;
dtDecodePolyId(from, salt, it, ip);
@ -1307,6 +1450,7 @@ bool dtNavMesh::getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float
if (ip >= (unsigned int)m_tiles[it].header->npolys) return false;
const dtMeshHeader* fromHeader = m_tiles[it].header;
const dtPoly* fromPoly = &fromHeader->polys[ip];
fromFlags = fromPoly->flags;
for (int i = 0; i < fromPoly->nlinks; ++i)
{
@ -1314,22 +1458,21 @@ bool dtNavMesh::getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float
if (link->ref != to)
continue;
if (fromPoly->flags & DT_POLY_OFFMESH_LINK)
{
// const int v = fromPoly->v[link->e];
const int v = fromHeader->links[fromPoly->links+0].ref == to ? 0 : 1;
vcopy(left, &fromHeader->verts[fromPoly->v[v]*3]);
vcopy(right, &fromHeader->verts[fromPoly->v[v]*3]);
return true;
}
else
{
dtDecodePolyId(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;
if (ip >= (unsigned int)m_tiles[it].header->npolys) return false;
const dtMeshHeader* toHeader = m_tiles[it].header;
const dtPoly* toPoly = &toHeader->polys[ip];
toFlags = toPoly->flags;
if (fromPoly->flags & DT_POLY_OFFMESH_LINK)
{
const int v = fromHeader->links[fromPoly->links+0].ref == to ? 0 : 1;
vcopy(left, &fromHeader->verts[fromPoly->v[v]*3]);
vcopy(right, &fromHeader->verts[fromPoly->v[v]*3]);
return true;
}
if (toPoly->flags & DT_POLY_OFFMESH_LINK)
{
@ -1338,7 +1481,6 @@ bool dtNavMesh::getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float
vcopy(right, &toHeader->verts[toPoly->v[v]*3]);
return true;
}
}
// Find portal vertices.
const int v0 = fromPoly->v[link->e];
@ -1382,7 +1524,8 @@ bool dtNavMesh::getPortalPoints(dtPolyRef from, dtPolyRef to, float* left, float
bool dtNavMesh::getEdgeMidPoint(dtPolyRef from, dtPolyRef to, float* mid) const
{
float left[3], right[3];
if (!getPortalPoints(from, to, left,right)) return false;
unsigned char fromFlags, toFlags;
if (!getPortalPoints(from, to, left,right, fromFlags, toFlags)) 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;

File diff suppressed because it is too large Load Diff

View File

@ -281,14 +281,14 @@
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
<integer>14</integer>
<integer>13</integer>
<integer>12</integer>
<integer>1</integer>
<integer>0</integer>
</array>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
<string>{{0, 23}, {282, 643}}</string>
<string>{{0, 98}, {282, 643}}</string>
</dict>
<key>PBXTopSmartGroupGIDs</key>
<array/>
@ -335,7 +335,7 @@
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>6BB7011810FA4288006DA0A6</string>
<string>6BE7321910FE712A00C1B074</string>
<key>history</key>
<array>
<string>6B57D358108C66B200DDD053</string>
@ -346,16 +346,13 @@
<string>6B8DEAA110BC7BCD00DF20FB</string>
<string>6BA1E63A10C1DB5B008007F6</string>
<string>6BA1E7F210C7B3FF008007F6</string>
<string>6BA1E8DB10C7CB62008007F6</string>
<string>6BA1E8E410C7D2FA008007F6</string>
<string>6BB4965F10C8F2AE00BC0805</string>
<string>6BB93D1510CFFC6D00F74F2B</string>
<string>6BB93D1B10CFFD7600F74F2B</string>
<string>6B9869F710DFFA98007D8D84</string>
<string>6BBB883C10EA9B6F008FEA1F</string>
<string>6BBB884E10EA9ECC008FEA1F</string>
<string>6BBB889B10EAA094008FEA1F</string>
<string>6BBB899F10EABD34008FEA1F</string>
<string>6BB7FDC010F37703006DA0A6</string>
<string>6BB7FDC110F37703006DA0A6</string>
<string>6BB7FE1010F37CF7006DA0A6</string>
@ -363,30 +360,32 @@
<string>6BB7FEA910F4B5E1006DA0A6</string>
<string>6BB7FEAD10F4B5E1006DA0A6</string>
<string>6BB7FEDE10F4B779006DA0A6</string>
<string>6BB7FF0210F4D699006DA0A6</string>
<string>6BB7FF0310F4D699006DA0A6</string>
<string>6BB7FF6C10F4E8E2006DA0A6</string>
<string>6BB7FF6D10F4E8E2006DA0A6</string>
<string>6BB7FF6E10F4E8E2006DA0A6</string>
<string>6BB7FF7310F4E8E2006DA0A6</string>
<string>6BB7FFBE10F4E9A8006DA0A6</string>
<string>6BB7FFD610F4EC73006DA0A6</string>
<string>6BB7000610F4F03D006DA0A6</string>
<string>6BB7001110F4F17C006DA0A6</string>
<string>6BB7001210F4F17C006DA0A6</string>
<string>6BB7001410F4F17C006DA0A6</string>
<string>6BB7002C10F4F257006DA0A6</string>
<string>6BB7003710F4F39B006DA0A6</string>
<string>6BB7003810F4F39B006DA0A6</string>
<string>6BB7003A10F4F39B006DA0A6</string>
<string>6BB7004C10F4F532006DA0A6</string>
<string>6BB7004F10F4F532006DA0A6</string>
<string>6BB7007210FA2B13006DA0A6</string>
<string>6BB700BF10FA3AB1006DA0A6</string>
<string>6BB700C010FA3AB1006DA0A6</string>
<string>6BB700F510FA3E31006DA0A6</string>
<string>6BB7010F10FA4171006DA0A6</string>
<string>6BB7011710FA4288006DA0A6</string>
<string>6BB35FED10FBD09300A9B4B8</string>
<string>6BB3601610FE561F00A9B4B8</string>
<string>6BB3601710FE561F00A9B4B8</string>
<string>6BB3602B10FE569B00A9B4B8</string>
<string>6BB3603D10FE59E200A9B4B8</string>
<string>6BB3605210FE5CBD00A9B4B8</string>
<string>6BB3605310FE5CBD00A9B4B8</string>
<string>6BB3605410FE5CBD00A9B4B8</string>
<string>6BB3606210FE5E8F00A9B4B8</string>
<string>6BE7320210FE6CEF00C1B074</string>
<string>6BE7320C10FE6EBE00C1B074</string>
<string>6BE7321210FE70FE00C1B074</string>
<string>6BE7321710FE712A00C1B074</string>
<string>6BE7320310FE6CEF00C1B074</string>
</array>
<key>prevStack</key>
<array>
@ -395,243 +394,39 @@
<string>6BBB87E910EA97CC008FEA1F</string>
<string>6BBB883F10EA9B6F008FEA1F</string>
<string>6BBB885510EA9ECC008FEA1F</string>
<string>6BBB886210EA9ECC008FEA1F</string>
<string>6BBB889D10EAA094008FEA1F</string>
<string>6BB7FD6310F3564B006DA0A6</string>
<string>6BB7FD6510F3564B006DA0A6</string>
<string>6BB7FD6910F3564B006DA0A6</string>
<string>6BB7FD8310F36BD5006DA0A6</string>
<string>6BB7FD8410F36BD5006DA0A6</string>
<string>6BB7FD9F10F36D7A006DA0A6</string>
<string>6BB7FDC710F37703006DA0A6</string>
<string>6BB7FDC810F37703006DA0A6</string>
<string>6BB7FDCB10F37703006DA0A6</string>
<string>6BB7FDCC10F37703006DA0A6</string>
<string>6BB7FDCD10F37703006DA0A6</string>
<string>6BB7FDD010F37703006DA0A6</string>
<string>6BB7FDD810F37703006DA0A6</string>
<string>6BB7FDD910F37703006DA0A6</string>
<string>6BB7FDDA10F37703006DA0A6</string>
<string>6BB7FDDB10F37703006DA0A6</string>
<string>6BB7FDDC10F37703006DA0A6</string>
<string>6BB7FDDD10F37703006DA0A6</string>
<string>6BB7FDDE10F37703006DA0A6</string>
<string>6BB7FDDF10F37703006DA0A6</string>
<string>6BB7FDE010F37703006DA0A6</string>
<string>6BB7FDE110F37703006DA0A6</string>
<string>6BB7FDE210F37703006DA0A6</string>
<string>6BB7FDE310F37703006DA0A6</string>
<string>6BB7FDF210F377DD006DA0A6</string>
<string>6BB7FDF310F377DD006DA0A6</string>
<string>6BB7FDF410F377DD006DA0A6</string>
<string>6BB7FDF510F377DD006DA0A6</string>
<string>6BB7FDF610F377DD006DA0A6</string>
<string>6BB7FDF810F377DD006DA0A6</string>
<string>6BB7FDFA10F377DD006DA0A6</string>
<string>6BB7FE1710F37CF7006DA0A6</string>
<string>6BB7FE1810F37CF7006DA0A6</string>
<string>6BB7FE1910F37CF7006DA0A6</string>
<string>6BB7FE1A10F37CF7006DA0A6</string>
<string>6BB7FE1B10F37CF7006DA0A6</string>
<string>6BB7FE1C10F37CF7006DA0A6</string>
<string>6BB7FE1D10F37CF7006DA0A6</string>
<string>6BB7FE1E10F37CF7006DA0A6</string>
<string>6BB7FE1F10F37CF7006DA0A6</string>
<string>6BB7FE2110F37CF7006DA0A6</string>
<string>6BB7FE2210F37CF7006DA0A6</string>
<string>6BB7FE2310F37CF7006DA0A6</string>
<string>6BB7FE4310F3817A006DA0A6</string>
<string>6BB7FE4410F3817A006DA0A6</string>
<string>6BB7FE4510F3817A006DA0A6</string>
<string>6BB7FE4610F3817A006DA0A6</string>
<string>6BB7FE4710F3817A006DA0A6</string>
<string>6BB7FE4810F3817A006DA0A6</string>
<string>6BB7FE4910F3817A006DA0A6</string>
<string>6BB7FE4A10F3817A006DA0A6</string>
<string>6BB7FE4B10F3817A006DA0A6</string>
<string>6BB7FE4C10F3817A006DA0A6</string>
<string>6BB7FE4D10F3817A006DA0A6</string>
<string>6BB7FE4E10F3817A006DA0A6</string>
<string>6BB7FE4F10F3817A006DA0A6</string>
<string>6BB7FE5010F3817A006DA0A6</string>
<string>6BB7FE5110F3817A006DA0A6</string>
<string>6BB7FE5210F3817A006DA0A6</string>
<string>6BB7FE5310F3817A006DA0A6</string>
<string>6BB7FE5410F3817A006DA0A6</string>
<string>6BB7FE5510F3817A006DA0A6</string>
<string>6BB7FE5610F3817A006DA0A6</string>
<string>6BB7FE5810F3817A006DA0A6</string>
<string>6BB7FE6310F381DC006DA0A6</string>
<string>6BB7FE6410F381DC006DA0A6</string>
<string>6BB7FE7810F38224006DA0A6</string>
<string>6BB7FE7910F38224006DA0A6</string>
<string>6BB7FE8510F3830D006DA0A6</string>
<string>6BB7FE9A10F4A1DB006DA0A6</string>
<string>6BB7FE9B10F4A1DB006DA0A6</string>
<string>6BB7FE9C10F4A1DB006DA0A6</string>
<string>6BB7FE9D10F4A1DB006DA0A6</string>
<string>6BB7FE9E10F4A1DB006DA0A6</string>
<string>6BB7FE9F10F4A1DB006DA0A6</string>
<string>6BB7FEA010F4A1DB006DA0A6</string>
<string>6BB7FEA110F4A1DB006DA0A6</string>
<string>6BB7FEB610F4B5E1006DA0A6</string>
<string>6BB7FEB710F4B5E1006DA0A6</string>
<string>6BB7FEB810F4B5E1006DA0A6</string>
<string>6BB7FEB910F4B5E1006DA0A6</string>
<string>6BB7FEBA10F4B5E1006DA0A6</string>
<string>6BB7FEBB10F4B5E1006DA0A6</string>
<string>6BB7FEBC10F4B5E1006DA0A6</string>
<string>6BB7FEBE10F4B5E1006DA0A6</string>
<string>6BB7FEC010F4B5E1006DA0A6</string>
<string>6BB7FEC110F4B5E1006DA0A6</string>
<string>6BB7FEC210F4B5E1006DA0A6</string>
<string>6BB7FEC310F4B5E1006DA0A6</string>
<string>6BB7FEC410F4B5E1006DA0A6</string>
<string>6BB7FEC510F4B5E1006DA0A6</string>
<string>6BB7FEC610F4B5E1006DA0A6</string>
<string>6BB7FEC810F4B5E1006DA0A6</string>
<string>6BB7FEC910F4B5E1006DA0A6</string>
<string>6BB7FECA10F4B5E1006DA0A6</string>
<string>6BB7FECB10F4B5E1006DA0A6</string>
<string>6BB7FECC10F4B5E1006DA0A6</string>
<string>6BB7FECF10F4B5E1006DA0A6</string>
<string>6BB7FED010F4B5E1006DA0A6</string>
<string>6BB7FED110F4B5E1006DA0A6</string>
<string>6BB7FED210F4B5E1006DA0A6</string>
<string>6BB7FED510F4B5E1006DA0A6</string>
<string>6BB7FEE110F4B779006DA0A6</string>
<string>6BB7FEE210F4B779006DA0A6</string>
<string>6BB7FEE310F4B779006DA0A6</string>
<string>6BB7FEE410F4B779006DA0A6</string>
<string>6BB7FEE510F4B779006DA0A6</string>
<string>6BB7FEEE10F4B7E6006DA0A6</string>
<string>6BB7FEF010F4B7E6006DA0A6</string>
<string>6BB7FF0E10F4D699006DA0A6</string>
<string>6BB7FF1110F4D699006DA0A6</string>
<string>6BB7FF1210F4D699006DA0A6</string>
<string>6BB7FF1310F4D699006DA0A6</string>
<string>6BB7FF1410F4D699006DA0A6</string>
<string>6BB7FF1510F4D699006DA0A6</string>
<string>6BB7FF1F10F4D699006DA0A6</string>
<string>6BB7FF2010F4D699006DA0A6</string>
<string>6BB7FF2110F4D699006DA0A6</string>
<string>6BB7FF2210F4D699006DA0A6</string>
<string>6BB7FF2310F4D699006DA0A6</string>
<string>6BB7FF2410F4D699006DA0A6</string>
<string>6BB7FF2510F4D699006DA0A6</string>
<string>6BB7FF2610F4D699006DA0A6</string>
<string>6BB7FF2710F4D699006DA0A6</string>
<string>6BB7FF2810F4D699006DA0A6</string>
<string>6BB7FF2910F4D699006DA0A6</string>
<string>6BB7FF2A10F4D699006DA0A6</string>
<string>6BB7FF2B10F4D699006DA0A6</string>
<string>6BB7FF3010F4D699006DA0A6</string>
<string>6BB7FF3410F4D699006DA0A6</string>
<string>6BB7FF3610F4D699006DA0A6</string>
<string>6BB7FF7910F4E8E2006DA0A6</string>
<string>6BB7FF7A10F4E8E2006DA0A6</string>
<string>6BB7FF7B10F4E8E2006DA0A6</string>
<string>6BB7FF7C10F4E8E2006DA0A6</string>
<string>6BB7FF7D10F4E8E2006DA0A6</string>
<string>6BB7FF7E10F4E8E2006DA0A6</string>
<string>6BB7FF7F10F4E8E2006DA0A6</string>
<string>6BB7FF8010F4E8E2006DA0A6</string>
<string>6BB7FF8110F4E8E2006DA0A6</string>
<string>6BB7FF8210F4E8E2006DA0A6</string>
<string>6BB7FF8310F4E8E2006DA0A6</string>
<string>6BB7FF8410F4E8E2006DA0A6</string>
<string>6BB7FF8510F4E8E2006DA0A6</string>
<string>6BB7FF8610F4E8E2006DA0A6</string>
<string>6BB7FF8710F4E8E2006DA0A6</string>
<string>6BB7FF8810F4E8E2006DA0A6</string>
<string>6BB7FF8910F4E8E2006DA0A6</string>
<string>6BB7FF8A10F4E8E2006DA0A6</string>
<string>6BB7FF8B10F4E8E2006DA0A6</string>
<string>6BB7FF8C10F4E8E2006DA0A6</string>
<string>6BB7FF8D10F4E8E2006DA0A6</string>
<string>6BB7FF8E10F4E8E2006DA0A6</string>
<string>6BB7FF8F10F4E8E2006DA0A6</string>
<string>6BB7FF9010F4E8E2006DA0A6</string>
<string>6BB7FF9110F4E8E2006DA0A6</string>
<string>6BB7FF9210F4E8E2006DA0A6</string>
<string>6BB7FF9310F4E8E2006DA0A6</string>
<string>6BB7FF9410F4E8E2006DA0A6</string>
<string>6BB7FF9510F4E8E2006DA0A6</string>
<string>6BB7FF9610F4E8E2006DA0A6</string>
<string>6BB7FF9710F4E8E2006DA0A6</string>
<string>6BB7FF9810F4E8E2006DA0A6</string>
<string>6BB7FF9910F4E8E2006DA0A6</string>
<string>6BB7FF9A10F4E8E2006DA0A6</string>
<string>6BB7FF9B10F4E8E2006DA0A6</string>
<string>6BB7FF9C10F4E8E2006DA0A6</string>
<string>6BB7FF9D10F4E8E2006DA0A6</string>
<string>6BB7FF9E10F4E8E2006DA0A6</string>
<string>6BB7FF9F10F4E8E2006DA0A6</string>
<string>6BB7FFA010F4E8E2006DA0A6</string>
<string>6BB7FFA110F4E8E2006DA0A6</string>
<string>6BB7FFA210F4E8E2006DA0A6</string>
<string>6BB7FFA310F4E8E2006DA0A6</string>
<string>6BB7FFA410F4E8E2006DA0A6</string>
<string>6BB7FFA510F4E8E2006DA0A6</string>
<string>6BB7FFA610F4E8E2006DA0A6</string>
<string>6BB7FFA710F4E8E2006DA0A6</string>
<string>6BB7FFA810F4E8E2006DA0A6</string>
<string>6BB7FFA910F4E8E2006DA0A6</string>
<string>6BB7FFAA10F4E8E2006DA0A6</string>
<string>6BB7FFAB10F4E8E2006DA0A6</string>
<string>6BB7FFAC10F4E8E2006DA0A6</string>
<string>6BB7FFAD10F4E8E2006DA0A6</string>
<string>6BB7FFB310F4E951006DA0A6</string>
<string>6BB7FFC010F4E9A8006DA0A6</string>
<string>6BB7FFC110F4E9A8006DA0A6</string>
<string>6BB7FFCC10F4EC02006DA0A6</string>
<string>6BB7FFCD10F4EC02006DA0A6</string>
<string>6BB7FFCE10F4EC02006DA0A6</string>
<string>6BB7FFCF10F4EC02006DA0A6</string>
<string>6BB7FFD010F4EC02006DA0A6</string>
<string>6BB7FFD110F4EC02006DA0A6</string>
<string>6BB7FFD910F4EC73006DA0A6</string>
<string>6BB7FFDA10F4EC73006DA0A6</string>
<string>6BB7FFDB10F4EC73006DA0A6</string>
<string>6BB7FFE110F4EC8C006DA0A6</string>
<string>6BB7FFEB10F4EF20006DA0A6</string>
<string>6BB7FFFE10F4EFB6006DA0A6</string>
<string>6BB7000010F4EFB6006DA0A6</string>
<string>6BB7000810F4F03D006DA0A6</string>
<string>6BB7000910F4F03D006DA0A6</string>
<string>6BB7000F10F4F045006DA0A6</string>
<string>6BB7001710F4F17C006DA0A6</string>
<string>6BB7001910F4F17C006DA0A6</string>
<string>6BB7001B10F4F17C006DA0A6</string>
<string>6BB7001D10F4F17C006DA0A6</string>
<string>6BB7001F10F4F17C006DA0A6</string>
<string>6BB7002110F4F17C006DA0A6</string>
<string>6BB7002310F4F17C006DA0A6</string>
<string>6BB7002410F4F17C006DA0A6</string>
<string>6BB7002510F4F17C006DA0A6</string>
<string>6BB7002710F4F17C006DA0A6</string>
<string>6BB7002F10F4F257006DA0A6</string>
<string>6BB7003010F4F257006DA0A6</string>
<string>6BB7003E10F4F39B006DA0A6</string>
<string>6BB7003F10F4F39B006DA0A6</string>
<string>6BB7004010F4F39B006DA0A6</string>
<string>6BB7004110F4F39B006DA0A6</string>
<string>6BB7004210F4F39B006DA0A6</string>
<string>6BB7005110F4F532006DA0A6</string>
<string>6BB7005710F4F532006DA0A6</string>
<string>6BB7005E10FA2777006DA0A6</string>
<string>6BB7007510FA2B13006DA0A6</string>
<string>6BB7008C10FA3475006DA0A6</string>
<string>6BB7008E10FA3475006DA0A6</string>
<string>6BB7009D10FA3649006DA0A6</string>
<string>6BB700AB10FA37BD006DA0A6</string>
<string>6BB700C310FA3AB1006DA0A6</string>
<string>6BB700C510FA3AB1006DA0A6</string>
<string>6BB700D110FA3C46006DA0A6</string>
<string>6BB700DF10FA3D11006DA0A6</string>
<string>6BB7007C10FA2E34006DA0A6</string>
<string>6BB7010B10FA40ED006DA0A6</string>
<string>6BB7011110FA4171006DA0A6</string>
<string>6BE7320010FE6BDC00C1B074</string>
<string>6BE7320610FE6CEF00C1B074</string>
<string>6BE7320E10FE6EBE00C1B074</string>
<string>6BE7320F10FE6EBE00C1B074</string>
<string>6BE7321410FE70FE00C1B074</string>
<string>6BE7321810FE712A00C1B074</string>
</array>
</dict>
<key>SplitCount</key>
@ -645,18 +440,18 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{0, 0}, {952, 566}}</string>
<string>{{0, 0}, {952, 572}}</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>566pt</string>
<string>572pt</string>
</dict>
<dict>
<key>Proportion</key>
<string>90pt</string>
<string>84pt</string>
<key>Tabs</key>
<array>
<dict>
@ -670,7 +465,9 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{10, 27}, {976, 119}}</string>
<string>{{10, 27}, {952, 57}}</string>
<key>RubberWindowFrame</key>
<string>11 76 1256 702 0 0 1280 778 </string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
@ -687,8 +484,6 @@
<dict>
<key>Frame</key>
<string>{{10, 27}, {952, 63}}</string>
<key>RubberWindowFrame</key>
<string>11 76 1256 702 0 0 1280 778 </string>
</dict>
<key>Module</key>
<string>PBXProjectFindModule</string>
@ -726,7 +521,7 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
<string>{{10, 27}, {952, 63}}</string>
<string>{{10, 27}, {952, 84}}</string>
</dict>
<key>Module</key>
<string>PBXBuildResultsModule</string>
@ -754,11 +549,11 @@
</array>
<key>TableOfContents</key>
<array>
<string>6BB7FD6B10F3564B006DA0A6</string>
<string>6BE731E710FE67F500C1B074</string>
<string>1CA23ED40692098700951B8B</string>
<string>6BB7FD6C10F3564B006DA0A6</string>
<string>6BE731E810FE67F500C1B074</string>
<string>6B8632A30F78115100E2684A</string>
<string>6BB7FD6D10F3564B006DA0A6</string>
<string>6BE731E910FE67F500C1B074</string>
<string>1CA23EDF0692099D00951B8B</string>
<string>1CA23EE00692099D00951B8B</string>
<string>1CA23EE10692099D00951B8B</string>
@ -907,14 +702,14 @@
</array>
<key>TableOfContents</key>
<array>
<string>6BB7FD6E10F3564B006DA0A6</string>
<string>6BE731EA10FE67F500C1B074</string>
<string>1CCC7628064C1048000F2A68</string>
<string>1CCC7629064C1048000F2A68</string>
<string>6BB7FD6F10F3564B006DA0A6</string>
<string>6BB7FD7010F3564B006DA0A6</string>
<string>6BB7FD7110F3564B006DA0A6</string>
<string>6BB7FD7210F3564B006DA0A6</string>
<string>6BB7FD7310F3564B006DA0A6</string>
<string>6BE731EB10FE67F500C1B074</string>
<string>6BE731EC10FE67F500C1B074</string>
<string>6BE731ED10FE67F500C1B074</string>
<string>6BE731EE10FE67F500C1B074</string>
<string>6BE731EF10FE67F500C1B074</string>
</array>
<key>ToolbarConfigUserDefaultsMinorVersion</key>
<string>2</string>
@ -946,8 +741,6 @@
<integer>5</integer>
<key>WindowOrderList</key>
<array>
<string>6BB7FDE610F37703006DA0A6</string>
<string>6BB7FDE710F37703006DA0A6</string>
<string>/Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj</string>
</array>
<key>WindowString</key>

View File

@ -49,6 +49,8 @@ class NavMeshTesterTool : public SampleTool
dtPolyRef m_parent[MAX_POLYS];
int m_npolys;
float m_straightPath[MAX_POLYS*3];
unsigned char m_straightPathFlags[MAX_POLYS];
dtPolyRef m_straightPathPolys[MAX_POLYS];
int m_nstraightPath;
float m_polyPickExt[3];
float m_smoothPath[MAX_SMOOTH*3];

View File

@ -182,7 +182,7 @@ void InputGeom::drawLinks(duDebugDraw* dd, const float s)
for (int i = 0; i < m_nlinks; ++i)
{
float* v = &m_linkVerts[i*3*2];
duDebugDrawArc(dd, v[0],v[1],v[2], v[3],v[4],v[5], 0.25f, duRGBA(255,255,255,192), 2.0f);
duDebugDrawArc(dd, v[0],v[1],v[2], v[3],v[4],v[5], 0.25f, duRGBA(255,255,255,192), 1.0f);
duDebugDrawCross(dd, v[0],v[1]+0.1f,v[2], s, duRGBA(0,0,0,255), 2.0f);
duDebugDrawCross(dd, v[3],v[4]+0.1f,v[5], s, duRGBA(0,0,0,255), 2.0f);
}

View File

@ -128,6 +128,43 @@ void NavMeshTesterTool::reset()
m_distanceToWall = 0;
}
static bool getSteerTarget(dtNavMesh* navMesh, const float* startPos, const float* endPos,
const float minTargetDist,
const dtPolyRef* path, const int pathSize,
float* steerPos, unsigned char& steerPosFlag, dtPolyRef& steerPosRef)
{
// Find steer target.
static const int MAX_STEER_POINTS = 3;
float steerPath[MAX_STEER_POINTS*3];
unsigned char steerPathFlags[MAX_STEER_POINTS];
dtPolyRef steerPathPolys[MAX_STEER_POINTS];
int nsteerPath = navMesh->findStraightPath(startPos, endPos, path, pathSize,
steerPath, steerPathFlags, steerPathPolys, MAX_STEER_POINTS);
if (!nsteerPath)
return false;
// Find vertex far enough to steer to.
int ns = 0;
while (ns < nsteerPath)
{
// Stop at Off-Mesh link or when point is further than slop away.
if ((steerPathFlags[ns] & DT_STRAIGHTPATH_OFFMESH_LINK) ||
!inRange(&steerPath[ns*3], startPos, minTargetDist, 1000.0f))
break;
ns++;
}
// Failed to find good point to steer to.
if (ns >= nsteerPath)
return false;
vcopy(steerPos, &steerPath[ns*3]);
steerPosFlag = steerPathFlags[ns];
steerPosRef = steerPathPolys[ns];
return true;
}
void NavMeshTesterTool::recalc()
{
if (!m_navMesh)
@ -154,9 +191,11 @@ void NavMeshTesterTool::recalc()
if (m_npolys)
{
m_nstraightPath = m_navMesh->findStraightPath(m_spos, m_epos, m_polys, m_npolys, m_straightPath, MAX_POLYS);
m_nstraightPath = m_navMesh->findStraightPath(m_spos, m_epos, m_polys, m_npolys,
m_straightPath, m_straightPathFlags, m_straightPathPolys, MAX_POLYS);
/* // Iterate over the path to find smooth path on the detail mesh surface.
// Iterate over the path to find smooth path on the detail mesh surface.
const dtPolyRef* polys = m_polys;
int npolys = m_npolys;
@ -172,31 +211,28 @@ void NavMeshTesterTool::recalc()
vcopy(&m_smoothPath[m_nsmoothPath*3], iterPos);
m_nsmoothPath++;
// Move towards target a small advancement at a time until target reached or
// when ran out of memory to store the path.
while (npolys && m_nsmoothPath < MAX_SMOOTH)
{
// Find steer target.
static const int MAX_STEER = 3;
float steerPath[MAX_STEER*3];
int nsteerPath = m_navMesh->findStraightPath(iterPos, m_epos, polys, npolys, steerPath, MAX_STEER);
if (!nsteerPath)
// Find location to steer towards.
float steerPos[3];
unsigned char steerPosFlag;
dtPolyRef steerPosRef;
if (!getSteerTarget(m_navMesh, iterPos, targetPos, SLOP,
polys, npolys, steerPos, steerPosFlag, steerPosRef))
break;
// Find vertex far enough to steer to.
int ns = 0;
while (ns < nsteerPath)
{
if (!inRange(&steerPath[ns*3], iterPos, SLOP, 1000.0f))
break;
ns++;
}
if (ns >= nsteerPath)
break;
bool endOfPath = inRange(&steerPath[ns*3], targetPos, SLOP*SLOP, 1.0f);
bool endOfPath = steerPosFlag & DT_STRAIGHTPATH_END;
bool offMeshLink = steerPosFlag & DT_STRAIGHTPATH_OFFMESH_LINK;
// Find movement delta.
float delta[3], len;
vsub(delta, &steerPath[ns*3], iterPos);
vsub(delta, steerPos, iterPos);
len = sqrtf(vdot(delta,delta));
if (endOfPath && len < STEP_SIZE)
// If the steer target is end of path or off-mesh link, do not move past the location.
if ((endOfPath || offMeshLink) && len < STEP_SIZE)
len = 1;
else
len = STEP_SIZE / len;
@ -209,17 +245,53 @@ void NavMeshTesterTool::recalc()
float h = 0;
m_navMesh->getPolyHeight(polys[n], result, &h);
result[1] = h;
// Shrink path corridor of possible.
// Shrink path corridor if advanced.
if (n)
{
polys += n;
npolys -= n;
}
// Update position.
vcopy(iterPos, result);
// Close enough to the target.
if (inRange(iterPos, targetPos, SLOP, 1.0f))
// Handle end of path and off-mesh links when close enough.
if (endOfPath && inRange(iterPos, steerPos, SLOP, 1.0f))
{
// Reached end of path.
vcopy(iterPos, targetPos);
npolys = 0;
if (m_nsmoothPath < MAX_SMOOTH)
{
vcopy(&m_smoothPath[m_nsmoothPath*3], iterPos);
m_nsmoothPath++;
}
break;
}
else if (offMeshLink && inRange(iterPos, steerPos, SLOP, 1.0f))
{
// Reached off-mesh link.
float startPos[3], endPos[3];
// Advance the path up to and over the off-mesh link.
dtPolyRef prevRef = 0, polyRef = polys[0];
while (npolys && polyRef != steerPosRef)
{
prevRef = polyRef;
polyRef = polys[0];
polys++;
npolys--;
}
// Handle the link.
if (m_navMesh->getOffMeshLinkPolyEndPoints(prevRef, polyRef, startPos, endPos))
{
if (m_nsmoothPath < MAX_SMOOTH)
{
vcopy(&m_smoothPath[m_nsmoothPath*3], startPos);
m_nsmoothPath++;
}
// Move position at the other side of the off-mesh link.
vcopy(iterPos, endPos);
}
}
// Store results.
@ -228,13 +300,15 @@ void NavMeshTesterTool::recalc()
vcopy(&m_smoothPath[m_nsmoothPath*3], iterPos);
m_nsmoothPath++;
}
}*/
}
}
}
else
{
m_npolys = 0;
m_nstraightPath = 0;
m_nsmoothPath = 0;
}
}
else if (m_toolMode == TOOLMODE_RAYCAST)
@ -334,20 +408,44 @@ void NavMeshTesterTool::handleRender()
for (int i = 1; i < m_npolys-1; ++i)
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_polys[i], pathCol);
}
if (m_nstraightPath)
{
const unsigned int pathCol = duRGBA(64,16,0,220);
const unsigned int offMeshCol = duRGBA(128,96,0,220);
dd.begin(DU_DRAW_LINES, 2.0f);
for (int i = 0; i < m_nstraightPath-1; ++i)
{
dd.vertex(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2], pathCol);
dd.vertex(m_straightPath[(i+1)*3], m_straightPath[(i+1)*3+1]+0.4f, m_straightPath[(i+1)*3+2], pathCol);
unsigned int col = 0;
if (m_straightPathFlags[i] & DT_STRAIGHTPATH_OFFMESH_LINK)
col = offMeshCol;
else
col = pathCol;
dd.vertex(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2], col);
dd.vertex(m_straightPath[(i+1)*3], m_straightPath[(i+1)*3+1]+0.4f, m_straightPath[(i+1)*3+2], col);
}
dd.end();
dd.begin(DU_DRAW_POINTS, 4.0f);
dd.begin(DU_DRAW_POINTS, 6.0f);
for (int i = 0; i < m_nstraightPath; ++i)
{
unsigned int col = 0;
if (m_straightPathFlags[i] & DT_STRAIGHTPATH_START)
col = startCol;
else if (m_straightPathFlags[i] & DT_STRAIGHTPATH_START)
col = endCol;
else if (m_straightPathFlags[i] & DT_STRAIGHTPATH_OFFMESH_LINK)
col = offMeshCol;
else
col = pathCol;
dd.vertex(m_straightPath[i*3], m_straightPath[i*3+1]+0.4f, m_straightPath[i*3+2], pathCol);
}
dd.end();
/* for (int i = 1; i < m_nstraightPath-1; ++i)
{
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_straightPathPolys[i], duRGBA(255,255,255,64));
}*/
}
if (m_nsmoothPath)
{

View File

@ -226,6 +226,8 @@ int main(int argc, char *argv[])
glFogf(GL_FOG_END, 10);
glFogfv(GL_FOG_COLOR, fogCol);
glDepthFunc(GL_LEQUAL);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);