From 618290ba46cc4aab68faa3d6a12969d3694219de Mon Sep 17 00:00:00 2001 From: Daniel Rakos Date: Sat, 12 Jan 2019 15:44:20 +0100 Subject: [PATCH] Mute errors on surface->index_array_len == 0 in the GLES3 renderer This error is generated whenever rendering collision debug meshes. There's no reason why this should be treated as an error as index-less meshes are supported and used across the engine. (cherry picked from commit 1dd98baaa65a204704e6fbb4e8d1e5cf97531a70) --- drivers/gles3/rasterizer_storage_gles3.cpp | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index b813fcf9d31..e17208c92ea 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -3771,28 +3771,30 @@ PoolVector RasterizerStorageGLES3::mesh_surface_get_index_array(RID p_m Surface *surface = mesh->surfaces[p_surface]; - ERR_FAIL_COND_V(surface->index_array_len == 0, PoolVector()); - PoolVector ret; ret.resize(surface->index_array_byte_size); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, surface->index_id); + + if (surface->index_array_byte_size > 0) { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, surface->index_id); #if defined(GLES_OVER_GL) || defined(__EMSCRIPTEN__) - { - PoolVector::Write w = ret.write(); - glGetBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, surface->index_array_byte_size, w.ptr()); - } + { + PoolVector::Write w = ret.write(); + glGetBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, surface->index_array_byte_size, w.ptr()); + } #else - void *data = glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, surface->index_array_byte_size, GL_MAP_READ_BIT); - ERR_FAIL_NULL_V(data, PoolVector()); - { - PoolVector::Write w = ret.write(); - copymem(w.ptr(), data, surface->index_array_byte_size); - } - glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); + void *data = glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, surface->index_array_byte_size, GL_MAP_READ_BIT); + ERR_FAIL_NULL_V(data, PoolVector()); + { + PoolVector::Write w = ret.write(); + copymem(w.ptr(), data, surface->index_array_byte_size); + } + glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); #endif - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + } + return ret; }