issue 46:getPolysAround with convex polygon query bounds
This commit is contained in:
parent
5ebcb453fb
commit
d83961ecd4
@ -68,6 +68,13 @@ inline void dtVsub(float* dest, const float* v1, const float* v2)
|
||||
dest[2] = v1[2]-v2[2];
|
||||
}
|
||||
|
||||
inline void dtVscale(float* dest, const float* v, const float t)
|
||||
{
|
||||
dest[0] = v[0]*t;
|
||||
dest[1] = v[1]*t;
|
||||
dest[2] = v[2]*t;
|
||||
}
|
||||
|
||||
inline void dtVmin(float* mn, const float* v)
|
||||
{
|
||||
mn[0] = dtMin(mn[0], v[0]);
|
||||
|
@ -274,7 +274,7 @@ public:
|
||||
dtPolyRef findNearestPoly(const float* center, const float* extents,
|
||||
const dtQueryFilter* filter, float* nearestPt) const;
|
||||
|
||||
// Returns polygons which touch the query box.
|
||||
// Returns polygons which overlap the query box.
|
||||
// Params:
|
||||
// center[3] - (in) the center of the search box.
|
||||
// extents[3] - (in) the extents of the search box.
|
||||
@ -338,7 +338,7 @@ public:
|
||||
int moveAlongPathCorridor(const float* startPos, const float* endPos, float* resultPos,
|
||||
const dtPolyRef* path, const int pathSize) const;
|
||||
|
||||
// Castst 'walkability' ray along the navmesh surface from startPos towards the endPos.
|
||||
// Casts 'walkability' ray along the navmesh surface from startPos towards the endPos.
|
||||
// Params:
|
||||
// startRef - (in) ref to the polygon where the start lies.
|
||||
// startPos[3] - (in) start position of the query.
|
||||
@ -366,18 +366,35 @@ public:
|
||||
|
||||
// Finds polygons found along the navigation graph which touch the specified circle.
|
||||
// Params:
|
||||
// centerRef - (in) ref to the polygon where the center lies.
|
||||
// centerPos[3] - (in) center if the query circle
|
||||
// radius - (in) radius of the query circle
|
||||
// startRef - (in) ref to the polygon where the search starts.
|
||||
// centerPos[3] - (in) center if the query circle.
|
||||
// radius - (in) radius of the query circle.
|
||||
// filter - (in) path polygon filter.
|
||||
// resultRef - (out, opt) refs to the polygons touched by the circle.
|
||||
// resultParent - (out, opt) parent of each result polygon.
|
||||
// resultCost - (out, opt) search cost at each result polygon.
|
||||
// maxResult - (int) maximum capacity of search results.
|
||||
// Returns: Number of results.
|
||||
int findPolysAround(dtPolyRef centerRef, const float* centerPos, float radius, const dtQueryFilter* filter,
|
||||
dtPolyRef* resultRef, dtPolyRef* resultParent, float* resultCost,
|
||||
const int maxResult) const;
|
||||
int findPolysAroundCircle(dtPolyRef startRef, const float* centerPos, float radius,
|
||||
const dtQueryFilter* filter,
|
||||
dtPolyRef* resultRef, dtPolyRef* resultParent, float* resultCost,
|
||||
const int maxResult) const;
|
||||
|
||||
// Finds polygons found along the navigation graph which touch the convex polygon shape.
|
||||
// Params:
|
||||
// startRef - (in) ref to the polygon where the search starts.
|
||||
// verts[3*n] - (in) vertices describing convex polygon shape (CCW).
|
||||
// nverts - (in) number of vertices in the polygon.
|
||||
// filter - (in) path polygon filter.
|
||||
// resultRef - (out, opt) refs to the polygons touched by the circle.
|
||||
// resultParent - (out, opt) parent of each result polygon.
|
||||
// resultCost - (out, opt) search cost at each result polygon.
|
||||
// maxResult - (int) maximum capacity of search results.
|
||||
// Returns: Number of results.
|
||||
int findPolysAroundShape(dtPolyRef startRef, const float* verts, const int nverts,
|
||||
const dtQueryFilter* filter,
|
||||
dtPolyRef* resultRef, dtPolyRef* resultParent, float* resultCost,
|
||||
const int maxResult) const;
|
||||
|
||||
// Returns closest point on navigation polygon.
|
||||
// Uses detail polygons to find the closest point to the navigation polygon surface.
|
||||
|
@ -2198,9 +2198,9 @@ int dtNavMesh::raycast(dtPolyRef centerRef, const float* startPos, const float*
|
||||
return n;
|
||||
}
|
||||
|
||||
int dtNavMesh::findPolysAround(dtPolyRef centerRef, const float* centerPos, float radius, const dtQueryFilter* filter,
|
||||
dtPolyRef* resultRef, dtPolyRef* resultParent, float* resultCost,
|
||||
const int maxResult) const
|
||||
int dtNavMesh::findPolysAroundCircle(dtPolyRef centerRef, const float* centerPos, float radius, const dtQueryFilter* filter,
|
||||
dtPolyRef* resultRef, dtPolyRef* resultParent, float* resultCost,
|
||||
const int maxResult) const
|
||||
{
|
||||
if (!centerRef) return 0;
|
||||
if (!getPolyByRef(centerRef)) return 0;
|
||||
@ -2282,20 +2282,174 @@ int dtNavMesh::findPolysAround(dtPolyRef centerRef, const float* centerPos, floa
|
||||
const dtMeshTile* neighbourTile = &m_tiles[it];
|
||||
const dtPoly* neighbourPoly = &neighbourTile->polys[ip];
|
||||
|
||||
// Do not advance if the polygon is excluded by the filter.
|
||||
if (!passFilter(filter, neighbourPoly->flags))
|
||||
continue;
|
||||
|
||||
// Find edge and calc distance to the edge.
|
||||
float va[3], vb[3];
|
||||
if (!getPortalPoints(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly, neighbourTile, va, vb))
|
||||
continue;
|
||||
float tseg;
|
||||
float distSqr = dtDistancePtSegSqr2D(centerPos, va, vb, tseg);
|
||||
|
||||
// If the circle is not touching the next polygon, skip it.
|
||||
float tseg;
|
||||
float distSqr = dtDistancePtSegSqr2D(centerPos, va, vb, tseg);
|
||||
if (distSqr > radiusSqr)
|
||||
continue;
|
||||
|
||||
dtNode newNode;
|
||||
newNode.pidx = m_nodePool->getNodeIdx(bestNode);
|
||||
newNode.id = neighbourRef;
|
||||
|
||||
// Cost
|
||||
float edgeMidPoint[3];
|
||||
dtVlerp(edgeMidPoint, va, vb, 0.5f);
|
||||
|
||||
newNode.total = bestNode->total + dtVdist(previousEdgeMidPoint, edgeMidPoint);
|
||||
|
||||
dtNode* actualNode = m_nodePool->getNode(newNode.id);
|
||||
if (!actualNode)
|
||||
continue;
|
||||
|
||||
if (!((actualNode->flags & DT_NODE_OPEN) && newNode.total > actualNode->total) &&
|
||||
!((actualNode->flags & DT_NODE_CLOSED) && newNode.total > actualNode->total))
|
||||
{
|
||||
actualNode->flags &= ~DT_NODE_CLOSED;
|
||||
actualNode->pidx = newNode.pidx;
|
||||
actualNode->total = newNode.total;
|
||||
|
||||
if (actualNode->flags & DT_NODE_OPEN)
|
||||
{
|
||||
m_openList->modify(actualNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (n < maxResult)
|
||||
{
|
||||
if (resultRef)
|
||||
resultRef[n] = actualNode->id;
|
||||
if (resultParent)
|
||||
resultParent[n] = m_nodePool->getNodeAtIdx(actualNode->pidx)->id;
|
||||
if (resultCost)
|
||||
resultCost[n] = actualNode->total;
|
||||
++n;
|
||||
}
|
||||
actualNode->flags = DT_NODE_OPEN;
|
||||
m_openList->push(actualNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int dtNavMesh::findPolysAroundShape(dtPolyRef centerRef, const float* verts, const int nverts,
|
||||
const dtQueryFilter* filter,
|
||||
dtPolyRef* resultRef, dtPolyRef* resultParent, float* resultCost,
|
||||
const int maxResult) const
|
||||
{
|
||||
if (!centerRef) return 0;
|
||||
if (!getPolyByRef(centerRef)) return 0;
|
||||
if (!m_nodePool || !m_openList) return 0;
|
||||
|
||||
m_nodePool->clear();
|
||||
m_openList->clear();
|
||||
|
||||
dtNode* startNode = m_nodePool->getNode(centerRef);
|
||||
startNode->pidx = 0;
|
||||
startNode->cost = 0;
|
||||
startNode->total = 0;
|
||||
startNode->id = centerRef;
|
||||
startNode->flags = DT_NODE_OPEN;
|
||||
m_openList->push(startNode);
|
||||
|
||||
int n = 0;
|
||||
if (n < maxResult)
|
||||
{
|
||||
if (resultRef)
|
||||
resultRef[n] = startNode->id;
|
||||
if (resultParent)
|
||||
resultParent[n] = 0;
|
||||
if (resultCost)
|
||||
resultCost[n] = 0;
|
||||
++n;
|
||||
}
|
||||
|
||||
float centerPos[3] = {0,0,0};
|
||||
for (int i = 0; i < nverts; ++i)
|
||||
dtVadd(centerPos,centerPos,&verts[i*3]);
|
||||
dtVscale(centerPos,centerPos,1.0f/nverts);
|
||||
|
||||
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.
|
||||
const dtPolyRef bestRef = bestNode->id;
|
||||
it = decodePolyIdTile(bestRef);
|
||||
ip = decodePolyIdPoly(bestRef);
|
||||
const dtMeshTile* bestTile = &m_tiles[it];
|
||||
const dtPoly* bestPoly = &bestTile->polys[ip];
|
||||
|
||||
// Get parent poly and tile.
|
||||
dtPolyRef parentRef = 0;
|
||||
const dtMeshTile* parentTile = 0;
|
||||
const dtPoly* parentPoly = 0;
|
||||
if (bestNode->pidx)
|
||||
parentRef = m_nodePool->getNodeAtIdx(bestNode->pidx)->id;
|
||||
if (parentRef)
|
||||
{
|
||||
it = decodePolyIdTile(parentRef);
|
||||
ip = decodePolyIdPoly(parentRef);
|
||||
parentTile = &m_tiles[it];
|
||||
parentPoly = &parentTile->polys[ip];
|
||||
|
||||
getEdgeMidPoint(parentRef, parentPoly, parentTile,
|
||||
bestRef, bestPoly, bestTile, previousEdgeMidPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
dtVcopy(previousEdgeMidPoint, centerPos);
|
||||
}
|
||||
|
||||
for (unsigned int i = bestPoly->firstLink; i != DT_NULL_LINK; i = bestTile->links[i].next)
|
||||
{
|
||||
const dtLink* link = &bestTile->links[i];
|
||||
dtPolyRef neighbourRef = link->ref;
|
||||
// Skip invalid neighbours and do not follow back to parent.
|
||||
if (!neighbourRef || neighbourRef == parentRef)
|
||||
continue;
|
||||
|
||||
// Expand to neighbour
|
||||
it = decodePolyIdTile(neighbourRef);
|
||||
ip = decodePolyIdPoly(neighbourRef);
|
||||
const dtMeshTile* neighbourTile = &m_tiles[it];
|
||||
const dtPoly* neighbourPoly = &neighbourTile->polys[ip];
|
||||
|
||||
// Do not advance if the polygon is excluded by the filter.
|
||||
if (!passFilter(filter, neighbourPoly->flags))
|
||||
continue;
|
||||
|
||||
// Find edge and calc distance to the edge.
|
||||
float va[3], vb[3];
|
||||
if (!getPortalPoints(bestRef, bestPoly, bestTile, neighbourRef, neighbourPoly, neighbourTile, va, vb))
|
||||
continue;
|
||||
|
||||
// If the poly is not touching the edge to the next polygon, skip the connection it.
|
||||
float tmin, tmax;
|
||||
int segMin, segMax;
|
||||
if (!dtIntersectSegmentPoly2D(va, vb, verts, nverts, tmin, tmax, segMin, segMax))
|
||||
continue;
|
||||
if (tmin > 1.0f || tmax < 0.0f)
|
||||
continue;
|
||||
|
||||
dtNode newNode;
|
||||
newNode.pidx = m_nodePool->getNodeIdx(bestNode);
|
||||
newNode.id = neighbourRef;
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -271,6 +271,7 @@
|
||||
<string>6BDD9E030F91110C00904EEF</string>
|
||||
<string>6B137C7D0F7FCBE800459200</string>
|
||||
<string>6B555DF5100B25FC00247EA3</string>
|
||||
<string>6BB7FE8E10F4A175006DA0A6</string>
|
||||
<string>29B97315FDCFA39411CA2CEA</string>
|
||||
<string>29B97317FDCFA39411CA2CEA</string>
|
||||
<string>29B97323FDCFA39411CA2CEA</string>
|
||||
@ -282,14 +283,14 @@
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
<array>
|
||||
<integer>42</integer>
|
||||
<integer>38</integer>
|
||||
<integer>55</integer>
|
||||
<integer>49</integer>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
</array>
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
|
||||
<string>{{0, 184}, {264, 632}}</string>
|
||||
<string>{{0, 409}, {264, 632}}</string>
|
||||
</dict>
|
||||
<key>PBXTopSmartGroupGIDs</key>
|
||||
<array/>
|
||||
@ -324,7 +325,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>Sample_SoloMeshSimple.cpp</string>
|
||||
<string>NavMeshTesterTool.cpp</string>
|
||||
<key>PBXSplitModuleInNavigatorKey</key>
|
||||
<dict>
|
||||
<key>Split0</key>
|
||||
@ -332,11 +333,11 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A40F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>Sample_SoloMeshSimple.cpp</string>
|
||||
<string>NavMeshTesterTool.cpp</string>
|
||||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>6BF9B22211EC4A600043574C</string>
|
||||
<string>6BCE5B9E11F6D4DB00FB894B</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>6BBB4AA1115B4F3400CF791D</string>
|
||||
@ -346,7 +347,6 @@
|
||||
<string>6BBB4AB0115B4F3400CF791D</string>
|
||||
<string>6BBB4AB2115B4F3400CF791D</string>
|
||||
<string>6BBB4ABF115B4F3400CF791D</string>
|
||||
<string>6BBB4B7F115B639200CF791D</string>
|
||||
<string>6BBB4C34115B7A3D00CF791D</string>
|
||||
<string>6BF5F27011747CFA000502A6</string>
|
||||
<string>6BF5F27311747CFA000502A6</string>
|
||||
@ -365,15 +365,11 @@
|
||||
<string>6B10011711AD19F90098A59A</string>
|
||||
<string>6B586E8311CF3E0000704B61</string>
|
||||
<string>6B77655511E3A9490029917E</string>
|
||||
<string>6B98453411E6013000FA177B</string>
|
||||
<string>6B98462E11E6141900FA177B</string>
|
||||
<string>6B98464311E6F9B400FA177B</string>
|
||||
<string>6B9846A011E7140300FA177B</string>
|
||||
<string>6B9846A111E7140300FA177B</string>
|
||||
<string>6B9846B911E7145500FA177B</string>
|
||||
<string>6B9846F311E7282C00FA177B</string>
|
||||
<string>6B9846F611E7282C00FA177B</string>
|
||||
<string>6B98471A11E734DF00FA177B</string>
|
||||
<string>6B98473011E737D800FA177B</string>
|
||||
<string>6B98474311E73ABF00FA177B</string>
|
||||
<string>6B98478311E74AB100FA177B</string>
|
||||
@ -383,7 +379,6 @@
|
||||
<string>6B9847E911E86DBB00FA177B</string>
|
||||
<string>6B9847EA11E86DBB00FA177B</string>
|
||||
<string>6B9847FB11E9AFC900FA177B</string>
|
||||
<string>6B9847FC11E9AFC900FA177B</string>
|
||||
<string>6B9847FE11E9AFC900FA177B</string>
|
||||
<string>6B98480D11E9B1DC00FA177B</string>
|
||||
<string>6B98482611E9D23600FA177B</string>
|
||||
@ -407,7 +402,13 @@
|
||||
<string>6BF9B21211EC49A30043574C</string>
|
||||
<string>6BF9B21311EC49A30043574C</string>
|
||||
<string>6BF9B21B11EC49F90043574C</string>
|
||||
<string>6BF9B21C11EC49F90043574C</string>
|
||||
<string>6BCE5B5611F6CBF700FB894B</string>
|
||||
<string>6BCE5B5911F6CBF700FB894B</string>
|
||||
<string>6BCE5B7E11F6D13700FB894B</string>
|
||||
<string>6BCE5B7F11F6D13700FB894B</string>
|
||||
<string>6BCE5B8C11F6D1AD00FB894B</string>
|
||||
<string>6BCE5B9A11F6D48100FB894B</string>
|
||||
<string>6BCE5B9B11F6D48100FB894B</string>
|
||||
</array>
|
||||
<key>prevStack</key>
|
||||
<array>
|
||||
@ -461,7 +462,6 @@
|
||||
<string>6B98453F11E6013000FA177B</string>
|
||||
<string>6B98454511E6013000FA177B</string>
|
||||
<string>6B98458E11E6039A00FA177B</string>
|
||||
<string>6B9845B911E609E600FA177B</string>
|
||||
<string>6B9845E111E60DBB00FA177B</string>
|
||||
<string>6B98465211E6F9B400FA177B</string>
|
||||
<string>6B98465411E6F9B400FA177B</string>
|
||||
@ -473,70 +473,39 @@
|
||||
<string>6B98477411E7406900FA177B</string>
|
||||
<string>6B98477911E7433F00FA177B</string>
|
||||
<string>6B9847C511E752CC00FA177B</string>
|
||||
<string>6BF9B13B11EB8CF20043574C</string>
|
||||
<string>6BF9B13C11EB8CF20043574C</string>
|
||||
<string>6BF9B13D11EB8CF20043574C</string>
|
||||
<string>6BF9B13E11EB8CF20043574C</string>
|
||||
<string>6BF9B13F11EB8CF20043574C</string>
|
||||
<string>6BF9B14111EB8CF20043574C</string>
|
||||
<string>6BF9B14211EB8CF20043574C</string>
|
||||
<string>6BF9B14311EB8CF20043574C</string>
|
||||
<string>6BF9B14511EB8CF20043574C</string>
|
||||
<string>6BF9B14611EB8CF20043574C</string>
|
||||
<string>6BF9B14711EB8CF20043574C</string>
|
||||
<string>6BF9B14A11EB8CF20043574C</string>
|
||||
<string>6BF9B14E11EB8CF20043574C</string>
|
||||
<string>6BF9B15011EB8CF20043574C</string>
|
||||
<string>6BF9B15111EB8CF20043574C</string>
|
||||
<string>6BF9B15411EB8CF20043574C</string>
|
||||
<string>6BF9B15511EB8CF20043574C</string>
|
||||
<string>6BF9B15611EB8CF20043574C</string>
|
||||
<string>6BF9B15711EB8CF20043574C</string>
|
||||
<string>6BF9B15911EB8CF20043574C</string>
|
||||
<string>6BF9B15C11EB8CF20043574C</string>
|
||||
<string>6BF9B15D11EB8CF20043574C</string>
|
||||
<string>6BF9B15E11EB8CF20043574C</string>
|
||||
<string>6BF9B15F11EB8CF20043574C</string>
|
||||
<string>6BF9B16011EB8CF20043574C</string>
|
||||
<string>6BF9B16111EB8CF20043574C</string>
|
||||
<string>6BF9B16211EB8CF20043574C</string>
|
||||
<string>6BF9B16311EB8CF20043574C</string>
|
||||
<string>6BF9B16411EB8CF20043574C</string>
|
||||
<string>6BF9B16511EB8CF20043574C</string>
|
||||
<string>6BF9B16611EB8CF20043574C</string>
|
||||
<string>6BF9B16911EB8CF20043574C</string>
|
||||
<string>6BF9B17B11EC2B780043574C</string>
|
||||
<string>6BF9B18B11EC2D470043574C</string>
|
||||
<string>6BF9B19011EC2DAE0043574C</string>
|
||||
<string>6BF9B19B11EC35DF0043574C</string>
|
||||
<string>6BF9B1A211EC361E0043574C</string>
|
||||
<string>6BF9B1A711EC36460043574C</string>
|
||||
<string>6BF9B1AE11EC36DA0043574C</string>
|
||||
<string>6BF9B1B311EC37080043574C</string>
|
||||
<string>6BF9B1BD11EC3A0D0043574C</string>
|
||||
<string>6BF9B1BF11EC3A0D0043574C</string>
|
||||
<string>6BF9B1C111EC3A0D0043574C</string>
|
||||
<string>6BF9B1C311EC3A0D0043574C</string>
|
||||
<string>6BF9B1C411EC3A0D0043574C</string>
|
||||
<string>6BF9B1C511EC3A0D0043574C</string>
|
||||
<string>6BF9B1D611EC3DD80043574C</string>
|
||||
<string>6BF9B1D811EC3DD80043574C</string>
|
||||
<string>6BF9B1D911EC3DD80043574C</string>
|
||||
<string>6BF9B1DA11EC3DD80043574C</string>
|
||||
<string>6BF9B1DB11EC3DD80043574C</string>
|
||||
<string>6BF9B1DC11EC3DD80043574C</string>
|
||||
<string>6BF9B1E611EC428F0043574C</string>
|
||||
<string>6BF9B1EB11EC43120043574C</string>
|
||||
<string>6BF9B1F411EC43FC0043574C</string>
|
||||
<string>6BF9B1F511EC43FC0043574C</string>
|
||||
<string>6BF9B1F611EC43FC0043574C</string>
|
||||
<string>6BF9B1FE11EC442C0043574C</string>
|
||||
<string>6BF9B14911EB8CF20043574C</string>
|
||||
<string>6BF9B20D11EC450E0043574C</string>
|
||||
<string>6BF9B21511EC49A30043574C</string>
|
||||
<string>6BF9B21611EC49A30043574C</string>
|
||||
<string>6BF9B21711EC49A30043574C</string>
|
||||
<string>6BF9B21D11EC49F90043574C</string>
|
||||
<string>6BCE5B5C11F6CBF700FB894B</string>
|
||||
<string>6BCE5B5D11F6CBF700FB894B</string>
|
||||
<string>6BCE5B5E11F6CBF700FB894B</string>
|
||||
<string>6BCE5B5F11F6CBF700FB894B</string>
|
||||
<string>6BCE5B6011F6CBF700FB894B</string>
|
||||
<string>6BCE5B6111F6CBF700FB894B</string>
|
||||
<string>6BCE5B6211F6CBF700FB894B</string>
|
||||
<string>6BCE5B6311F6CBF700FB894B</string>
|
||||
<string>6BCE5B6411F6CBF700FB894B</string>
|
||||
<string>6BCE5B6511F6CBF700FB894B</string>
|
||||
<string>6BCE5B6611F6CBF700FB894B</string>
|
||||
<string>6BCE5B6711F6CBF700FB894B</string>
|
||||
<string>6BCE5B6811F6CBF700FB894B</string>
|
||||
<string>6BCE5B6911F6CBF700FB894B</string>
|
||||
<string>6BCE5B6A11F6CBF700FB894B</string>
|
||||
<string>6BCE5B6B11F6CBF700FB894B</string>
|
||||
<string>6BCE5B6C11F6CBF700FB894B</string>
|
||||
<string>6BCE5B8211F6D13700FB894B</string>
|
||||
<string>6BCE5B8311F6D13700FB894B</string>
|
||||
<string>6BCE5B8411F6D13700FB894B</string>
|
||||
<string>6BCE5B8511F6D13700FB894B</string>
|
||||
<string>6BCE5B8611F6D13700FB894B</string>
|
||||
<string>6BCE5B8711F6D13700FB894B</string>
|
||||
<string>6BCE5B8811F6D13700FB894B</string>
|
||||
<string>6BCE5B8E11F6D1AD00FB894B</string>
|
||||
<string>6BCE5B9711F6D42D00FB894B</string>
|
||||
<string>6BCE5B9C11F6D48100FB894B</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
@ -550,18 +519,18 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {887, 444}}</string>
|
||||
<string>{{0, 0}, {887, 568}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>33 87 1173 691 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXNavigatorGroup</string>
|
||||
<key>Proportion</key>
|
||||
<string>444pt</string>
|
||||
<string>568pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Proportion</key>
|
||||
<string>202pt</string>
|
||||
<string>77pt</string>
|
||||
<key>Tabs</key>
|
||||
<array>
|
||||
<dict>
|
||||
@ -575,7 +544,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {887, 38}}</string>
|
||||
<string>{{10, 27}, {887, 66}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>XCDetailModule</string>
|
||||
@ -592,8 +561,6 @@
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {887, 175}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>33 87 1173 691 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXProjectFindModule</string>
|
||||
@ -631,7 +598,9 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {887, 113}}</string>
|
||||
<string>{{10, 27}, {887, 50}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>33 87 1173 691 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXBuildResultsModule</string>
|
||||
@ -659,11 +628,11 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>6BF9B11A11EB75D30043574C</string>
|
||||
<string>6BCE5B6E11F6CBF700FB894B</string>
|
||||
<string>1CA23ED40692098700951B8B</string>
|
||||
<string>6BF9B11B11EB75D30043574C</string>
|
||||
<string>6BCE5B6F11F6CBF700FB894B</string>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<string>6BF9B11C11EB75D30043574C</string>
|
||||
<string>6BCE5B7011F6CBF700FB894B</string>
|
||||
<string>1CA23EDF0692099D00951B8B</string>
|
||||
<string>1CA23EE00692099D00951B8B</string>
|
||||
<string>1CA23EE10692099D00951B8B</string>
|
||||
@ -812,14 +781,14 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>6BF9B16D11EB8D0B0043574C</string>
|
||||
<string>6BCE5B7111F6CBF700FB894B</string>
|
||||
<string>1CCC7628064C1048000F2A68</string>
|
||||
<string>1CCC7629064C1048000F2A68</string>
|
||||
<string>6BF9B16E11EB8D0B0043574C</string>
|
||||
<string>6BF9B16F11EB8D0B0043574C</string>
|
||||
<string>6BF9B17011EB8D0B0043574C</string>
|
||||
<string>6BF9B17111EB8D0B0043574C</string>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<string>6BCE5B7211F6CBF700FB894B</string>
|
||||
<string>6BCE5B7311F6CBF700FB894B</string>
|
||||
<string>6BCE5B7411F6CBF700FB894B</string>
|
||||
<string>6BCE5B7511F6CBF700FB894B</string>
|
||||
<string>6BCE5B7611F6CBF700FB894B</string>
|
||||
</array>
|
||||
<key>ToolbarConfigUserDefaultsMinorVersion</key>
|
||||
<string>2</string>
|
||||
@ -851,8 +820,6 @@
|
||||
<integer>5</integer>
|
||||
<key>WindowOrderList</key>
|
||||
<array>
|
||||
<string>6BF9B17211EB8D0B0043574C</string>
|
||||
<string>6BF9B17311EB8D0B0043574C</string>
|
||||
<string>/Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj</string>
|
||||
</array>
|
||||
<key>WindowString</key>
|
||||
|
@ -36,7 +36,8 @@ class NavMeshTesterTool : public SampleTool
|
||||
TOOLMODE_PATHFIND_STRAIGHT,
|
||||
TOOLMODE_RAYCAST,
|
||||
TOOLMODE_DISTANCE_TO_WALL,
|
||||
TOOLMODE_FIND_POLYS_AROUND,
|
||||
TOOLMODE_FIND_POLYS_IN_CIRCLE,
|
||||
TOOLMODE_FIND_POLYS_IN_POLY,
|
||||
};
|
||||
|
||||
ToolMode m_toolMode;
|
||||
@ -56,6 +57,7 @@ class NavMeshTesterTool : public SampleTool
|
||||
float m_polyPickExt[3];
|
||||
float m_smoothPath[MAX_SMOOTH*3];
|
||||
int m_nsmoothPath;
|
||||
float m_queryPoly[4*3];
|
||||
|
||||
float m_spos[3];
|
||||
float m_epos[3];
|
||||
|
@ -176,9 +176,14 @@ void NavMeshTesterTool::handleMenu()
|
||||
m_toolMode = TOOLMODE_RAYCAST;
|
||||
recalc();
|
||||
}
|
||||
if (imguiCheck("Find Polys Around", m_toolMode == TOOLMODE_FIND_POLYS_AROUND))
|
||||
if (imguiCheck("Find Polys in Circle", m_toolMode == TOOLMODE_FIND_POLYS_IN_CIRCLE))
|
||||
{
|
||||
m_toolMode = TOOLMODE_FIND_POLYS_AROUND;
|
||||
m_toolMode = TOOLMODE_FIND_POLYS_IN_CIRCLE;
|
||||
recalc();
|
||||
}
|
||||
if (imguiCheck("Find Polys in Poly", m_toolMode == TOOLMODE_FIND_POLYS_IN_POLY))
|
||||
{
|
||||
m_toolMode = TOOLMODE_FIND_POLYS_IN_POLY;
|
||||
recalc();
|
||||
}
|
||||
|
||||
@ -667,7 +672,7 @@ void NavMeshTesterTool::recalc()
|
||||
m_distanceToWall = m_navMesh->findDistanceToWall(m_startRef, m_spos, 100.0f, &m_filter, m_hitPos, m_hitNormal);
|
||||
}
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_FIND_POLYS_AROUND)
|
||||
else if (m_toolMode == TOOLMODE_FIND_POLYS_IN_CIRCLE)
|
||||
{
|
||||
if (m_sposSet && m_startRef && m_eposSet)
|
||||
{
|
||||
@ -675,11 +680,48 @@ void NavMeshTesterTool::recalc()
|
||||
const float dz = m_epos[2] - m_spos[2];
|
||||
float dist = sqrtf(dx*dx + dz*dz);
|
||||
#ifdef DUMP_REQS
|
||||
printf("fp %f %f %f %f 0x%x 0x%x\n",
|
||||
printf("fpc %f %f %f %f 0x%x 0x%x\n",
|
||||
m_spos[0],m_spos[1],m_spos[2], dist,
|
||||
m_filter.includeFlags, m_filter.excludeFlags);
|
||||
#endif
|
||||
m_npolys = m_navMesh->findPolysAround(m_startRef, m_spos, dist, &m_filter, m_polys, m_parent, 0, MAX_POLYS);
|
||||
m_npolys = m_navMesh->findPolysAroundCircle(m_startRef, m_spos, dist, &m_filter,
|
||||
m_polys, m_parent, 0, MAX_POLYS);
|
||||
}
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_FIND_POLYS_IN_POLY)
|
||||
{
|
||||
if (m_sposSet && m_startRef && m_eposSet)
|
||||
{
|
||||
const float nx = (m_epos[2] - m_spos[2])*0.25f;
|
||||
const float nz = -(m_epos[0] - m_spos[0])*0.25f;
|
||||
const float agentHeight = m_sample ? m_sample->getAgentHeight() : 0;
|
||||
|
||||
m_queryPoly[0] = m_spos[0] + nx*1.2f;
|
||||
m_queryPoly[1] = m_spos[1] + agentHeight/2;
|
||||
m_queryPoly[2] = m_spos[2] + nz*1.2f;
|
||||
|
||||
m_queryPoly[3] = m_spos[0] - nx*1.3f;
|
||||
m_queryPoly[4] = m_spos[1] + agentHeight/2;
|
||||
m_queryPoly[5] = m_spos[2] - nz*1.3f;
|
||||
|
||||
m_queryPoly[6] = m_epos[0] - nx*0.8f;
|
||||
m_queryPoly[7] = m_epos[1] + agentHeight/2;
|
||||
m_queryPoly[8] = m_epos[2] - nz*0.8f;
|
||||
|
||||
m_queryPoly[9] = m_epos[0] + nx;
|
||||
m_queryPoly[10] = m_epos[1] + agentHeight/2;
|
||||
m_queryPoly[11] = m_epos[2] + nz;
|
||||
|
||||
#ifdef DUMP_REQS
|
||||
printf("fpp %f %f %f %f %f %f %f %f %f %f %f %f 0x%x 0x%x\n",
|
||||
m_queryPoly[0],m_queryPoly[1],m_queryPoly[2],
|
||||
m_queryPoly[3],m_queryPoly[4],m_queryPoly[5],
|
||||
m_queryPoly[6],m_queryPoly[7],m_queryPoly[8],
|
||||
m_queryPoly[9],m_queryPoly[10],m_queryPoly[11],
|
||||
m_filter.includeFlags, m_filter.excludeFlags);
|
||||
#endif
|
||||
m_npolys = m_navMesh->findPolysAroundShape(m_startRef, m_queryPoly, 4, &m_filter,
|
||||
m_polys, m_parent, 0, MAX_POLYS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -878,7 +920,7 @@ void NavMeshTesterTool::handleRender()
|
||||
dd.end();
|
||||
dd.depthMask(true);
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_FIND_POLYS_AROUND)
|
||||
else if (m_toolMode == TOOLMODE_FIND_POLYS_IN_CIRCLE)
|
||||
{
|
||||
for (int i = 0; i < m_npolys; ++i)
|
||||
{
|
||||
@ -906,6 +948,40 @@ void NavMeshTesterTool::handleRender()
|
||||
dd.depthMask(true);
|
||||
}
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_FIND_POLYS_IN_POLY)
|
||||
{
|
||||
for (int i = 0; i < m_npolys; ++i)
|
||||
{
|
||||
duDebugDrawNavMeshPoly(&dd, *m_navMesh, m_polys[i], pathCol);
|
||||
dd.depthMask(false);
|
||||
if (m_parent[i])
|
||||
{
|
||||
float p0[3], p1[3];
|
||||
dd.depthMask(false);
|
||||
getPolyCenter(m_navMesh, m_parent[i], p0);
|
||||
getPolyCenter(m_navMesh, m_polys[i], p1);
|
||||
duDebugDrawArc(&dd, p0[0],p0[1],p0[2], p1[0],p1[1],p1[2], 0.25f, 0.0f, 0.4f, duRGBA(0,0,0,128), 2.0f);
|
||||
dd.depthMask(true);
|
||||
}
|
||||
dd.depthMask(true);
|
||||
}
|
||||
|
||||
if (m_sposSet && m_eposSet)
|
||||
{
|
||||
dd.depthMask(false);
|
||||
const unsigned int col = duRGBA(64,16,0,220);
|
||||
dd.begin(DU_DRAW_LINES, 2.0f);
|
||||
for (int i = 0, j = 3; i < 4; j=i++)
|
||||
{
|
||||
const float* p0 = &m_queryPoly[j*3];
|
||||
const float* p1 = &m_queryPoly[i*3];
|
||||
dd.vertex(p0, col);
|
||||
dd.vertex(p1, col);
|
||||
}
|
||||
dd.end();
|
||||
dd.depthMask(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NavMeshTesterTool::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
|
Loading…
x
Reference in New Issue
Block a user