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.

91 lines
3.8 KiB

  1. DLL_IMPORT CLinkedMiniProfiler *g_pPhysicsMiniProfilers;
  2. #if 0
  3. #define BONE_PROFILE(ID) static CLinkedMiniProfiler s_miniprofiler_##ID(#ID, &g_pPhysicsMiniProfilers); \
  4. CMiniProfilerGuard mpguard_##ID(&s_miniprofiler_##ID);
  5. #define BONE_PROFILE_LOOP(ID,COUNT) static CLinkedMiniProfiler s_miniprofiler_##ID(#ID, &g_pPhysicsMiniProfilers); \
  6. CMiniProfilerGuard mpguard_##ID(&s_miniprofiler_##ID,(COUNT));
  7. #define BONE_PROFILE_FUNC() static CLinkedMiniProfiler s_miniprofiler_FUNC(__FUNCTION__, &g_pPhysicsMiniProfilers); \
  8. CMiniProfilerGuard mpguard_##ID(&s_miniprofiler_FUNC);
  9. #else
  10. #define BONE_PROFILE(ID)
  11. #define BONE_PROFILE_LOOP(ID,COUNT)
  12. #define BONE_PROFILE_FUNC()
  13. #endif
  14. template <typename T>
  15. class CBoneSetupMemoryPool
  16. {
  17. public:
  18. T *Alloc()
  19. {
  20. T *p = (T *)m_FreeBlocks.Pop();
  21. if ( !p )
  22. {
  23. p = (T *)MemAlloc_AllocAligned( sizeof( T ) * MAXSTUDIOBONES, 16 );
  24. if ( ((size_t)p) % MAX(TSLIST_NODE_ALIGNMENT,16) != 0 )
  25. DebuggerBreak();
  26. }
  27. return p;
  28. }
  29. void Free( T *p )
  30. {
  31. m_FreeBlocks.Push( (TSLNodeBase_t *)p );
  32. }
  33. private:
  34. CTSListBase m_FreeBlocks;
  35. };
  36. extern CBoneSetupMemoryPool<BoneQuaternionAligned> g_QuaternionPool;
  37. extern CBoneSetupMemoryPool<BoneVector> g_VectorPool;
  38. extern CBoneSetupMemoryPool<matrix3x4a_t> g_MatrixPool;
  39. void CalcDecompressedAnimation( const mstudiocompressedikerror_t *pCompressed, int iFrame, float fraq, BoneVector &pos, BoneQuaternion &q );
  40. void QuaternionAccumulate( const Quaternion &p, float s, const Quaternion &q, Quaternion &qt );
  41. void CalcAnimation( const CStudioHdr *pStudioHdr, BoneVector *pos, BoneQuaternion *q, mstudioseqdesc_t &seqdesc, int sequence, int animation, float cycle, int boneMask );
  42. void BlendBones( const CStudioHdr *pStudioHdr, BoneQuaternionAligned q1[MAXSTUDIOBONES], BoneVector pos1[MAXSTUDIOBONES], mstudioseqdesc_t &seqdesc, int sequence, const BoneQuaternionAligned q2[MAXSTUDIOBONES], const BoneVector pos2[MAXSTUDIOBONES], float s, int boneMask );
  43. void ScaleBones( const CStudioHdr *pStudioHdr, BoneQuaternion q1[MAXSTUDIOBONES], BoneVector pos1[MAXSTUDIOBONES], int sequence, float s, int boneMask );
  44. void CalcPose( const CStudioHdr *pStudioHdr, CIKContext *pIKContext, BoneVector pos[], BoneQuaternionAligned q[], int sequence, float cycle, const float poseParameter[], int boneMask, float flWeight = 1.0f, float flTime = 0.0f );
  45. bool CalcPoseSingle( const CStudioHdr *pStudioHdr, BoneVector pos[], BoneQuaternionAligned q[], mstudioseqdesc_t &seqdesc, int sequence, float cycle, const float poseParameter[], int boneMask, float flTime );
  46. void CalcBoneAdj( const CStudioHdr *pStudioHdr, BoneVector pos[], BoneQuaternion q[], const float controllers[], int boneMask );
  47. void BuildBoneChainPartial(
  48. const CStudioHdr *pStudioHdr,
  49. const matrix3x4_t &rootxform,
  50. const BoneVector pos[],
  51. const BoneQuaternion q[],
  52. int iBone,
  53. matrix3x4_t *pBoneToWorld,
  54. CBoneBitList &boneComputed,
  55. int iRoot );
  56. class CBoneSetup
  57. {
  58. public:
  59. CBoneSetup( const CStudioHdr *pStudioHdr, int boneMask, const float poseParameter[], IPoseDebugger *pPoseDebugger = NULL );
  60. void InitPose( BoneVector pos[], BoneQuaternionAligned q[] );
  61. void AccumulatePose( BoneVector pos[], BoneQuaternion q[], int sequence, float cycle, float flWeight, float flTime, CIKContext *pIKContext );
  62. void CalcAutoplaySequences( BoneVector pos[], BoneQuaternion q[], float flRealTime, CIKContext *pIKContext );
  63. private:
  64. void AddSequenceLayers( BoneVector pos[], BoneQuaternion q[], mstudioseqdesc_t &seqdesc, int sequence, float cycle, float flWeight, float flTime, CIKContext *pIKContext );
  65. void AddLocalLayers( BoneVector pos[], BoneQuaternion q[], mstudioseqdesc_t &seqdesc, int sequence, float cycle, float flWeight, float flTime, CIKContext *pIKContext );
  66. public:
  67. const CStudioHdr *m_pStudioHdr;
  68. int m_boneMask;
  69. const float *m_flPoseParameter;
  70. IPoseDebugger *m_pPoseDebugger;
  71. };