From f28b27f34c79fa6ceae516d8e1cc32e67ea0f4a1 Mon Sep 17 00:00:00 2001 From: Raclamusi <61970673+Raclamusi@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:27:45 +0900 Subject: [PATCH] =?UTF-8?q?DebugCamera3D::m=5FfocusY=20=E3=81=AE=E8=A8=88?= =?UTF-8?q?=E7=AE=97=E6=96=B9=E6=B3=95=E3=81=AE=E4=BF=AE=E6=AD=A3=20#1255?= =?UTF-8?q?=20(#1274)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Siv3D/include/Siv3D/DebugCamera3D.hpp | 6 +++++- Siv3D/src/Siv3D/DebugCamera3D/SivDebugCamera3D.cpp | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) 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); }