BVB Source Codes

CRYENGINE Show ParticleDataStreams.h Source code

Return Download CRYENGINE: download ParticleDataStreams.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 "ParticleMath.h"
  6.  
  7. namespace pfx2
  8. {
  9.  
  10. #ifdef CRY_PFX2_USE_SSE
  11.   #define CRY_PFX2_PARTICLESGROUP_STRIDE 4 // can be 8 for AVX or 64 forGPU
  12. #else
  13.   #define CRY_PFX2_PARTICLESGROUP_STRIDE 1
  14. #endif
  15. #define CRY_PFX2_PARTICLESGROUP_LOWER(id) ((id) & ~((CRY_PFX2_PARTICLESGROUP_STRIDE - 1)))
  16. #define CRY_PFX2_PARTICLESGROUP_UPPER(id) ((id) | ((CRY_PFX2_PARTICLESGROUP_STRIDE - 1)))
  17.  
  18. //////////////////////////////////////////////////////////////////////////
  19. // TIStream
  20.  
  21. template<typename T, typename Tv = T>
  22. struct TIStream
  23. {
  24. public:
  25.         explicit TIStream(const T* pStream = nullptr, T defaultVal = T());
  26.         bool IsValid() const { return m_safeMask != 0; }
  27.         T    Load(TParticleId pId) const;
  28.         T    Load(TParticleId pId, T defaultVal) const;
  29.         T    SafeLoad(TParticleId pId) const;
  30. #ifdef CRY_PFX2_USE_SSE
  31.         Tv   Load(TParticleGroupId pgId) const;
  32.         Tv   Load(TParticleIdv pIdv, T defaultVal) const;
  33.         Tv   SafeLoad(TParticleGroupId pId) const;
  34. #endif
  35. protected:
  36.         const T* __restrict m_pStream;
  37.         Tv                  m_safeSink;
  38.         uint32              m_safeMask;
  39. };
  40.  
  41. template<typename T, typename Tv = T>
  42. struct TIOStream : public TIStream<T, Tv>
  43. {
  44. private:
  45.         using TIStream<T, Tv>::m_pStream;
  46. public:
  47.         explicit TIOStream(const T* pStream = nullptr, T defaultVal = T()) : TIStream<T, Tv>(pStream, defaultVal) {}
  48.         void Store(TParticleId pId, T value);
  49. #ifdef CRY_PFX2_USE_SSE
  50.         void Store(TParticleGroupId pgId, Tv value);
  51. #endif
  52. };
  53.  
  54. typedef TIStream<float, floatv>             IFStream;
  55. typedef TIOStream<float, floatv>            IOFStream;
  56. typedef TIStream<UCol, UColv>               IColorStream;
  57. typedef TIOStream<UCol, UColv>              IOColorStream;
  58. typedef TIStream<uint32, uint32v>           IUintStream;
  59. typedef TIOStream<uint32>                   IOUintStream;
  60. typedef TIStream<TParticleId, TParticleIdv> IPidStream;
  61. typedef TIOStream<TParticleId>              IOPidStream;
  62.  
  63. //////////////////////////////////////////////////////////////////////////
  64.  
  65. struct IVec3Stream
  66. {
  67. public:
  68.         IVec3Stream(const float* pX, const float* pY, const float* pZ, Vec3 defaultVal = Vec3());
  69.         Vec3  Load(TParticleId pId) const;
  70.         Vec3  SafeLoad(TParticleId pId) const;
  71. #ifdef CRY_PFX2_USE_SSE
  72.         Vec3v Load(TParticleGroupId pgId) const;
  73.         Vec3v Load(TParticleIdv pIdv, Vec3 defaultVal = Vec3(ZERO)) const;
  74.         Vec3v SafeLoad(TParticleGroupId pgId) const;
  75. #endif
  76. protected:
  77.         const Vec3v             m_safeSink;
  78.         const float* __restrict m_pXStream;
  79.         const float* __restrict m_pYStream;
  80.         const float* __restrict m_pZStream;
  81.         const uint32            m_safeMask;
  82. };
  83.  
  84. struct IOVec3Stream : public IVec3Stream
  85. {
  86. public:
  87.         IOVec3Stream(float* pX, float* pY, float* pZ, Vec3 defaultVal = Vec3()) : IVec3Stream(pX, pY, pZ, defaultVal) {}
  88.         void  Store(TParticleId pId, Vec3 value);
  89. #ifdef CRY_PFX2_USE_SSE
  90.         void  Store(TParticleGroupId pgId, const Vec3v& value) const;
  91. #endif
  92. };
  93.  
  94. struct IQuatStream
  95. {
  96. public:
  97.         IQuatStream(const float* pX, const float* pY, const float* pZ, const float* pW, Quat defaultVal = Quat());
  98.         Quat  Load(TParticleId pId) const;
  99.         Quat  SafeLoad(TParticleId pId) const;
  100. #ifdef CRY_PFX2_USE_SSE
  101.         Quatv Load(TParticleGroupId pgId) const;
  102.         Quatv Load(TParticleIdv pIdv, Quat defaultVal = Quat(IDENTITY)) const;
  103.         Quatv SafeLoad(TParticleGroupId pgId) const;
  104. #endif
  105. protected:
  106.         const Quat              m_safeSink;
  107.         const float* __restrict m_pXStream;
  108.         const float* __restrict m_pYStream;
  109.         const float* __restrict m_pZStream;
  110.         const float* __restrict m_pWStream;
  111.         const uint32            m_safeMask;
  112. };
  113.  
  114. struct IOQuatStream : public IQuatStream
  115. {
  116. public:
  117.         IOQuatStream(float* pX, float* pY, float* pZ, float* pW, Quat defaultVal = Quat()) : IQuatStream(pX, pY, pZ, pW, defaultVal) {}
  118.         void  Store(TParticleId pId, Quat value);
  119. #ifdef CRY_PFX2_USE_SSE
  120.         void  Store(TParticleGroupId pgId, const Quatv& value) const;
  121. #endif
  122. };
  123.  
  124. //////////////////////////////////////////////////////////////////////////
  125.  
  126. struct STempVec3Stream
  127. {
  128. public:
  129.         STempVec3Stream(TParticleHeap* pMemHeap, SUpdateRange range);
  130.         void Clear(SUpdateRange context);
  131.         IOVec3Stream GetIOVec3Stream() const { return m_stream; }
  132. private:
  133.         TFloatArray  m_xBuffer;
  134.         TFloatArray  m_yBuffer;
  135.         TFloatArray  m_zBuffer;
  136.         IOVec3Stream m_stream;
  137. };
  138.  
  139. }
  140.  
  141. #include "ParticleDataStreamsImpl.h"
  142.  
downloadParticleDataStreams.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