BVB Source Codes

CRYENGINE Show FeatureMotion.h Source code

Return Download CRYENGINE: download FeatureMotion.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #pragma once
  4.  
  5. #include "ParticleSystem/ParticleFeature.h"
  6. #include "ParamMod.h"
  7.  
  8. namespace pfx2
  9. {
  10.  
  11. class  CFeatureCollision;
  12. struct IFeatureMotion;
  13.  
  14. struct ILocalEffector : public _i_reference_target_t
  15. {
  16. public:
  17.         bool         IsEnabled() const { return m_enabled; }
  18.         virtual void AddToMotionFeature(CParticleComponent* pComponent, IFeatureMotion* pFeature) = 0;
  19.         virtual void ComputeEffector(const SUpdateContext& context, IOVec3Stream localVelocities, IOVec3Stream localAccelerations) {}
  20.         virtual void ComputeMove(const SUpdateContext& context, IOVec3Stream localMoves, float fTime) {}
  21.         virtual void Serialize(Serialization::IArchive& ar);
  22.         virtual void SetParameters(gpu_pfx2::IParticleFeatureGpuInterface* gpuInterface) const {}
  23. private:
  24.         SEnable m_enabled;
  25. };
  26.  
  27. struct IFeatureMotion
  28. {
  29.         virtual void AddToComputeList(ILocalEffector* pEffector) = 0;
  30.         virtual void AddToMoveList(ILocalEffector* pEffector) = 0;
  31. };
  32.  
  33. //////////////////////////////////////////////////////////////////////////
  34.  
  35. enum EIntegrator
  36. {
  37.         EI_Linear,
  38.         EI_DragFast,
  39. };
  40.  
  41. class CFeatureMotionPhysics : public CParticleFeature, public IFeatureMotion
  42. {
  43. private:
  44.         typedef _smart_ptr<ILocalEffector> PLocalEffector;
  45.  
  46. public:
  47.         CRY_PFX2_DECLARE_FEATURE
  48.  
  49.         CFeatureMotionPhysics();
  50.  
  51.         // CParticleFeature
  52.         virtual EFeatureType GetFeatureType() override { return EFT_Motion; }
  53.         virtual void         AddToComponent(CParticleComponent* pComponent, SComponentParams* pParams) override;
  54.  
  55.         virtual void Serialize(Serialization::IArchive& ar) override;
  56.         virtual void InitParticles(const SUpdateContext& context) override;
  57.         virtual void Update(const SUpdateContext& context) override;
  58.         // ~CParticleFeature
  59.  
  60.         // IFeatureMotion
  61.         virtual void AddToComputeList(ILocalEffector* pEffector) override;
  62.         virtual void AddToMoveList(ILocalEffector* pEffector) override;
  63.         // ~IFeatureMotion
  64.  
  65. private:
  66.         void Integrate(const SUpdateContext& context);
  67.         void LinearSimpleIntegral(const SUpdateContext& context);
  68.         void LinearDragFastIntegral(const SUpdateContext& context);
  69.         void AngularSimpleIntegral(const SUpdateContext& context);
  70.         void AngularDragFastIntegral(const SUpdateContext& context);
  71.         void ProcessCollisions(const SUpdateContext& context);
  72.         void CollisionResponse(const SUpdateContext& context);
  73.  
  74.         std::vector<PLocalEffector>          m_localEffectors;
  75.         std::vector<ILocalEffector*>         m_computeList;
  76.         std::vector<ILocalEffector*>         m_moveList;
  77.         CParamMod<SModParticleField, SFloat> m_gravity;
  78.         CParamMod<SModParticleField, UFloat> m_drag;
  79.         CFeatureCollision*                   m_pCollisionFeature;
  80.         Vec3        m_uniformAcceleration;
  81.         Vec3        m_uniformWind;
  82.         UFloat      m_windMultiplier;
  83.         UFloat      m_angularDragMultiplier;
  84.         EIntegrator m_linearIntegrator;
  85.         EIntegrator m_angularIntegrator;
  86. };
  87.  
  88. //////////////////////////////////////////////////////////////////////////
  89.  
  90. class CFeatureMotionCryPhysics : public CParticleFeature
  91. {
  92. public:
  93.         CRY_PFX2_DECLARE_FEATURE
  94.  
  95.         CFeatureMotionCryPhysics();
  96.  
  97.         virtual EFeatureType GetFeatureType() override { return EFT_Motion; }
  98.  
  99.         virtual void AddToComponent(CParticleComponent* pComponent, SComponentParams* pParams) override;
  100.         virtual void Serialize(Serialization::IArchive& ar) override;
  101.         virtual void PostInitParticles(const SUpdateContext& context) override;
  102.         virtual void Update(const SUpdateContext& context) override;
  103.  
  104. private:
  105.         string m_surfaceTypeName;
  106.         SFloat m_gravity;
  107.         UFloat m_drag;
  108.         SFloat m_density;
  109.         SFloat m_thickness;
  110.         Vec3   m_uniformAcceleration;
  111. };
  112.  
  113. extern EParticleDataType
  114.   EPVF_Acceleration,
  115.   EPVF_VelocityField;
  116.  
  117. }
  118.  
downloadFeatureMotion.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