diff options
| author | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
| commit | 39ed87570bdb2f86969d4be821c94b722dc71179 (patch) | |
| tree | abc53757f75f40c80278e87650ea92808274aa59 /mp/src/game/client/bonetoworldarray.h | |
| download | source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip | |
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/game/client/bonetoworldarray.h')
| -rw-r--r-- | mp/src/game/client/bonetoworldarray.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/mp/src/game/client/bonetoworldarray.h b/mp/src/game/client/bonetoworldarray.h new file mode 100644 index 00000000..d3a2f31f --- /dev/null +++ b/mp/src/game/client/bonetoworldarray.h @@ -0,0 +1,71 @@ +//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef BONETOWORLDARRAY_H
+#define BONETOWORLDARRAY_H
+
+#include "tier0/tslist.h"
+
+#if defined( _WIN32 )
+#pragma once
+#endif
+
+#include "tier0/memdbgon.h" // for _aligned_malloc usage below
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+template <int NUM_ARRAYS>
+class CBoneToWorldArrays
+{
+public:
+ enum
+ {
+ ALIGNMENT = 128,
+ };
+
+ CBoneToWorldArrays()
+ {
+ const int SIZE_ARRAY = AlignValue( sizeof(matrix3x4_t) * MAXSTUDIOBONES, ALIGNMENT );
+ m_pBase = (matrix3x4_t *)_aligned_malloc( SIZE_ARRAY * NUM_ARRAYS, ALIGNMENT );
+ for ( int i = 0; i < NUM_ARRAYS; i++ )
+ {
+ matrix3x4_t *pArray = (matrix3x4_t *)((byte *)m_pBase + SIZE_ARRAY * i);
+ Assert( (size_t)pArray % ALIGNMENT == 0 );
+ Free( pArray );
+ }
+ }
+
+ ~CBoneToWorldArrays()
+ {
+ _aligned_free( m_pBase );
+ }
+
+ int NumArrays()
+ {
+ return NUM_ARRAYS;
+ }
+
+ matrix3x4_t *Alloc( bool bBlock = true )
+ {
+ TSLNodeBase_t *p;
+ while ( ( p = m_Free.Pop() ) == NULL && bBlock )
+ {
+ ThreadPause();
+ }
+ return (matrix3x4_t *)p;
+ }
+
+ void Free( matrix3x4_t *p )
+ {
+ m_Free.Push( (TSLNodeBase_t *) p );
+ }
+
+private:
+ CTSListBase m_Free;
+ matrix3x4_t *m_pBase;
+};
+
+#endif // BONETOWORLDARRAY_H
|