BVB Source Codes

CRYENGINE Show ParticleContainerImpl.h Source code

Return Download CRYENGINE: download ParticleContainerImpl.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  Created:     21/10/2014 by Filipe amim
  5. //  Description:
  6. // -------------------------------------------------------------------------
  7. //
  8. ////////////////////////////////////////////////////////////////////////////
  9.  
  10. #ifndef PARTICLECONTAINERIMPL_H
  11. #define PARTICLECONTAINERIMPL_H
  12.  
  13. #pragma once
  14.  
  15. namespace pfx2
  16. {
  17.  
  18. //////////////////////////////////////////////////////////////////////////
  19. // CParticleContainer
  20.  
  21. ILINE TParticleId CParticleContainer::GetRealId(TParticleId pId) const
  22. {
  23.         if (pId < m_lastId)
  24.                 return pId;
  25.         const uint numSpawn = GetNumSpawnedParticles();
  26.         const uint gapSize = m_firstSpawnId - m_lastId;
  27.         const uint movingId = m_lastSpawnId - min(gapSize, numSpawn);
  28.         const uint offset = movingId - m_lastId;
  29.         if (pId >= movingId)
  30.                 return pId - offset;
  31.         return pId;
  32. }
  33.  
  34. template<typename T>
  35. ILINE void CParticleContainer::FillData(EParticleDataType type, const T& data, SUpdateRange range)
  36. {
  37.         // PFX2_TODO : the way it is, this function cannot be vectorized
  38.         CRY_PFX2_ASSERT(type.info().isType<T>());
  39.         if (HasData(type))
  40.         {
  41.                 uint dim = type.info().dimension;
  42.                 for (uint i = 0; i < dim; ++i)
  43.                 {
  44.                         T* pBuffer = GetData<T>(type + i);
  45.                         CRY_PFX2_FOR_RANGE_PARTICLES(range)
  46.                         {
  47.                                 pBuffer[particleId] = data;
  48.                         }
  49.                         CRY_PFX2_FOR_END;
  50.                 }
  51.         }
  52. }
  53.  
  54. ILINE void CParticleContainer::CopyData(EParticleDataType dstType, EParticleDataType srcType, SUpdateRange range)
  55. {
  56.         CRY_PFX2_ASSERT(dstType.info().type == srcType.info().type);
  57.         if (HasData(dstType) && HasData(srcType))
  58.         {
  59.                 size_t stride = dstType.info().typeSize();
  60.                 size_t count = range.m_lastParticleId - range.m_firstParticleId;
  61.                 uint dim = dstType.info().dimension;
  62.                 for (uint i = 0; i < dim; ++i)
  63.                         memcpy(
  64.                           (byte*)m_pData[dstType + i] + stride * range.m_firstParticleId,
  65.                           (byte*)m_pData[srcType + i] + stride * range.m_firstParticleId,
  66.                           stride * count);
  67.         }
  68. }
  69.  
  70. ILINE IFStream CParticleContainer::GetIFStream(EParticleDataType type, float defaultVal) const
  71. {
  72.         return IFStream(GetData<float>(type), defaultVal);
  73. }
  74.  
  75. ILINE IOFStream CParticleContainer::GetIOFStream(EParticleDataType type)
  76. {
  77.         return IOFStream(GetData<float>(type));
  78. }
  79.  
  80. ILINE IVec3Stream CParticleContainer::GetIVec3Stream(EParticleDataType type, Vec3 defaultVal) const
  81. {
  82.         CRY_PFX2_ASSERT(type.info().isType<float>(3));
  83.         return IVec3Stream(
  84.           GetData<float>(type),
  85.           GetData<float>(type + 1u),
  86.           GetData<float>(type + 2u),
  87.           defaultVal);
  88. }
  89.  
  90. ILINE IOVec3Stream CParticleContainer::GetIOVec3Stream(EParticleDataType type)
  91. {
  92.         CRY_PFX2_ASSERT(type.info().isType<float>(3));
  93.         return IOVec3Stream(
  94.           GetData<float>(type),
  95.           GetData<float>(type + 1u),
  96.           GetData<float>(type + 2u));
  97. }
  98.  
  99. ILINE IQuatStream CParticleContainer::GetIQuatStream(EParticleDataType type, Quat defaultVal) const
  100. {
  101.         CRY_PFX2_ASSERT(type.info().isType<float>(4));
  102.         return IQuatStream(
  103.           GetData<float>(type),
  104.           GetData<float>(type + 1u),
  105.           GetData<float>(type + 2u),
  106.           GetData<float>(type + 3u),
  107.           defaultVal);
  108. }
  109. ILINE IOQuatStream CParticleContainer::GetIOQuatStream(EParticleDataType type)
  110. {
  111.         CRY_PFX2_ASSERT(type.info().isType<float>(4));
  112.         return IOQuatStream(
  113.           GetData<float>(type),
  114.           GetData<float>(type + 1u),
  115.           GetData<float>(type + 2u),
  116.           GetData<float>(type + 3u));
  117. }
  118.  
  119. ILINE IColorStream CParticleContainer::GetIColorStream(EParticleDataType type) const
  120. {
  121.         return IColorStream(GetData<UCol>(type));
  122. }
  123.  
  124. ILINE IOColorStream CParticleContainer::GetIOColorStream(EParticleDataType type)
  125. {
  126.         return IOColorStream(GetData<UCol>(type));
  127. }
  128.  
  129. ILINE IUintStream CParticleContainer::GetIUintStream(EParticleDataType type, uint32 defaultVal) const
  130. {
  131.         return IUintStream(GetData<uint>(type));
  132. }
  133.  
  134. ILINE IOUintStream CParticleContainer::GetIOUintStream(EParticleDataType type)
  135. {
  136.         return IOUintStream(GetData<uint>(type));
  137. }
  138.  
  139. ILINE IPidStream CParticleContainer::GetIPidStream(EParticleDataType type, TParticleId defaultVal) const
  140. {
  141.         return IPidStream(GetData<TParticleId>(type));
  142. }
  143.  
  144. ILINE IOPidStream CParticleContainer::GetIOPidStream(EParticleDataType type)
  145. {
  146.         return IOPidStream(GetData<TParticleId>(type));
  147. }
  148.  
  149. template<typename T>
  150. ILINE TIStream<T> CParticleContainer::GetTIStream(EParticleDataType type, const T& defaultVal) const
  151. {
  152.         return TIStream<T>(GetData<T>(type));
  153. }
  154.  
  155. template<typename T>
  156. ILINE TIOStream<T> CParticleContainer::GetTIOStream(EParticleDataType type)
  157. {
  158.         return TIOStream<T>(GetData<T>(type));
  159. }
  160.  
  161. ILINE SUpdateRange CParticleContainer::GetFullRange() const
  162. {
  163.         SUpdateRange range;
  164.         range.m_firstParticleId = 0;
  165.         range.m_lastParticleId = GetLastParticleId();
  166.         return range;
  167. }
  168.  
  169. ILINE SUpdateRange CParticleContainer::GetSpawnedRange() const
  170. {
  171.         SUpdateRange range;
  172.         range.m_firstParticleId = GetFirstSpawnParticleId();
  173.         range.m_lastParticleId = GetLastParticleId();
  174.         return range;
  175. }
  176.  
  177. }
  178.  
  179. #endif
  180.  
downloadParticleContainerImpl.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