Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.1 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef C_IMPACT_EFFECTS_H
  7. #define C_IMPACT_EFFECTS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier0/memdbgon.h"
  12. //-----------------------------------------------------------------------------
  13. // Purpose: DustParticle emitter
  14. //-----------------------------------------------------------------------------
  15. class CDustParticle : public CSimpleEmitter
  16. {
  17. public:
  18. explicit CDustParticle( const char *pDebugName ) : CSimpleEmitter( pDebugName ) {}
  19. //Create
  20. static CDustParticle *Create( const char *pDebugName="dust" )
  21. {
  22. return new CDustParticle( pDebugName );
  23. }
  24. //Roll
  25. virtual float UpdateRoll( SimpleParticle *pParticle, float timeDelta )
  26. {
  27. pParticle->m_flRoll += pParticle->m_flRollDelta * timeDelta;
  28. pParticle->m_flRollDelta += pParticle->m_flRollDelta * ( timeDelta * -8.0f );
  29. if ( fabs( pParticle->m_flRollDelta ) < 0.5f )
  30. {
  31. pParticle->m_flRollDelta = ( pParticle->m_flRollDelta > 0.0f ) ? 0.5f : -0.5f;
  32. }
  33. return pParticle->m_flRoll;
  34. }
  35. //Velocity
  36. virtual void UpdateVelocity( SimpleParticle *pParticle, float timeDelta )
  37. {
  38. Vector saveVelocity = pParticle->m_vecVelocity;
  39. //Decellerate
  40. static float dtime;
  41. static float decay;
  42. if ( dtime != timeDelta )
  43. {
  44. dtime = timeDelta;
  45. float expected = 0.5;
  46. decay = exp( log( 0.0001f ) * dtime / expected );
  47. }
  48. pParticle->m_vecVelocity = pParticle->m_vecVelocity * decay;
  49. if ( pParticle->m_vecVelocity.LengthSqr() < (32.0f*32.0f) )
  50. {
  51. VectorNormalize( saveVelocity );
  52. pParticle->m_vecVelocity = saveVelocity * 32.0f;
  53. }
  54. }
  55. //Alpha
  56. virtual float UpdateAlpha( const SimpleParticle *pParticle )
  57. {
  58. float tLifetime = pParticle->m_flLifetime / pParticle->m_flDieTime;
  59. float ramp = 1.0f - tLifetime;
  60. //Non-linear fade
  61. if ( ramp < 0.75f )
  62. ramp *= ramp;
  63. return ramp;
  64. }
  65. private:
  66. CDustParticle( const CDustParticle & ); // not defined, not accessible
  67. };
  68. void GetColorForSurface( trace_t *trace, Vector *color );
  69. #include "tier0/memdbgoff.h"
  70. #endif // C_IMPACT_EFFECTS_H