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.

85 lines
2.2 KiB

  1. //========= Copyright 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. class C_BaseAnimating;
  12. class CStudioHdr;
  13. #include "mathlib/vector.h"
  14. class CBoneMergeCache
  15. {
  16. public:
  17. CBoneMergeCache();
  18. void Init( C_BaseAnimating *pOwner );
  19. // Updates the lookups that let it merge bones quickly.
  20. void UpdateCache();
  21. // This copies the transform from all bones in the followed entity that have
  22. // names that match our bones.
  23. void MergeMatchingBones( int boneMask );
  24. // copy bones instead of matrices
  25. void CopyParentToChild( const Vector parentPos[], const Quaternion parentQ[], Vector childPos[], Quaternion childQ[], int boneMask );
  26. void CopyChildToParent( const Vector childPos[], const Quaternion childQ[], Vector parentPos[], Quaternion parentQ[], int boneMask );
  27. // Returns true if the specified bone is one that gets merged in MergeMatchingBones.
  28. int IsBoneMerged( int iBone ) const;
  29. // Gets the origin for the first merge bone on the parent.
  30. bool GetAimEntOrigin( Vector *pAbsOrigin, QAngle *pAbsAngles );
  31. bool GetRootBone( matrix3x4_t &rootBone );
  32. private:
  33. // This is the entity that we're keeping the cache updated for.
  34. C_BaseAnimating *m_pOwner;
  35. // All the cache data is based off these. When they change, the cache data is regenerated.
  36. // These are either all valid pointers or all NULL.
  37. C_BaseAnimating *m_pFollow;
  38. CStudioHdr *m_pFollowHdr;
  39. const studiohdr_t *m_pFollowRenderHdr;
  40. CStudioHdr *m_pOwnerHdr;
  41. // This is the mask we need to use to set up bones on the followed entity to do the bone merge
  42. int m_nFollowBoneSetupMask;
  43. // Cache data.
  44. class CMergedBone
  45. {
  46. public:
  47. unsigned short m_iMyBone;
  48. unsigned short m_iParentBone;
  49. };
  50. CUtlVector<CMergedBone> m_MergedBones;
  51. CUtlVector<unsigned char> m_BoneMergeBits; // One bit for each bone. The bit is set if the bone gets merged.
  52. };
  53. inline int CBoneMergeCache::IsBoneMerged( int iBone ) const
  54. {
  55. if ( m_pOwnerHdr )
  56. return m_BoneMergeBits[iBone >> 3] & ( 1 << ( iBone & 7 ) );
  57. else
  58. return 0;
  59. }
  60. #endif // BONE_MERGE_CACHE_H