summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2020-01-03 12:34:11 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2020-01-03 12:34:11 -0600
commit120c6dc8506647d3edd33e533bba65bb9bc081c8 (patch)
tree8fcf78a207ed27476d5286a532df416091270e4f /Source/Core
parent540a3ce66529157b18cce539b5e337b4398b87d9 (diff)
DolphinQt: Fix accelerometer indicator math.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp
index cf9c042599..8e81b380d5 100644
--- a/Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp
+++ b/Source/Core/DolphinQt/Config/Mapping/MappingIndicator.cpp
@@ -724,12 +724,11 @@ void AccelerometerMappingIndicator::paintEvent(QPaintEvent*)
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
const auto angle = std::acos(state.Normalized().Dot({0, 0, 1}));
- const auto axis = state.Normalized().Cross({0, 0, 1}).Normalized();
+ const auto axis = state.Normalized().Cross({0, 0, 1});
- // Odd checks to handle case of 0g (draw no sphere) and perfect up/down orientation.
- const auto rotation = (!state.LengthSquared() || axis.LengthSquared() < 2) ?
- Common::Matrix33::Rotate(angle, axis) :
- Common::Matrix33::Identity();
+ // Check that axis is non-zero to handle perfect up/down orientations.
+ const auto rotation = Common::Matrix33::Rotate(
+ angle, axis.LengthSquared() ? axis.Normalized() : Common::Vec3{0, 1, 0});
// Draw sphere.
p.setPen(Qt::NoPen);