瀏覽代碼

Updated meshoptimizer.

Бранимир Караџић 5 年之前
父節點
當前提交
5a863ea47d
共有 2 個文件被更改,包括 6 次插入20 次删除
  1. 4 19
      3rdparty/meshoptimizer/src/simplifier.cpp
  2. 2 1
      3rdparty/meshoptimizer/src/vertexfilter.cpp

+ 4 - 19
3rdparty/meshoptimizer/src/simplifier.cpp

@@ -86,26 +86,10 @@ struct PositionHasher
 
 	size_t hash(unsigned int index) const
 	{
-		// MurmurHash2
-		const unsigned int m = 0x5bd1e995;
-		const int r = 24;
-
-		unsigned int h = 0;
 		const unsigned int* key = reinterpret_cast<const unsigned int*>(vertex_positions + index * vertex_stride_float);
 
-		for (size_t i = 0; i < 3; ++i)
-		{
-			unsigned int k = key[i];
-
-			k *= m;
-			k ^= k >> r;
-			k *= m;
-
-			h *= m;
-			h ^= k;
-		}
-
-		return h;
+		// Optimized Spatial Hashing for Collision Detection of Deformable Objects
+		return (key[0] * 73856093) ^ (key[1] * 19349663) ^ (key[2] * 83492791);
 	}
 
 	bool equal(unsigned int lhs, unsigned int rhs) const
@@ -421,7 +405,8 @@ struct Collapse
 	unsigned int v0;
 	unsigned int v1;
 
-	union {
+	union
+	{
 		unsigned int bidi;
 		float error;
 		unsigned int errorui;

+ 2 - 1
3rdparty/meshoptimizer/src/vertexfilter.cpp

@@ -143,7 +143,8 @@ static void decodeFilterExp(unsigned int* data, size_t count)
 		int m = int(v << 8) >> 8;
 		int e = int(v) >> 24;
 
-		union {
+		union
+		{
 			float f;
 			unsigned int ui;
 		} u;