Permalink
Browse files

bsuit: Horrible hack to stop gun clipping

  • Loading branch information...
DolceTriade committed Oct 14, 2017
1 parent 8fa048c commit 7870f49a2763bfb2542b21deb1e84230c623f5bc
@@ -6,10 +6,10 @@ modifiers
{
HandDelta
Segmented
HumanRotations
BattlesuitRotations
}

headoffset 0 -5.0 16
headoffset 0 -5.0 16
footsteps default

// the client game needs to know the names of the first and the last
@@ -168,13 +168,20 @@ static bool CG_ParseCharacterFile( const char *filename, clientInfo_t *ci )
if ( !Q_stricmp( token, "HandDelta" ) )
{
ci->modifiers.emplace_back(new AnimDelta());
} else if ( !Q_stricmp( token, "HumanRotations" ) )
}
else if ( !Q_stricmp( token, "HumanRotations" ) )
{
ci->modifiers.emplace_back(new HumanSkeletonRotations());
} else if ( !Q_stricmp( token, "Segmented" ) )
}
else if ( !Q_stricmp( token, "BattlesuitRotations" ) )
{
ci->modifiers.emplace_back(new BsuitSkeletonRotations());
}
else if ( !Q_stricmp( token, "Segmented" ) )
{
ci->modifiers.emplace_back(new SegmentedSkeletonCombiner());
} else
}
else
{
Log::Notice("Unknown modifier '%s' in %s's character.cfg", token, ci->modelName);
}
@@ -85,6 +85,45 @@ void HumanSkeletonRotations::Apply(const SkeletonModifierContext& ctx, refSkelet
QuatMultiply2( skeleton->bones[ leftShoulderBone ].t.rot, rotation );
}

bool BsuitSkeletonRotations::ParseConfiguration(clientInfo_t* ci, const char* token, const char** data_p)
{
if (!Q_stricmp(token, "torsoControlBone")) {
torsoControlBone = BoneLookup(ci, COM_Parse2(data_p));
return true;
}
if (!Q_stricmp(token, "leftShoulder")) {
leftShoulderBone = BoneLookup(ci, COM_Parse2(data_p));
return true;
}
if (!Q_stricmp(token, "rightShoulder")) {
rightShoulderBone = BoneLookup(ci, COM_Parse2(data_p));
return true;
}
return false;
}

void BsuitSkeletonRotations::Apply(const SkeletonModifierContext& ctx, refSkeleton_t* skeleton)
{
// rotate torso
if ( torsoControlBone >= 0 && torsoControlBone < skeleton->numBones )
{
// HACK: convert angles to bone system
quat_t rotation;
QuatFromAngles( rotation, ctx.torsoYawAngle, 0, 0 );
QuatMultiply2( skeleton->bones[ torsoControlBone ].t.rot, rotation );
}

// HACK: limit angle (avoids worst of the gun clipping through the body)
// Needs some proper animation fixes...
auto pitch = Math::Clamp<vec_t>(ctx.pitchAngle, -40, 20);
quat_t rotation;
QuatFromAngles( rotation, -pitch, 0, 0 );
QuatMultiply2( skeleton->bones[ rightShoulderBone ].t.rot, rotation );

// Relationships are emphirically derived. They will probably need to be changed upon changes to the human model
QuatFromAngles( rotation, pitch, 0, 0);
QuatMultiply2( skeleton->bones[ leftShoulderBone ].t.rot, rotation );
}

bool SegmentedSkeletonCombiner::ParseConfiguration(clientInfo_t* ci, const char* token, const char** data_p)
{
@@ -38,6 +38,18 @@ class HumanSkeletonRotations : public SkeletonModifier
int rightShoulderBone = -1;
};

class BsuitSkeletonRotations : public SkeletonModifier
{
public:
virtual bool ParseConfiguration( clientInfo_t* ci, const char* token, const char** data_p ) override;
virtual void Apply( const SkeletonModifierContext& ctx, refSkeleton_t* skeleton ) override;

private:
int torsoControlBone = -1;
int leftShoulderBone = -1;
int rightShoulderBone = -1;
};


class SegmentedSkeletonCombiner : public SkeletonModifier
{

0 comments on commit 7870f49

Please sign in to comment.