Godot Engine – Multi-platform 2D and 3D game engine
meshoptimizer: Update to 1.1.1
Jakub Marcowskif2b426969658
diff --git a/thirdparty/README.md b/thirdparty/README.mdindex 916fb2e0a70..e3d4af737b5 100644--- a/thirdparty/README.md+++ b/thirdparty/README.md@@ -720,7 +720,7 @@ Update instructions:## meshoptimizer- Upstream: https://github.com/zeux/meshoptimizer-- Version: 1.1 (dc9d09ed83e1004aef47a1c3c597e0ec64848a37, 2026)+- Version: 1.1.1 (b22872835dbabc56a6e4a366ea9917f62b7daf1a, 2026)- License: MITFiles extracted from upstream repository:diff --git a/thirdparty/meshoptimizer/allocator.cpp b/thirdparty/meshoptimizer/allocator.cppindex 6b6083da280..058fbf3129c 100644--- a/thirdparty/meshoptimizer/allocator.cpp+++ b/thirdparty/meshoptimizer/allocator.cpp@@ -1,6 +1,8 @@// This file is part of meshoptimizer library; see meshoptimizer.h for version/license details#include "meshoptimizer.h"+#include <assert.h>+#ifdef MESHOPTIMIZER_ALLOC_EXPORTmeshopt_Allocator::Storage& meshopt_Allocator::storage(){@@ -11,6 +13,8 @@ meshopt_Allocator::Storage& meshopt_Allocator::storage()void meshopt_setAllocator(void* (MESHOPTIMIZER_ALLOC_CALLCONV* allocate)(size_t), void (MESHOPTIMIZER_ALLOC_CALLCONV* deallocate)(void*)){+ assert(allocate && deallocate);+meshopt_Allocator::Storage& s = meshopt_Allocator::storage();s.allocate = allocate;s.deallocate = deallocate;diff --git a/thirdparty/meshoptimizer/meshletutils.cpp b/thirdparty/meshoptimizer/meshletutils.cppindex e91969e58c9..b92332addaf 100644--- a/thirdparty/meshoptimizer/meshletutils.cpp+++ b/thirdparty/meshoptimizer/meshletutils.cpp@@ -491,7 +491,7 @@ void meshopt_optimizeMeshletLevel(unsigned int* meshlet_vertices, size_t vertex_// if subsequent triangles don't share edges ca or bc, we can rotate the triangle to fix thisbool needab = false, needbc = false, needca = false;- for (size_t j = i + 1; j < triangle_count && j <= i + 3; ++j)+ for (size_t j = i + 1; j < triangle_count && j <= i + cache_cutoff; ++j){unsigned char oa = indices[j * 3 + 0], ob = indices[j * 3 + 1], oc = indices[j * 3 + 2];@@ -513,6 +513,12 @@ void meshopt_optimizeMeshletLevel(unsigned int* meshlet_vertices, size_t vertex_unsigned char t = c;c = b, b = a, a = t;}+ else if (!needab && needbc && !needca)+ {+ // abc -> cab: put bc at most recent FIFO position+ unsigned char t = c;+ c = b, b = a, a = t;+ }}indices[i * 3 + 0] = a, indices[i * 3 + 1] = b, indices[i * 3 + 2] = c;diff --git a/thirdparty/meshoptimizer/meshoptimizer.h b/thirdparty/meshoptimizer/meshoptimizer.hindex 7d951192b8a..da6acf06e17 100644--- a/thirdparty/meshoptimizer/meshoptimizer.h+++ b/thirdparty/meshoptimizer/meshoptimizer.h@@ -1215,7 +1215,7 @@ template <typename T>inline void meshopt_remapIndexBuffer(T* destination, const T* indices, size_t index_count, const unsigned int* remap){meshopt_IndexAdapter<T> in(NULL, indices, indices ? index_count : 0);- meshopt_IndexAdapter<T> out(destination, 0, index_count);+ meshopt_IndexAdapter<T> out(destination, NULL, index_count);meshopt_remapIndexBuffer(out.data, indices ? in.data : NULL, index_count, remap);}@@ -1263,7 +1263,7 @@ inline size_t meshopt_generateProvokingIndexBuffer(T* destination, unsigned int*meshopt_IndexAdapter<T> out(destination, NULL, index_count);size_t bound = vertex_count + (index_count / 3);- assert(size_t(T(bound - 1)) == bound - 1); // bound - 1 must fit in T+ assert(bound == 0 || size_t(T(bound - 1)) == bound - 1); // bound - 1 must fit in T(void)bound;return meshopt_generateProvokingIndexBuffer(out.data, reorder, in.data, index_count, vertex_count);@@ -1435,7 +1435,7 @@ template <typename T>inline size_t meshopt_unstripify(T* destination, const T* indices, size_t index_count, T restart_index){meshopt_IndexAdapter<T> in(NULL, indices, index_count);- meshopt_IndexAdapter<T> out(destination, NULL, (index_count - 2) * 3);+ meshopt_IndexAdapter<T> out(destination, NULL, index_count == 0 ? 0 : (index_count - 2) * 3);return meshopt_unstripify(out.data, in.data, index_count, unsigned(restart_index));}diff --git a/thirdparty/meshoptimizer/rasterizer.cpp b/thirdparty/meshoptimizer/rasterizer.cppindex bd788ffdb51..0e640bc0287 100644--- a/thirdparty/meshoptimizer/rasterizer.cpp+++ b/thirdparty/meshoptimizer/rasterizer.cpp@@ -172,7 +172,7 @@ static float transformTriangles(float* triangles, const unsigned int* indices, sextent = (maxv[1] - minv[1]) < extent ? extent : (maxv[1] - minv[1]);extent = (maxv[2] - minv[2]) < extent ? extent : (maxv[2] - minv[2]);- float scale = kViewport / extent;+ float scale = extent == 0.f ? 0.f : kViewport / extent;for (size_t i = 0; i < index_count; ++i){diff --git a/thirdparty/meshoptimizer/vertexcodec.cpp b/thirdparty/meshoptimizer/vertexcodec.cppindex 545ca90708a..dabf9854873 100644--- a/thirdparty/meshoptimizer/vertexcodec.cpp+++ b/thirdparty/meshoptimizer/vertexcodec.cpp@@ -1416,7 +1416,7 @@ inline v128_t unzigzag16(v128_t v)SIMD_TARGETinline v128_t rotate32(v128_t v, int r){- return wasm_v128_or(wasm_i32x4_shl(v, r), wasm_i32x4_shr(v, 32 - r));+ return wasm_v128_or(wasm_i32x4_shl(v, r), wasm_u32x4_shr(v, 32 - r));}#endif