diff --git a/Siv3D/include/Siv3D/DebugCamera3D.hpp b/Siv3D/include/Siv3D/DebugCamera3D.hpp index 952252793..a66581c46 100644 --- a/Siv3D/include/Siv3D/DebugCamera3D.hpp +++ b/Siv3D/include/Siv3D/DebugCamera3D.hpp @@ -32,7 +32,11 @@ namespace s3d protected: - double m_focusY = (BasicCamera3D::m_focusPosition - BasicCamera3D::m_eyePosition).normalized().y; + double m_focusY = [this] + { + const auto focusVector = (BasicCamera3D::m_focusPosition - BasicCamera3D::m_eyePosition); + return (focusVector.y / std::hypot(focusVector.x, focusVector.z)); + }(); double m_phi = std::atan2((BasicCamera3D::m_focusPosition.z - BasicCamera3D::m_eyePosition.z), (BasicCamera3D::m_focusPosition.x - BasicCamera3D::m_eyePosition.x)); diff --git a/Siv3D/src/Siv3D/DebugCamera3D/SivDebugCamera3D.cpp b/Siv3D/src/Siv3D/DebugCamera3D/SivDebugCamera3D.cpp index 8f5d8a672..964d84ba1 100644 --- a/Siv3D/src/Siv3D/DebugCamera3D/SivDebugCamera3D.cpp +++ b/Siv3D/src/Siv3D/DebugCamera3D/SivDebugCamera3D.cpp @@ -294,9 +294,9 @@ namespace s3d void DebugCamera3D::setView(const Vec3& eyePosition, const Vec3& focusPosition, const Vec3& upDirection) noexcept { - m_focusY = (focusPosition - eyePosition).normalized().y; - m_phi = std::atan2((focusPosition.z - eyePosition.z), - (focusPosition.x - eyePosition.x)); + const auto focusVector = (focusPosition - eyePosition); + m_focusY = (focusVector.y / std::hypot(focusVector.x, focusVector.z)); + m_phi = std::atan2(focusVector.z, focusVector.x); BasicCamera3D::setView(eyePosition, focusPosition, upDirection); }