Added spawnflag to make prop_ragdoll bones use constraints which are fixed to each other (also known as "make statue")

This commit is contained in:
Blixibon 2021-01-23 09:32:28 -06:00
parent 8e283f3738
commit b720ec4c84
2 changed files with 16 additions and 0 deletions

View File

@ -56,6 +56,9 @@ const float ATTACHED_DAMPING_SCALE = 50.0f;
#define SF_RAGDOLLPROP_MOTIONDISABLED 0x4000
#define SF_RAGDOLLPROP_ALLOW_STRETCH 0x8000
#define SF_RAGDOLLPROP_STARTASLEEP 0x10000
#ifdef MAPBASE
#define SF_RAGDOLLPROP_FIXED_CONSTRAINTS 0x20000
#endif
//-----------------------------------------------------------------------------
// Networking
@ -758,7 +761,11 @@ void CRagdollProp::InitRagdoll( const Vector &forceVector, int forceBone, const
params.pCurrentBones = pBoneToWorld;
params.jointFrictionScale = 1.0;
params.allowStretch = HasSpawnFlags(SF_RAGDOLLPROP_ALLOW_STRETCH);
#ifdef MAPBASE
params.fixedConstraints = HasSpawnFlags(SF_RAGDOLLPROP_FIXED_CONSTRAINTS);
#else
params.fixedConstraints = false;
#endif
RagdollCreate( m_ragdoll, params, physenv );
RagdollApplyAnimationAsVelocity( m_ragdoll, pPrevBones, pBoneToWorld, dt );
if ( m_anglesOverrideString != NULL_STRING && Q_strlen(m_anglesOverrideString.ToCStr()) > 0 )

View File

@ -174,6 +174,10 @@ void RagdollSetupAnimatedFriction( IPhysicsEnvironment *pPhysEnv, ragdoll_t *rag
}
}
#ifdef MAPBASE
ConVar g_ragdoll_fixed_constraints_mass( "g_ragdoll_fixed_constraints_mass", "1000", FCVAR_REPLICATED );
#endif
static void RagdollAddSolid( IPhysicsEnvironment *pPhysEnv, ragdoll_t &ragdoll, const ragdollparams_t &params, solid_t &solid )
{
if ( solid.index >= 0 && solid.index < params.pCollide->solidCount)
@ -186,7 +190,12 @@ static void RagdollAddSolid( IPhysicsEnvironment *pPhysEnv, ragdoll_t &ragdoll,
{
if ( params.fixedConstraints )
{
#ifdef MAPBASE
if (g_ragdoll_fixed_constraints_mass.GetFloat() != -1)
solid.params.mass = g_ragdoll_fixed_constraints_mass.GetFloat();
#else
solid.params.mass = 1000.f;
#endif
}
solid.params.rotInertiaLimit = 0.1;