BVB Source Codes

CRYENGINE Show ParticleDataStreamsImpl.h Source code

Return Download CRYENGINE: download ParticleDataStreamsImpl.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifdef CRY_PFX2_USE_SSE
  4. template<> ILINE pfx2::UColv convert<pfx2::UColv>(UCol v) { return _mm_set1_epi32(v.dcolor); }
  5. #endif
  6.  
  7. namespace pfx2
  8. {
  9.  
  10. //////////////////////////////////////////////////////////////////////////
  11. // TIStream
  12.  
  13. template<typename T, typename Tv>
  14. ILINE TIStream<T, Tv>::TIStream(const T* pStream, T defaultVal)
  15.         : m_safeSink(convert<Tv>(defaultVal))
  16.         , m_pStream(pStream ? pStream : reinterpret_cast<T*>(&m_safeSink))
  17.         , m_safeMask(pStream ? ~0 : 0)
  18. {
  19. }
  20.  
  21. template<typename T, typename Tv>
  22. ILINE T TIStream<T, Tv >::Load(TParticleId pId) const
  23. {
  24.         return *(m_pStream + pId);
  25. }
  26.  
  27. template<typename T, typename Tv>
  28. ILINE T TIStream<T, Tv >::Load(TParticleId pId, T defaultVal) const
  29. {
  30.         return (pId != gInvalidId) ? *(m_pStream + pId) : defaultVal;
  31. }
  32.  
  33. template<typename T, typename Tv>
  34. ILINE T TIStream<T, Tv >::SafeLoad(TParticleId pId) const
  35. {
  36.         return *(m_pStream + (pId & m_safeMask));
  37. }
  38.  
  39. template<typename T, typename Tv>
  40. ILINE void TIOStream<T, Tv >::Store(TParticleId pId, T value)
  41. {
  42.         *(const_cast<T*>(m_pStream) + pId) = value;
  43. }
  44.  
  45. //////////////////////////////////////////////////////////////////////////
  46.  
  47. ILINE IVec3Stream::IVec3Stream(const float* pX, const float* pY, const float* pZ, Vec3 defaultVal)
  48.         : m_safeSink(ToFloatv(defaultVal.x), ToFloatv(defaultVal.y), ToFloatv(defaultVal.z))
  49.         , m_pXStream((pX && pY && pZ) ? pX : (float*)&m_safeSink.x)
  50.         , m_pYStream((pX && pY && pZ) ? pY : (float*)&m_safeSink.y)
  51.         , m_pZStream((pX && pY && pZ) ? pZ : (float*)&m_safeSink.z)
  52.         , m_safeMask((pX && pY && pZ) ? ~0 : 0)
  53. {
  54. }
  55.  
  56. ILINE Vec3 IVec3Stream::Load(TParticleId pId) const
  57. {
  58.         return Vec3(*(m_pXStream + pId), *(m_pYStream + pId), *(m_pZStream + pId));
  59. }
  60.  
  61. ILINE Vec3 IVec3Stream::SafeLoad(TParticleId pId) const
  62. {
  63.         return Vec3(
  64.                 *(m_pXStream + (pId & m_safeMask)),
  65.                 *(m_pYStream + (pId & m_safeMask)),
  66.                 *(m_pZStream + (pId & m_safeMask)));
  67. }
  68.  
  69. ILINE void IOVec3Stream::Store(TParticleId pId, Vec3 value)
  70. {
  71.         *(const_cast<float*>(m_pXStream) + pId) = value.x;
  72.         *(const_cast<float*>(m_pYStream) + pId) = value.y;
  73.         *(const_cast<float*>(m_pZStream) + pId) = value.z;
  74. }
  75.  
  76. ILINE IQuatStream::IQuatStream(const float* pX, const float* pY, const float* pZ, const float* pW, Quat defaultVal)
  77.         : m_safeSink(defaultVal)
  78.         , m_pXStream((pX && pY && pZ && pW) ? pX : (float*)&m_safeSink.v.x)
  79.         , m_pYStream((pX && pY && pZ && pW) ? pY : (float*)&m_safeSink.v.y)
  80.         , m_pZStream((pX && pY && pZ && pW) ? pZ : (float*)&m_safeSink.v.z)
  81.         , m_pWStream((pX && pY && pZ && pW) ? pW : (float*)&m_safeSink.w)
  82.         , m_safeMask((pX && pY && pZ && pW) ? ~0 : 0)
  83. {
  84. }
  85.  
  86. ILINE Quat IQuatStream::Load(TParticleId pId) const
  87. {
  88.         return Quat(
  89.                 *(m_pWStream + pId),
  90.                 *(m_pXStream + pId),
  91.                 *(m_pYStream + pId),
  92.                 *(m_pZStream + pId));
  93. }
  94.  
  95. ILINE Quat IQuatStream::SafeLoad(TParticleId pId) const
  96. {
  97.         return Quat(
  98.                 *(m_pWStream + (pId & m_safeMask)),
  99.                 *(m_pXStream + (pId & m_safeMask)),
  100.                 *(m_pYStream + (pId & m_safeMask)),
  101.                 *(m_pZStream + (pId & m_safeMask)));
  102. }
  103.  
  104. ILINE void IOQuatStream::Store(TParticleId pId, Quat value)
  105. {
  106.         *(const_cast<float*>(m_pWStream) + pId) = value.w;
  107.         *(const_cast<float*>(m_pXStream) + pId) = value.v.x;
  108.         *(const_cast<float*>(m_pYStream) + pId) = value.v.y;
  109.         *(const_cast<float*>(m_pZStream) + pId) = value.v.z;
  110. }
  111.  
  112. //////////////////////////////////////////////////////////////////////////
  113.  
  114. ILINE STempVec3Stream::STempVec3Stream(TParticleHeap* pMemHeap, SUpdateRange range)
  115.         : m_xBuffer(*pMemHeap, range.m_lastParticleId - range.m_firstParticleId)
  116.         , m_yBuffer(*pMemHeap, range.m_lastParticleId - range.m_firstParticleId)
  117.         , m_zBuffer(*pMemHeap, range.m_lastParticleId - range.m_firstParticleId)
  118.         , m_stream(m_xBuffer.data() - range.m_firstParticleId, m_yBuffer.data() - range.m_firstParticleId, m_zBuffer.data() - range.m_firstParticleId)
  119. {
  120. }
  121.  
  122. ILINE void STempVec3Stream::Clear(SUpdateRange range)
  123. {
  124.         const uint numBytes = (range.m_lastParticleId - range.m_firstParticleId) * sizeof(float);
  125.         memset(m_xBuffer.data(), 0, numBytes);
  126.         memset(m_yBuffer.data(), 0, numBytes);
  127.         memset(m_zBuffer.data(), 0, numBytes);
  128. }
  129.  
  130. }
  131.  
  132. #ifdef CRY_PFX2_USE_SSE
  133.         #include "ParticleDataStreamsImplSSE.h"
  134. #endif
  135.  
downloadParticleDataStreamsImpl.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