4751 Commits

Author SHA1 Message Date
Kawe Mazidjatari
b144b200ad Recast: major improvements to traverse link algorithm
From now on, internal links are connected first before external neighbor links. This now also happens in the same pass which improves performance (this yields better results and behavior after the last few and current changes).

Also added a fine tunable test dictating whether links should only connect when edges overlap, or when one of the edges overlap (can be tweaked by setting an elevation trigger, by skipping out on lower elevations if this deems necessary, but typically doesn't).

The slope angle option was originally in the table but removed. After reconsideration this has been brought back in as you cannot define min/max slopes with 3d distances and elevation differences. The distance either needs to be 2d (which will break the max 2550.f distance per link rule), or an additional slope check has to be used to define this properly.

 After a lot of fine tuning, the results appear to be almost identical to the original navmeshes shipped with Respawn games. The algorithm is also a lot faster now (went from 30 seconds to 8 seconds on the staging area with much better and more accurate results).
2024-08-28 14:06:11 +02:00
Kawe Mazidjatari
f9fb1c6c64 Recast: move surface area quantization into its own function
Avoid potential mistakes in the future by using the wrong quant factor.
2024-08-28 13:47:21 +02:00
Kawe Mazidjatari
4f72c9aee8 Recast: implement new math functions
Implement functions for deriving vector magnitude and scalar projections.
2024-08-28 13:44:27 +02:00
Kawe Mazidjatari
bf251bccd5 Recast: fix naming of constant (XZY -> XYZ)
The direction is represented over the XY plane, previously XZ on Recast's original coordinate system. There were multiple inconsistencies in Recast where the XZ plane got represented as XY and visa versa.
2024-08-28 12:25:36 +02:00
Kawe Mazidjatari
57e66f1dfc Recast: add utility to get tile side by vector direction
Necessary for next upgrade to traverse link algorithm to get the neighbor tile facing the direction of the edge's normal.
2024-08-28 12:17:29 +02:00
Kawe Mazidjatari
a3753dec9f Recast: fix crash in tile tool when navmesh is NULL 2024-08-28 12:14:40 +02:00
Kawe Mazidjatari
2ccd443a8d Recast: fix misleading member variable name
These are draw parameters.
2024-08-26 00:54:10 +02:00
Kawe Mazidjatari
d81f6a24aa Recast: fix bugs causing mesh links to leak when removing and readding tiles
Rework the way traverse links are tracked and how the traverse table gets recreated when a tile gets removed/added. We would rebuild the entire traverse network and thus leak links since we also cleared the map that tracks the connections.
2024-08-25 23:58:04 +02:00
Kawe Mazidjatari
794f619d84 Recast: adds support for drawing off-mesh connection traverse links 2024-08-25 11:24:57 +02:00
Kawe Mazidjatari
247f2c65f1 Recast: (large change) full support for off-mesh links
Off-mesh links are now fully reverse engineered and working in Titanfall 2 and Apex Legends.
2024-08-25 11:21:01 +02:00
Kawe Mazidjatari
1a8acd5c16 Recast: fix incorrect dtLink allocation count for off-mesh links
Noticed this issue when creating multiple number of off-mesh links between 2 polygon islands. Turns out a pull request was already created to address this problem at https://github.com/recastnavigation/recastnavigation/pull/622. Merged the changes directly as this yields correct behavior as far as off-mesh links have been tested.
2024-08-24 20:33:37 +02:00
Kawe Mazidjatari
5b1bdbef68 Recast: fix stack var typo and update documentation around off-mesh ref yaw angles 2024-08-24 20:05:58 +02:00
Kawe Mazidjatari
0d1b12819e Recast: calculate ref yaw as radians, and calculate ref pos from radians
Must be converted to radians as per the comment. The behavior in-game is now correct after this patch.
2024-08-24 20:00:09 +02:00
Kawe Mazidjatari
b49033154c Recast: add debug option to mark tile by ref 2024-08-23 14:30:22 +02:00
Kawe Mazidjatari
cff151687d Recast: fix typo causing bug in rdClassifyPointInsideBounds
Needs the square root for normalization.
2024-08-23 14:15:26 +02:00
Kawe Mazidjatari
fab5344703 Recast: extern drawMeshTile as duDebugDrawMeshTile
Allow usage outside debug draw implementation.
2024-08-23 14:09:07 +02:00
Kawe Mazidjatari
20c8523a56 Recast: fix crash when drawing traverse links without navmesh query
Must have a navmesh query.
2024-08-23 14:08:26 +02:00
Kawe Mazidjatari
549a4a3e64 Recast: draw off-mesh connection traverse links
Off-mesh connections also have traverse links.
2024-08-23 14:07:17 +02:00
Kawe Mazidjatari
36a4d75b2f Recast: fix rdClassifyPointOutsideBounds and rewrite rdClassifyPointInsideBounds
-x and +x have to be flipped because of the coordinate system conversion (OpenGL XZY -> Source XYZ). The diagonal cases of rdClassifyPointInsideBounds also rarely worked... Rewritten to use rdClassifyPointOutsideBounds instead by moving the point outside the box towards its direction. Hack but works very reliably.
2024-08-23 14:02:13 +02:00
Kawe Mazidjatari
83ab1c87ff Recast: small debug draw refactor
Move all render logic to separate functions and add flag to disable/enable the rendering of the poly faces.
2024-08-22 23:48:16 +02:00
Kawe Mazidjatari
7a963c7fb3 Recast: properly restore off-mesh connection draw flags
Instead of setting it to the old flags (undoing any changes we did while we were at the off-mesh connection tool) only set the off-mesh draw flag if it was enabled since that's the only one we disable when entering this tool.
2024-08-22 23:45:28 +02:00
Kawe Mazidjatari
50e0e6ec58 Recast: fix precision loss when compiling with /fp:fast
See https://github.com/recastnavigation/recastnavigation/issues/424
2024-08-22 19:41:17 +02:00
Kawe Mazidjatari
ec056e277e Recast: rcFilterLedgeSpans optimizations and improvements
Merge recastnavigation/recastnavigation#672

Actually improves the filtering of ledge spans as they are now a lot firmer against their limits, this is also beneficial for traverse link generation as we get more accurate ledge spans to work with (making the offsetting math do its job better since it assumes accurate ledge spans).

There was a report further down this pull request that pathing results differed after this change, along with a new one at https://github.com/recastnavigation/recastnavigation/issues/729. I was however not able to replicate it, nor did any behavior change in-game on a navmesh generated on kings canyon.
2024-08-22 19:17:29 +02:00
Kawe Mazidjatari
de5fb7cbef Recast: remove comment
Should be kept as Y since we changed the coordinate system.
2024-08-22 17:34:10 +02:00
Kawe Mazidjatari
fc1bfa8bfe Recast: add note to detail vert height offset 2024-08-22 16:00:45 +02:00
Kawe Mazidjatari
9b1651420c Recast: remove adjustable neighbor link extender from traverse link algorithm
Only limit it to the actual neighborhood since otherwise removing a tile will become a problem, the current logic only unlinks it from its neighborhood if its not an off-mesh link. We also should keep it that way. If user wants links that extend further horizontally, they should increase the tile size.
2024-08-22 15:02:38 +02:00
Kawe Mazidjatari
0bcafc9928 Recast: use improve unionTraverseLinkedPolyGroups performance
Use the unsafe version of getTileAndPolyByRef instead, the refs have already been validated by the time we reach this function.
2024-08-22 14:06:23 +02:00
Kawe Mazidjatari
759dab221b Recast: fix crash case when removing tile and iterating over removed tile
Must check if there's an header, since if a tile has been removed that header will be null.
2024-08-22 14:04:46 +02:00
Kawe Mazidjatari
3d3af4609b Recast: fix typo in dtNavMesh::removeTile
Must be link.ref, loop behavior is now correct.
2024-08-22 13:35:29 +02:00
Kawe Mazidjatari
698fe11008 Recast: allow off-mesh links to be established beyond neighboring tiles
Slightly more expensive than just checking neighbors, but offers a lot more possibilities with off-mesh links (long diagonal jump, zip lines, etc..). The mesh linking stage has now been moved to an offline process anyways so performance isn't a huge issue here.
2024-08-22 13:02:50 +02:00
Kawe Mazidjatari
739d590574 Recast: ignore off-mesh links for traverse links
Do not link or union off-mesh links to traverse links.
2024-08-22 01:14:49 +02:00
Kawe Mazidjatari
cf6d3f3dcf Recast: revert default navmesh type adjustments
These were adjusted in commit 513f4a52971f5ca9090a4789c34733b9946ad390, the reason for this was because smaller tiles had a lot less errors in-game than larger ones. But the issue was that our BVTree was incorrectly transformed, and thus poly's on edges would almost always be outside their respective bounding volumes. Now the navmeshes work normally regardless of tile sizes, but 512 sized tiles generate and perform better than 256 ones.
2024-08-21 19:22:37 +02:00
Kawe Mazidjatari
d0d132655b Recast: transform BVTree in queryPolygonsInTile (XZY -> XYZ)
Should be the either the last, or one of the last XZY to XYZ conversions.
2024-08-21 19:18:11 +02:00
Kawe Mazidjatari
62e5d28892 Recast: don't generate poly mesh cells without detail meshes
Must have detail meshes in order to generate these. Also removed unused local variable.
2024-08-21 14:55:01 +02:00
Kawe Mazidjatari
c8fc3f58d8 Recast: subdivision const correctness 2024-08-21 14:48:36 +02:00
Kawe Mazidjatari
8fce111502 Recast: fix BVTree calculations and rendering (XZY -> XYZ)
Should've been converted to the source engine coordinate system as well, but we missed this as then rendering thereof was 'fixed' incorrectly causing incorrect bounding volumes to appear correctly. Fixed the renderer and the calculation; the AI now never gets stuck in-game regardless whether 256 or 512 sized tiles are used.
2024-08-21 14:40:33 +02:00
Kawe Mazidjatari
5aff50f8cf Recast: add option to disable BVTree creation 2024-08-21 11:11:32 +02:00
Kawe Mazidjatari
dd9493d651 Recast: find the best traverse type rather than returning the first valid
Better results + slightly updated table to allow coverage on all traverse types again.
2024-08-21 02:45:32 +02:00
Kawe Mazidjatari
291ce4488a Client: fix push/pop style var mismatch
Since the table was taken out of the child instance in commit 245ff565042870e0cded7a2ec3dcc868a00414af, we should no longer handle the window and frame separately. Car count must now be counted together.
2024-08-21 02:26:48 +02:00
Kawe Mazidjatari
3a17d60182 Recast: don't add tiles tagged as userId=1
Engine behavior.
2024-08-21 02:24:59 +02:00
Kawe Mazidjatari
0b688c6807 Recast: implement neighbor extending logic in traverse link algorithm
Allow the user to specify how far to extend from the current tile towards the direction of the traverse link, this is useful when navmeshes with smaller tiles are generated as the neighbor lookup boundary for these are essentially bound to the tile size, thus smaller tiles will result in smaller links unless we extend to further neighbors.
2024-08-20 23:48:39 +02:00
Kawe Mazidjatari
1024f50c0c Recast: only link 2 polygons with the same traverse type once
Major improvement to generated navmesh, avoids duplicated links.
2024-08-20 22:22:43 +02:00
Kawe Mazidjatari
afbcd4d91b Recast: improve link offsetting code and add debug mode to tile tool
Add extra offset to dynamic calculation rather than after. And add debug option in the Tile Tool to debug tile LUT.
2024-08-20 19:14:40 +02:00
Kawe Mazidjatari
0b0a257ff1 Recast: fix compile error for MSET 5
Syntax error.
2024-08-20 10:56:49 +02:00
Kawe Mazidjatari
d2c287bef7 Recast: add options for traverse ray offsets 2024-08-20 10:56:21 +02:00
Kawe Mazidjatari
513f4a5297 Recast: many fixes regarding tile numbering
Reducing the tile size to 16 for all types completely eliminated the issue where an NPC in-game fails to find a steer poly after traversal (call to dtNavMeshQuery::findNearestPoly fails). Tile size of 16 causes correct tile numbering for world bmins and bmaxs. Also added 2 new sliders allowing the change of min and max tile bits + some additional cleanup.
2024-08-20 02:27:29 +02:00
Kawe Mazidjatari
34f81f035e Recast: add ability to fine tune and toggle traverse types
Added table that allows you to fine tune and toggle traverse types for all anim types and navmeshes. Also tweaked default values with newer fine tuned ones to improve link generation more. There's still a ton of fine tuning work left to be done.
2024-08-19 01:55:58 +02:00
Kawe Mazidjatari
245ff56504 Client: freeze server list detail columns
Keep the details column in display when scrolling.
2024-08-18 23:32:16 +02:00
Kawe Mazidjatari
016191878a Recast: add reverse engineered poly area and flags
Add new reversed flags, and properly handle poly flags per navmesh set version.
2024-08-17 23:56:52 +02:00
Kawe Mazidjatari
9c190cc7ca Recast: initialize tile cell occupy state
Initialize it in the file.
2024-08-17 22:58:59 +02:00