diff options
author | K. S. Ernest (iFire) Lee <fire@users.noreply.github.com> | 2021-05-29 17:35:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-29 17:35:03 -0700 |
commit | da12086ceb21454aa505847ce4c3c1478c5a4ea6 (patch) | |
tree | 2341d7b9b95a180f322225be1ef78c80e5f9a4fc /thirdparty | |
parent | b63f9b59615a4a63f1a45564d78243a2929c3c03 (diff) | |
parent | 9f37456743ab2e859d86d7988e419fa622422fb3 (diff) |
Merge pull request #49197 from HaSa1002/sync-meshopt
Meshoptimizer: Sync with upstream commit f5d83e8
Diffstat (limited to 'thirdparty')
-rw-r--r-- | thirdparty/README.md | 2 | ||||
-rw-r--r-- | thirdparty/meshoptimizer/simplifier.cpp | 16 |
2 files changed, 12 insertions, 6 deletions
diff --git a/thirdparty/README.md b/thirdparty/README.md index d3599fd195..1500e8d656 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -367,7 +367,7 @@ File extracted from upstream release tarball: ## meshoptimizer - Upstream: https://github.com/zeux/meshoptimizer -- Version: 0.16 (95893c0566646434dd675b708d293fcb2d526d08, 2021) +- Version: git (f5d83e879c48f8664783a69b4f50711d27549b66, 2021) - License: MIT Files extracted from upstream repository: diff --git a/thirdparty/meshoptimizer/simplifier.cpp b/thirdparty/meshoptimizer/simplifier.cpp index 059cabb055..0f10ebef4b 100644 --- a/thirdparty/meshoptimizer/simplifier.cpp +++ b/thirdparty/meshoptimizer/simplifier.cpp @@ -120,8 +120,13 @@ struct PositionHasher { const unsigned int* key = reinterpret_cast<const unsigned int*>(vertex_positions + index * vertex_stride_float); + // scramble bits to make sure that integer coordinates have entropy in lower bits + unsigned int x = key[0] ^ (key[0] >> 17); + unsigned int y = key[1] ^ (key[1] >> 17); + unsigned int z = key[2] ^ (key[2] >> 17); + // Optimized Spatial Hashing for Collision Detection of Deformable Objects - return (key[0] * 73856093) ^ (key[1] * 19349663) ^ (key[2] * 83492791); + return (x * 73856093) ^ (y * 19349663) ^ (z * 83492791); } bool equal(unsigned int lhs, unsigned int rhs) const @@ -1160,7 +1165,7 @@ struct IdHasher struct TriangleHasher { - unsigned int* indices; + const unsigned int* indices; size_t hash(unsigned int i) const { @@ -1375,9 +1380,10 @@ static float interpolate(float y, float x0, float y0, float x1, float y1, float } // namespace meshopt #ifndef NDEBUG -unsigned char* meshopt_simplifyDebugKind = 0; -unsigned int* meshopt_simplifyDebugLoop = 0; -unsigned int* meshopt_simplifyDebugLoopBack = 0; +// Note: this is only exposed for debug visualization purposes; do *not* use these in debug builds +MESHOPTIMIZER_API unsigned char* meshopt_simplifyDebugKind = 0; +MESHOPTIMIZER_API unsigned int* meshopt_simplifyDebugLoop = 0; +MESHOPTIMIZER_API unsigned int* meshopt_simplifyDebugLoopBack = 0; #endif size_t meshopt_simplify(unsigned int* destination, const unsigned int* indices, size_t index_count, const float* vertex_positions_data, size_t vertex_count, size_t vertex_positions_stride, size_t target_index_count, float target_error, float* out_result_error) |