BVB Source Codes

CRYENGINE Show FeatureLife.cpp Source code

Return Download CRYENGINE: download FeatureLife.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  Created:     29/09/2014 by Filipe amim
  5. //  Description:
  6. // -------------------------------------------------------------------------
  7. //
  8. ////////////////////////////////////////////////////////////////////////////
  9.  
  10. #include "StdAfx.h"
  11. #include "ParticleSystem/ParticleFeature.h"
  12. #include "ParamMod.h"
  13. #include "FeatureCommon.h"
  14.  
  15. CRY_PFX2_DBG
  16.  
  17. namespace pfx2
  18. {
  19.  
  20. class CFeatureLifeTime : public CParticleFeature
  21. {
  22. public:
  23.         CRY_PFX2_DECLARE_FEATURE
  24.  
  25.         CFeatureLifeTime()
  26.                 : m_lifeTime(1.0f)
  27.                 , CParticleFeature(gpu_pfx2::eGpuFeatureType_LifeTime)
  28.         {}
  29.  
  30.         virtual EFeatureType GetFeatureType() override
  31.         {
  32.                 return EFT_Life;
  33.         }
  34.  
  35.         virtual void AddToComponent(CParticleComponent* pComponent, SComponentParams* pParams) override
  36.         {
  37.                 pParams->m_baseParticleLifeTime = m_lifeTime.GetBaseValue();
  38.                 m_lifeTime.AddToComponent(pComponent, this, EPDT_LifeTime);
  39.  
  40.                 if (auto pInt = GetGpuInterface())
  41.                 {
  42.                         gpu_pfx2::SFeatureParametersLifeTime params;
  43.                         params.lifeTime = m_lifeTime.GetBaseValue();
  44.                         pInt->SetParameters(params);
  45.                 }
  46.         }
  47.  
  48.         virtual void Serialize(Serialization::IArchive& ar) override
  49.         {
  50.                 CParticleFeature::Serialize(ar);
  51.                 ar(m_lifeTime, "LifeTime", "Life time");
  52.         }
  53.  
  54.         virtual void InitParticles(const SUpdateContext& context) override
  55.         {
  56.                 CRY_PFX2_PROFILE_DETAIL;
  57.  
  58.                 m_lifeTime.InitParticles(context, EPDT_LifeTime);
  59.         }
  60.  
  61. private:
  62.         CParamMod<SModParticleSpawnInit, UFloat10> m_lifeTime;
  63. };
  64.  
  65. CRY_PFX2_IMPLEMENT_FEATURE(CParticleFeature, CFeatureLifeTime, "Life", "Time", colorLife);
  66.  
  67. class CFeatureLifeImmortal : public CParticleFeature
  68. {
  69. public:
  70.         CRY_PFX2_DECLARE_FEATURE
  71.  
  72.         virtual EFeatureType GetFeatureType() override
  73.         {
  74.                 return EFT_Life;
  75.         }
  76.  
  77.         virtual void AddToComponent(CParticleComponent* pComponent, SComponentParams* pParams) override
  78.         {
  79.                 pParams->m_baseParticleLifeTime = gInfinity;
  80.                 pComponent->AddToUpdateList(EUL_InitUpdate, this);
  81.                 pComponent->AddToUpdateList(EUL_Update, this);
  82.         }
  83.  
  84.         virtual void Serialize(Serialization::IArchive& ar) override
  85.         {
  86.                 CParticleFeature::Serialize(ar);
  87.                 AddNoPropertiesLabel(ar);
  88.         }
  89.  
  90.         virtual void InitParticles(const SUpdateContext& context) override
  91.         {
  92.                 CRY_PFX2_PROFILE_DETAIL;
  93.  
  94.                 CParticleContainer& container = context.m_container;
  95.                 IOFStream lifeTimes = container.GetIOFStream(EPDT_LifeTime);
  96.  
  97.                 CRY_PFX2_FOR_SPAWNED_PARTICLEGROUP(context)
  98.                 lifeTimes.Store(particleGroupId, ToFloatv(0.0f));
  99.                 CRY_PFX2_FOR_END;
  100.         }
  101.  
  102.         virtual void Update(const SUpdateContext& context) override
  103.         {
  104.                 CRY_PFX2_PROFILE_DETAIL;
  105.                 KillOnParentDeath(context);
  106.         }
  107.  
  108. private:
  109. };
  110.  
  111. CRY_PFX2_IMPLEMENT_FEATURE(CParticleFeature, CFeatureLifeImmortal, "Life", "Immortal", colorLife);
  112.  
  113. }
  114.  
downloadFeatureLife.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