IMNM.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #ifndef __IMNM_H__
  9. #define __IMNM_H__
  10. #pragma once
  11. #include <CryCommon/BaseTypes.h>
  12. namespace MNM
  13. {
  14. namespace Constants
  15. {
  16. enum Edges
  17. {
  18. InvalidEdgeIndex = ~0u
  19. };
  20. enum TileIdConstants
  21. {
  22. InvalidTileID = 0,
  23. };
  24. enum TriangleIDConstants
  25. {
  26. InvalidTriangleID = 0,
  27. };
  28. enum EStaticIsland
  29. {
  30. eStaticIsland_InvalidIslandID = 0,
  31. eStaticIsland_FirstValidIslandID = 1,
  32. };
  33. enum EGlobalIsland
  34. {
  35. eGlobalIsland_InvalidIslandID = 0,
  36. };
  37. enum EOffMeshLink
  38. {
  39. eOffMeshLinks_InvalidOffMeshLinkID = 0,
  40. };
  41. }
  42. // ------------------------------------------------------------------------------------------
  43. // Basic types used in the MNM namespace
  44. typedef uint32 TileID;
  45. typedef uint32 TriangleID;
  46. typedef uint32 OffMeshLinkID;
  47. // StaticIslandIDs identify triangles that are statically connected inside a mesh
  48. // and that are reachable without the use of any off mesh links.
  49. typedef uint32 StaticIslandID;
  50. // GlobalIslandIDs define IDs able to code and connect islands between meshes.
  51. struct GlobalIslandID
  52. {
  53. GlobalIslandID(const uint64 defaultValue = MNM::Constants::eGlobalIsland_InvalidIslandID)
  54. : id(defaultValue)
  55. {
  56. static_assert(sizeof(StaticIslandID) <= 4, "The maximum supported size for StaticIslandIDs is 4 bytes.");
  57. }
  58. GlobalIslandID(const uint32 navigationMeshID, const MNM::StaticIslandID islandID)
  59. {
  60. id = ((uint64)navigationMeshID << 32) | islandID;
  61. }
  62. GlobalIslandID operator=(const GlobalIslandID other)
  63. {
  64. id = other.id;
  65. return *this;
  66. }
  67. inline bool operator==(const GlobalIslandID& rhs) const
  68. {
  69. return id == rhs.id;
  70. }
  71. inline bool operator<(const GlobalIslandID& rhs) const
  72. {
  73. return id < rhs.id;
  74. }
  75. MNM::StaticIslandID GetStaticIslandID() const
  76. {
  77. return (MNM::StaticIslandID) (id & ((uint64)1 << 32) - 1);
  78. }
  79. uint32 GetNavigationMeshIDAsUint32() const
  80. {
  81. return static_cast<uint32>(id >> 32);
  82. }
  83. uint64 id;
  84. };
  85. }
  86. #endif // __IMNM_H__