BVB Source Codes

CRYENGINE Show TargetTrackCommon.cpp Source code

Return Download CRYENGINE: download TargetTrackCommon.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. /*************************************************************************
  4.    -------------------------------------------------------------------------
  5.    $Id$
  6.    $DateTime$
  7.    Description: Defines common helpers for the Target Track system
  8.  
  9.    -------------------------------------------------------------------------
  10.    History:
  11.    - 02:01:2010: Created by Kevin Kirst
  12.  
  13. *************************************************************************/
  14.  
  15. #include "StdAfx.h"
  16. #include "TargetTrackCommon.h"
  17.  
  18. namespace TargetTrackHelpers
  19. {
  20. const float STargetTrackStimulusConfig::INVALID_VALUE = 0.0f;
  21.  
  22. //////////////////////////////////////////////////////////////////////////
  23. SEnvelopeData::SEnvelopeData()
  24.         : m_fCurrentValue(0.0f)
  25.         , m_fStartTime(0.0f)
  26.         , m_fLastInvokeTime(0.0f)
  27.         , m_fLastRunningValue(0.0f)
  28.         , m_fLastReleasingValue(0.0f)
  29.         , m_bReinvoked(false)
  30. {
  31.  
  32. }
  33.  
  34. //////////////////////////////////////////////////////////////////////////
  35. STargetTrackStimulusEvent::STargetTrackStimulusEvent(tAIObjectID ownerId)
  36.         : m_vTargetPos(ZERO)
  37.         , m_ownerId(ownerId)
  38.         , m_targetId(0)
  39.         , m_eTargetThreat(AITHREAT_AGGRESSIVE)
  40.         , m_eStimulusType(eEST_Generic)
  41. {
  42.         assert(m_ownerId > 0);
  43. }
  44.  
  45. //////////////////////////////////////////////////////////////////////////
  46. STargetTrackStimulusEvent::STargetTrackStimulusEvent(tAIObjectID ownerId, tAIObjectID targetId, const char* szStimulusName, const SStimulusEvent& eventInfo)
  47.         : m_sStimulusName(szStimulusName)
  48.         , m_vTargetPos(eventInfo.vPos)
  49.         , m_ownerId(ownerId)
  50.         , m_targetId(targetId)
  51.         , m_eTargetThreat(eventInfo.eTargetThreat)
  52.         , m_eStimulusType(eventInfo.eStimulusType)
  53. {
  54.         assert(m_ownerId > 0);
  55.         assert(szStimulusName && szStimulusName[0]);
  56. }
  57.  
  58. //////////////////////////////////////////////////////////////////////////
  59. STargetTrackPulseConfig::STargetTrackPulseConfig()
  60.         : m_fValue(0.0f)
  61.         , m_fDuration(0.0f)
  62.         , m_bInherited(false)
  63. {
  64.  
  65. }
  66.  
  67. //////////////////////////////////////////////////////////////////////////
  68. STargetTrackPulseConfig::STargetTrackPulseConfig(const char* szPulse, float fValue, float fDuration)
  69.         : m_sPulse(szPulse)
  70.         , m_fValue(fValue)
  71.         , m_fDuration(fDuration)
  72.         , m_bInherited(false)
  73. {
  74.         assert(szPulse && szPulse[0]);
  75. }
  76.  
  77. //////////////////////////////////////////////////////////////////////////
  78. STargetTrackPulseConfig::STargetTrackPulseConfig(const STargetTrackPulseConfig& other, bool bInherited /*= false*/)
  79.         : m_sPulse(other.m_sPulse)
  80.         , m_fValue(other.m_fValue)
  81.         , m_fDuration(other.m_fDuration)
  82.         , m_bInherited(false)
  83. {
  84.         m_bInherited = (bInherited || other.m_bInherited);
  85. }
  86.  
  87. //////////////////////////////////////////////////////////////////////////
  88. STargetTrackModifierConfig::STargetTrackModifierConfig()
  89.         : m_uId(0)
  90.         , m_fValue(1.0f)
  91.         , m_fLimit(0.0f)
  92.         , m_bInherited(false)
  93. {
  94.  
  95. }
  96.  
  97. //////////////////////////////////////////////////////////////////////////
  98. STargetTrackModifierConfig::STargetTrackModifierConfig(uint32 uId, float fValue, float fLimit)
  99.         : m_uId(uId)
  100.         , m_fValue(fValue)
  101.         , m_fLimit(0.0f)
  102.         , m_bInherited(false)
  103. {
  104.         assert(m_uId > 0);
  105.  
  106.         m_fLimit = max(fLimit, 0.0f);
  107. }
  108.  
  109. //////////////////////////////////////////////////////////////////////////
  110. STargetTrackModifierConfig::STargetTrackModifierConfig(const STargetTrackModifierConfig& other, bool bInherited /*= false*/)
  111.         : m_uId(other.m_uId)
  112.         , m_fValue(other.m_fValue)
  113.         , m_fLimit(0.0f)
  114.         , m_bInherited(false)
  115. {
  116.         m_fLimit = max(other.m_fLimit, 0.0f);
  117.         m_bInherited = (bInherited || other.m_bInherited);
  118. }
  119.  
  120. //////////////////////////////////////////////////////////////////////////
  121. STargetTrackStimulusConfig::STargetTrackStimulusConfig()
  122.         : m_fPeak(0.0f)
  123.         , m_fAttack(INVALID_VALUE)
  124.         , m_fDecay(INVALID_VALUE)
  125.         , m_fSustainRatio(INVALID_VALUE)
  126.         , m_fRelease(INVALID_VALUE)
  127.         , m_fIgnore(INVALID_VALUE)
  128.         , m_bHostileOnly(false)
  129.         , m_ucInheritanceMask(0)
  130. {
  131.  
  132. }
  133.  
  134. //////////////////////////////////////////////////////////////////////////
  135. STargetTrackStimulusConfig::STargetTrackStimulusConfig(const char* szStimulus, bool bHostileOnly, float fPeak, float fSustainRatio, float fAttack, float fDecay, float fRelease, float fIgnore)
  136.         : m_sStimulus(szStimulus)
  137.         , m_bHostileOnly(bHostileOnly)
  138.         , m_ucInheritanceMask(0)
  139. {
  140.         assert(szStimulus && szStimulus[0]);
  141.  
  142.         m_fPeak = (fPeak > FLT_EPSILON ? fPeak : INVALID_VALUE);
  143.         m_fAttack = (fAttack > FLT_EPSILON ? fAttack : INVALID_VALUE);
  144.         m_fDecay = (fDecay > FLT_EPSILON ? fDecay : INVALID_VALUE);
  145.         m_fSustainRatio = (fSustainRatio > FLT_EPSILON ? fSustainRatio : INVALID_VALUE);
  146.         m_fRelease = (fRelease > FLT_EPSILON ? fRelease : INVALID_VALUE);
  147.         m_fIgnore = (fIgnore > FLT_EPSILON ? fIgnore : INVALID_VALUE);
  148. }
  149.  
  150. //////////////////////////////////////////////////////////////////////////
  151. STargetTrackStimulusConfig::STargetTrackStimulusConfig(const STargetTrackStimulusConfig& other, bool bInherited /*= false*/)
  152.         : m_sStimulus(other.m_sStimulus)
  153.         , m_fPeak(other.m_fPeak)
  154.         , m_fAttack(other.m_fAttack)
  155.         , m_fDecay(other.m_fDecay)
  156.         , m_fSustainRatio(other.m_fSustainRatio)
  157.         , m_fRelease(other.m_fRelease)
  158.         , m_fIgnore(other.m_fIgnore)
  159.         , m_bHostileOnly(other.m_bHostileOnly)
  160.         , m_ucInheritanceMask(other.m_ucInheritanceMask)
  161. {
  162.         m_pulses.clear();
  163.         m_pulses.reserve(other.m_pulses.size());
  164.         m_modifiers.clear();
  165.         m_modifiers.reserve(other.m_modifiers.size());
  166.         m_threatLevels.clear();
  167.         m_threatLevels.reserve(other.m_threatLevels.size());
  168.  
  169.         TPulseContainer::const_iterator itOtherPulse = other.m_pulses.begin();
  170.         TPulseContainer::const_iterator itOtherPulseEnd = other.m_pulses.end();
  171.         for (; itOtherPulse != itOtherPulseEnd; ++itOtherPulse)
  172.         {
  173.                 const uint32 uOtherPulseHash = itOtherPulse->first;
  174.                 const STargetTrackPulseConfig& otherPulse = itOtherPulse->second;
  175.  
  176.                 TPulseContainer::value_type pulsePair(uOtherPulseHash, TargetTrackHelpers::STargetTrackPulseConfig(otherPulse, bInherited));
  177.                 m_pulses.insert(pulsePair);
  178.         }
  179.  
  180.         TModifierContainer::const_iterator itOtherMod = other.m_modifiers.begin();
  181.         TModifierContainer::const_iterator itOtherModEnd = other.m_modifiers.end();
  182.         for (; itOtherMod != itOtherModEnd; ++itOtherMod)
  183.         {
  184.                 const STargetTrackModifierConfig& otherMod = itOtherMod->second;
  185.  
  186.                 TModifierContainer::value_type modPair(otherMod.m_uId, TargetTrackHelpers::STargetTrackModifierConfig(otherMod, bInherited));
  187.                 m_modifiers.insert(modPair);
  188.         }
  189.  
  190.         TThreatLevelContainer::const_iterator itOtherThreatLevel = other.m_threatLevels.begin();
  191.         TThreatLevelContainer::const_iterator itOtherThreatLevelEnd = other.m_threatLevels.end();
  192.         for (; itOtherThreatLevel != itOtherThreatLevelEnd; ++itOtherThreatLevel)
  193.         {
  194.                 TThreatLevelContainer::value_type threatPair(itOtherThreatLevel->first, itOtherThreatLevel->second);
  195.                 m_threatLevels.insert(threatPair);
  196.         }
  197. }
  198.  
  199. //////////////////////////////////////////////////////////////////////////
  200. STargetTrackConfig::STargetTrackConfig()
  201.         : m_bTemplateApplied(false)
  202. {
  203.  
  204. }
  205.  
  206. //////////////////////////////////////////////////////////////////////////
  207. STargetTrackConfig::STargetTrackConfig(const char* szName)
  208.         : m_sName(szName)
  209.         , m_bTemplateApplied(false)
  210. {
  211.         assert(szName && szName[0]);
  212. }
  213. }
  214.  
downloadTargetTrackCommon.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