Browse Source

Merge pull request #6365 from takahirox/FixColorHashCode

Fix getHashCode() of Colors
David Catuhe 6 năm trước cách đây
mục cha
commit
55a9caf042
1 tập tin đã thay đổi với 7 bổ sung7 xóa
  1. 7 7
      src/Maths/math.ts

+ 7 - 7
src/Maths/math.ts

@@ -65,9 +65,9 @@ export class Color3 {
      * @returns an unique number that can be used to hash Color3 objects
      */
     public getHashCode(): number {
-        let hash = this.r || 0;
-        hash = (hash * 397) ^ (this.g || 0);
-        hash = (hash * 397) ^ (this.b || 0);
+        let hash = (this.r * 255) || 0;
+        hash = (hash * 397) ^ ((this.g * 255) || 0);
+        hash = (hash * 397) ^ ((this.b * 255) || 0);
         return hash;
     }
 
@@ -779,10 +779,10 @@ export class Color4 {
      * @returns an unique number that can be used to hash Color4 objects
      */
     public getHashCode(): number {
-        let hash = this.r || 0;
-        hash = (hash * 397) ^ (this.g || 0);
-        hash = (hash * 397) ^ (this.b || 0);
-        hash = (hash * 397) ^ (this.a || 0);
+        let hash = (this.r * 255) || 0;
+        hash = (hash * 397) ^ ((this.g * 255) || 0);
+        hash = (hash * 397) ^ ((this.b * 255) || 0);
+        hash = (hash * 397) ^ ((this.a * 255) || 0);
         return hash;
     }