diff options
author | Graham Pentheny <graham.pentheny@gmail.com> | 2022-11-25 20:05:57 -0500 |
---|---|---|
committer | Graham Pentheny <graham.pentheny@gmail.com> | 2022-11-27 19:22:33 -0500 |
commit | 36de150c74e8c86e204ce64dc5a2865b6aee79a7 (patch) | |
tree | d7171ffec3e12fa478b42991e8939cd061dd7b66 /thirdparty/recastnavigation/Recast/Source/RecastRasterization.cpp | |
parent | fa270c2456df5ad12f51584c4ff891e2cf728cec (diff) | |
download | redot-engine-36de150c74e8c86e204ce64dc5a2865b6aee79a7.tar.gz |
Updated Recast to 4fef044
In some cases Godot can generate input parameters to Recast that cause it to crash. Specifically when baking NavigationMeshes for input meshes that have axis extents less than half the NavigationMesh CellSize.
This has been fixed upstream in Recast (in https://github.com/recastnavigation/recastnavigation/commit/3901c5854c958593443859fd1214162452ff2982). Updating Godot's Recast integration fixes this crash issue in Godot as well.
Diffstat (limited to 'thirdparty/recastnavigation/Recast/Source/RecastRasterization.cpp')
-rw-r--r-- | thirdparty/recastnavigation/Recast/Source/RecastRasterization.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/thirdparty/recastnavigation/Recast/Source/RecastRasterization.cpp b/thirdparty/recastnavigation/Recast/Source/RecastRasterization.cpp index a4cef74909..673550e79e 100644 --- a/thirdparty/recastnavigation/Recast/Source/RecastRasterization.cpp +++ b/thirdparty/recastnavigation/Recast/Source/RecastRasterization.cpp @@ -264,7 +264,8 @@ static bool rasterizeTri(const float* v0, const float* v1, const float* v2, // Calculate the footprint of the triangle on the grid's y-axis int y0 = (int)((tmin[2] - bmin[2])*ics); int y1 = (int)((tmax[2] - bmin[2])*ics); - y0 = rcClamp(y0, 0, h-1); + // use -1 rather than 0 to cut the polygon properly at the start of the tile + y0 = rcClamp(y0, -1, h-1); y1 = rcClamp(y1, 0, h-1); // Clip the triangle into all grid cells it touches. @@ -283,7 +284,7 @@ static bool rasterizeTri(const float* v0, const float* v1, const float* v2, dividePoly(in, nvIn, inrow, &nvrow, p1, &nvIn, cz+cs, 2); rcSwap(in, p1); if (nvrow < 3) continue; - + if (y < 0) continue; // find the horizontal bounds in the row float minX = inrow[0], maxX = inrow[0]; for (int i=1; i<nvrow; ++i) @@ -293,7 +294,10 @@ static bool rasterizeTri(const float* v0, const float* v1, const float* v2, } int x0 = (int)((minX - bmin[0])*ics); int x1 = (int)((maxX - bmin[0])*ics); - x0 = rcClamp(x0, 0, w-1); + if (x1 < 0 || x0 >= w) { + continue; + } + x0 = rcClamp(x0, -1, w-1); x1 = rcClamp(x1, 0, w-1); int nv, nv2 = nvrow; @@ -305,7 +309,7 @@ static bool rasterizeTri(const float* v0, const float* v1, const float* v2, dividePoly(inrow, nv2, p1, &nv, p2, &nv2, cx+cs, 0); rcSwap(inrow, p2); if (nv < 3) continue; - + if (x < 0) continue; // Calculate min and max of the span. float smin = p1[1], smax = p1[1]; for (int i = 1; i < nv; ++i) |