diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /sp/src/game/shared/expressionsample.h | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'sp/src/game/shared/expressionsample.h')
| -rw-r--r-- | sp/src/game/shared/expressionsample.h | 282 |
1 files changed, 141 insertions, 141 deletions
diff --git a/sp/src/game/shared/expressionsample.h b/sp/src/game/shared/expressionsample.h index e3af4f36..663328dc 100644 --- a/sp/src/game/shared/expressionsample.h +++ b/sp/src/game/shared/expressionsample.h @@ -1,141 +1,141 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef EXPRESSIONSAMPLE_H
-#define EXPRESSIONSAMPLE_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "interpolatortypes.h"
-
-class CUtlBuffer;
-class ISceneTokenProcessor;
-class IChoreoStringPool;
-
-#pragma pack(1)
-struct EdgeInfo_t
-{
- EdgeInfo_t() :
- m_bActive( false ),
- m_CurveType( CURVE_DEFAULT ),
- m_flZeroPos( 0.0f )
- {
- }
-
- bool m_bActive;
- unsigned short m_CurveType;
- float m_flZeroPos;
-};
-
-struct CExpressionSample
-{
- CExpressionSample() :
- value( 0.0f ),
- time( 0.0f )
- {
- selected = 0;
- m_curvetype = CURVE_DEFAULT;
- }
-
- void SetCurveType( int curveType )
- {
- m_curvetype = curveType;
- }
-
- int GetCurveType() const
- {
- return m_curvetype;
- }
-
- // Height
- float value;
- // time from start of event
- float time;
-
- unsigned short selected : 1;
-private:
- unsigned short m_curvetype : 15;
-};
-#pragma pack()
-
-//-----------------------------------------------------------------------------
-// Purpose: Provides generic access to scene or event ramp data
-//-----------------------------------------------------------------------------
-class ICurveDataAccessor
-{
-public:
- virtual float GetDuration() = 0;
- virtual bool CurveHasEndTime() = 0; // only matters for events
- virtual int GetDefaultCurveType() = 0;
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: The generic curve data
-//-----------------------------------------------------------------------------
-
-class CCurveData
-{
-public:
- int GetCount( void );
- CExpressionSample *Get( int index );
- CExpressionSample *Add( float time, float value, bool selected );
- void Delete( int index );
- void Clear( void );
- void Resort( ICurveDataAccessor *data );
-
- EdgeInfo_t *GetEdgeInfo( int idx );
-
- void SetEdgeInfo( bool leftEdge, int curveType, float zero );
- void GetEdgeInfo( bool leftEdge, int& curveType, float& zero ) const;
- void SetEdgeActive( bool leftEdge, bool state );
- bool IsEdgeActive( bool leftEdge ) const;
- int GetEdgeCurveType( bool leftEdge ) const;
- float GetEdgeZeroValue( bool leftEdge ) const;
- void RemoveOutOfRangeSamples( ICurveDataAccessor *data );
-
- void SaveToBuffer( CUtlBuffer& buf, IChoreoStringPool *pStringPool );
- bool RestoreFromBuffer( CUtlBuffer& buf, IChoreoStringPool *pStringPool );
-
- void Parse( ISceneTokenProcessor *tokenizer, ICurveDataAccessor *data );
- void FileSave( CUtlBuffer& buf, int level, const char *name );
-
- float GetIntensity( ICurveDataAccessor *data, float time );
- CExpressionSample *GetBoundedSample( ICurveDataAccessor *data, int number, bool& bClamped );
-
- CCurveData & operator = (const CCurveData &src)
- {
- // Copy ramp over
- m_Ramp.RemoveAll();
- int i;
- for ( i = 0; i < src.m_Ramp.Count(); i++ )
- {
- CExpressionSample sample = src.m_Ramp[ i ];
- CExpressionSample *newSample = Add( sample.time, sample.value, sample.selected );
- newSample->SetCurveType( sample.GetCurveType() );
- }
- m_RampEdgeInfo[ 0 ] = src.m_RampEdgeInfo[ 0 ];
- m_RampEdgeInfo[ 1 ] = src.m_RampEdgeInfo[ 1 ];
-
- return *this;
-
- };
-
-private:
- CUtlVector< CExpressionSample > m_Ramp;
- EdgeInfo_t m_RampEdgeInfo[ 2 ];
-
-public:
- float GetIntensityArea( ICurveDataAccessor *data, float time );
-
-private:
- void UpdateIntensityArea( ICurveDataAccessor *data );
- CUtlVector< float > m_RampAccumulator;
-};
-
-
-#endif // EXPRESSIONSAMPLE_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef EXPRESSIONSAMPLE_H +#define EXPRESSIONSAMPLE_H +#ifdef _WIN32 +#pragma once +#endif + +#include "interpolatortypes.h" + +class CUtlBuffer; +class ISceneTokenProcessor; +class IChoreoStringPool; + +#pragma pack(1) +struct EdgeInfo_t +{ + EdgeInfo_t() : + m_bActive( false ), + m_CurveType( CURVE_DEFAULT ), + m_flZeroPos( 0.0f ) + { + } + + bool m_bActive; + unsigned short m_CurveType; + float m_flZeroPos; +}; + +struct CExpressionSample +{ + CExpressionSample() : + value( 0.0f ), + time( 0.0f ) + { + selected = 0; + m_curvetype = CURVE_DEFAULT; + } + + void SetCurveType( int curveType ) + { + m_curvetype = curveType; + } + + int GetCurveType() const + { + return m_curvetype; + } + + // Height + float value; + // time from start of event + float time; + + unsigned short selected : 1; +private: + unsigned short m_curvetype : 15; +}; +#pragma pack() + +//----------------------------------------------------------------------------- +// Purpose: Provides generic access to scene or event ramp data +//----------------------------------------------------------------------------- +class ICurveDataAccessor +{ +public: + virtual float GetDuration() = 0; + virtual bool CurveHasEndTime() = 0; // only matters for events + virtual int GetDefaultCurveType() = 0; +}; + +//----------------------------------------------------------------------------- +// Purpose: The generic curve data +//----------------------------------------------------------------------------- + +class CCurveData +{ +public: + int GetCount( void ); + CExpressionSample *Get( int index ); + CExpressionSample *Add( float time, float value, bool selected ); + void Delete( int index ); + void Clear( void ); + void Resort( ICurveDataAccessor *data ); + + EdgeInfo_t *GetEdgeInfo( int idx ); + + void SetEdgeInfo( bool leftEdge, int curveType, float zero ); + void GetEdgeInfo( bool leftEdge, int& curveType, float& zero ) const; + void SetEdgeActive( bool leftEdge, bool state ); + bool IsEdgeActive( bool leftEdge ) const; + int GetEdgeCurveType( bool leftEdge ) const; + float GetEdgeZeroValue( bool leftEdge ) const; + void RemoveOutOfRangeSamples( ICurveDataAccessor *data ); + + void SaveToBuffer( CUtlBuffer& buf, IChoreoStringPool *pStringPool ); + bool RestoreFromBuffer( CUtlBuffer& buf, IChoreoStringPool *pStringPool ); + + void Parse( ISceneTokenProcessor *tokenizer, ICurveDataAccessor *data ); + void FileSave( CUtlBuffer& buf, int level, const char *name ); + + float GetIntensity( ICurveDataAccessor *data, float time ); + CExpressionSample *GetBoundedSample( ICurveDataAccessor *data, int number, bool& bClamped ); + + CCurveData & operator = (const CCurveData &src) + { + // Copy ramp over + m_Ramp.RemoveAll(); + int i; + for ( i = 0; i < src.m_Ramp.Count(); i++ ) + { + CExpressionSample sample = src.m_Ramp[ i ]; + CExpressionSample *newSample = Add( sample.time, sample.value, sample.selected ); + newSample->SetCurveType( sample.GetCurveType() ); + } + m_RampEdgeInfo[ 0 ] = src.m_RampEdgeInfo[ 0 ]; + m_RampEdgeInfo[ 1 ] = src.m_RampEdgeInfo[ 1 ]; + + return *this; + + }; + +private: + CUtlVector< CExpressionSample > m_Ramp; + EdgeInfo_t m_RampEdgeInfo[ 2 ]; + +public: + float GetIntensityArea( ICurveDataAccessor *data, float time ); + +private: + void UpdateIntensityArea( ICurveDataAccessor *data ); + CUtlVector< float > m_RampAccumulator; +}; + + +#endif // EXPRESSIONSAMPLE_H |