43 Commits

Author SHA1 Message Date
Kawe Mazidjatari
ec1f72bf04 Recast: major optimization on Editor::connectTileTraverseLinks
Check if we have enough space for num new links before starting the complex calculations. This optimization saved 10+ seconds on the firing range and had no effect on the output results; the navmesh still hashed to the same value as the one build before this patch.
2024-08-16 01:21:49 +02:00
Kawe Mazidjatari
97ceae59e6 Recast: traverse linking code cleanup and improvements
Split traverse link creation and updating code from the editor, only alloc traverse table when we are creating them or when we load navmeshes that have them, don't alloc them before the navmesh is built. Also moved the disjoint set data to the editor class so we can cache the results and reuse them later after editing the navmesh post build. Traverse link algorithm now also ignores polys marked unlinked.
2024-08-14 11:30:43 +02:00
Kawe Mazidjatari
3aaa3827c2 Recast: major improvements to traverse linking algorithm
* Properly calculate how much we need to offset from the navmesh's edge to account for the ledge span
* Properly check if the edge we are connecting to overhangs our lower link position.
* Check if our ledge span offset causes the link to clip into geometry, and skip linking if so.
* Removed an improper intersection test in 'Editor::connectTileTraverseLinks', which caused many false positives (all issues this fixes, have been fixed with the improved 'traverseLinkInLOS'.
* Removed extraneous 'CanOverlapPoly' check; all links can now overlap poly's without issues if they pass through the 'traverseLinkInLOS' test.
* Only perform offsetting calculation if we have an amount to offset.
* Split 'dtCalcLinkDistance' into 2 functions, one that calculates it and 'dtQuantLinkDistance' that performs the quantization.
* Removed incorrect and experimental code from 'dtNavMesh::connectExtOffMeshLinks', this was to test off-mesh links for MSET 5, but this wasn't the correct approach.
2024-08-13 23:47:33 +02:00
Kawe Mazidjatari
a99984b0f3 Recast: support traverse links connecting to external tiles + major performance improvement
Now connect to neighbor tiles (still work in progress). Also moved poly overlap and raycast logic to separate functions. The raycast checks are now performed as a very last step as previously we would raycast, and then determine we can't establish the link because the traverse type was NULL or the distance was too great, which both could be checked before the raycast and are also a lot cheaper to check. Changing the order of checks significantly improved the performance.

Also fixed a bug in dtCalcLinkDistance, if the number exceeds 2550.f, it would overflow and cause links to be a lot larger. If the value exceeds the number now, it would return 0 and no link will be established.
2024-08-12 11:09:48 +02:00
Kawe Mazidjatari
b63cb1d52c Recast: improve naming consistency for the traverse system
Traversal and traverse were mixed in variable/function naming. Forced consistency. No logic was changed this patch.
2024-08-09 14:35:47 +02:00
Kawe Mazidjatari
acaf4cf32b Recast: initial working implementation of traverse link generation algorithm
Traversing now works in-game, but there's still work needed to polish the algorithm and creating a proper lookup for jump types as currently only 1 jump type is supported.
2024-08-08 17:44:27 +02:00
Kawe Mazidjatari
848fbabc79 Recast: simplify quantization 2024-08-08 01:33:27 +02:00
Amos
2a45ced5f4 Recast: fix compile error caused by missed version checks 2024-07-24 10:26:41 +02:00
Amos
49a0ceb148 Recast: initial implementation of multi-set support
Allow to compile the editor for separate versions of the navmesh set. NavMesh cells are now also partially reversed and properly read out. Creating and writing them will happen in the future.
2024-07-22 18:48:41 +02:00
Amos
38223fb6f3 Recast: properly skip over intermediate poly data
Needs to be multiplied by sizeof(int).
2024-07-21 23:23:48 +02:00
Amos
bff3bfd5ea Recast: add missing prefix to utility function
Needs to be prefixed with 'dt' for consistency and to avoid cluttering the global namespace.
2024-07-21 22:27:55 +02:00
Kawe Mazidjatari
7d5c07b2e7 Recast: fix compiler warning and floor value
Value of dtCalcLinkDistance has to be floored to match Titanfall 2 values.
2024-07-19 00:01:11 +02:00
Kawe Mazidjatari
e57e85b88a Recast: initial implementation of jump links for off-mesh links
These should set them up properly in theory. Needs testing.
2024-07-18 23:58:39 +02:00
Kawe Mazidjatari
5ec7862b71 Recast: more missed XZY -> XYZ changes 2024-07-18 18:06:34 +02:00
Kawe Mazidjatari
98a8898a43 Recast: fix bug in dtNavMesh::findNearestPolyInTile (XZY -> XYZ)
Hight should always be on the Z axis.
2024-07-18 17:05:08 +02:00
Kawe Mazidjatari
740c593197 Recast: setup off-mesh connections properly (WIP)
Titanfall navmeshes have the dtOffMeshConnection::userId field changed from unsigned into to unsigned short, and the lower half seems to be used for the jump types and (possibly) some flag. Work in progress implementation of the jump system on off-mesh links.
2024-07-18 17:00:31 +02:00
Kawe Mazidjatari
fce53b6eed Recast: update dtLink variable names and assignments
Light cleanup and added new names and documentation of what's currently know.
2024-07-18 15:49:51 +02:00
Kawe Mazidjatari
38f57d95ad Recast: several large improvements
The dtNavMesh structure members were marked as public, but they should be private. Made them private. Also, dtNavMesh::addTile was reconstructing all links, even when we add tiles with pre-existing links. The link building logic has been moved to a new member function 'dtNavMesh::connectTile'. This should only be called once the navmesh tile has been added succesfully during build. If we load a navmesh now, the existing links will be used from now on. The dtNavMesh::m_tileCount member is now also correctly incremented and decremented in addTile/removetile.
2024-07-17 17:51:01 +02:00
Kawe Mazidjatari
243bd3348e Recast: update stack variable name
Match structure field name.
2024-07-16 20:51:04 +02:00
Kawe Mazidjatari
961b4e2e51 Recast: fix bugs in dtNavMesh::addTile and dtCreateNavMeshData
Some data that is in between the poly's and links weren't skipped properly. The engine skips this data in dtNavMesh::addTile, we didn't. This is now skipped properly by advancing over it before going over the links. The 2nd and 3rd bug was that the poly's end pointer, and off-mesh connections end pointer was set to the data size of the poly's and off-mesh connections rather than the poly and off-mesh con count. This small oversight has been fixed and the end pointers are now set correctly. The function dtCreateNavMeshData has also been updated to take this data into account correctly, it was using the Titanfall 2 NavMesh (NavMesh Set Version 5), structure sizes but this has been changed in Apex (NavMesh Set Version 7 and 8). These fixes did reduce the NavMesh's file size by a few kilobytes per megabyte.
2024-07-16 19:35:08 +02:00
Kawe Mazidjatari
1853b571c5 Recast: use math functions from Recast & Detour itself
Make the code base more consistent.
2024-07-16 02:08:06 +02:00
Kawe Mazidjatari
cf755b286b Recast: fix missed XZY -> XYZ conversion in dtNavMesh::getPolyHeight
Should set height to Z.
2024-07-16 01:18:01 +02:00
Kawe Mazidjatari
b3ce300338 Recast: properly split PCH between library and editor
Both were using the same PCH, but the recast library doesn't need anything from SDL or ImGui, properly split them apart and cleaned up includes.
2024-07-15 20:53:38 +02:00
Kawe Mazidjatari
5f90ea08f2 Recast: make all math helpers shared
There was an issue where Recast's common math library was less complete than that of Detour. Some common math operations were also isolated in specific translation units causing copies everywhere. All common math operations have been moved to the Shared library ultimately fixing all the above issues.
2024-07-15 19:27:55 +02:00
Kawe Mazidjatari
6a3bc50778 Recast: dtCalcPolySurfaceArea cleanup
j -> i.
2024-07-13 00:39:58 +02:00
Kawe Mazidjatari
9fa6b6c42a Recast: fix compiler error
New function wasn't renamed correctly, fixed rename error.
2024-07-12 22:14:05 +02:00
Kawe Mazidjatari
2f9776d495 Recast: properly set dtPoly::surfaceArea
This field has been reverse engineered and set correctly in this commit. The field contains the quantized surface area of the polygon.
2024-07-12 21:38:50 +02:00
Kawe Mazidjatari
59a8f12e0e Recast: allow setting table count in dtNavMesh::init
Needed for pre-allocation on solo mesh.
2024-07-12 12:53:43 +02:00
Kawe Mazidjatari
c64ebe12c2 Recast: fix incorrect renaming
Everything 'dtAlloc', 'rcAlloc', 'dtAlloc', 'dtFree', got renamed into 'rdAlloc', 'rdFree'. There were a lot of object allocators that used these suffixes which were not accounted for causing those to be renamed. Everything has been renamed back to their original names (excluding the actual rdAlloc/rdFree functions as these were supposed to be renamed).

No code logic was changed in this commit.
The accidental renaming was caused in commit fa8d89d287752782ebdd5d9563f04fa72ef0bee9
2024-07-07 17:25:42 +02:00
Kawe Mazidjatari
917b33bb71 Recast: move Detour_IsGoalPolyReachable to dtNavMesh
Make the code shared so we can also use it in the Recast editor.
2024-07-07 12:05:35 +02:00
Kawe Mazidjatari
602fa7d1ec Recast: editor improvements
- Separate disjoint set and traversal table building code
- Use game types and data to determine what to build into the traversal tables (e.g., 5 traversal tables for _small and only 1  for the rest).
- Automatically initialize the editor using the _small navmesh parameters instead of the broken defaults.
2024-07-06 19:51:31 +02:00
Kawe Mazidjatari
1a3f7b6bda Recast: rename reachability table to traversal table
The static pathing code is split into 2 elements, the disjoint sets (poly groups), and the traversal table (which links poly groups, visually known as poly islands) together through jump or offmesh links. Reachability covers more than just traversal in the context of this game engine, therefore it has been renamed to avoid future confusion.
2024-07-05 17:48:48 +02:00
Kawe Mazidjatari
615f63d82a Recast: rename structure fields and add more documentation
A more consistent name with what has bee reversed so far. Also added documentation on what has been reversed entirely and as much information that i have about stuff that has been partially figured out.
2024-07-05 10:38:16 +02:00
Kawe Mazidjatari
fa8d89d287 Recast: make assert and allocation code shared
All recast/detour allocation and assertion code were identical, with the exception of their names (rc* for recast, dt* for detour). We want to use Recast's rcVectorBase class in Detour code, as there is no Detour equivalent, but copying it in its whole isn't good practice (especially considering there is more boilerplate code we want to get rid of in the future). Moved these to Shared so Detour could use it as well under the name rdVectorBase (rd stands for Recast Detour). No changes to the logic of the code were made in this patch.
2024-07-04 11:32:56 +02:00
Kawe Mazidjatari
1ac6f9be60 Recast: integrate static pathing generation/parsing code into editor
Instead of building the static pathing data when the NavMesh is getting saved, build it right after the NavMesh has been build. also, parse this data out from NavMesh files loaded from the disk. This patch also documented some extra features and designs. In the future, static pathing logic will also be implemented in the detour path query code.
2024-07-04 00:54:50 +02:00
Kawe Mazidjatari
f999c6ae6d Recast: split dtLink::flags into actual fields
Its split into 3 separate fields, this will be used in the future for fixing jump links between poly's.
2024-07-03 11:59:52 +02:00
Kawe Mazidjatari
b7bca8e15c Recast: remove extraneous clamp for saltbits
Due to the change in 4ced95e2c111178a4127a663d95dc5c02e764d00, there are always 4 salt bits or less.
2024-07-02 16:12:56 +02:00
Kawe Mazidjatari
4ced95e2c1 Recast: properly calculate tile and poly bits during build
Tile bits should be 16, and polyBits 28 - tileBits. This is also the reason why the 'm_saltBits < 10' check no longer exists in the executable.
2024-07-02 14:18:11 +02:00
Kawe Mazidjatari
97204c20dc Recast: light formatting improvements
Keep the style consistent with the rest.
2024-07-02 14:13:05 +02:00
Kawe Mazidjatari
7c90262829 Recast: remove unused and incorrect code
Should no longer be used as tiles are now built correctly after the change in a2d5d52dc4e571388b9b86f21e40a5110a69665e
2024-07-02 01:28:58 +02:00
Kawe Mazidjatari
cc73d147fc Recast: implement off-mesh connection yaw angles and reference positions
Used by the engine for AI wall running, but also other AI logic like move direction. This probably is some cached ref pos + yaw to save on computation in the runtime, and probably used to lerp the AI to the correct direction before jumping. Current implementation seems very close to original navs now, though, the original navs appear to have some yaw angles being rotated a bit, probably manual adjustments to make the AI face a wall that isn't perpendicular.

Also implemented debug drawing for the new ref positions, and made the start circle of the off-mesh connection red, and the end position green to make it easy what is what in bidirectional connections.
2024-06-30 17:36:01 +02:00
Kawe Mazidjatari
0e54998a36 Recast: reverse some fields 2024-04-03 14:52:12 +02:00
Kawe Mazidjatari
fd3e227a86 Align folder structure with p4 2023-09-19 22:13:22 +02:00