Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void C_BaseEntity::CalcAbsolutePosition( )
- {
- // There are periods of time where we're gonna have to live with the
- // fact that we're in an indeterminant state and abs queries (which
- // shouldn't be happening at all; I have assertions for those), will
- // just have to accept stale data.
- if (!s_bAbsRecomputationEnabled)
- return;
- // FIXME: Recompute absbox!!!
- if ((m_iEFlags & EFL_DIRTY_ABSTRANSFORM) == 0)
- {
- // quick check to make sure we really don't need an update
- // Assert( m_pMoveParent || m_vecAbsOrigin == GetLocalOrigin() );
- return;
- }
- AUTO_LOCK( m_CalcAbsolutePositionMutex );
- if ((m_iEFlags & EFL_DIRTY_ABSTRANSFORM) == 0) // need second check in event another thread grabbed mutex and did the calculation
- {
- return;
- }
- RemoveEFlags( EFL_DIRTY_ABSTRANSFORM );
- if (!m_pMoveParent)
- {
- // Construct the entity-to-world matrix
- // Start with making an entity-to-parent matrix
- AngleMatrix( GetLocalAngles(), GetLocalOrigin(), m_rgflCoordinateFrame );
- m_vecAbsOrigin = GetLocalOrigin();
- m_angAbsRotation = GetLocalAngles();
- NormalizeAngles( m_angAbsRotation );
- return;
- }
- if ( IsEffectActive(EF_BONEMERGE) )
- {
- MoveToAimEnt();
- return;
- }
- // Construct the entity-to-world matrix
- // Start with making an entity-to-parent matrix
- matrix3x4_t matEntityToParent;
- AngleMatrix( GetLocalAngles(), matEntityToParent );
- MatrixSetColumn( GetLocalOrigin(), 3, matEntityToParent );
- // concatenate with our parent's transform
- matrix3x4_t scratchMatrix;
- ConcatTransforms( GetParentToWorldTransform( scratchMatrix ), matEntityToParent, m_rgflCoordinateFrame );
- // pull our absolute position out of the matrix
- MatrixGetColumn( m_rgflCoordinateFrame, 3, m_vecAbsOrigin );
- // if we have any angles, we have to extract our absolute angles from our matrix
- if ( m_angRotation == vec3_angle && m_iParentAttachment == 0 )
- {
- // just copy our parent's absolute angles
- VectorCopy( m_pMoveParent->GetAbsAngles(), m_angAbsRotation );
- }
- else
- {
- MatrixAngles( m_rgflCoordinateFrame, m_angAbsRotation );
- }
- // This is necessary because it's possible that our moveparent's CalculateIKLocks will trigger its move children
- // (ie: this entity) to call GetAbsOrigin(), and they'll use the moveparent's OLD bone transforms to get their attachments
- // since the moveparent is right in the middle of setting up new transforms.
- //
- // So here, we keep our absorigin invalidated. It means we're returning an origin that is a frame old to CalculateIKLocks,
- // but we'll still render with the right origin.
- if ( m_iParentAttachment != 0 && (m_pMoveParent->GetEFlags() & EFL_SETTING_UP_BONES) )
- {
- m_iEFlags |= EFL_DIRTY_ABSTRANSFORM;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement