4751 Commits

Author SHA1 Message Date
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
Kawe Mazidjatari
ed9cd80034 Recast: fix generation of concave polygons
These changes seem to yield better results for the larger maps. The improvements are minimal however. This change is probably more noticable on tile cache.
2024-10-25 01:12:51 +02:00
Kawe Mazidjatari
6451405fba Recast: ensure polygon is always within bounding volume
In recastnavigation/recastnavigation@15ebb8bd25 the change was made to use detail polygons, but it appears that after this change, the bounding volume gets build under the polygons, especially if the polygons's Z are equal on all vertices. Flooring the mins and ceiling the maxs appears to yield correct behavior in all scenarios by making sure the bounding volume always encases its respective polygon.
2024-10-25 00:51:54 +02:00
Kawe Mazidjatari
563427ae63 Recast: add option to disable rendering of shape volumes 2024-10-25 00:40:40 +02:00
Kawe Mazidjatari
349f7bd3b9 Recast: move and rename render flags
Improve code readability.
2024-10-25 00:39:35 +02:00
Kawe Mazidjatari
d1c5228d23 Recast: add getter for area edge color
Also get the color for the edge per area type, previously we would still render a blue edge on a green trigger area.
2024-10-24 15:06:12 +02:00
Kawe Mazidjatari
136bc8623b Recast: fix compile error for MSET 5 Recast builds
Titanfall 2 versions (MSET 5) do not support hints.
2024-10-22 14:28:03 +02:00
Kawe Mazidjatari
d7f2b7d319 Recast: implement off-mesh connection editor
Allows the user to modify core attributes of any off-mesh connection in the world.
2024-10-22 12:05:44 +02:00
Kawe Mazidjatari
1bb531c36b Recast: add option to reset shape volume attributes
When you edit a shape volume, you might want to fully reset it and start over again.
2024-10-22 12:03:26 +02:00
Kawe Mazidjatari
fda4e694d6 Recast: build navmesh directly into the game's load path
The engine loads it from here during development, store the file directly there so we can hot reload it into the game.
2024-10-22 12:02:22 +02:00
Kawe Mazidjatari
fc4fabd116 Recast: fix a crash in the tile builder tool
Check if tile isn't null before derefing it for the header.
2024-10-22 12:01:09 +02:00
Kawe Mazidjatari
8eb294b731 Recast: only run polygroup union logic if it won't be collapsed
No point in running this code if we are going to collapse it. This also fixes a possible deadlock when removing and rebuilding individual tiles.
2024-10-22 11:59:43 +02:00
Kawe Mazidjatari
1ad2f18573 Recast: improve comment for dtNavMesh::isGoalPolyReachable 2024-10-22 11:58:18 +02:00
Kawe Mazidjatari
ac6da44a18 Recast: properly implement navmesh destructor
Reverse engineered the last types that were mostly unused and unneeded by the navmesh. But to properly implement the destructor it had to go in. Cells and hints now get freed as well and we can now rely on our own destructor for the navmesh data allocated by the game.
2024-10-22 11:56:26 +02:00
Kawe Mazidjatari
aaddd53cfc Recast: increase cell height to 6.0
This was required as a cell height of 2.0 is too low for the map "mp_rr_canyonlands_64k_x_64k". This particular level is very large, and has another level far underneath; its the old firing range. In order to ensure full coverage on Z, the cell height must be increased. After the change in commit b3946e924aeea05f65f9fcba5e9043771d14af23, the new cell height actually produces more accurate and consistent results accross all levels.
2024-10-20 01:34:32 +02:00
Kawe Mazidjatari
8e3097c321 Recast: move cross marker to the center of the highlighted tile or poly
Make it easier to see where a small polygon or tile is as the cross is noticable.
2024-10-20 01:29:55 +02:00
Kawe Mazidjatari
62ccee8bb2 Recast: remove links from semi connected off-mesh connections
If an off-mesh connection has a base link, but no land link, there will be an invalid link as we never process there. These links must be removed. Due to this change, the link flagging had to be moved to a separate loop as we would otherwise store the dead link in the file (it won't cause a crash as it has been unlinked, but there is no reason it should be stored). Also improved the detection of external off-mesh connections landing on our current tile, instead of doing a position lookup just decode the polyref and check if the index equals our current tile.
2024-10-20 01:28:36 +02:00
Kawe Mazidjatari
b3946e924a Recast: use step height for the climb height parameter
The Hull_s::height field is actually Hull_s::stepHeight. This results in much better navigation and prevents entities "popping" into air as they shouldn't be able to walk over some obstacles.
2024-10-19 12:45:12 +02:00
Kawe Mazidjatari
b28b167467 Recast: fix regression in geometry raycaster
After the implementation of brush intersection detection in commit 6fa5080fe51e2ea118f2cf4f922bcb6e815b3a9f, we return out as soon as we have a hit, even when tmin is provided. But if tmin is provided, the caller is interested in finding the closest intersection so we must go over the input mesh as well. This fixes a bug of raycasts going through geometry when there's a brush behind it.
2024-10-19 12:02:53 +02:00
Kawe Mazidjatari
9ebecbee20 Recast: properly remap off-mesh connection polyrefs
External references were never updated. Especially when the tile we process doesn't own an off-mesh connection, but does have one landing on it. After this patch, the navmesh passes all tests in game and all polygons appear to be remapped correctly when using all features of the Detour NavMesh (single step verification). Also no issues reported from address sanitizer after several tests on extremely large and complicated navmeshes.
2024-10-19 11:55:56 +02:00
Kawe Mazidjatari
e62051eff3 Recast: fix several bugs related to off-mesh connections
- Off-mesh connections should always be linked to target poly's first. Also set the linked flag on titanfall navmeshes as this is necessary during the pruning stage.
- When connecting off-mesh links, we need to iterate over tiles using m_maxTiles, not m_tileCount as m_tileCount counts the number of added tiles, while m_maxTiles contains the maximum tiles in the lookup array, there can be empties in between.
- Radians to degrees and visa versa has been moved to a simple inline function, but during this, a regression was made where it was accidentally inverted in dtCalcOffMeshRefYaw and dtCalcOffMeshRefPos.
2024-10-19 11:51:24 +02:00
Kawe Mazidjatari
49907272fb Recast: fix off-mesh connection remap during prune
Off-mesh connections were not properly mapped to their polygon instance, causing
a heap buffer overflow.
2024-10-18 15:48:57 +02:00
Kawe Mazidjatari
d9db7d3d15 Recast: fix crash in prune tool
Always check if we allocated a flag buffer before showing the options.
2024-10-18 13:51:28 +02:00
Kawe Mazidjatari
fc43cbabd9 Recast: fix a crash during NavMesh load without traverse tables
The sizes still need to be set as the engine at least needs to allocate the traverse table buffer.
2024-10-18 13:29:32 +02:00