From 454116716e7934f6bd80d7040a2c06a7c18d4c64 Mon Sep 17 00:00:00 2001 From: ueshita Date: Tue, 22 Nov 2022 00:09:48 +0900 Subject: [PATCH] Fix some switching decisions for index format. --- servers/rendering_server.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 6cb1684baf5..9551b983fc8 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -625,7 +625,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint const int *src = indices.ptr(); for (int i = 0; i < p_index_array_len; i++) { - if (p_vertex_array_len < (1 << 16) && p_vertex_array_len > 0) { + if (p_vertex_array_len <= (1 << 16) && p_vertex_array_len > 0) { uint16_t v = src[i]; memcpy(&iw[i * 2], &v, 2); @@ -835,10 +835,10 @@ void RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_format, i break; } /* determine whether using 16 or 32 bits indices */ - if (p_vertex_len >= (1 << 16) || p_vertex_len == 0) { - elem_size = 4; - } else { + if (p_vertex_len <= (1 << 16) && p_vertex_len > 0) { elem_size = 2; + } else { + elem_size = 4; } r_offsets[i] = elem_size; continue; @@ -1280,7 +1280,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector arr; arr.resize(p_index_len); - if (p_vertex_len < (1 << 16)) { + if (p_vertex_len <= (1 << 16)) { int *w = arr.ptrw(); for (int j = 0; j < p_index_len; j++) {