Vertex.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Microsoft.Xna.Framework;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. namespace MonoGame.Extended.Triangulation
  6. {
  7. /// <summary>
  8. /// MIT Licensed: https://github.com/nickgravelyn/Triangulator
  9. /// </summary>
  10. struct Vertex
  11. {
  12. public readonly Vector2 Position;
  13. public readonly int Index;
  14. public Vertex(Vector2 position, int index)
  15. {
  16. Position = position;
  17. Index = index;
  18. }
  19. public override bool Equals(object obj)
  20. {
  21. if (obj.GetType() != typeof(Vertex))
  22. return false;
  23. return Equals((Vertex)obj);
  24. }
  25. public bool Equals(Vertex obj)
  26. {
  27. return obj.Position.Equals(Position) && obj.Index == Index;
  28. }
  29. public override int GetHashCode()
  30. {
  31. unchecked
  32. {
  33. return (Position.GetHashCode() * 397) ^ Index;
  34. }
  35. }
  36. public override string ToString()
  37. {
  38. return string.Format("{0} ({1})", Position, Index);
  39. }
  40. }
  41. }