Skip to content

Commit

Permalink
Fix stability issues with muzzle direction
Browse files Browse the repository at this point in the history
  • Loading branch information
fholger committed Aug 20, 2023
1 parent 488fe0f commit c08da63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Sources/CryGame C++/Solution1/CryGame/WeaponClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,10 @@ void CWeaponClass::GetMuzzlePosAngles(Vec3& muzzlePos, Vec3& muzzleAngles)
Matrix34 worldMuzzleTransform = m * m_muzzleTransform * Matrix33::CreateRotationY(gf_PI_DIV_2);

// eliminate roll from the final transform, to make grenade throws more consistent
Vec3 fwd = worldMuzzleTransform.GetForward();
Vec3 fwd = worldMuzzleTransform.GetForward().GetNormalized();
Vec3 up = Vec3(0, 0, 1);
Vec3 left = -fwd.Cross(up);
up = left.Cross(-fwd);
Vec3 left = -fwd.Cross(up).GetNormalized();
up = left.Cross(-fwd).GetNormalized();
worldMuzzleTransform.SetMatFromVectors(left, -fwd, up, worldMuzzleTransform.GetTranslation());

muzzleAngles = ToAnglesDeg(worldMuzzleTransform);
Expand Down
6 changes: 3 additions & 3 deletions Sources/CryGame C++/Solution1/CryGame/XPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2475,9 +2475,9 @@ void CPlayer::ModifyWeaponPosition(CWeaponClass* weapon, Vec3& weaponAngles, Vec
Matrix34 worldOffHandTransform = GetWorldControllerTransform(m_offHand);
Vec3 forward = worldOffHandTransform.GetTranslation() - worldControllerTransform.GetTranslation();
forward.Normalize();
Vec3 left = ((Matrix33)worldControllerTransform).GetColumn(0);
Vec3 up = left.Cross(-forward);
left = -forward.Cross(up);
Vec3 left = ((Matrix33)worldControllerTransform).GetColumn(0).GetNormalized();
Vec3 up = left.Cross(-forward).GetNormalized();
left = -forward.Cross(up).GetNormalized();
worldControllerTransform.SetMatFromVectors(left, -forward, up, worldControllerTransform.GetTranslation());
}

Expand Down

0 comments on commit c08da63

Please sign in to comment.