Team Fortress 2 Source Code as on 22/4/2020
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.

131 lines
2.6 KiB

  1. //========= Copyright 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. CBoneAccessor( matrix3x4_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, matrix3x4_t *pBones );
  21. #endif
  22. int GetReadableBones();
  23. void SetReadableBones( int flags );
  24. int GetWritableBones();
  25. void SetWritableBones( int flags );
  26. // Get bones for read or write access.
  27. const matrix3x4_t& GetBone( int iBone ) const;
  28. const matrix3x4_t& operator[]( int iBone ) const;
  29. matrix3x4_t& GetBoneForWrite( int iBone );
  30. matrix3x4_t *GetBoneArrayForWrite( ) const;
  31. private:
  32. #if defined( CLIENT_DLL ) && defined( _DEBUG )
  33. void SanityCheckBone( int iBone, bool bReadable ) const;
  34. #endif
  35. // Only used in the client DLL for debug verification.
  36. const C_BaseAnimating *m_pAnimating;
  37. matrix3x4_t *m_pBones;
  38. int m_ReadableBones; // Which bones can be read.
  39. int m_WritableBones; // Which bones can be written.
  40. };
  41. inline CBoneAccessor::CBoneAccessor()
  42. {
  43. m_pAnimating = NULL;
  44. m_pBones = NULL;
  45. m_ReadableBones = m_WritableBones = 0;
  46. }
  47. inline CBoneAccessor::CBoneAccessor( matrix3x4_t *pBones )
  48. {
  49. m_pAnimating = NULL;
  50. m_pBones = pBones;
  51. }
  52. #if defined( CLIENT_DLL )
  53. inline void CBoneAccessor::Init( const C_BaseAnimating *pAnimating, matrix3x4_t *pBones )
  54. {
  55. m_pAnimating = pAnimating;
  56. m_pBones = pBones;
  57. }
  58. #endif
  59. inline int CBoneAccessor::GetReadableBones()
  60. {
  61. return m_ReadableBones;
  62. }
  63. inline void CBoneAccessor::SetReadableBones( int flags )
  64. {
  65. m_ReadableBones = flags;
  66. }
  67. inline int CBoneAccessor::GetWritableBones()
  68. {
  69. return m_WritableBones;
  70. }
  71. inline void CBoneAccessor::SetWritableBones( int flags )
  72. {
  73. m_WritableBones = flags;
  74. }
  75. inline const matrix3x4_t& CBoneAccessor::GetBone( int iBone ) const
  76. {
  77. #if defined( CLIENT_DLL ) && defined( _DEBUG )
  78. SanityCheckBone( iBone, true );
  79. #endif
  80. return m_pBones[iBone];
  81. }
  82. inline const matrix3x4_t& CBoneAccessor::operator[]( int iBone ) const
  83. {
  84. #if defined( CLIENT_DLL ) && defined( _DEBUG )
  85. SanityCheckBone( iBone, true );
  86. #endif
  87. return m_pBones[iBone];
  88. }
  89. inline matrix3x4_t& CBoneAccessor::GetBoneForWrite( int iBone )
  90. {
  91. #if defined( CLIENT_DLL ) && defined( _DEBUG )
  92. SanityCheckBone( iBone, false );
  93. #endif
  94. return m_pBones[iBone];
  95. }
  96. inline matrix3x4_t *CBoneAccessor::GetBoneArrayForWrite( void ) const
  97. {
  98. return m_pBones;
  99. }
  100. #endif // BONE_ACCESSOR_H