BVB Source Codes

CRYENGINE Show Tile.h Source code

Return Download CRYENGINE: download Tile.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __MNM_TILE_H
  4. #define __MNM_TILE_H
  5.  
  6. #pragma once
  7.  
  8. #include <CryAISystem/NavigationSystem/MNMTile.h>
  9.  
  10. #include "MNM.h"
  11.  
  12. namespace MNM
  13. {
  14. struct STile
  15. {
  16.         // #MNM_TODO pavloi 2016.07.22: CNavMesh is friend for time being, so I don't have to fix data access in lot's of places right now.
  17.         friend class CNavMesh;
  18.  
  19.         STile();
  20.  
  21.         const Tile::STriangle* GetTriangles() const      { return triangles; }
  22.         const Tile::Vertex*    GetVertices() const       { return vertices; }
  23.         const Tile::SLink*     GetLinks() const          { return links; }
  24.         const Tile::SBVNode*   GetBVNodes() const        { return nodes; }
  25.  
  26.         uint16                 GetTrianglesCount() const { return triangleCount; }
  27.         uint16                 GetVerticesCount() const  { return vertexCount; }
  28.         uint16                 GetLinksCount() const     { return linkCount; }
  29.         uint16                 GetBVNodesCount() const   { return nodeCount; }
  30.  
  31.         uint32                 GetHashValue() const      { return hashValue; }
  32.  
  33.         void                   GetTileData(Tile::STileData& outTileData) const;
  34.  
  35.         void                   SetTriangles(std::unique_ptr<Tile::STriangle[]>&& pTriangles, uint16 count);
  36.         void                   SetVertices(std::unique_ptr<Tile::Vertex[]>&& pVertices, uint16 count);
  37.         void                   SetNodes(std::unique_ptr<Tile::SBVNode[]>&& pNodes, uint16 count);
  38.         void                   SetLinks(std::unique_ptr<Tile::SLink[]>&& pLinks, uint16 count);
  39.  
  40.         void                   SetHashValue(uint32 value);
  41.  
  42.         void                   CopyTriangles(const Tile::STriangle* triangles, uint16 count);
  43.         void                   CopyVertices(const Tile::Vertex* vertices, uint16 count);
  44.         void                   CopyNodes(const Tile::SBVNode* nodes, uint16 count);
  45.         void                   CopyLinks(const Tile::SLink* links, uint16 count);
  46.  
  47.         void                   AddOffMeshLink(const TriangleID triangleID, const uint16 offMeshIndex);
  48.         void                   UpdateOffMeshLink(const TriangleID triangleID, const uint16 offMeshIndex);
  49.         void                   RemoveOffMeshLink(const TriangleID triangleID);
  50.  
  51.         void                   Swap(STile& other);
  52.         void                   Destroy();
  53.  
  54.         vector3_t::value_type  GetTriangleArea(const TriangleID triangleID) const;
  55.  
  56. #if MNM_USE_EXPORT_INFORMATION
  57.         void        ResetConnectivity(uint8 accessible);
  58.         inline bool IsTriangleAccessible(const uint16 triangleIdx) const
  59.         {
  60.                 assert((triangleIdx >= 0) && (triangleIdx < connectivity.triangleCount));
  61.                 return (connectivity.trianglesAccessible[triangleIdx] != 0);
  62.         }
  63.         inline bool IsTileAccessible() const
  64.         {
  65.                 return (connectivity.tileAccessible != 0);
  66.         }
  67.  
  68.         inline void SetTriangleAccessible(const uint16 triangleIdx)
  69.         {
  70.                 assert((triangleIdx >= 0) && (triangleIdx < connectivity.triangleCount));
  71.  
  72.                 connectivity.tileAccessible = 1;
  73.                 connectivity.trianglesAccessible[triangleIdx] = 1;
  74.         }
  75. #endif
  76.  
  77.         enum DrawFlags
  78.         {
  79.                 DrawTriangles         = BIT(0),
  80.                 DrawInternalLinks     = BIT(1),
  81.                 DrawExternalLinks     = BIT(2),
  82.                 DrawOffMeshLinks      = BIT(3),
  83.                 DrawMeshBoundaries    = BIT(4),
  84.                 DrawBVTree            = BIT(5),
  85.                 DrawAccessibility     = BIT(6),
  86.                 DrawTrianglesId       = BIT(7),
  87.                 DrawIslandsId         = BIT(8),
  88.                 DrawTriangleBackfaces = BIT(9),
  89.                 DrawAll               = ~0ul,
  90.         };
  91.  
  92.         void Draw(size_t drawFlags, vector3_t origin, TileID tileID, const std::vector<float>& islandAreas) const;
  93.  
  94. #if DEBUG_MNM_DATA_CONSISTENCY_ENABLED
  95.         void ValidateTriangles() const;
  96. #else
  97.         void ValidateTriangles() const {}
  98. #endif // DEBUG_MNM_DATA_CONSISTENCY_ENABLED
  99.  
  100. #if DEBUG_MNM_DATA_CONSISTENCY_ENABLED
  101. private:
  102.         void ValidateTriangleLinks();
  103. #endif
  104.  
  105. private:
  106.  
  107.         // #MNM_TODO pavloi 2016.07.26: consider replacing with unique_ptr.
  108.         // Needs changes in TileContainerArray - it expects STile to be POD without destructor, so it can just memcpy it.
  109.         Tile::STriangle* triangles;
  110.         Tile::Vertex*    vertices;
  111.         Tile::SBVNode*   nodes;
  112.         Tile::SLink*     links;
  113.  
  114.         uint16           triangleCount;
  115.         uint16           vertexCount;
  116.         uint16           nodeCount;
  117.         uint16           linkCount;
  118.  
  119.         uint32           hashValue;
  120.  
  121. #if MNM_USE_EXPORT_INFORMATION
  122.  
  123. private:
  124.         struct TileConnectivity
  125.         {
  126.                 TileConnectivity()
  127.                         : tileAccessible(1)
  128.                         , trianglesAccessible(NULL)
  129.                         , triangleCount(0)
  130.                 {
  131.                 }
  132.  
  133.                 uint8  tileAccessible;
  134.                 uint8* trianglesAccessible;
  135.                 uint16 triangleCount;
  136.         };
  137.  
  138.         bool ConsiderExportInformation() const;
  139.         void InitConnectivity(uint16 oldTriangleCount, uint16 newTriangleCount);
  140.  
  141.         TileConnectivity connectivity;
  142.  
  143. #endif
  144. };
  145. }
  146.  
  147. #if DEBUG_MNM_DATA_CONSISTENCY_ENABLED
  148. struct CompareLink
  149. {
  150.         CompareLink(const MNM::Tile::SLink& link)
  151.         {
  152.                 m_link.edge = link.edge;
  153.                 m_link.side = link.side;
  154.                 m_link.triangle = link.triangle;
  155.         }
  156.  
  157.         bool operator()(const MNM::Tile::SLink& other)
  158.         {
  159.                 return m_link.edge == other.edge && m_link.side == other.side && m_link.triangle == other.triangle;
  160.         }
  161.  
  162.         MNM::Tile::SLink m_link;
  163. };
  164.  
  165. inline void BreakOnMultipleAdjacencyLinkage(const MNM::Tile::SLink* start, const MNM::Tile::SLink* end, const MNM::Tile::SLink& linkToTest)
  166. {
  167.         if (std::count_if(start, end, CompareLink(linkToTest)) > 1)
  168.                 __debugbreak();
  169. }
  170. #else
  171. inline void BreakOnMultipleAdjacencyLinkage(const MNM::Tile::SLink* start, const MNM::Tile::SLink* end, const MNM::Tile::SLink& linkToTest)
  172. {
  173.  
  174. }
  175. #endif
  176.  
  177. #endif  // #ifndef __MNM_TILE_H
  178.  
downloadTile.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top