BVB Source Codes

CRYENGINE Show Range.cpp Source code

Return Download CRYENGINE: download Range.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /********************************************************************
  4.    ---------------------------------------------------------------------
  5.    File name:   Range.h
  6.    $Id$
  7.    $DateTime$
  8.    Description: Single Range donut
  9.    ---------------------------------------------------------------------
  10.    History:
  11.    - 24:08:2007 : Created by Ricardo Pillosu
  12.  
  13.  *********************************************************************/
  14. #include "StdAfx.h"
  15. #include "Range.h"
  16. #include "PersonalRangeSignaling.h"
  17.  
  18. // Description:
  19. //   Constructor
  20. // Arguments:
  21. //
  22. // Return:
  23. //
  24. CRange::CRange(CPersonalRangeSignaling* pPersonal) : m_pPersonal(pPersonal), m_fRadius(-1.0f), m_fBoundary(-1.0f), m_pSignalData(NULL)
  25. {
  26.         CRY_ASSERT(pPersonal != NULL);
  27. }
  28.  
  29. // Description:
  30. //   Destructor
  31. // Arguments:
  32. //
  33. // Return:
  34. //
  35. CRange::~CRange()
  36. {
  37.         if (gEnv->pAISystem)
  38.                 gEnv->pAISystem->FreeSignalExtraData(m_pSignalData);
  39. }
  40.  
  41. // Description:
  42. //   Constructor
  43. // Arguments:
  44. //
  45. // Return:
  46. //
  47. void CRange::Init(float fRadius, float fBoundary, const char* sSignal, IAISignalExtraData* pData /*= NULL*/)
  48. {
  49.         CRY_ASSERT(fRadius >= 1.0f);
  50.         CRY_ASSERT(fBoundary >= 0.0f);
  51.         CRY_ASSERT(sSignal != NULL);
  52.  
  53.         m_sSignal = sSignal;
  54.         m_fRadius = fRadius * fRadius;
  55.         m_fBoundary = fBoundary + fRadius;
  56.         m_fBoundary *= m_fBoundary;
  57.  
  58.         // Clone extra data
  59.         if (pData && gEnv->pAISystem)
  60.         {
  61.                 gEnv->pAISystem->FreeSignalExtraData(m_pSignalData);
  62.                 m_pSignalData = gEnv->pAISystem->CreateSignalExtraData();
  63.                 CRY_ASSERT(m_pSignalData);
  64.                 *m_pSignalData = *pData;
  65.         }
  66. }
  67.  
  68. // Description:
  69. //   Destructor
  70. // Arguments:
  71. //
  72. // Return:
  73. //
  74. bool CRange::IsInRange(const Vec3& vPos) const
  75. {
  76.         bool bResult = false;
  77.         IEntity* pEntity = m_pPersonal->GetEntity();
  78.         CRY_ASSERT(pEntity);
  79.         if (pEntity)
  80.         {
  81.                 Vec3 vOrigin = pEntity->GetPos();
  82.                 bResult = IsInRange((vPos - vOrigin).GetLengthSquared());
  83.         }
  84.         return bResult;
  85. }
  86.  
  87. // Description:
  88. //   Destructor
  89. // Arguments:
  90. //
  91. // Return:
  92. //
  93. bool CRange::IsInRangePlusBoundary(const Vec3& vPos) const
  94. {
  95.         bool bResult = false;
  96.         IEntity* pEntity = m_pPersonal->GetEntity();
  97.         CRY_ASSERT(pEntity);
  98.         if (pEntity)
  99.         {
  100.                 Vec3 vOrigin = pEntity->GetPos();
  101.                 bResult = IsInRangePlusBoundary((vPos - vOrigin).GetLengthSquared());
  102.         }
  103.         return bResult;
  104. }
  105.  
downloadRange.cpp 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