BVB Source Codes

CRYENGINE Show Shape2.h Source code

Return Download CRYENGINE: download Shape2.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /********************************************************************
  4.    -------------------------------------------------------------------------
  5.    File name:   Shape2.h
  6.    $Id$
  7.    Description: Temp file holding code extracted from CAISystem.h/cpp
  8.  
  9.    -------------------------------------------------------------------------
  10.    History:
  11.  
  12.  *********************************************************************/
  13.  
  14. #ifndef _SHAPE2_H_
  15. #define _SHAPE2_H_
  16.  
  17. class CShapeMask
  18. {
  19. public:
  20.         CShapeMask();
  21.         ~CShapeMask();
  22.  
  23.         /// Builds this mask according to pShape down to the granularity
  24.         void Build(const struct SShape* pShape, float granularity);
  25.  
  26.         /// categorisation of a point according to this mask
  27.         enum EType {TYPE_IN, TYPE_EDGE, TYPE_OUT};
  28.         EType  GetType(const Vec3 pt) const;
  29.  
  30.         size_t MemStats() const;
  31. private:
  32.         /// used just during building
  33.         EType GetType(const struct SShape* pShape, const Vec3& min, const Vec3& max) const;
  34.         /// gets the min/max values of the 2D box indicated by i and j
  35.         void  GetBox(Vec3& min, Vec3& max, int i, int j);
  36.         AABB     m_aabb;
  37.         unsigned m_nx, m_ny;
  38.         float    m_dx, m_dy; // number of pixels
  39.  
  40.         // container bit-pair is indexed by x + y * m_bytesPerRow
  41.         unsigned   m_bytesPerRow;
  42.         typedef std::vector<unsigned char> TContainer;
  43.         TContainer m_container;
  44. };
  45.  
  46. struct SShape
  47. {
  48.         SShape();
  49.  
  50.         explicit SShape(
  51.           const ListPositions& shape_
  52.           , const AABB& aabb_
  53.           , IAISystem::ENavigationType navType = IAISystem::NAV_UNSET
  54.           , int type = 0
  55.           , bool closed_ = false
  56.           , float height_ = 0.0f
  57.           , EAILightLevel lightLevel_ = AILL_NONE
  58.           , bool temp = false
  59.           );
  60.  
  61.         explicit SShape(
  62.           const ListPositions& shape_
  63.           , bool allowMask = false
  64.           , IAISystem::ENavigationType navType_ = IAISystem::NAV_UNSET
  65.           , int type_ = 0
  66.           , bool closed_ = false
  67.           , float height_ = 0.0f
  68.           , EAILightLevel lightLevel_ = AILL_NONE
  69.           , bool temp = false);
  70.  
  71.         ~SShape();
  72.  
  73.         void RecalcAABB();
  74.  
  75.         /// Builds a mask with a specified granularity
  76.         void BuildMask(float granularity);
  77.  
  78.         void ReleaseMask();
  79.  
  80.         // offsets this shape(called when segmented world shifts)
  81.         void                          OffsetShape(const Vec3& offset);
  82.  
  83.         ListPositions::const_iterator NearestPointOnPath(const Vec3& pos, bool forceLoop, float& dist, Vec3& nearestPt, float* distAlongPath = 0,
  84.                                                          Vec3* segmentDir = 0, uint32* segmentStartIndex = 0, float* pathLength = 0, float* segmentFraction = 0) const;
  85.  
  86.         // Populate an array with intersection distances
  87.         // Can combine with IsPointInsideShape to establish entry/exit where appropriate
  88.         // If testHeight is true, will take the height of sides into account
  89.         // If testTopBottom is true, will test for intersection on top and bottom sides of a closed shape
  90.         int    GetIntersectionDistances(const Vec3& start, const Vec3& end, float intersectDistArray[], int maxIntersections, bool testHeight = false, bool testTopBottom = false) const;
  91.  
  92.         Vec3   GetPointAlongPath(float dist) const;
  93.  
  94.         bool   IsPointInsideShape(const Vec3& pos, bool checkHeight) const;
  95.  
  96.         bool   ConstrainPointInsideShape(Vec3& pos, bool checkHeight) const;
  97.  
  98.         size_t MemStats() const;
  99.  
  100.         ListPositions              shape;       /// Points describing the shape.
  101.         AABB                       aabb;        /// Bounding box of the shape points.
  102.         IAISystem::ENavigationType navType;     /// Navigation type associated with AIPaths
  103.         int                        type;        /// AIobject/anchor type associated with an AIshape
  104.         float                      height;      /// Height of the shape. The shape volume is described as [aabb.minz, aabb.minz+height]
  105.         float                      devalueTime; /// Timeout for occupied AIpaths
  106.         bool                       temporary;   /// Flag indicating if the path is temporary and should be deleted upon reset.
  107.         bool                       enabled;     /// Flag indicating if the shape is enabled. Disabled shapes are excluded from queries.
  108.         EAILightLevel              lightLevel;  /// The light level modifier of the shape.
  109.         bool                       closed;      /// Flag indicating if the shape is a closed volume
  110.         class ShapeMaskPtr
  111.         {
  112.         public:
  113.                 ShapeMaskPtr(CShapeMask* ptr = 0) : m_p(ptr) {}
  114.                 ShapeMaskPtr(const ShapeMaskPtr& other) : m_p(0) { if (other.m_p) { m_p = new CShapeMask; * m_p = *other.m_p; } }
  115.                 ~ShapeMaskPtr() { SAFE_DELETE(m_p); }
  116.                 CShapeMask*       operator->()       { return m_p; }
  117.                 const CShapeMask* operator->() const { return m_p; }
  118.                 CShapeMask&       operator*()        { return *m_p; }
  119.                 const CShapeMask& operator*() const  { return *m_p; }
  120.                 operator CShapeMask*() { return m_p; }
  121.                 CShapeMask*       Get()              { return m_p; }
  122.                 const CShapeMask* Get() const        { return m_p; }
  123.         private:
  124.                 CShapeMask*       m_p;
  125.         };
  126.         ShapeMaskPtr shapeMask;             /// Optional mask for this shape that speeds up 2D in/out/edge tests
  127. };
  128.  
  129. typedef std::map<string, SShape> ShapeMap;
  130.  
  131. struct SPerceptionModifierShape : SShape
  132. {
  133.         SPerceptionModifierShape(const ListPositions& shape, float reductionPerMetre, float reductionMax, float fHeight, bool isClosed);
  134.  
  135.         float fReductionPerMetre;
  136.         float fReductionMax;
  137. };
  138.  
  139. typedef std::map<string, SPerceptionModifierShape> PerceptionModifierShapeMap;
  140.  
  141. #endif
  142.  
downloadShape2.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