BVB Source Codes

CRYENGINE Show ParticleUtils.h Source code

Return Download CRYENGINE: download ParticleUtils.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   ParticleUtils.h
  5. //  Version:     v1.00
  6. //  Created:     11/03/2010 by Corey (split out from other files).
  7. //  Compilers:   Visual Studio.NET
  8. //  Description: Splitting out some of the particle specific containers to here.
  9. //                                                       Will be moved to a proper home eventually.
  10. // -------------------------------------------------------------------------
  11. //  History:
  12. //
  13. ////////////////////////////////////////////////////////////////////////////
  14.  
  15. #ifndef __particleutils_h__
  16. #define __particleutils_h__
  17. #pragma once
  18.  
  19. //////////////////////////////////////////////////////////////////////////
  20. // Ref target that doesn't auto-delete. Handled manually
  21. template<typename Counter> class _plain_reference_target
  22. {
  23. public:
  24.         _plain_reference_target()
  25.                 : m_nRefCounter(0)
  26.         {}
  27.  
  28.         ~_plain_reference_target()
  29.         {
  30.                 assert(m_nRefCounter == 0);
  31. #ifdef _DEBUG
  32.                 m_nRefCounter = -1;
  33. #endif
  34.         }
  35.  
  36.         void AddRef()
  37.         {
  38.                 assert(m_nRefCounter >= 0);
  39.                 ++m_nRefCounter;
  40.         }
  41.  
  42.         void Release()
  43.         {
  44.                 --m_nRefCounter;
  45.                 assert(m_nRefCounter >= 0);
  46.         }
  47.  
  48.         Counter NumRefs() const
  49.         {
  50.                 assert(m_nRefCounter >= 0);
  51.                 return m_nRefCounter;
  52.         }
  53.  
  54. protected:
  55.         Counter m_nRefCounter;
  56. };
  57.  
  58. extern ITimer* g_pParticleTimer;
  59.  
  60. ILINE ITimer* GetParticleTimer()
  61. {
  62.         return g_pParticleTimer;
  63. }
  64.  
  65. //////////////////////////////////////////////////////////////////////////
  66. // 3D helper functions
  67.  
  68. inline void RotateTo(Quat& qRot, Vec3 const& vNorm)
  69. {
  70.         qRot = Quat::CreateRotationV0V1(qRot.GetColumn1(), vNorm) * qRot;
  71. }
  72. inline void OrientTo(Quat& qRot, Vec3 const& vNorm)
  73. {
  74.         qRot = Quat::CreateRotationV0V1(qRot.GetColumn2(), vNorm) * qRot;
  75. }
  76. inline bool CheckNormalize(Vec3& vDest, const Vec3& vSource)
  77. {
  78.         float fLenSq = vSource.GetLengthSquared();
  79.         if (fLenSq > FLT_MIN)
  80.         {
  81.                 vDest = vSource * isqrt_tpl(fLenSq);
  82.                 return true;
  83.         }
  84.         return false;
  85. }
  86. inline bool CheckNormalize(Vec3& v)
  87. {
  88.         return CheckNormalize(v, v);
  89. }
  90.  
  91. #endif // __particleutils_h__
  92.  
downloadParticleUtils.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