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.

117 lines
3.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef BONE_MERGE_CACHE_H
  7. #define BONE_MERGE_CACHE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #if defined( CLIENT_DLL )
  12. #undef CBaseAnimating
  13. #define CBaseAnimating C_BaseAnimating
  14. #endif
  15. class CBaseAnimating;
  16. class CStudioHdr;
  17. struct studiohdr_t;
  18. #ifndef CLIENT_DLL
  19. #include "bone_setup.h"
  20. #endif
  21. #include "mathlib/vector.h"
  22. class CBoneMergeCache
  23. {
  24. public:
  25. CBoneMergeCache();
  26. void Init( CBaseAnimating *pOwner );
  27. // Updates the lookups that let it merge bones quickly.
  28. void UpdateCache();
  29. // This copies the transform from all bones in the followed entity that have
  30. // names that match our bones.
  31. #ifdef CLIENT_DLL
  32. void MergeMatchingBones( int boneMask );
  33. #else
  34. void BuildMatricesWithBoneMerge( const CStudioHdr *pStudioHdr, const QAngle& angles,
  35. const Vector& origin, const Vector pos[MAXSTUDIOBONES],
  36. const Quaternion q[MAXSTUDIOBONES], matrix3x4_t bonetoworld[MAXSTUDIOBONES],
  37. CBaseAnimating *pParent, CBoneCache *pParentCache, int boneMask );
  38. #endif
  39. void MergeMatchingPoseParams( void );
  40. void CopyFromFollow( const BoneVector followPos[], const BoneQuaternion followQ[], int boneMask, BoneVector myPos[], BoneQuaternion myQ[] );
  41. void CopyToFollow( const BoneVector myPos[], const BoneQuaternion myQ[], int boneMask, BoneVector followPos[], BoneQuaternion followQ[] );
  42. bool IsCopied( );
  43. // Returns true if the specified bone is one that gets merged in MergeMatchingBones.
  44. int IsBoneMerged( int iBone ) const;
  45. // Gets the origin for the first merge bone on the parent.
  46. bool GetAimEntOrigin( Vector *pAbsOrigin, QAngle *pAbsAngles );
  47. bool GetRootBone( matrix3x4_t &rootBone );
  48. void ForceCacheClear( void ) { m_bForceCacheClear = true; UpdateCache(); }
  49. const unsigned short *GetRawIndexMapping( void ) { return &m_iRawIndexMapping[0]; }
  50. protected:
  51. // This is the entity that we're keeping the cache updated for.
  52. CBaseAnimating *m_pOwner;
  53. // All the cache data is based off these. When they change, the cache data is regenerated.
  54. // These are either all valid pointers or all NULL.
  55. CBaseAnimating *m_pFollow;
  56. CStudioHdr *m_pFollowHdr;
  57. const studiohdr_t *m_pFollowRenderHdr;
  58. CStudioHdr *m_pOwnerHdr;
  59. const studiohdr_t *m_pOwnerRenderHdr;
  60. // keeps track if this entity is part of a reverse bonemerge
  61. int m_nCopiedFramecount;
  62. // This is the mask we need to use to set up bones on the followed entity to do the bone merge
  63. int m_nFollowBoneSetupMask;
  64. // Cache data.
  65. class CMergedBone
  66. {
  67. public:
  68. unsigned short m_iMyBone; // index of MergeCache's owner's bone
  69. unsigned short m_iParentBone; // index of m_pFollow's matching bone
  70. };
  71. // This is an array of pose param indices on the follower to pose param indices on the owner
  72. int m_nOwnerToFollowPoseParamMapping[MAXSTUDIOPOSEPARAM];
  73. CUtlVector<CMergedBone> m_MergedBones;
  74. CVarBitVec m_BoneMergeBits; // One bit for each bone. The bit is set if the bone gets merged.
  75. unsigned short m_iRawIndexMapping[ MAXSTUDIOBONES ];
  76. bool m_bForceCacheClear;
  77. };
  78. inline int CBoneMergeCache::IsBoneMerged( int iBone ) const
  79. {
  80. if ( m_pOwnerHdr )
  81. return m_BoneMergeBits.Get( iBone );
  82. else
  83. return 0;
  84. }
  85. #endif // BONE_MERGE_CACHE_H