Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NavigationMeshInstance crash baking static colliders with PlaneShape and ConvexPolygon #65764

Closed
dweremeichik opened this issue Sep 14, 2022 · 3 comments · Fixed by #69189
Closed

Comments

@dweremeichik
Copy link

Godot version

v3.5.stable.official [991bb6a]

System information

Debian 11 (bullseye), OpenGL ES 3.0 Renderer: Mesa DRI Intel(R) HD Graphics 4400 (HSW GT2) Async. shader compilation: OFF

Issue description

Editor crash when attempting to bake a NavigationMeshInstance with Parsed Geometry (geometry_parsed_geometry_type) set to Static Colliders with a PlaneShape and ConvexPolygon as descendants.

================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v3.5.stable.official (991bb6ac74ac8c09d7683041b50a8ced3a2defb1)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x38d60) [0x7f25190f1d60] (??:0)
[2] godot() [0x11205ab] (??:0)
[3] godot() [0xfda0cb] (??:0)
[4] godot() [0xfdc752] (??:0)
[5] godot() [0xabffd9] (??:0)
[6] godot() [0x2e6fd89] (??:0)
[7] godot() [0x2e7b14a] (??:0)
[8] godot() [0x20012ea] (??:0)
[9] godot() [0x20025a0] (??:0)
[10] godot() [0x20028ee] (??:0)
[11] godot() [0x179c895] (??:0)
[12] godot() [0x2e6f937] (??:0)
[13] godot() [0x2015381] (??:0)
[14] godot() [0x201ba21] (??:0)
[15] godot() [0x201dd25] (??:0)
[16] godot() [0x201dffb] (??:0)
[17] godot() [0xd08ad5] (??:0)
[18] godot() [0x2e6fd89] (??:0)
[19] godot() [0x2e61cbe] (??:0)
[20] godot() [0x1fb1a5b] (??:0)
[21] godot() [0x1fca810] (??:0)
[22] godot() [0xa40c0b] (??:0)
[23] godot() [0xa41e59] (??:0)
[24] godot() [0xa46f74] (??:0)
[25] godot() [0xa015dc] (??:0)
[26] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xea) [0x7f25190dcd0a] (??:0)
[27] godot() [0xa13fde] (??:0)
-- END OF BACKTRACE --
================================================================

Steps to reproduce

Your best bet is to simply use the attached MRP, that being said:

Create this structure:
image

The first collision shape should be a PlaneShape.
MeshInstance2 is translated 1 unit in the Y direction.
The second collision shape is a ConvexPolygon and was generated from MeshInstance2; its settings look like:
image

(If you change the z value for any of the four points, the crash no longer occurs.)

Under NavigationMeshInstance create a NavMesh. Change Geoemtry -> Parsed Geometry to Static Colliders. Click Bake NavMesh. The crash should occur.

Minimal reproduction project

nav_bake_crash_mrp.zip

@timothyqiu
Copy link
Member

Probably related to recastnavigation/recastnavigation#514

@smix8
Copy link
Contributor

smix8 commented Sep 14, 2022

PlaneShape or even ConvexPolygon is not the problem here. The first is ignored by the parsing anyway as it is deprecated.

Rotating your shape even by 0.001 prevents the crash. It crashes because source geometry aligned 100% with the y-axis with no depth is invalid and it fails the ReCast span calculation. This is not specific to ConvexPolygon, it will happen with any other node type in Godot that allows to set the geometry depth to zero. Since Godot has no checks for this situation it adds the corrupted source geometry regardless which crashes ReCast that also has no check for it. What @timothyqiu linked prevents the crash on the ReCast side but it does not change the fact that this source geometry is illogical and should never be used in the first place.

grahamboree added a commit to grahamboree/recastnavigation that referenced this issue Nov 26, 2022
Specifically, when rasterizing a triangle into a heightfield with width or height of 0.  This can happen when the input geometry bounding box extents are less than half the cell size in either x or z.  This is a degenerate case, but can crop up in real life scenarios (see godotengine/godot#65764) so we should at least ensure it doesn't crash here.
@grahamboree
Copy link
Contributor

This can happen when the extent of the input geometry bounding box is less than half the CellSize. This generates a heightfield size of 0 on either the x or z axis, and causes Recast to crash.

Here's another sample project that causes a crash in the Recast code.
GodotRecastTest.zip

This has been fixed upstream in Recast as part of recastnavigation/recastnavigation@3901c58. I've submitted a PR (#69189) to update the Recast integration in Godot to fix this issue.

@akien-mga akien-mga added this to the 3.6 milestone Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants