Skip to content

Commit ad4dff7

Browse files
committed
Fix RenderingServer::mesh_surface_get_lods()
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.
1 parent 30456ba commit ad4dff7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

servers/rendering_server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ Dictionary RenderingServer::mesh_surface_get_lods(RID p_mesh, int p_surface) con
17311731
const uint16_t *rptr = (const uint16_t *)r;
17321732
int *w = lods.ptrw();
17331733
for (uint32_t j = 0; j < lc; j++) {
1734-
w[j] = rptr[i];
1734+
w[j] = rptr[j];
17351735
}
17361736
} else {
17371737
uint32_t lc = sd.lods[i].index_data.size() / 4;
@@ -1740,7 +1740,7 @@ Dictionary RenderingServer::mesh_surface_get_lods(RID p_mesh, int p_surface) con
17401740
const uint32_t *rptr = (const uint32_t *)r;
17411741
int *w = lods.ptrw();
17421742
for (uint32_t j = 0; j < lc; j++) {
1743-
w[j] = rptr[i];
1743+
w[j] = rptr[j];
17441744
}
17451745
}
17461746

0 commit comments

Comments
 (0)