forked from hitmen047/Source-PlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbone_merge_cache.h
85 lines (60 loc) · 2.19 KB
/
bone_merge_cache.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef BONE_MERGE_CACHE_H
#define BONE_MERGE_CACHE_H
#ifdef _WIN32
#pragma once
#endif
class C_BaseAnimating;
class CStudioHdr;
#include "mathlib/vector.h"
class CBoneMergeCache
{
public:
CBoneMergeCache();
void Init( C_BaseAnimating *pOwner );
// Updates the lookups that let it merge bones quickly.
void UpdateCache();
// This copies the transform from all bones in the followed entity that have
// names that match our bones.
void MergeMatchingBones( int boneMask );
// copy bones instead of matrices
void CopyParentToChild( const Vector parentPos[], const Quaternion parentQ[], Vector childPos[], Quaternion childQ[], int boneMask );
void CopyChildToParent( const Vector childPos[], const Quaternion childQ[], Vector parentPos[], Quaternion parentQ[], int boneMask );
// Returns true if the specified bone is one that gets merged in MergeMatchingBones.
int IsBoneMerged( int iBone ) const;
// Gets the origin for the first merge bone on the parent.
bool GetAimEntOrigin( Vector *pAbsOrigin, QAngle *pAbsAngles );
bool GetRootBone( matrix3x4_t &rootBone );
private:
// This is the entity that we're keeping the cache updated for.
C_BaseAnimating *m_pOwner;
// All the cache data is based off these. When they change, the cache data is regenerated.
// These are either all valid pointers or all NULL.
C_BaseAnimating *m_pFollow;
CStudioHdr *m_pFollowHdr;
const studiohdr_t *m_pFollowRenderHdr;
CStudioHdr *m_pOwnerHdr;
// This is the mask we need to use to set up bones on the followed entity to do the bone merge
int m_nFollowBoneSetupMask;
// Cache data.
class CMergedBone
{
public:
unsigned short m_iMyBone;
unsigned short m_iParentBone;
};
CUtlVector<CMergedBone> m_MergedBones;
CUtlVector<unsigned char> m_BoneMergeBits; // One bit for each bone. The bit is set if the bone gets merged.
};
inline int CBoneMergeCache::IsBoneMerged( int iBone ) const
{
if ( m_pOwnerHdr )
return m_BoneMergeBits[iBone >> 3] & ( 1 << ( iBone & 7 ) );
else
return 0;
}
#endif // BONE_MERGE_CACHE_H