Skip to content

Commit

Permalink
DebugCamera3D::m_focusY の計算方法の修正 #1255 (#1274)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raclamusi authored Nov 17, 2024
1 parent 762eb79 commit f28b27f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Siv3D/include/Siv3D/DebugCamera3D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions Siv3D/src/Siv3D/DebugCamera3D/SivDebugCamera3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit f28b27f

Please sign in to comment.