284 Commits

Author SHA1 Message Date
Kawe Mazidjatari
3a51c4f8c9 Recast: take cylinder caps into account during intersection test
Cylinder caps were not accounted for and thus tmin/tmax were never set causing incorrect ray tracing results when intersecting with a cylinder cap.
2024-09-20 21:54:24 +02:00
Kawe Mazidjatari
32f470f2ed Recast: add functions for checking if point is in cylinder and AABB 2024-09-20 16:00:23 +02:00
Kawe Mazidjatari
4640a81d09 Recast: add cylindric and AABB intersection functions
'rdIntersectSegmentCylinder' is a new function that will be used for intersection tests on cylindric clip volumes.
'rdIntersectSegmentAABB' was already present in the library, but used and reimplemented across multiple source files (pending deduplication).
2024-09-20 14:55:45 +02:00
Kawe Mazidjatari
f98b3b9bff Recast: fix order of cylinder vertex drawing (XZY -> XYZ)
Face normals were flipped after the coordinate system change. This patch solves the issue.
2024-09-20 11:43:55 +02:00
Kawe Mazidjatari
98756f1a0b Recast: reorder function
Was in between area markers, move it above.
2024-09-20 00:30:52 +02:00
Kawe Mazidjatari
11e83769b5 Recast: also assign flags to compact height field in rcMarkCylinderArea
This function is currently not in use, but will be used.
2024-09-20 00:18:23 +02:00
Kawe Mazidjatari
4083318f83 Recast: separate box creation code from renderer
Allow usage in external code.
2024-09-20 00:07:00 +02:00
Kawe Mazidjatari
4a9bfbe79a Recast: vastly improve reliability of land-side off-mesh link tile query
Instead of a box query, just take the position in the tile grid the land-side off-mesh vert is on. This vastly improves the query reliability for off-mesh links with a larger radius to the point it never fails if it is in a valid location. The box query isn't needed here as the off-mesh vert has to be on a tile, else the polygon box query will fail (unless its bounding box does happen to overlap with the point, but in this case the off-mesh connection is placed improperly causing the only factor to have its link established being luck).
2024-09-19 15:44:23 +02:00
Kawe Mazidjatari
b2d0db40ef Recast: properly flag off-mesh connection polygons
MSET 7 or higher needs proper off-mesh connection flags.
2024-09-19 00:11:49 +02:00
Kawe Mazidjatari
30570981e1 Recast: move poly flags and area enums to Detour NavMesh header
Also needs to be used in building and query code, moved to Detour NavMesh header.
2024-09-19 00:02:37 +02:00
Kawe Mazidjatari
d5fa52499c Recast: combine off-mesh link basing and land connection logic
Combine the 2 to avoid an extra loop. Also break out of tile grid loop as soon as a link has been established to save even more processing time.
2024-09-18 17:28:10 +02:00
Kawe Mazidjatari
8eaa349dbc Recast: assign dtOffMeshConnection::userId
Was never assigned properly.
2024-09-18 17:24:08 +02:00
Kawe Mazidjatari
b042327629 Recast: fix incorrect dtOffMeshConnection::userId offset
Field offset was incorrect for MSET 7 or higher.
2024-09-18 17:23:00 +02:00
Kawe Mazidjatari
1a0b6efae5 Recast: properly set traverse type fields in off-mesh connections for MSET 7 or higher
The structure was incorrect prior to this patch for MSET 7 or higher.
2024-09-18 11:41:33 +02:00
Kawe Mazidjatari
a6d4a53021 Recast: make proper wrappers for radians and degrees conversion
Avoid bugs where radians gets converted to radians, or degrees to degrees.
2024-09-16 16:29:46 +02:00
Kawe Mazidjatari
36484dbb82 Recast: increase traverse link brightness 2024-09-04 22:47:58 +02:00
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
6050ce5555 Recast: boilerplate code and constants deduplication 2024-09-04 13:39:05 +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
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
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
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
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
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
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