4357 Commits

Author SHA1 Message Date
Kawe Mazidjatari
0b606b21fd Recast: improve code consistency 2024-09-04 22:47:36 +02:00
Kawe Mazidjatari
e019de8dcd Recast: make detail triangle flags enum shared
The same constants are used between Recast and Detour, but Recast had to declare and match the constant locally as it couldn't access the one from the Detour library. This patch avoids duplicate definitions and potential issues during refactors.
2024-09-04 16:19:19 +02:00
Kawe Mazidjatari
6fa5080fe5 Recast: also cast ray against convex hulls for clip brushes
A ray should not go through clip brushes. This fixes an issue were traverse links are generated inside or through clip brushes.
2024-09-04 16:08:30 +02:00
Kawe Mazidjatari
6050ce5555 Recast: boilerplate code and constants deduplication 2024-09-04 13:39:05 +02:00
Kawe Mazidjatari
33acd65e5a Recast: initialize member variable in OffMeshConnectionTool 2024-09-04 11:44:12 +02:00
Kawe Mazidjatari
9f0312cbf1 Recast: add option for changing off-mesh connection radius
New slider that is also synced on change with the selected NavMesh type.
2024-09-04 11:38:00 +02:00
Kawe Mazidjatari
1378a6db9c Recast: make off-mesh links more visible
Use the dark blue color so it doesn't collide with traverse link colors.
2024-09-04 11:21:32 +02:00
Kawe Mazidjatari
e89a1d9436 Recast: add the last few flags to the list as well 2024-09-04 10:36:11 +02:00
Kawe Mazidjatari
d1bad5c130 Recast: add logic for setting polygon flags in convex hulls
User can now define a convex hull or box area, and set polygons flags as desired from the convex volume tool or through the project files.
2024-09-04 10:30:54 +02:00
Kawe Mazidjatari
f364e1b4c3 Recast: add array of poly flag names 2024-09-04 10:26:41 +02:00
Kawe Mazidjatari
9113b36bfd Core: fix typo's in function comment headers
Small typo's, fixed to retain consistency.
2024-09-04 01:09:09 +02:00
Kawe Mazidjatari
78e2987ca9 Server: fix incorrect edict parameters in public interface
Shouldn't be pointers; in this engine, edict_t is an unsigned short.
2024-09-04 01:05:01 +02:00
Kawe Mazidjatari
6e26b3c4be Server: fix compile error
Belongs to commit c64f28be25d2adec24d921a5a2398325fa93abab.
2024-09-04 00:58:22 +02:00
Kawe Mazidjatari
f5c0b428cb Recast: add hook bodies for NavMesh functions
Used for debugging the Detour implementation of the engine.
2024-09-04 00:57:26 +02:00
Kawe Mazidjatari
c64f28be25 Server: fix rare NavMesh hotswap crash
Detour_LevelInit resets the global NavMesh query, but if code is going to utilize the global Detour query for an existing query on a subsequent frame without attaching a NavMesh in the mean time, the code will crash. The previously attached NavMesh type has to be reattached after the hotswap.
2024-09-04 00:48:54 +02:00
Kawe Mazidjatari
7739a6c909 Recast: minor improvement to traverse link selection algorithm
Slight optimization to skip unsupported ones out before computing anything, and also improves the generation results as we try to get the best one out of the supported ones, instead of taking one from supported and unsupported and then later check if its unsupported. (if the best type is 9, and 9 isn't supported while 8 is, and 8 would've been the candidate after 9, then this patch will still give the link a chance for 8 while the previous implementation would've skipped it entirely and returned DT_NULL_TRAVERSE_TYPE, ultimately resulting in no link whatsoever.
2024-09-04 00:42:58 +02:00
Kawe Mazidjatari
0814efe613 Recast: API improvement; move traverse link algorithm to navmesh class
The algorithm has been moved to the dtNavMesh class, and now features a parameter based design allowing code that utilizes the algorithm to define engine-specific tests such as the raycasting, traverse masking, etc. The code can now be hooked up to any level editor without changing a line of code inside the Recast & Detour library. All parameters have been documented thoroughly. The code now also properly returns errors if out of memory, or if invalid parameters were provided. This commit does not affect the results of the traverse link generation, the navmesh remains identical to the one generated on the previous design.
2024-09-04 00:31:03 +02:00
Kawe Mazidjatari
1e92548624 Recast: move common definitions to separate header
Moved to separate header so they can be used everywhere.
2024-09-03 11:08:23 +02:00
Kawe Mazidjatari
98454cceab Recast: poly mesh cells are an MSET >= 8 only feature 2024-09-03 10:57:54 +02:00
Kawe Mazidjatari
6fd2d41856 Recast: fix traverse link generation for type '1'
Should overlap on both sub-edges before the link gets established. Avoids the AI getting stuck in game when they don't.
2024-09-03 10:56:51 +02:00
Kawe Mazidjatari
807a327b6f Recast: fix compiler warnings caused by unused local variables 2024-09-03 01:52:22 +02:00
Kawe Mazidjatari
afab9c2206 Recast: fix crash in dtPathCorridor
Must alloc the jumpTypes array, currently not fully implemented yet.
2024-09-02 18:02:47 +02:00
Kawe Mazidjatari
652d8f9da0 Recast: remove invert parameter from rdCalcEdgeNormal*
Extraneous parameter.
2024-09-02 17:26:16 +02:00
Kawe Mazidjatari
603878d413 Recast: fix heap buffer overflow in createPolyMeshCells
Must iterate up to num detail tris for current detail mesh instead of total detail tris for entire tile mesh.
2024-09-02 17:17:21 +02:00
Kawe Mazidjatari
ec741313c2 Recast: fix stack corruption caused by out-of-scope variable usage
pmin and pmax pointed to these stack arrays, but these stack arrays were inside the loop while pmin and pmax, along with their usages were outside the scope of the loop causing undefined behavior when they pointed to the currently out-of-scope stack variables. Moved the arrays outside the loop so they remain valid up to the last point they are needed.
2024-09-02 15:40:29 +02:00
Kawe Mazidjatari
3e56daf398 Recast: properly handle out-of-memory situations during build
Return false if createBVTree or createPolyMeshCells fails as a result of memory allocation failure rather than crashing the application.
2024-09-02 15:36:23 +02:00
Kawe Mazidjatari
7071de1643 Recast: BVTree build bug fix and large optimization
dtMeshHeader::bvNodeCount is always set to polycount*2, but when we have null bv nodes, then these will also be used during dtNavMeshQuery::queryPolygonsInTile, which can yield incorrect results when the null nodes overlaps query box. Also added an additional optimization to only store non-null BV nodes which can save a significant amount of memory during the runtime. After this bug fix and optimization, the resulting mesh still works as intended in-game.
2024-09-02 15:20:59 +02:00
Kawe Mazidjatari
05cc26dfe5 Recast: tag semi and fully unlinked tiles with userid's
Fully unlinked can be removed entirely, semi unlinked needs a rebuild to remove unlinked polygons (still work in progress). Added ability to automatically remove fully unlinked tiles.
2024-09-02 12:25:15 +02:00
Kawe Mazidjatari
e315b8d36f Recast: move fine tuner under collapsing header
UX improvements.
2024-09-01 00:02:28 +02:00
Kawe Mazidjatari
66cf9678d2 Recast: add method for marking cells as occupied 2024-09-01 00:01:51 +02:00
Kawe Mazidjatari
3227208533 Recast: fix signed/unsigned mismatch 2024-08-31 23:40:21 +02:00
Kawe Mazidjatari
ec115d7c97 Recast: start of jump type implementation in findStraightPath 2024-08-31 23:03:44 +02:00
Kawe Mazidjatari
ab88364779 Recast: fix comment location 2024-08-31 15:59:36 +02:00
Kawe Mazidjatari
b39214e517 Recast: check for traverse filter in dtNavMeshQuery::moveAlongSurface 2024-08-31 15:58:57 +02:00
Kawe Mazidjatari
14225dccc1 Recast: optimizations for getPortalPoints
Don't loop over the linked list again to find the corresponding link while we already have a pointer to it.
2024-08-31 15:58:28 +02:00
Kawe Mazidjatari
54f1e217de Recast: start of navmesh query modifications
Start of implementing changes of Titanfall 2 and Apex into dtNavMeshQuery.
2024-08-31 15:13:24 +02:00
Kawe Mazidjatari
7fb9a2d48b Recast: fix typo in function name 2024-08-31 11:57:09 +02:00
Kawe Mazidjatari
09a052ff18 Recast: tag unlinked and unusable tiles
Don't add tiles with no links to the position lookup table.
2024-08-31 11:54:09 +02:00
Kawe Mazidjatari
537f149be3 Recast: fix compile error
This function was removed in commit 041d02cd654d94bf4b059c212cb6a63a39e5324e but it should've been kept in as it was still used for dtNavMeshQuery::findRandomPointAroundCircle. Only the quantizer should be removed.
2024-08-30 15:54:30 +02:00
Kawe Mazidjatari
77b9d056e8 Recast: properly flag polygons after creation
Titanfall 2 navmeshes flag their polygons as follows. The pattern was always that if a polygon connects to a polygon on a neighboring tile, it should be flagged as   EDITOR_POLYFLAGS_HAS_NEIGHBOUR, and if the polygon's surface area isn't higher than 120 (NAVMESH_SMALL_POLYGON_THRESHOLD) it should be flagged as EDITOR_POLYFLAGS_TOO_SMALL.
2024-08-30 15:51:28 +02:00
Kawe Mazidjatari
041d02cd65 Recast: move polygon surface area calculation to librecast
Let recast compute this instead of detour. We need this before the detour navmesh is getting build as we have to determine whether a polygon is too small before that, and flag it as such.
2024-08-30 15:43:21 +02:00
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