SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.0 KiB

4 years ago
  1. using System.Collections.Generic;
  2. namespace UnityEngine.TestTools.Utils
  3. {
  4. public class Vector3EqualityComparer : IEqualityComparer<Vector3>
  5. {
  6. private const float k_DefaultError = 0.0001f;
  7. private readonly float AllowedError;
  8. private static readonly Vector3EqualityComparer m_Instance = new Vector3EqualityComparer();
  9. public static Vector3EqualityComparer Instance { get { return m_Instance; } }
  10. private Vector3EqualityComparer() : this(k_DefaultError) {}
  11. public Vector3EqualityComparer(float allowedError)
  12. {
  13. this.AllowedError = allowedError;
  14. }
  15. public bool Equals(Vector3 expected, Vector3 actual)
  16. {
  17. return Utils.AreFloatsEqual(expected.x, actual.x, AllowedError) &&
  18. Utils.AreFloatsEqual(expected.y, actual.y, AllowedError) &&
  19. Utils.AreFloatsEqual(expected.z, actual.z, AllowedError);
  20. }
  21. public int GetHashCode(Vector3 vec3)
  22. {
  23. return 0;
  24. }
  25. }
  26. }