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

Clamp NavigationMesh sample_distance above zero #61061

Merged

Conversation

smix8
Copy link
Contributor

@smix8 smix8 commented May 15, 2022

Previously Godot would set all sample_distance values < 0.9 to 0 which causes the crashes. This pr limits the sample_distance range selection to 0.1 - 16.0 and also clamps sample_distance that are below 0.1 before ReCast receives them.

While default ReCast library has support for 0.0 and >= 0.9 'sample_distance' the Godot implementation does not for a zero value. In fact against the ReCast doc numbers below 0.9 also work in Godot. Godot was already using values as low as 0.01 on small grids cause the Godot implementation is multiplying the sample_distance with cell_size behind the scene and cell_size can get as low as 0.1 in value.

Fixes #38173

@Calinou Calinou added bug topic:editor crash cherrypick:3.x Considered for cherry-picking into a future 3.x release topic:navigation labels May 15, 2022
@Calinou Calinou added this to the 4.0 milestone May 15, 2022
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from my comment, makes sense to me.

While default ReCast library has support for 0.0 'sample_distance' the Godot implementation does not an crashes.
Previously Godot would set all sample_distance values below 0.9 to 0 which causes the crashes.

This limits the sample_distance range selection to 0.1 - 16.0 and also clamps sample_distance that are below 0.1 before ReCast receives them.
@smix8 smix8 force-pushed the navigation_mesh_sample_distance_range_4.x branch from abe236e to e33fa9d Compare May 16, 2022 12:25
@akien-mga akien-mga merged commit eaa4e86 into godotengine:master May 16, 2022
@akien-mga
Copy link
Member

Thanks!

@smix8 smix8 deleted the navigation_mesh_sample_distance_range_4.x branch May 16, 2022 14:05
@akien-mga
Copy link
Member

Cherry-picked for 3.5.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label May 16, 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 this pull request may close these issues.

Godot crash while generating the NavigationMeshInstance
3 participants