//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFBaseRocket::PostDataUpdate( DataUpdateType_t type ) { // Pass through to the base class. BaseClass::PostDataUpdate( type ); if ( type == DATA_UPDATE_CREATED ) { // Now stick our initial velocity and angles into the interpolation history. CInterpolatedVar<Vector> &interpolator = GetOriginInterpolator(); interpolator.ClearHistory(); CInterpolatedVar<QAngle> &rotInterpolator = GetRotationInterpolator(); rotInterpolator.ClearHistory(); float flChangeTime = GetLastChangeTime( LATCH_SIMULATION_VAR ); // Add a sample 1 second back. Vector vCurOrigin = GetLocalOrigin() - m_vInitialVelocity; interpolator.AddToHead( flChangeTime - 1.0f, &vCurOrigin, false ); QAngle vCurAngles = GetLocalAngles(); rotInterpolator.AddToHead( flChangeTime - 1.0f, &vCurAngles, false ); // Add the current sample. vCurOrigin = GetLocalOrigin(); interpolator.AddToHead( flChangeTime, &vCurOrigin, false ); rotInterpolator.AddToHead( flChangeTime - 1.0, &vCurAngles, false ); } }
void C_DODBaseRocket::PostDataUpdate( DataUpdateType_t type ) { BaseClass::PostDataUpdate( type ); if ( type == DATA_UPDATE_CREATED ) { // Now stick our initial velocity into the interpolation history CInterpolatedVar< Vector > &interpolator = GetOriginInterpolator(); interpolator.ClearHistory(); float changeTime = GetLastChangeTime( LATCH_SIMULATION_VAR ); // Add a sample 1 second back. Vector vCurOrigin = GetLocalOrigin() - m_vInitialVelocity; interpolator.AddToHead( changeTime - 1.0, &vCurOrigin, false ); // Add the current sample. vCurOrigin = GetLocalOrigin(); interpolator.AddToHead( changeTime, &vCurOrigin, false ); // do the same for angles CInterpolatedVar< QAngle > &rotInterpolator = GetRotationInterpolator(); rotInterpolator.ClearHistory(); // Add a rotation sample 1 second back QAngle vCurAngles = GetLocalAngles(); rotInterpolator.AddToHead( changeTime - 1.0, &vCurAngles, false ); // Add the current rotation rotInterpolator.AddToHead( changeTime - 1.0, &vCurAngles, false ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_BaseObject::Simulate( void ) { if ( IsPlacing() && !MustBeBuiltOnAttachmentPoint() ) { int iValidPlacement = ( IsPlacementPosValid() && ServerValidPlacement() ) ? 1 : 0; if ( m_iLastPlacementPosValid != iValidPlacement ) { m_iLastPlacementPosValid = iValidPlacement; OnPlacementStateChanged( m_iLastPlacementPosValid > 0 ); } // We figure out our own placement pos, but we still leave it to the server to // do collision with other entities and nobuild triggers, so that sets the // placement animation SetLocalOrigin( m_vecBuildOrigin ); InvalidateBoneCache(); // Clear out our origin and rotation interpolation history // so we don't pop when we teleport in the actual position from the server CInterpolatedVar< Vector > &interpolator = GetOriginInterpolator(); interpolator.ClearHistory(); CInterpolatedVar<QAngle> &rotInterpolator = GetRotationInterpolator(); rotInterpolator.ClearHistory(); } BaseClass::Simulate(); }
void C_HL2MPRagdoll::CreateHL2MPRagdoll( void ) { // First, initialize all our data. If we have the player's entity on our client, // then we can make ourselves start out exactly where the player is. C_HL2MP_Player *pPlayer = dynamic_cast< C_HL2MP_Player* >( m_hPlayer.Get() ); if ( pPlayer && !pPlayer->IsDormant() ) { // move my current model instance to the ragdoll's so decals are preserved. pPlayer->SnatchModelInstance( this ); VarMapping_t *varMap = GetVarMapping(); // Copy all the interpolated vars from the player entity. // The entity uses the interpolated history to get bone velocity. bool bRemotePlayer = (pPlayer != C_BasePlayer::GetLocalPlayer()); if ( bRemotePlayer ) { Interp_Copy( pPlayer ); SetAbsAngles( pPlayer->GetRenderAngles() ); GetRotationInterpolator().Reset(); m_flAnimTime = pPlayer->m_flAnimTime; SetSequence( pPlayer->GetSequence() ); m_flPlaybackRate = pPlayer->GetPlaybackRate(); } else { // This is the local player, so set them in a default // pose and slam their velocity, angles and origin SetAbsOrigin( m_vecRagdollOrigin ); SetAbsAngles( pPlayer->GetRenderAngles() ); SetAbsVelocity( m_vecRagdollVelocity ); int iSeq = pPlayer->GetSequence(); if ( iSeq == -1 ) { Assert( false ); // missing walk_lower? iSeq = 0; } SetSequence( iSeq ); // walk_lower, basic pose SetCycle( 0.0 ); Interp_Reset( varMap ); } } else { // overwrite network origin so later interpolation will // use this position SetNetworkOrigin( m_vecRagdollOrigin ); SetAbsOrigin( m_vecRagdollOrigin ); SetAbsVelocity( m_vecRagdollVelocity ); Interp_Reset( GetVarMapping() ); } SetModelIndex( m_nModelIndex ); // Make us a ragdoll.. m_nRenderFX = kRenderFxRagdoll; matrix3x4_t boneDelta0[MAXSTUDIOBONES]; matrix3x4_t boneDelta1[MAXSTUDIOBONES]; matrix3x4_t currentBones[MAXSTUDIOBONES]; const float boneDt = 0.05f; if ( pPlayer && !pPlayer->IsDormant() ) { pPlayer->GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } else { GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt ); }
void C_SDKRagdoll::CreateRagdoll() { // First, initialize all our data. If we have the player's entity on our client, // then we can make ourselves start out exactly where the player is. C_SDKPlayer *pPlayer = dynamic_cast< C_SDKPlayer* >( m_hPlayer.Get() ); if ( pPlayer && !pPlayer->IsDormant() ) { // move my current model instance to the ragdoll's so decals are preserved. pPlayer->SnatchModelInstance( this ); VarMapping_t *varMap = GetVarMapping(); // Copy all the interpolated vars from the player entity. // The entity uses the interpolated history to get bone velocity. if ( !pPlayer->IsLocalPlayer() && pPlayer->IsInterpolationEnabled() ) { Interp_Copy( pPlayer ); SetAbsAngles( pPlayer->GetRenderAngles() ); GetRotationInterpolator().Reset(); m_flAnimTime = pPlayer->m_flAnimTime; SetSequence( pPlayer->GetSequence() ); m_flPlaybackRate = pPlayer->GetPlaybackRate(); } else { // This is the local player, so set them in a default // pose and slam their velocity, angles and origin SetAbsOrigin( m_vecRagdollOrigin ); SetAbsAngles( pPlayer->GetRenderAngles() ); SetAbsVelocity( m_vecRagdollVelocity ); int iSeq = LookupSequence( "RagdollSpawn" ); // hax, find a neutral standing pose if ( iSeq == -1 ) { Assert( false ); // missing look_idle? iSeq = 0; } SetSequence( iSeq ); // look_idle, basic pose SetCycle( 0.0 ); Interp_Reset( varMap ); } m_nBody = pPlayer->GetBody(); } else { // overwrite network origin so later interpolation will // use this position SetNetworkOrigin( m_vecRagdollOrigin ); SetAbsOrigin( m_vecRagdollOrigin ); SetAbsVelocity( m_vecRagdollVelocity ); Interp_Reset( GetVarMapping() ); } SetModelIndex( m_nModelIndex ); // Turn it into a ragdoll. if ( cl_ragdoll_physics_enable.GetInt() ) { // Make us a ragdoll.. m_nRenderFX = kRenderFxRagdoll; matrix3x4_t boneDelta0[MAXSTUDIOBONES]; matrix3x4_t boneDelta1[MAXSTUDIOBONES]; matrix3x4_t currentBones[MAXSTUDIOBONES]; const float boneDt = 0.05f; if ( pPlayer && pPlayer == C_BasePlayer::GetLocalPlayer() ) { pPlayer->GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } else { GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt ); } else { ClientLeafSystem()->SetRenderGroup( GetRenderHandle(), RENDER_GROUP_TRANSLUCENT_ENTITY ); } // Fade out the ragdoll in a while StartFadeOut( cl_ragdoll_fade_time.GetFloat() ); SetNextClientThink( gpGlobals->curtime + 5.0f ); }
void C_GENPCRagdoll::CreateRagdoll( void ) { // First, initialize all our data. If we have the player's entity on our client, // then we can make ourselves start out exactly where the player is. C_AI_BaseNPC *pNPC = dynamic_cast< C_AI_BaseNPC* >( m_hNPC.Get() ); // Cache away our skin before we start meddling (setting it later down) int skin = 0; if ( pNPC ) skin = pNPC->GetSkin(); if ( pNPC && !pNPC->IsDormant() ) { // move my current model instance to the ragdoll's so decals are preserved. pNPC->SnatchModelInstance( this ); // Copy all the interpolated vars from the player entity. // The entity uses the interpolated history to get bone velocity. Interp_Copy( pNPC ); SetAbsAngles( pNPC->GetRenderAngles() ); GetRotationInterpolator().Reset(); m_flAnimTime = pNPC->m_flAnimTime; SetSequence( pNPC->GetSequence() ); m_flPlaybackRate = pNPC->GetPlaybackRate(); } else { // overwrite network origin so later interpolation will // use this position SetNetworkOrigin( m_vecRagdollOrigin ); SetAbsOrigin( m_vecRagdollOrigin ); SetAbsVelocity( m_vecRagdollVelocity ); Interp_Reset( GetVarMapping() ); } SetModelIndex( m_nModelIndex ); // Make us a ragdoll.. m_nRenderFX = kRenderFxRagdoll; matrix3x4_t boneDelta0[MAXSTUDIOBONES]; matrix3x4_t boneDelta1[MAXSTUDIOBONES]; matrix3x4_t currentBones[MAXSTUDIOBONES]; const float boneDt = 0.05f; if ( pNPC && !pNPC->IsDormant() ) { pNPC->GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } else { GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } // Finally reset our skin m_nSkin = skin; InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt ); }
void C_StriderRagdoll::CreateStriderRagdoll( void ) { // First, initialize all our data. If we have the player's entity on our client, // then we can make ourselves start out exactly where the player is. C_QUA_Strider *pStrider = dynamic_cast< C_QUA_Strider* >( m_hStrider.Get()); if ( pStrider) { // move my current model instance to the ragdoll's so decals are preserved. pStrider->SnatchModelInstance( this ); VarMapping_t *varMap = GetVarMapping(); // Copy all the interpolated vars from the player entity. // The entity uses the interpolated history to get bone velocity. /*bool bRemotePlayer = (pPlayer != C_BasePlayer::GetLocalPlayer()); if ( bRemotePlayer ) {*/ Interp_Copy( varMap, this, pStrider, pStrider->C_BaseAnimating::GetVarMapping() ); SetAbsAngles( pStrider->GetRenderAngles() ); GetRotationInterpolator().Reset(); m_flAnimTime = pStrider->m_flAnimTime; SetSequence( pStrider->GetSequence() ); m_flPlaybackRate = pStrider->GetPlaybackRate(); SetPoseParameter(LookupPoseParameter("body_height"),200.0f); /*} else {*/ // This is the local player, so set them in a default // pose and slam their velocity, angles and origin // SetAbsOrigin( m_vecRagdollOrigin ); // // SetAbsAngles( pPlayer->GetRenderAngles() ); // SetAbsVelocity( m_vecRagdollVelocity ); // int iSeq = pPlayer->GetSequence(); // if ( iSeq == -1 ) // { // Assert( false ); // missing walk_lower? // iSeq = 0; // } // // SetSequence( iSeq ); // walk_lower, basic pose // SetCycle( 0.0 ); // Interp_Reset( varMap ); //} } else { // overwrite network origin so later interpolation will // use this position SetNetworkOrigin( m_vecRagdollOrigin ); SetAbsOrigin( m_vecRagdollOrigin ); SetAbsVelocity( m_vecRagdollVelocity ); SetSequence(LookupSequence("idle01")); SetPoseParameter(LookupPoseParameter("body_height"),m_fAltura); Interp_Reset( GetVarMapping() ); } SetModelIndex( m_nModelIndex ); //engine->Con_NPrintf(27,"Le volvemos a poner de altura: %f",m_fAltura); SetPoseParameter(LookupPoseParameter("body_height"),200.0f); // Make us a ragdoll.. m_nRenderFX = kRenderFxRagdoll; BecomeRagdollOnClient( /*false*/ ); //FixMe No? xd }
void C_CFRagdoll::CreateRagdoll() { // First, initialize all our data. If we have the player's entity on our client, // then we can make ourselves start out exactly where the player is. C_CFPlayer *pPlayer = dynamic_cast< C_CFPlayer* >( m_hPlayer.Get() ); if ( pPlayer && !pPlayer->IsDormant() ) { // move my current model instance to the ragdoll's so decals are preserved. pPlayer->SnatchModelInstance( this ); VarMapping_t *varMap = GetVarMapping(); // Copy all the interpolated vars from the player entity. // The entity uses the interpolated history to get bone velocity. bool bRemotePlayer = (pPlayer != C_BasePlayer::GetLocalPlayer()); if ( bRemotePlayer ) { Interp_Copy( pPlayer ); SetAbsAngles( pPlayer->GetRenderAngles() ); GetRotationInterpolator().Reset(); m_flAnimTime = pPlayer->m_flAnimTime; SetSequence( pPlayer->GetSequence() ); m_flPlaybackRate = pPlayer->GetPlaybackRate(); } else { // This is the local player, so set them in a default // pose and slam their velocity, angles and origin SetAbsOrigin( m_vecRagdollOrigin ); SetAbsAngles( pPlayer->GetRenderAngles() ); SetAbsVelocity( m_vecRagdollVelocity ); int iSeq = LookupSequence( "idle" ); if ( iSeq == -1 ) { Assert( false ); // missing walk_lower? iSeq = 0; } SetSequence( iSeq ); // walk_lower, basic pose SetCycle( 0.0 ); Interp_Reset( varMap ); } } else { // overwrite network origin so later interpolation will // use this position SetNetworkOrigin( m_vecRagdollOrigin ); SetAbsOrigin( m_vecRagdollOrigin ); SetAbsVelocity( m_vecRagdollVelocity ); Interp_Reset( GetVarMapping() ); } if (pPlayer) { SetModelIndex( m_nModelIndex ); m_nSkin = pPlayer->m_nSkin; SetBodygroup(1, pPlayer->m_bIsDecapitated); } // Turn it into a ragdoll. if ( cl_ragdoll_physics_enable.GetBool() ) { // Make us a ragdoll.. m_nRenderFX = kRenderFxRagdoll; matrix3x4_t boneDelta0[MAXSTUDIOBONES]; matrix3x4_t boneDelta1[MAXSTUDIOBONES]; matrix3x4_t currentBones[MAXSTUDIOBONES]; const float boneDt = 0.05f; // We have to make sure that we're initting this client ragdoll off of the same model. // GetRagdollInitBoneArrays uses the *player* Hdr, which may be a different model than // the ragdoll Hdr, if we try to create a ragdoll in the same frame that the player // changes their player model. CStudioHdr *pRagdollHdr = GetModelPtr(); CStudioHdr *pPlayerHdr = NULL; if ( pPlayer ) pPlayerHdr = pPlayer->GetModelPtr(); bool bChangedModel = false; if ( pRagdollHdr && pPlayerHdr ) { bChangedModel = pRagdollHdr->GetVirtualModel() != pPlayerHdr->GetVirtualModel(); Assert( !bChangedModel && "C_CFRagdoll::CreateRagdoll: Trying to create ragdoll with a different model than the player it's based on" ); } if ( pPlayer && !pPlayer->IsDormant() && !bChangedModel && pPlayerHdr ) { pPlayer->GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } else { GetRagdollInitBoneArrays( boneDelta0, boneDelta1, currentBones, boneDt ); } InitAsClientRagdoll( boneDelta0, boneDelta1, currentBones, boneDt ); } SetNextClientThink( CLIENT_THINK_ALWAYS ); }