Skip to content

Commit

Permalink
Merge pull request #80788 from AThousandShips/gl_multimesh
Browse files Browse the repository at this point in the history
Fix memory access error for `MultiMesh` with GLES3
  • Loading branch information
akien-mga committed Aug 21, 2023
2 parents 4bba963 + 6cb28e4 commit 4e8bfe6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/gles3/storage/mesh_storage.cpp
Expand Up @@ -1689,14 +1689,16 @@ void MeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_b
// Color and custom need to be packed so copy buffer to data_cache and pack.

_multimesh_make_local(multimesh);
multimesh->data_cache = p_buffer;

float *w = multimesh->data_cache.ptrw();
uint32_t old_stride = multimesh->xform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12;
old_stride += multimesh->uses_colors ? 4 : 0;
old_stride += multimesh->uses_custom_data ? 4 : 0;
ERR_FAIL_COND(p_buffer.size() != (multimesh->instances * (int)old_stride));

multimesh->data_cache = p_buffer;

float *w = multimesh->data_cache.ptrw();

for (int i = 0; i < multimesh->instances; i++) {
{
float *dataptr = w + i * old_stride;
Expand Down

0 comments on commit 4e8bfe6

Please sign in to comment.