Skip to content

Commit f80e203

Browse files
committed
perf: backport CalcBones optimizations from CS:GO
* lower LODs are now marked as set up * align parent transform matrix
1 parent 1d2246f commit f80e203

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/game/client/c_baseanimating.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2850,6 +2850,20 @@ bool C_BaseAnimating::SetupBones( matrix3x4_t *pBoneToWorldOut, int nMaxBones, i
28502850
}
28512851
}
28522852

2853+
// If we're setting up LOD N, we have set up all lower LODs also
2854+
// because lower LODs always use subsets of the bones of higher LODs.
2855+
int nLOD = 0;
2856+
int nMask = BONE_USED_BY_VERTEX_LOD0;
2857+
for( ; nLOD < MAX_NUM_LODS; ++nLOD, nMask <<= 1 )
2858+
{
2859+
if ( boneMask & nMask )
2860+
break;
2861+
}
2862+
for( ; nLOD < MAX_NUM_LODS; ++nLOD, nMask <<= 1 )
2863+
{
2864+
boneMask |= nMask;
2865+
}
2866+
28532867
#ifdef DEBUG_BONE_SETUP_THREADING
28542868
if ( cl_warn_thread_contested_bone_setup.GetBool() )
28552869
{
@@ -2917,7 +2931,7 @@ bool C_BaseAnimating::SetupBones( matrix3x4_t *pBoneToWorldOut, int nMaxBones, i
29172931
return false;
29182932

29192933
// Setup our transform based on render angles and origin.
2920-
matrix3x4_t parentTransform;
2934+
ALIGN16 matrix3x4_t parentTransform ALIGN16_POST;
29212935
AngleMatrix( GetRenderAngles(), GetRenderOrigin(), parentTransform );
29222936

29232937
// Load the boneMask with the total of what was asked for last frame.

0 commit comments

Comments
 (0)