From caaefe206bcea74aa1e4ed6f3fd7e8dec1b1ab45 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 18 Jan 2022 12:01:36 +0800 Subject: [PATCH] used Vector3f instead of Vector4f at lookat function. --- inc/hgl/math/Matrix.h | 2 +- src/Math/Matrix4f.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/inc/hgl/math/Matrix.h b/inc/hgl/math/Matrix.h index 4e30684..4697539 100644 --- a/inc/hgl/math/Matrix.h +++ b/inc/hgl/math/Matrix.h @@ -74,7 +74,7 @@ namespace hgl * @param target 目标位置 * @param up 向上向量 */ - Matrix4f lookat(const Vector4f &eye,const Vector4f &target,const Vector4f &up); + Matrix4f lookat(const Vector3f &eye,const Vector3f &target,const Vector3f &up); inline Matrix4f translate(const Vector3f &v) { diff --git a/src/Math/Matrix4f.cpp b/src/Math/Matrix4f.cpp index 073a76a..d5aca47 100644 --- a/src/Math/Matrix4f.cpp +++ b/src/Math/Matrix4f.cpp @@ -103,12 +103,12 @@ namespace hgl ); } - Matrix4f lookat(const Vector4f &eye,const Vector4f &target,const Vector4f &up) + Matrix4f lookat(const Vector3f &eye,const Vector3f &target,const Vector3f &up) { - Vector4f forward=normalize(target-eye); - Vector4f right=normalize(cross(forward,up)); + Vector3f forward=normalize(target-eye); + Vector3f right=normalize(cross(forward,up)); - Vector4f nup=cross(right,forward); + Vector3f nup=cross(right,forward); return Matrix4f( right.x, nup.x,