Merge pull request #68997 from ueshita/fix_verts_65536

Fix some switching decisions for index format. (vertex length 65536)
This commit is contained in:
Rémi Verschelde 2022-11-22 21:37:17 +01:00
commit 834c7ff2c0
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 5 additions and 5 deletions

View File

@ -625,7 +625,7 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
const int *src = indices.ptr(); const int *src = indices.ptr();
for (int i = 0; i < p_index_array_len; i++) { 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]; uint16_t v = src[i];
memcpy(&iw[i * 2], &v, 2); memcpy(&iw[i * 2], &v, 2);
@ -835,10 +835,10 @@ void RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_format, i
break; break;
} }
/* determine whether using 16 or 32 bits indices */ /* determine whether using 16 or 32 bits indices */
if (p_vertex_len >= (1 << 16) || p_vertex_len == 0) { if (p_vertex_len <= (1 << 16) && p_vertex_len > 0) {
elem_size = 4;
} else {
elem_size = 2; elem_size = 2;
} else {
elem_size = 4;
} }
r_offsets[i] = elem_size; r_offsets[i] = elem_size;
continue; continue;
@ -1280,7 +1280,7 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
Vector<int> arr; Vector<int> arr;
arr.resize(p_index_len); arr.resize(p_index_len);
if (p_vertex_len < (1 << 16)) { if (p_vertex_len <= (1 << 16)) {
int *w = arr.ptrw(); int *w = arr.ptrw();
for (int j = 0; j < p_index_len; j++) { for (int j = 0; j < p_index_len; j++) {