various BuildTransformations fixes

This commit is contained in:
Kamay Xutax 2024-04-03 00:50:54 +02:00
parent 35325f3177
commit 446b3f348b
9 changed files with 31 additions and 24 deletions

View file

@ -1458,7 +1458,7 @@ void C_BaseAnimating::GetCachedBoneMatrix( int boneIndex, matrix3x4_t &out )
//-----------------------------------------------------------------------------
// Purpose: move position and rotation transforms into global matrices
//-----------------------------------------------------------------------------
void C_BaseAnimating::BuildTransformations( CStudioHdr *hdr, Vector *pos, Quaternion *q, const matrix3x4_t &cameraTransform, int boneMask, CBoneBitList &boneComputed )
void C_BaseAnimating::BuildTransformations( CStudioHdr *hdr, Vector *pos, Quaternion *q, const matrix3x4_t &cameraTransform, int boneMask, CBoneBitList &boneComputed, float flCurrentTime )
{
VPROF_BUDGET( "C_BaseAnimating::BuildTransformations", VPROF_BUDGETGROUP_CLIENT_ANIMATION );
@ -1574,7 +1574,7 @@ void C_BaseAnimating::BuildTransformations( CStudioHdr *hdr, Vector *pos, Quater
}
// do jiggle physics
m_pJiggleBones->BuildJiggleTransformations( i, gpGlobals->realtime, jiggleInfo, goalMX, GetBoneForWrite( i ) );
m_pJiggleBones->BuildJiggleTransformations( i, flCurrentTime, jiggleInfo, goalMX, GetBoneForWrite( i ) );
}
else if (hdr->boneParent(i) == -1)
@ -1982,9 +1982,16 @@ void C_BaseAnimating::StandardBlendingRules( CStudioHdr *hdr, Vector pos[], Quat
AccumulateLayers( boneSetup, pos, q, currentTime );
if ( m_pIk )
{
CIKContext auto_ik;
auto_ik.Init( hdr, GetRenderAngles(), GetRenderOrigin(), currentTime, gpGlobals->framecount, boneMask );
boneSetup.CalcAutoplaySequences( pos, q, currentTime, &auto_ik );
}
else
{
boneSetup.CalcAutoplaySequences( pos, q, currentTime, NULL );
}
if ( hdr->numbonecontrollers() )
{
@ -3024,7 +3031,7 @@ bool C_BaseAnimating::SetupBones( matrix3x4_t *pBoneToWorldOut, int nMaxBones, i
m_pIk->SolveDependencies( pos, q, m_BoneAccessor.GetBoneArrayForWrite(), boneComputed );
}
BuildTransformations( hdr, pos, q, parentTransform, bonesMaskNeedRecalc, boneComputed );
BuildTransformations( hdr, pos, q, parentTransform, bonesMaskNeedRecalc, boneComputed, currentTime );
RemoveFlag( EFL_SETTING_UP_BONES );
ControlMouth( hdr );

View file

@ -139,7 +139,7 @@ public:
// base model functionality
float ClampCycle( float cycle, bool isLooping );
virtual void GetPoseParameters( CStudioHdr *pStudioHdr, float poseParameter[MAXSTUDIOPOSEPARAM] );
virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed );
virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed, float currentTime );
virtual void ApplyBoneMatrixTransform( matrix3x4_t& transform );
virtual int VPhysicsGetObjectList( IPhysicsObject **pList, int listMax );

View file

@ -1162,7 +1162,7 @@ void C_BaseFlex::SetupWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightC
// Purpose: Use the local bone positions to set flex control weights
// via boneflexdrivers specified in the model
//-----------------------------------------------------------------------------
void C_BaseFlex::BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed )
void C_BaseFlex::BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed, float currentTime )
{
const int nBoneFlexDriverCount = pStudioHdr->BoneFlexDriverCount();
@ -1181,7 +1181,7 @@ void C_BaseFlex::BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quat
}
}
BaseClass::BuildTransformations( pStudioHdr, pos, q, cameraTransform, boneMask, boneComputed );
BaseClass::BuildTransformations( pStudioHdr, pos, q, cameraTransform, boneMask, boneComputed, currentTime );
}

View file

@ -147,7 +147,7 @@ public:
virtual void OnThreadedDrawSetup();
// model specific
virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed );
virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed, float currentTime );
static void LinkToGlobalFlexControllers( CStudioHdr *hdr );
virtual void SetupWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights );
virtual bool SetupGlobalWeights( const matrix3x4_t *pBoneToWorld, int nFlexWeightCount, float *pFlexWeights, float *pFlexDelayedWeights );

View file

