BVB Source Codes

CRYENGINE Show ParticleCommon.h Source code

Return Download CRYENGINE: download ParticleCommon.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  Created:     06/04/2014 by Filipe amim
  5. //  Description:
  6. // -------------------------------------------------------------------------
  7. //
  8. ////////////////////////////////////////////////////////////////////////////
  9.  
  10. #ifndef PARTICLECOMMON_H
  11. #define PARTICLECOMMON_H
  12.  
  13. #pragma once
  14.  
  15. #include <CryParticleSystem/IParticlesPfx2.h>
  16. #include <CryRenderer/RenderElements/CREParticle.h>
  17.  
  18. // compile options
  19. // #define CRY_DEBUG_PARTICLE_SYSTEM                            // enable debugging on all particle source code
  20. // #define CRY_PFX1_BAIL_UNSUPPORTED            // disable pfx1 features that not yet supported by pfx2 for precision profiling
  21. // #define CRY_PFX2_LOAD_PRIORITY                                       // when trying to load a pfx1 effect, try to load pfx2 effect with the same name first
  22. #define CRY_PFX2_PROFILE_DETAILS // more in detail profile of pfx2. Individual features and sub update parts will appear here.
  23. // ~compile options
  24.  
  25. #if defined(CRY_DEBUG_PARTICLE_SYSTEM) && CRY_PLATFORM_WINDOWS
  26.         #define CRY_PFX2_DBG          \
  27.           __pragma(optimize("", off)) \
  28.           __pragma(inline_depth(0))
  29. #else
  30.         #define CRY_PFX2_DBG
  31. #endif
  32. #
  33. #ifndef _RELEASE
  34.         #define CRY_PFX2_ASSERT(cond) { CRY_ASSERT(cond); }
  35. #else
  36.         #define CRY_PFX2_ASSERT(cond)
  37. #endif
  38. #
  39. #ifdef CRY_PFX2_PROFILE_DETAILS
  40.         #define CRY_PFX2_PROFILE_DETAIL FUNCTION_PROFILER(GetISystem(), PROFILE_PARTICLE);
  41. #else
  42.         #define CRY_PFX2_PROFILE_DETAIL
  43. #endif
  44.  
  45. #define CRY_PFX2_PARTICLES_ALIGNMENT 16
  46.  
  47. #if (CRY_PLATFORM_WINDOWS || CRY_PLATFORM_LINUX || CRY_PLATFORM_DURANGO || CRY_PLATFORM_ORBIS || CRY_PLATFORM_APPLE) && !CRY_PLATFORM_NEON
  48.         #define CRY_PFX2_USE_SSE
  49.         #if (CRY_PLATFORM_DURANGO || CRY_PLATFORM_ORBIS)
  50.                 #define CRY_PFX2_USE_SEE4
  51.         #endif
  52. #endif
  53. #if CRY_PLATFORM_X86
  54.         #undef CRY_PFX2_USE_SSE // limited code generation in x86, disabling SSE entirely for now.
  55.         #// msvc x86 only supports up to 3 arguments by copy of type __m128. More than that will require
  56.         #// references. That makes it incompatible with Vec4_tpl.
  57. #endif
  58.  
  59. namespace pfx2
  60. {
  61.  
  62. const uint gMinimumVersion = 1;
  63. const uint gCurrentVersion = 9;
  64.  
  65. class CParticleSystem;
  66. class CParticleEffect;
  67. class CParticleComponent;
  68. class CParticleFeature;
  69.  
  70. class CParticleEmitter;
  71. class CParticleComponentRuntime;
  72.  
  73. struct SComponentParams;
  74.  
  75. typedef _smart_ptr<CParticleFeature> TParticleFeaturePtr;
  76.  
  77. typedef uint32                       TInstanceDataOffset;
  78. const TParticleId gInvalidId = -1;
  79. const float gInfinity = std::numeric_limits<float>::infinity();
  80.  
  81. typedef stl::HeapAllocator<stl::PSyncNone>                                    TParticleHeap;
  82. typedef TParticleHeap::Array<TParticleId, uint, CRY_PFX2_PARTICLES_ALIGNMENT> TParticleIdArray;
  83. typedef TParticleHeap::Array<float, uint, CRY_PFX2_PARTICLES_ALIGNMENT>       TFloatArray;
  84.  
  85. #ifdef CRY_PFX2_USE_SSE
  86.  
  87. struct TParticleGroupId
  88. {
  89. public:
  90.         TParticleGroupId() {}
  91.         TParticleGroupId(uint32 i) { id = i; }
  92.         TParticleGroupId&                 operator=(uint32 i)                                            { id = i; return *this; }
  93.         friend bool                       operator<(const TParticleGroupId a, const TParticleGroupId b)  { return a.id < b.id; }
  94.         friend bool                       operator<=(const TParticleGroupId a, const TParticleGroupId b) { return a.id <= b.id; }
  95.         friend bool                       operator>=(const TParticleGroupId a, const TParticleGroupId b) { return a.id >= b.id; }
  96.         friend bool                       operator==(const TParticleGroupId a, const TParticleGroupId b) { return a.id == b.id; }
  97.         TParticleGroupId&                 operator++()                                                   { ++id; return *this; }
  98.         TParticleGroupId                  operator++(int)                                                { id++; return *this; }
  99.         TParticleGroupId&                 operator+=(int stride)                                         { id += stride; return *this; }
  100.         template<class type> friend type* operator+(type* ptr, TParticleGroupId id)                      { return ptr + id.id; }
  101.         friend TParticleGroupId           operator&(TParticleGroupId id, uint32 mask)                    { return TParticleGroupId(id.id & mask); }
  102.         uint32                            Get() const                                                    { return id; }
  103. private:
  104.         uint32 id;
  105. };
  106.  
  107. #else
  108.  
  109. typedef TParticleId TParticleGroupId;
  110.  
  111. #endif
  112.  
  113. struct SRenderContext
  114. {
  115.         SRenderContext(const SRendParams& rParams, const SRenderingPassInfo& passInfo)
  116.                 : m_renderParams(rParams)
  117.                 , m_passInfo(passInfo)
  118.                 , m_distance(0.0f)
  119.                 , m_lightVolumeId(0)
  120.                 , m_fogVolumeId(0) {}
  121.         const SRendParams&        m_renderParams;
  122.         const SRenderingPassInfo& m_passInfo;
  123.         float                     m_distance;
  124.         uint16                    m_lightVolumeId;
  125.         uint16                    m_fogVolumeId;
  126. };
  127.  
  128. struct SUpdateRange
  129. {
  130.         explicit SUpdateRange(TParticleId firstParticleId = 0, TParticleId lastParticleId = 0)
  131.                 : m_firstParticleId(firstParticleId)
  132.                 , m_lastParticleId(lastParticleId) {}
  133.         TParticleId m_firstParticleId;
  134.         TParticleId m_lastParticleId;
  135. };
  136.  
  137. enum EFeatureType
  138. {
  139.         EFT_Generic = 0x0,        // this feature does nothing in particular. Can have many of this per component.
  140.         EFT_Spawn   = BIT(0),     // this feature is capable of spawning particles. At least one is needed in a component.
  141.         EFT_Size    = BIT(2),     // this feature changes particles sizes. At least one is required per component.
  142.         EFT_Life    = BIT(3),     // this feature changes particles life time. At least one is required per component.
  143.         EFT_Render  = BIT(4),     // this feature renders particles. Each component can only have either none or just one of this.
  144.         EFT_Motion  = BIT(5),     // this feature moved particles around. Each component can only have either none or just one of this.
  145. };
  146.  
  147. }
  148.  
  149. #endif // PARTICLECOMMON_H
  150.  
downloadParticleCommon.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