optimization for GetBoneFrame: return a reference instead of a copy

This commit is contained in:
L 2023-01-30 00:26:30 +01:00
parent 9ada899127
commit bea6f39207
3 changed files with 6 additions and 8 deletions

View file

@ -1002,7 +1002,7 @@ void skeletor_c::GetFrame( skelAnimFrame_t *newFrame )
}
SkelMat4 &skeletor_c::GetBoneFrame( int boneIndex )
SkelMat4 &skeletor_c::GetBoneFrame( int boneIndex ) const
{
return m_bone[ boneIndex ]->GetTransform( &m_frameList );
}

View file

@ -115,7 +115,7 @@ public:
void LoadMorphTargetNames( skelHeaderGame_t *modelHeader );
void GetFrame( skelAnimFrame_t *newFrame );
int GetMorphWeightFrame( int *data );
SkelMat4 &GetBoneFrame( int boneIndex );
SkelMat4 &GetBoneFrame( int boneIndex ) const;
void GetFrameBounds( SkelVec3 *, SkelVec3 * );
float GetModelLODRadius();
bool IsBoneOnGround( int boneIndex, float threshold );

View file

@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "qcommon.h"
#include "../skeletor/skeletor.h"
#include "tiki_cache.h"
#include "tiki_tag.h"
/*
===============
@ -76,13 +77,10 @@ TIKI_OrientationInternal
*/
orientation_t TIKI_OrientationInternal( dtiki_t *tiki, int entnum, int tagnum, float scale )
{
orientation_t or;
skeletor_c *skeletor;
SkelMat4 pTransform;
skeletor = ( skeletor_c * )TIKI_GetSkeletor( tiki, entnum );
pTransform = skeletor->GetBoneFrame( tagnum );
const skeletor_c* skeletor = ( skeletor_c * )TIKI_GetSkeletor( tiki, entnum );
const SkelMat4& pTransform = skeletor->GetBoneFrame( tagnum );
orientation_t or ;
or.origin[ 0 ] = ( pTransform.val[ 3 ][ 0 ] + tiki->load_origin[ 0 ] ) * ( scale * tiki->load_scale );
or.origin[ 1 ] = ( pTransform.val[ 3 ][ 1 ] + tiki->load_origin[ 1 ] ) * ( scale * tiki->load_scale );
or.origin[ 2 ] = ( pTransform.val[ 3 ][ 2 ] + tiki->load_origin[ 2 ] ) * ( scale * tiki->load_scale );