72 Commits

Author SHA1 Message Date
Graham Pentheny
5111139558
Fixes for many low-severity compiler warnings (#576)
* Fixes for many low-severity compiler warnings

Mostly a lot of pedantic things like end-of-file newlines and commas on the last enum value.  However some fixes like the weak v-tables warnings fixes might help with code gen.  It's unclear if the linker is able to elide multiple copies of the same type's v-table in different translation units, (sometimes it can) but these fixes ensure we don't have to rely on it.
2022-11-11 21:03:03 -05:00
EfveZombie
0af470fe74
fix: use closestPointOnPoly instead of getPolyHeight in dtNavMeshQuery::findRandomPoint (#560) 2022-10-13 11:27:06 +02:00
Jan Haller
cf4f3e15a8
Poly query API: expose distance and isOverPoly (#448)
* Add dtNavMeshQuery.findNearestPoly() overload with parameters: distance, isOverPoly

* dtNavMeshQuery::findNearestPoly(): improve documentation, avoid code duplication

* Make code C++98-compatible

* Remove distance parameter from dtNavMeshQuery::queryPolygons()
2021-01-23 13:25:41 +01:00
Jakob Botsch Nielsen
54bb0943e5 Make closestPointOnPoly and getPolyHeight more robust
* Make dtClosestHeightPointTriangle use no epsilon (except for checking
denominator)
* When point is outside poly, directly find closest height from boundary
detail edges instead of first interpolating and then finding height from
detail tris.
* When point is inside poly, if all dtClosestHeightPointTriangle queries
failed, then find height from detail edges. This should only happen if
the point is right on top of an internal detail tri edge.
2019-03-16 16:18:23 +01:00
Jakob Botsch Nielsen
a0e6605642 Deduplicate closestPointOnPoly 2019-03-16 16:18:23 +01:00
Jakob Botsch Nielsen
3a619d773d
Add consistent input validation to dtNavMeshQuery (#374)
Validate input values, including that points are finite.
2019-02-24 21:10:42 +01:00
aymarfisherman
7cca61dc41 Renamed all instances of 'extents' to 'halfExtents' (#279) 2017-08-20 17:05:51 +02:00
Jakob Botsch Nielsen
88b8d409a7 Properly use detail mesh from closestPointOnPoly (#228)
When a point is outside the polygon being queried in
dtNavMesh::closestPointOnPoly and dtNavMeshQuery::closestPoinOnPoly,
Detour will interpolate along one of the edges to find the closest point
on the poly. However, Detour did not properly use the interpolated point
to find the correct height according to the detail mesh.

Fix #227
2016-09-07 10:55:35 +02:00
Jakob Botsch Nielsen
64385e9ed0 Fix findPath to return DT_OUT_OF_NODES correctly (#222)
findPath was unconditionally overriding the status it used to indicate
DT_OUT_OF_NODES for later. Restore this behavior so it properly can
return this failure flag.

Fix #221
2016-07-27 20:40:42 +02:00
Jakob Botsch Nielsen
2a0c31b8ef Add getPathFromDijkstraSearch function (#211)
This adds a method to dtNavMeshQuery that allows users to retrieve paths
from the nodes explored by the previous Dijkstra search. This is useful
after Dijkstra searches to retrieve arbitrary paths inside the explored
area.
2016-06-10 12:20:27 +02:00
Jakob Botsch Nielsen
8628710178 Take area costs into account in Dijkstra searches (#208)
findPolysAroundCircle and findPolysAroundShape were only using distances
to compute the costs. This was inconsistent with other APIs that
performed cost-based searches and accepted filters as parameters.
2016-05-24 17:54:03 +02:00
Jakob Botsch Nielsen
12569b5cf6 Append results correctly in Dijkstra searches (#205)
This changes the Dijkstra searches in findPolysAroundCircle and
findPolysAroundShape to append the results when we visit nodes in the
main loop. The algorithm guarantees that we will never visit them again
after this, so at this point we are guaranteed that we cannot find a
better path.

Previously results would be appended the first time we saw a polygon
which meant later improvements on the paths to those polygons would not
be reflected in the results.

Fix #204
2016-05-18 13:01:41 -04:00
Ben Hymers
222fa1ee6f Fix possible out of bounds array access in Detour closest point functions
These were reported by Coverity Scan. They're extremely unlikely but still
possible - if all edges of a poly are FLT_MAX or further away from the
input point, a negative index may be used to access the verts array of a
poly.

The fix is to arbitrarily pick the first edge as the closest in case all
are tied as being very far away.
2016-03-14 10:22:31 +00:00
Ben Hymers
2f382134d4 Remove dead assignments to status value in findStraightPath
Add comments explaining why the return values are ignored
Clarify the status return value logic in appendVertex
2016-03-14 09:03:41 +00:00
Ben Hymers
8f16b7de2f Remove dead assignments
Credit to @rafzi in PR #93
2016-03-14 09:03:40 +00:00
Jakob Botsch Nielsen
09afa02f4a Fail when too many nodes are requested
dtNavMeshQuery now fails initialization if too many nodes are requested
in the node pool. This could cause wrong paths and infinite loops to
happen if the node indices started overflowing dtNodeIndex or
dtNode::pidx.

Fix #178
2016-02-22 08:45:24 +00:00
Jakob Botsch Nielsen
e30a6635a2 Fix warnings and increase demo text pool size
Fix three warnings added in fc5df2c, and increase the text pool size in
the demo. This would frequently be overflowed, even just by building
with the default settings and expanding the log.
2016-02-16 10:27:18 +01:00
Jakob Botsch Nielsen
fc5df2c6fd Add API to query polygons in batches
This adds a version of queryPolygon that takes an interface which is
passed batches of polygons in the search area. This new API is then used
from the old queryPolygons to collect polygons, and from findNearestRef
to find the nearest poly in an arbitrarily sized area. Previously
findNearestPoly had an arbitrary poly limit of 128 which could cause it
to return potentially wrong results.

Fix #107
2016-01-25 23:25:48 +01:00
Jakob Botsch Nielsen
643a3a7043 findNearestPoly now fails when nearestRef is null, and only assigns it when the function succeeds 2015-12-17 18:57:06 +01:00
Jakob Botsch Nielsen
7d924b1eee Use intermediate variable for nearest point in findNearestPoly
When the same point is used as center and as nearestPt, the function
would override center and give wrong results.

Fix #118
2015-12-16 18:18:11 +01:00
Richard Fine
67736ae7d5 Include hit edge index in dtRaycastHit.
This makes it simpler to investigate exactly what is blocking a ray - for example, if an agent cannot move onto a polygon due to QueryFilter flags, then this provides a way for the agent to find out which flags it needs to have and to perform a state change which alters its movement flags.
2015-11-15 21:46:30 +00:00
Kromster80
5c45736347 MAX_SEARCH constant instead of hardcoded value 2015-01-06 23:26:14 +03:00
Kromster80
2dce2dfd0c Synced Header and CPP variable names 2014-11-28 14:34:43 +03:00
axelrodR
5d480636d1 Removed the multiple nodes per tile boundary. Left only the any-angle improvement. 2014-06-27 17:53:04 +03:00
axelrodR
2172c712b1 bugfix in raycast: accidentally overwriting the previous tile ref. 2014-06-25 00:56:16 +03:00
axelrodR
a350a92264 addressed Mikko's comment about isValidPolyRef returning a boolean and not dtStatus. 2014-05-28 00:18:01 +03:00
axelrodR
27ffa5b4d3 fixes following mikko's comments from 11/4/14 2014-04-23 16:24:36 +03:00
axelrodR
9b73c5cf51 Merge branch 'master' of https://github.com/memononen/recastnavigation 2014-04-23 14:53:04 +03:00
axelrodR
4b43c33ae1 bug fix: finalizeSlicedFindPathPartial() did not handle the case of DT_NODE_PARENT_DETACHED at all. 2014-02-27 09:27:32 +02:00
axelrodR
c2b2b03b8f bug fix: returned path had duplicates of nodes 2014-02-27 01:47:21 +02:00
axelrodR
1613a5565f following mikko's comments on push #17 (part 2). Interfaces changes, the most notable is adding option flags to initSlicedFindPath that can cancel the any-angle search 2014-02-26 21:29:13 +02:00
axelrodR
1b7b918641 following mikko's comments on push #17. Interfaces changes, the most notable is adding a new raycast function and converted the existing to a thin wrapper. 2014-02-25 11:33:06 +02:00
Mikko Mononen
bad6c17182 Merge pull request #16 from qiqian/master
calculate off-mesh-connection height correctly
2014-02-21 10:33:01 +02:00
axelrodR
7bc913aada Merge branch 'master' of https://github.com/axelrodR/recastnavigation 2014-02-16 16:57:30 +02:00
axelrodR
120de6256f changed path planner to Theta*, changed the raycast function to emit a cost based on the actual traversal cost 2014-02-16 16:51:29 +02:00
axelrodR
dcbfd7c116 Merge branch 'master' of https://github.com/memononen/recastnavigation 2014-02-16 16:43:37 +02:00
Mikko Mononen
19e2d8dbe6 Fixed pos-over-poly case for finding nearest polygon 2014-02-16 11:27:45 +02:00
axelrodR
0494d61ddb Merge branch 'master' of https://github.com/memononen/recastnavigation 2014-02-13 00:08:49 +02:00
Mikko Mononen
6702143bc1 Fix for broken raycasts, changes how findNearestPoly works, slight API change
- test case supports raycasts
- changes how findNearestPoly works directly over polygons
- API change: findNearestPoly has additional parameter
2014-02-11 20:32:00 +02:00
axelrodR
e2722403be bugfix: raycasts sometimes fail when the origin is near a boundary of a triangle with a slope. The fix of considers polygons to have a thickness for the purpose of finding closest nodes. 2014-02-10 00:30:46 +02:00
Qian Qian
90d5a85b85 calculate off-mesh-connection height correctly 2014-02-03 16:34:47 +08:00
axelrodR
72b7123e72 moving from creating several nodes at once for the same ref to creating as needed based on ref and state (where state is currently used only for border poly to keep the arrival side). 2014-01-31 11:26:12 +02:00
axelrodR
d2306cacdd improving path aesthetics at tile crossing: in the old code, when a new node is found a single 3D position is associated with it. This position is used regardless of arriving from a new tile. A minor issue on a normal navmesh, this produces many problems when crossing tiles. Points might be located on different borders altogether depending on where one arrived from first.
The new code assigns several (consecutive) dtNodes for polygons that lie on tile boundary. Each node gets its own point. since the nodes are packed together consecutively, it is easy to find the right node by reference even though there are several.
2014-01-30 11:57:13 +02:00
Matthew Endsley
b0e4e6a834 Add wrappers for the standard math library
Simplifies transition to software based math libraries
for projects requiring determinism.
2013-09-15 20:09:01 -07:00
Mikko Mononen
de6fd8c3ef - use "cylinder distance" for nearest point in polygon
- added option for findStraightPath() to append vertices at get edge crossings
- added scale parameter for .obj loader
2012-09-05 05:57:31 +00:00
Mikko Mononen
64802ecd0e - Improved unconnected off-mesh connection debug draw
- Fixed connecting off-mesh links which connect to the same tile x,y but different layer
- Fixed crash in navmehs query closestPointOnPolyInTile() when the poly is off-mesh connection
2012-06-12 03:28:43 +00:00
Mikko Mononen
00edec6ffb - dtCrowd API Changed!
- finalizeSlicedFindPathPartial() returns best if no existing match found
- refactored crowd move requests
- removed adjustMoveTarget()
- added requestMoveVelocity() and resetMoveTarget()
- improved path replanning robustness
- added move visualization to crowd tool
2012-05-31 09:07:54 +00:00
Mikko Mononen
cd3a68dd9b Random polygon selection for Detour. 2012-02-27 07:17:51 +00:00
Mikko Mononen
e6b1d141d2 Fixed warnings when compiling with -Wshadow. 2012-02-22 17:25:46 +00:00
Mikko Mononen
ff7fd29008 Potential fix for navmesh query crash when using off-mesh cons and no BV-tree. 2012-02-06 14:54:00 +00:00