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.

135 lines
2.8 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef BONE_ACCESSOR_H
  7. #define BONE_ACCESSOR_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "studio.h"
  12. class C_BaseAnimating;
  13. class CBoneAccessor
  14. {
  15. public:
  16. CBoneAccessor();
  17. explicit CBoneAccessor( matrix3x4a_t *pBones ); // This can be used to allow access to all bones.
  18. // Initialize.
  19. #if defined( CLIENT_DLL )
  20. void Init( const C_BaseAnimating *pAnimating, matrix3x4a_t *pBones );
  21. #endif
  22. int GetReadableBones();
  23. void SetReadableBones( int flags );
  24. int GetWritableBones();
  25. void SetWritableBones( int flags );
  26. bool isBoneAvailableForRead( int iBone ) const;
  27. bool isBoneAvailableForWrite( int iBone ) const;
  28. // Get bones for read or write access.
  29. const matrix3x4a_t& GetBone( int iBone ) const;
  30. const matrix3x4a_t& operator[]( int iBone ) const;
  31. matrix3x4a_t& GetBoneForWrite( int iBone );
  32. matrix3x4a_t *GetBoneArrayForWrite( ) const;
  33. private:
  34. #if defined( CLIENT_DLL ) && defined( _DEBUG )
  35. void SanityCheckBone( int iBone, bool bReadable ) const;
  36. #endif
  37. // Only used in the client DLL for debug verification.
  38. const C_BaseAnimating *m_pAnimating;
  39. matrix3x4a_t *m_pBones;
  40. int m_ReadableBones; // Which bones can be read.
  41. int m_WritableBones; // Which bones can be written.
  42. };
  43. inline CBoneAccessor::CBoneAccessor()
  44. {
  45. m_pAnimating = NULL;
  46. m_pBones = NULL;
  47. m_ReadableBones = m_WritableBones = 0;
  48. }
  49. inline CBoneAccessor::CBoneAccessor( matrix3x4a_t *pBones )
  50. {
  51. m_pAnimating = NULL;
  52. m_pBones = pBones;
  53. }
  54. #if defined( CLIENT_DLL )
  55. inline void CBoneAccessor::Init( const C_BaseAnimating *pAnimating, matrix3x4a_t *pBones )
  56. {
  57. m_pAnimating = pAnimating;
  58. m_pBones = pBones;
  59. }
  60. #endif
  61. inline int CBoneAccessor::GetReadableBones()
  62. {
  63. return m_ReadableBones;
  64. }
  65. inline void CBoneAccessor::SetReadableBones( int flags )
  66. {
  67. m_ReadableBones = flags;
  68. }
  69. inline int CBoneAccessor::GetWritableBones()
  70. {
  71. return m_WritableBones;
  72. }
  73. inline void CBoneAccessor::SetWritableBones( int flags )
  74. {
  75. m_WritableBones = flags;
  76. }
  77. inline const matrix3x4a_t& CBoneAccessor::GetBone( int iBone ) const
  78. {
  79. #if defined( CLIENT_DLL ) && defined( _DEBUG )
  80. SanityCheckBone( iBone, true );
  81. #endif
  82. return m_pBones[iBone];
  83. }
  84. inline const matrix3x4a_t& CBoneAccessor::operator[]( int iBone ) const
  85. {
  86. #if defined( CLIENT_DLL ) && defined( _DEBUG )
  87. SanityCheckBone( iBone, true );
  88. #endif
  89. return m_pBones[iBone];
  90. }
  91. inline matrix3x4a_t& CBoneAccessor::GetBoneForWrite( int iBone )
  92. {
  93. #if defined( CLIENT_DLL ) && defined( _DEBUG )
  94. SanityCheckBone( iBone, false );
  95. #endif
  96. return m_pBones[iBone];
  97. }
  98. inline matrix3x4a_t *CBoneAccessor::GetBoneArrayForWrite( void ) const
  99. {
  100. return m_pBones;
  101. }
  102. #endif // BONE_ACCESSOR_H