4524 Commits

Author SHA1 Message Date
Kawe Mazidjatari
bef18681cf Recast: return out early if we have no regions 2024-11-06 14:27:11 +01:00
Kawe Mazidjatari
eb6692ab9e Recast: fix heap buffer overflow in partitioning code
Fixes https://github.com/recastnavigation/recastnavigation/issues/317. This can happen when we mave multiple spans in the X row. So far this crash only occured in Capitol City in Apex Legend's Worlds Edge map, where there are internal polygons in high rise buildings with 10 or more floors equally placed on top of another.
2024-11-06 14:24:14 +01:00
Kawe Mazidjatari
851ae9c75f Recast: fix typo in parameter name
After coordinate system conversion, this shouldb e X-Y.
2024-11-06 14:17:30 +01:00
Kawe Mazidjatari
652b5d7018 Game: make navmesh render plane culling optional
Plane culling is too aggressive on larger tiles, make it optional.
2024-11-06 14:12:12 +01:00
Kawe Mazidjatari
c4cdbe38ce Recast: increase max span height bits
Increase to 29 bits for span limits, previously this was 13 and since the next field in the struct was a pointer, we end up using the 4 bytes padding so the struct size didn't increase. The reason for this increase is that rcSpan::smin and rcSpan::smax overflow when building a navmesh with a low cell height. This is especially an issue with maps that contain mountains. For the season 1 kings canyon map, the tiles containg the polygons for the firing range will be entirely flat due to the massive height difference between the base map and the firing range which resides under the map, causing it to be clamped to the previous MAX_HEIGHT value.
2024-11-05 02:06:06 +01:00
Kawe Mazidjatari
5e36f58956 Recast: add toggle to disable automatic traverse link building 2024-11-04 22:10:42 +01:00
Kawe Mazidjatari
3e5540e762 Recast: improve traverse type parameters
Slightly more fine tuned for better results, especially between type 10 and 21, make AI climb on lower ledges and perform higher jumps on higher ledges. Also ensured full coverage for all "accross" traverse activities by closing all min/max distance gaps.
2024-11-04 20:57:37 +01:00
Kawe Mazidjatari
98ed726cb4 Recast: always start from north during traverse linkage
During new tests, not starting from the neighboring tile at north caused some smaller links to not establish, which is roughly 30 links in angel_city.bsp. This patch makes it always start from north without any alternation and yields the best results during all tests.
2024-11-03 16:52:01 +01:00
Kawe Mazidjatari
065150158a Recast: small optimization for traverse link algorithm
Only calculate edge directions and normals when we are sure this is going to get used.
2024-11-03 15:36:09 +01:00
Kawe Mazidjatari
3e7c7cb7da Recast: fix incorrect base side classification
rdClassifyDirection never got intercardinal sides causing it to be unreliable and inaccurate. rdClassifyPointInsideBounds and rdClassifyPointOutsideBounds are tested and confirmed correct during every case, switched use to rdClassifyPointInsideBounds instead and removed rdClassifyDirection for the start side of the neighbor tile lookup. For the links: the base side is always the opposite of the land side.
2024-11-03 15:33:44 +01:00
Kawe Mazidjatari
d0a8549dc9 Recast: change return type of tile side getters to unsigned char
Value will never be higher than 7 as we only have 8 sides (0-7). Avoids having to cast as dtLink::side is an unsigned char.
2024-11-03 15:21:25 +01:00
Kawe Mazidjatari
b4e7bb7886 Recast: never attempt link to the same polygon
Big optimization as you cannot link to the same polygon, you also cannot link to the same triangle. This drops polyCount number of iterations on polygons per tile.
2024-11-03 15:16:10 +01:00
Kawe Mazidjatari
7c3509fd34 Recast: add dedicated double-precission time type
The library used signed 32bit integers and single precission floating points to represent build times, but on long build times this will overflow. Added a dedicated time type while promoting it to double precission and adjusting all use cases throughout the library.
2024-11-03 12:25:11 +01:00
Kawe Mazidjatari
b41141018e Recast: run the full compass rose during traverse linkage
Go over each neighboring tile starting with the tile facing the edge normal, and then its oposite, and perform the same alternation on the next tiles. This link pattern gives the best and most consistent results by trying to link all sides equally. In order to guarantee maximum coverage, the link count multiplication has been increased from 8 to 32 per detail mesh bound as this new approach is creating an incredible amount of new links. Some of the links will end up not being used, but these will be removed during the prune stage.
2024-11-03 02:04:27 +01:00
Kawe Mazidjatari
1d994404d6 Recast: fix incorrect land-side classification for neighbor links
Out of bounds classification for land poly's edge must always be performed on the AABB of the base tile.
2024-11-03 01:57:43 +01:00
Kawe Mazidjatari
393944b064 Recast: major improvement to traverse link validation
- Portal kink point is now always offset twice the walkable radius to account ledge spans and center of hull to ledge, any extra is put on top with the default being 4.f to account for irregularities.
- Make sure we have enough clearance over the kink point and lower start point of the portal so that the NPC does not clip into overhead obstacles when performing an animation.
- Make sure we don't link a portal from underneath geometry by performing a raycast from the edge's mid point, and 2 additional ones if the link's span is larger than 100.f in world units.
2024-11-03 00:43:34 +01:00
Kawe Mazidjatari
4ea7c3ebfc Recast: add tile side wrapper
This allows for getting the direct side of a side by doing side-1, side+1, etc.. A useful case would be to get tiles at sides facing the normal of an edge on our own tile and doing anything with these tiles.
2024-11-02 21:00:21 +01:00
Kawe Mazidjatari
1e2c445cf3 Recast: remove unnecessary abs with epsilon check
Introduced in 2745f8b27c43b9c78c106e3dc278a2d1752fd7a5 but this is not needed.
2024-11-02 20:57:26 +01:00
Kawe Mazidjatari
7ee884b39c Recast: fix bug in cylinder intersect detection code
If there's no movement on the x-y plane between sp and sq, there will be no magnitude, and thus also no discriminant. The code however will continue as it only checks if discriminant < 0. Due to this, the code  will no longer take the origin and radius of the cylinder into account and that will cause any ray that extends above or below the cylinder to be a hit, regardless of where it was emitted from in the world. If we have no magnitude, we should always check if the start point resides inside the cylinder area on the x-y plane and determine from there whether to perform a vertical intersection test.
2024-11-02 20:46:51 +01:00
Kawe Mazidjatari
a229662a8e Recast: deduplicate epsilon constant
Value was identical to RD_EPS.
2024-11-02 20:11:00 +01:00
Kawe Mazidjatari
2745f8b27c Recast: use epsilon for vertical intersection tests
Take floating point precission into account.
2024-11-02 20:09:14 +01:00
Kawe Mazidjatari
1f4e7cc080 Recast: fix bug in tile side debug slider
Range 0-7 are 8 sides. -1 is none. The clamp had 1 extra.
2024-11-02 20:06:54 +01:00
Kawe Mazidjatari
7c71e1d147 Recast: add virtual getter for agent slope 2024-11-02 20:06:01 +01:00
Kawe Mazidjatari
7eebab51a4 Recast: ignore winding order in intersectSegmentTriangle
We don't care if we hit the backface, always register. This allows for doing just 1 raycast and significantly saving on build times.
2024-11-02 19:59:32 +01:00
Kawe Mazidjatari
a218cef231 Recast: fix initialization for traverse link draw parameters
m_traverseLinkDrawParams.dynamicOffset was never initialized.
2024-11-01 21:00:59 +01:00
Kawe Mazidjatari
b47b52dd08 Recast: optimize alignPortalLimits
Only calculate shiftAmount if we are going to shift the portal left or right.
2024-11-01 16:07:49 +01:00
Kawe Mazidjatari
e2197dd3fe Recast: fix typo in API documentation
Portal align can also be 0.5 but not higher.
2024-11-01 14:01:11 +01:00
Kawe Mazidjatari
bb140317c7 Recast: implement traverse portal alignment
Shift portal mins and maxs together to try and align the portals. The system is dynamic and will take portal span into consideration. Also slightly changed the API to implement an optimization by switching the directional vector of the edges to their normals as we only need the normals in traverseLinkInLOS, this avoids having to recalculate them.
2024-11-01 13:57:38 +01:00
Kawe Mazidjatari
8d5bc23cf6 Game: improve in-game navmesh rendering
Draw inner and outer poly boundaries, and only draw detail meshes if this was specified by the user. Most of the time we don't want to draw detail as this has a huge performance cost.
2024-11-01 13:37:32 +01:00
Kawe Mazidjatari
2c5659164b Recast: improve rendering of poly edges on dead polygons 2024-11-01 13:28:58 +01:00
Kawe Mazidjatari
2b89373ca1 Recast: allow clamped input for off-mesh connection
Improve UX
2024-11-01 13:28:05 +01:00
Kawe Mazidjatari
1d9d0ed6d6 Recast: constify 2024-10-31 19:29:42 +01:00
Kawe Mazidjatari
bbb6d8569c Recast: restore traverse type 1 minimum distance value
This was increased in commit 0a4817a707035e49e757dcd16d132ac5a5a9a46c to address an issue where the AI gets stuck in corners, but the issue also happened on other traverse types (abeit much more rare). After investigating the problem again, the issue was caused by connecting adjacent polygons with traverse portals (which causes an infinite recursion during pathfinding if the first link of that polygon happens to reference the one from which the traversal is taking place). This issue has been patched in commit 582ecec0381b4071f2f7fd1920eeb27c8c8539c7, therefore, we should restore this to its default value again.
2024-10-31 19:24:46 +01:00
Kawe Mazidjatari
48aa2700fa Recast: remove extraneous polygroup check from traverse link algorithm
The static pathing data is either not built, or has to be rebuilt at this stage. If we have do happen to have dead polygons that we can use for traverse portals then we should leverage them to get as much coverage as possible.
2024-10-31 19:21:08 +01:00
Kawe Mazidjatari
582ecec038 Recast: do not connect adjacent polygons with traverse links
Connecting adjacent polygons with traverse links will cause pathfinding to run into itself infinitely if either of the 2 poly's first link references the polygon from which the traverse link originates from. The behavior in-game is that the AI become stuck in the area with error code FAIL_NO_ROUTE_BLOCKED. Implemented the method 'dtNavMesh::arePolysAdjacent' to make sure we never connect adjacent polygons on our own or neighboring tile with a traverse link.
2024-10-31 19:09:59 +01:00
Kawe Mazidjatari
e7240e5551 Recast: increase default "extra" ray trace offset
Results in many more accurate links and prevents most that are technically valid from being dropped. This seems to be the best value during all tests.
2024-10-31 12:45:22 +01:00
Kawe Mazidjatari
e69e960c78 Recast: increase the cell size rather than the tile size for large navmeshes
Use a cell size of 15 instead for navmeshes used for titans and goliaths (_large and _extra_large). This value results in identical values with Titanfall 2 regarding bounding volume quantization factors.
2024-10-31 12:42:32 +01:00
Kawe Mazidjatari
ce14f2a150 Recast: only set bits corresponding to polygroup in traverse table
The table is fully nulled when allocated, resetting bits is not necessary.
2024-10-29 12:52:20 +01:00
Kawe Mazidjatari
64de9f6a48 Recast: use spherical extends to clamp off-mesh link to poly
The traversability of off-mesh links is not dictated by the walkable climb in this engine; an off-mesh connection can be higher from the ground due to ziplines.
2024-10-29 12:51:24 +01:00
Kawe Mazidjatari
81c0cab610 Recast: also take trigger areas into consideration for traversal ray tracing
Currently, trigger only gets used for hazard or door area's, and we don't want NPC's to traverse through these. The collision detection system needs a small overhaul to take actual polygon flags or contents into account which will allow for a much more detailed filtering. This will be done once we use more areas than just hazard or door.
2024-10-29 12:47:57 +01:00
Kawe Mazidjatari
3d91bc3143 Recast: fix micro-LUTs for hull traversability
Some of them were incorrectly assigned and also missed a few traverse types dedicated to of-mesh connections. These new values now correspond exactly to the values the game uses. The only one that couldn't be confirmed is GOLIATH, but it should be the same as TITAN. This will fix cases where a polygon island is marked as unreachable for an NPC hull that could traverse a link connecting its current island to the goal one.
2024-10-29 12:44:39 +01:00
Kawe Mazidjatari
7118c94beb Recast: fix shape volume editor bugs
Convex volume hmin and hmax are mapped to world coordinates, thus we need to treat them as such. Also fixed a bug where deselecting a shape, and selecting another one, and then resetting the other ones causes it to be reset to the data of the previously selected shape as the index thereof was never reset on deselect.
2024-10-29 12:38:34 +01:00
Kawe Mazidjatari
ca2e8bc32d CMake: turn off fast math
The engine is not compiled with fast math. Added a detailed comment explaining how this was figured out and why it should be kept disabled.
2024-10-28 17:15:00 +01:00
Kawe Mazidjatari
787fc85f29 Recast: update rasterization and polygonization parameters
These new parameters give the best results so far when generating the navmesh over both vphysics and BVH4 collision geometry. Also removed a todo comment that has been addressed.
2024-10-28 17:01:52 +01:00
Kawe Mazidjatari
3ca08ede1a Recast: rename off-mesh connection debug draw function
Force naming consistency.
2024-10-28 16:59:42 +01:00
Kawe Mazidjatari
8340951b9e Recast: move the off-mesh ref vert towards the clamped start vert
Must be moved as well rather than staying in place when the start point is clamped.
2024-10-27 02:28:01 +02:00
Kawe Mazidjatari
0a4817a707 Recast: set minimum distance default for traverse type 1 to 48
Type 1 can cause the AI to become stuck when a link is established within a hole that is too short. Testing revealed that any link beyond this length, wether its on a hole or gap, does not cause the AI to become stuck. Updated default.
2024-10-27 02:26:25 +02:00
Kawe Mazidjatari
1990a2d4b4 Recast: enable shape volume rendering by default 2024-10-27 02:24:52 +02:00
Kawe Mazidjatari
67c5145862 Recast: expose option to ignore input triangle winding order to user interface
Disabled by default.
2024-10-25 16:35:20 +02:00
Kawe Mazidjatari
0940ad3ce6 Recast: add option to ignore input triangle winding order
The mesh data from the game's BVH4 tree does not appear to have a fixed triangle winding order, making it nearly impossible to generate correct navmeshes while using the decoded BVH4 data. Fixing the sign enables us to generate the navmesh over the game's collision data properly rather than using the render mesh. This change does not appear to have a negative effect on the generated NavMesh.
2024-10-25 11:04:27 +02:00