Skip to content

Commit

Permalink
Near perfect match of unarmed head yaw compared to vanilla
Browse files Browse the repository at this point in the history
  • Loading branch information
yohjimane committed Aug 27, 2023
1 parent a2b5744 commit 1515602
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/xrGame/ActorAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ static const float p_spin0_factor = 0.0f;
static const float p_spin1_factor = 0.2f;
static const float p_shoulder_factor = 0.7f;
static const float p_head_factor = 0.1f;
static const float p_head_unarmed_factor = 0.1f;
static const float r_spin0_factor = 0.3f;
static const float r_spin1_factor = 0.3f;
static const float r_shoulder_factor = 0.2f;
Expand Down Expand Up @@ -80,13 +81,15 @@ void CActor::Spine2Callback(CBoneInstance* B)
B->mTransform.mulA_43(spin);
B->mTransform.c = c;
}
extern Fvector g_first_person_cam_offset;
void CActor::HeadCallback(CBoneInstance* B)
{
CActor* A = static_cast<CActor*>(B->callback_param());
VERIFY(A);
Fmatrix spin;
float bone_yaw = angle_normalize_signed(A->r_torso.yaw - A->r_model_yaw - A->r_model_yaw_delta) * y_head_factor;
float bone_pitch = angle_normalize_signed(A->r_torso.pitch) * p_head_factor;
float correctedHeadFactor = A->inventory().GetActiveSlot() == NO_ACTIVE_SLOT ? p_head_unarmed_factor : p_head_factor;
float bone_pitch = angle_normalize_signed(A->cam_Active()->GetWorldPitch()) * correctedHeadFactor;
float bone_roll = angle_normalize_signed(A->r_torso.roll) * r_head_factor;
Fvector c = B->mTransform.c;
spin.setXYZ(-bone_pitch, bone_yaw, bone_roll);
Expand Down

0 comments on commit 1515602

Please sign in to comment.