WiimoteEmu: Apply "Tilt" rotations separately and before those of "Point" and "Swing" for proper tilted pointing.

This commit is contained in:
Jordan Woyak 2020-04-18 13:15:52 -05:00
parent 2d8758daaa
commit bd067875e7
2 changed files with 5 additions and 4 deletions

View File

@ -96,7 +96,8 @@ void Nunchuk::Update()
EmulateTilt(&m_tilt_state, m_tilt, 1.f / ::Wiimote::UPDATE_FREQ);
EmulateShake(&m_shake_state, m_shake, 1.f / ::Wiimote::UPDATE_FREQ);
const auto transformation = GetRotationalMatrix(-m_tilt_state.angle - m_swing_state.angle);
const auto transformation =
GetRotationalMatrix(-m_tilt_state.angle) * GetRotationalMatrix(-m_swing_state.angle);
Common::Vec3 accel =
transformation *

View File

@ -823,9 +823,9 @@ Common::Matrix44 Wiimote::GetTransformation(const Common::Matrix33& extra_rotati
// TODO: Think about and clean up matrix order + make nunchuk match.
return Common::Matrix44::Translate(-m_shake_state.position) *
Common::Matrix44::FromMatrix33(
extra_rotation * GetRotationalMatrix(-m_tilt_state.angle - m_swing_state.angle -
m_cursor_state.angle)) *
Common::Matrix44::FromMatrix33(extra_rotation * GetRotationalMatrix(-m_tilt_state.angle) *
GetRotationalMatrix(-m_cursor_state.angle) *
GetRotationalMatrix(-m_swing_state.angle)) *
Common::Matrix44::Translate(-m_swing_state.position - m_cursor_state.position);
}