4416 Commits

Author SHA1 Message Date
Kawe Mazidjatari
05b6e23a75 Recast: fix naming consistency of helper function
Should be upper case to match the rest.
2024-08-29 22:43:15 +02:00
Kawe Mazidjatari
400fe00cea Recast: improve generation of traverse link type 7
At least one edge must overlap another during the projection test.
2024-08-29 22:41:52 +02:00
Kawe Mazidjatari
5bf5713eba Recast: allow moving cursor through UI 2024-08-29 16:26:25 +02:00
Kawe Mazidjatari
25cd598b17 Recast: major improvement to traverse linking algorithm
Instead of using just the polygon edges, use the detail edges as well. Ray cast errors have been fully eliminated; nothing ever clips through geometry anymore. The results are also a lot more detailed now as we can connect various sub edges together. The resulting navmesh also performs better in-game, the npc's are now a lot more fluent with jumps and climbs, they rarely clip though geometry, if they do its typically an error with the input geometry used to build the navmesh.

There was also a bug in GetBestTraverseType; the exclusive check (where at least one overlap had to occur) returned true if both overlap tests failed. This has been fixed by flipping the check and now checking if at least one overlaps when an exclusive test was specified.
2024-08-29 16:18:51 +02:00
Kawe Mazidjatari
632e70aae1 Recast: reorder location of 'dtGetDetailTriEdgeFlags'
Move under dtPolyDetail structure.
2024-08-29 16:12:40 +02:00
Kawe Mazidjatari
75ff8adfac Recast: implement function for calculation sub edge area's 2024-08-29 16:11:55 +02:00
Kawe Mazidjatari
0b64e3bea1 Recast: add render option for poly detail edges 2024-08-28 23:56:44 +02:00
Kawe Mazidjatari
6dc9434460 Recast: update traverse reachability when removing all tiles
Must be updated.
2024-08-28 17:40:47 +02:00
Kawe Mazidjatari
3833b22b08 Recast: split traverse link creation from static path creation 2024-08-28 16:35:05 +02:00
Kawe Mazidjatari
05649dbcc3 Recast: use tile marker improvements
Use rdClassifyPointOutsideBounds to mark neighbor tile so it only gets marked if we mark a tile, and a polygon outside the marked tile. Also added an optimization so the same tile doesn't get rendered twice (side == 0xff).
2024-08-28 15:57:17 +02:00
Kawe Mazidjatari
a2e539c2a5 Recast: increase max off-mesh links to 1024
For larger maps, its possible to exceed the original limit of 256.
2024-08-28 15:52:13 +02:00
Kawe Mazidjatari
ff9fb328f3 Recast: store off-mesh link traverse type and lookup orders in project file
Now also gets stored in the project file. Also reordered the way each field gets stored so its easier to tweak or add/remove outside the editor by external tools.
2024-08-28 15:51:35 +02:00
Kawe Mazidjatari
bcc86f2250 Recast: fix bug when setting off-mesh vert orders
Properly switch between flags, previously the switch was on the same flag.
2024-08-28 15:49:27 +02:00
Kawe Mazidjatari
0bfd44abba Recast: properly handle off-mesh linked polygon reachability
Handle it in the same loop as standard traverse links, off-mesh links also have a link determining its traverse type after it has been reverse engineered and fixed. The output and behavior is now correct.
2024-08-28 14:55:16 +02:00
Kawe Mazidjatari
4dfdbaee17 Recast: fix bug when removing and readding tiles on unlinked polygons
We would only clear polygons that weren't marked as unlinked, this was introduced when the prune tool was refactored to use the unlinked polygroup tag. The side effect is, when you remove a tile, and cause a polygon on a neighbor tile to not link to anything, it will be marked as unlinked which is the correct behavior, but when you readd the tile, the entire island will be marked as unlinked.

The function dtCreateDisjointPolyGroups got fixed later by not taking traverse links into account, since polygon islands linked together with traverse links are still disjoint. This was also the time the check had to be removed when clearing all labels but this didn't happen.

Removing and readding tiles now work properly after this patch.
2024-08-28 14:40:08 +02:00
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