From 55ed12f8d1eb6887d348be03aee5573d44177ffb Mon Sep 17 00:00:00 2001 From: Michael Sartain Date: Thu, 2 Oct 2014 08:25:55 -0700 Subject: Updated the SDK with the latest code from the TF and HL2 branches. --- mp/src/game/shared/props_shared.cpp | 46 ++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 11 deletions(-) (limited to 'mp/src/game/shared/props_shared.cpp') diff --git a/mp/src/game/shared/props_shared.cpp b/mp/src/game/shared/props_shared.cpp index 6d0f9209..7bb0c03b 100644 --- a/mp/src/game/shared/props_shared.cpp +++ b/mp/src/game/shared/props_shared.cpp @@ -600,6 +600,10 @@ public: pModel->mpBreakMode = MULTIPLAYER_BREAK_CLIENTSIDE; } } + else if ( !strcmpi( pKey, "velocity" ) ) + { + UTIL_StringToVector( pModel->velocity.Base(), pValue ); + } } virtual void SetDefaults( void *pData ) { @@ -617,6 +621,7 @@ public: pModel->placementName[0] = 0; pModel->placementIsBone = false; pModel->mpBreakMode = MULTIPLAYER_BREAK_DEFAULT; + pModel->velocity = vec3_origin; m_wroteCollisionGroup = false; } @@ -626,7 +631,7 @@ private: bool m_wroteCollisionGroup; }; -void BreakModelList( CUtlVector &list, int modelindex, float defBurstScale, int defCollisionGroup ) +void BuildPropList( const char *pszBlockName, CUtlVector &list, int modelindex, float defBurstScale, int defCollisionGroup ) { vcollide_t *pCollide = modelinfo->GetVCollide( modelindex ); if ( !pCollide ) @@ -638,7 +643,7 @@ void BreakModelList( CUtlVector &list, int modelindex, float defBu CBreakParser breakParser( defBurstScale, defCollisionGroup ); const char *pBlock = pParse->GetCurrentBlockName(); - if ( !strcmpi( pBlock, "break" ) ) + if ( !strcmpi( pBlock, pszBlockName ) ) { int index = list.AddToTail(); breakmodel_t &breakModel = list[index]; @@ -652,6 +657,11 @@ void BreakModelList( CUtlVector &list, int modelindex, float defBu physcollision->VPhysicsKeyParserDestroy( pParse ); } +void BreakModelList( CUtlVector &list, int modelindex, float defBurstScale, int defCollisionGroup ) +{ + BuildPropList( "break", list, modelindex, defBurstScale, defCollisionGroup ); +} + #if !defined(_STATIC_LINKED) || defined(CLIENT_DLL) int GetAutoMultiplayerPhysicsMode( Vector size, float mass ) { @@ -1226,9 +1236,8 @@ void PropBreakableCreateAll( int modelindex, IPhysicsObject *pPhysics, const Vec // Purpose: // Input : modelindex - //----------------------------------------------------------------------------- -void PrecacheGibsForModel( int iModel ) +void PrecachePropsForModel( int iModel, const char *pszBlockName ) { - VPROF_BUDGET( "PrecacheGibsForModel", VPROF_BUDGETGROUP_PLAYER ); vcollide_t *pCollide = modelinfo->GetVCollide( iModel ); if ( !pCollide ) return; @@ -1241,7 +1250,7 @@ void PrecacheGibsForModel( int iModel ) while ( !pParse->Finished() ) { const char *pBlock = pParse->GetCurrentBlockName(); - if ( !strcmpi( pBlock, "break" ) ) + if ( !strcmpi( pBlock, pszBlockName ) ) { breakmodel_t breakModel; pParse->ParseCustom( &breakModel, &breakParser ); @@ -1257,6 +1266,12 @@ void PrecacheGibsForModel( int iModel ) physcollision->VPhysicsKeyParserDestroy( pParse ); } +void PrecacheGibsForModel( int iModel ) +{ + VPROF_BUDGET( "PrecacheGibsForModel", VPROF_BUDGETGROUP_PLAYER ); + PrecachePropsForModel( iModel, "break" ); +} + //----------------------------------------------------------------------------- // Purpose: // Input : &list - @@ -1448,12 +1463,21 @@ CBaseEntity *CreateGibsFromList( CUtlVector &list, int modelindex, } Vector objectVelocity = params.velocity; - float flScale = VectorNormalize( objectVelocity ); - objectVelocity.x += RandomFloat( -1.f, 1.0f ); - objectVelocity.y += RandomFloat( -1.0f, 1.0f ); - objectVelocity.z += RandomFloat( 0.0f, 1.0f ); - VectorNormalize( objectVelocity ); - objectVelocity *= flScale; + Vector gibVelocity = vec3_origin; + if ( !list[i].velocity.IsZero() ) + { + VectorRotate( list[i].velocity, matrix, gibVelocity ); + objectVelocity = gibVelocity; + } + else + { + float flScale = VectorNormalize( objectVelocity ); + objectVelocity.x += RandomFloat( -1.f, 1.0f ); + objectVelocity.y += RandomFloat( -1.0f, 1.0f ); + objectVelocity.z += RandomFloat( 0.0f, 1.0f ); + VectorNormalize( objectVelocity ); + objectVelocity *= flScale; + } if (pPhysics) { -- cgit v1.2.3