Skip to content

Commit 1515602

Browse files
committed
Near perfect match of unarmed head yaw compared to vanilla
1 parent a2b5744 commit 1515602

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/xrGame/ActorAnimation.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static const float p_spin0_factor = 0.0f;
3030
static const float p_spin1_factor = 0.2f;
3131
static const float p_shoulder_factor = 0.7f;
3232
static const float p_head_factor = 0.1f;
33+
static const float p_head_unarmed_factor = 0.1f;
3334
static const float r_spin0_factor = 0.3f;
3435
static const float r_spin1_factor = 0.3f;
3536
static const float r_shoulder_factor = 0.2f;
@@ -80,13 +81,15 @@ void CActor::Spine2Callback(CBoneInstance* B)
8081
B->mTransform.mulA_43(spin);
8182
B->mTransform.c = c;
8283
}
84+
extern Fvector g_first_person_cam_offset;
8385
void CActor::HeadCallback(CBoneInstance* B)
8486
{
8587
CActor* A = static_cast<CActor*>(B->callback_param());
8688
VERIFY(A);
8789
Fmatrix spin;
8890
float bone_yaw = angle_normalize_signed(A->r_torso.yaw - A->r_model_yaw - A->r_model_yaw_delta) * y_head_factor;
89-
float bone_pitch = angle_normalize_signed(A->r_torso.pitch) * p_head_factor;
91+
float correctedHeadFactor = A->inventory().GetActiveSlot() == NO_ACTIVE_SLOT ? p_head_unarmed_factor : p_head_factor;
92+
float bone_pitch = angle_normalize_signed(A->cam_Active()->GetWorldPitch()) * correctedHeadFactor;
9093
float bone_roll = angle_normalize_signed(A->r_torso.roll) * r_head_factor;
9194
Fvector c = B->mTransform.c;
9295
spin.setXYZ(-bone_pitch, bone_yaw, bone_roll);

0 commit comments

Comments
 (0)