@ -1956,10 +1956,10 @@ void GetCorrectionMatrices(
}
void C_CSPlayer::BuildTransformations( CStudioHdr *pHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed )
void C_CSPlayer::BuildTransformations( CStudioHdr *pHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed, float currentTime )
{
// First, setup our model's transformations like normal.
BaseClass::BuildTransformations( pHdr, pos, q, cameraTransform, boneMask, boneComputed );
BaseClass::BuildTransformations( pHdr, pos, q, cameraTransform, boneMask, boneComputed, currentTime );
if ( IsLocalPlayer() && !C_BasePlayer::ShouldDrawLocalPlayer() )
return;
@ -1975,7 +1975,7 @@ void C_CSPlayer::BuildTransformations( CStudioHdr *pHdr, Vector *pos, Quaternion
return;
// Have the weapon setup its bones.
pWeapon->SetupBones( NULL, 0, BONE_USED_BY_ANYTHING, gpGlobals->curtime );
pWeapon->SetupBones( NULL, 0, BONE_USED_BY_ANYTHING, currentTime );
int iWeaponBone = 0;
if ( FindWeaponAttachmentBone( pWeapon, iWeaponBone ) )

View file

@ -110,7 +110,7 @@ public:
CUtlVector< C_BaseParticleEntity* > m_SmokeGrenades;
virtual bool ShouldDraw( void );
virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed );
virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed, float currentTime );
virtual C_BaseAnimating * BecomeRagdollOnClient();
virtual IRagdoll* GetRepresentativeRagdoll() const;

View file

@ -51,7 +51,7 @@ void C_NPC_Puppet::OnDataChanged( DataUpdateType_t updateType )
//-----------------------------------------------------------------------------
// Purpose: We need to slam our position!
//-----------------------------------------------------------------------------
void C_NPC_Puppet::BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed )
void C_NPC_Puppet::BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed, float currentTime )
{
if ( m_hAnimationTarget && m_nTargetAttachment != -1 )
{
@ -68,7 +68,7 @@ void C_NPC_Puppet::BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Qu
}
// Call the baseclass
BaseClass::BuildTransformations( pStudioHdr, pos, q, cameraTransform, boneMask, boneComputed );
BaseClass::BuildTransformations( pStudioHdr, pos, q, cameraTransform, boneMask, boneComputed, currentTime );
}
//-----------------------------------------------------------------------------

View file

@ -641,9 +641,9 @@ bool C_BaseHLPlayer::CreateMove( float flInputSampleTime, CUserCmd *pCmd )
//-----------------------------------------------------------------------------
// Purpose: Input handling
//-----------------------------------------------------------------------------
void C_BaseHLPlayer::BuildTransformations( CStudioHdr *hdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed )
void C_BaseHLPlayer::BuildTransformations( CStudioHdr *hdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed, float currentTIme )
{
BaseClass::BuildTransformations( hdr, pos, q, cameraTransform, boneMask, boneComputed );
BaseClass::BuildTransformations( hdr, pos, q, cameraTransform, boneMask, boneComputed, currentTIme );
BuildFirstPersonMeathookTransformations( hdr, pos, q, cameraTransform, boneMask, boneComputed, "ValveBiped.Bip01_Head1" );
}

View file

@ -389,7 +389,7 @@ public:
void GetRenderBounds( Vector& theMins, Vector& theMaxs );
virtual void AddEntity( void );
virtual void AccumulateLayers( IBoneSetup &boneSetup, Vector pos[], Quaternion q[], float currentTime );
virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t &cameraTransform, int boneMask, CBoneBitList &boneComputed );
virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t &cameraTransform, int boneMask, CBoneBitList &boneComputed, float currentTime );
IPhysicsObject *GetElement( int elementNum );
virtual void UpdateOnRemove();
virtual float LastBoneChangedTime();
@ -565,7 +565,7 @@ void C_ServerRagdoll::AccumulateLayers( IBoneSetup &boneSetup, Vector pos[], Qua
}
}
void C_ServerRagdoll::BuildTransformations( CStudioHdr *hdr, Vector *pos, Quaternion q[], const matrix3x4_t &cameraTransform, int boneMask, CBoneBitList &boneComputed )
void C_ServerRagdoll::BuildTransformations( CStudioHdr *hdr, Vector *pos, Quaternion q[], const matrix3x4_t &cameraTransform, int boneMask, CBoneBitList &boneComputed, float currentTime )
{
if ( !hdr )
return;
@ -714,14 +714,14 @@ public:
return BaseClass::SetupBones( pBoneToWorldOut, nMaxBones, boneMask, currentTime );
}
virtual void BuildTransformations( CStudioHdr *hdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed )
virtual void BuildTransformations( CStudioHdr *hdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed, float currentTime )
{
VPROF_BUDGET( "C_ServerRagdollAttached::SetupBones", VPROF_BUDGETGROUP_CLIENT_ANIMATION );
if ( !hdr )
return;
float frac = RemapVal( gpGlobals->curtime, m_parentTime, m_parentTime+ATTACH_INTERP_TIME, 0, 1 );
float frac = RemapVal( currentTime, m_parentTime, m_parentTime+ATTACH_INTERP_TIME, 0, 1 );
frac = clamp( frac, 0.f, 1.f );
// interpolate offset over some time
Vector offset = m_vecOffset * (1-frac);
@ -734,13 +734,13 @@ public:
if ( parent )
{
Assert( parent != this );
parent->SetupBones( NULL, -1, BONE_USED_BY_ANYTHING, gpGlobals->curtime );
parent->SetupBones( NULL, -1, BONE_USED_BY_ANYTHING, currentTime );
matrix3x4_t boneToWorld;
parent->GetCachedBoneMatrix( m_boneIndexAttached, boneToWorld );
VectorTransform( m_attachmentPointBoneSpace, boneToWorld, worldOrigin );
}
BaseClass::BuildTransformations( hdr, pos, q, cameraTransform, boneMask, boneComputed );
BaseClass::BuildTransformations( hdr, pos, q, cameraTransform, boneMask, boneComputed, currentTime );
if ( parent )
{