Skip to content

Fix RenderingServer::mesh_surface_get_lods() #107985

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

Merged
merged 1 commit into from
Jun 25, 2025

Conversation

simpkins
Copy link
Contributor

@simpkins simpkins commented Jun 25, 2025

This function was incorrectly using the surface number to index into the LOD indices vector. This resulted in just returning the same index over and over again. In theory if you had a mesh with more surfaces than one of its LOD vectors it could read pass the end of the LOD index array.

The SoftBody3D code creates a new ArrayMesh by duplicating the input mesh, and uses mesh_surface_get_lods() to duplicate the LODs. The broken behavior here results in SoftBody3D creating broken meshes that render nothing due to each LOD just using a single vertex. This commit fixes SoftBody3D to now work correctly with meshes with LODs.

Fixes #107984.
bugsquad edit: Fixes #98915

This function was incorrectly using the surface number to index into the
LOD indices vector.  This resulted in just returning the same index over
and over again.  In theory if you had a mesh with more surfaces than one
of its LOD vectors it could read pass the end of the LOD index array.

The SoftBody3D code creates a new ArrayMesh by duplicating the input
mesh, and uses `mesh_surface_get_lods()` to duplicate the LODs.  The
broken behavior here results in SoftBody3D creating broken meshes that
render nothing due to each LOD just using a single vertex.  This commit
fixes SoftBody3D to now work correctly with meshes with LODs.

Fixes godotengine#107984.
@simpkins simpkins requested a review from a team as a code owner June 25, 2025 17:40
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

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

Wow! Good find

@clayjohn clayjohn added bug topic:rendering topic:3d cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release labels Jun 25, 2025
@clayjohn clayjohn added this to the 4.5 milestone Jun 25, 2025
@akien-mga akien-mga changed the title Fix RenderingServer::mesh_surface_get_lods() Fix RenderingServer::mesh_surface_get_lods() Jun 25, 2025
@Repiteo Repiteo merged commit 6af3aa5 into godotengine:master Jun 25, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jun 25, 2025

Thanks! Congratulations on your first merged contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release topic:rendering topic:3d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ArrayMesh::surface_get_lods() returns invalid data Heap buffer overflow in RenderingServer::mesh_surface_get_lods
3 participants