Improved Vector4::Normalize

Fixed length output


Former-commit-id: 2ff9aeca4e125965251187a1b7e2a4c6e0c08e5a
This commit is contained in:
Lynix 2013-02-19 01:19:31 +01:00
parent b6940e9d8b
commit 0051b76b9b
1 changed files with 6 additions and 5 deletions

View File

@ -130,15 +130,16 @@ NzVector4<T>& NzVector4<T>::Minimize(const NzVector4& vec)
template<typename T> template<typename T>
NzVector4<T>& NzVector4<T>::Normalize(T* length) NzVector4<T>& NzVector4<T>::Normalize(T* length)
{ {
x /= w; T invLength = F(1.0)/w;
y /= w; x *= invLength; // Attention, briser cette logique casserait Frustum::Extract
z /= w; y *= invLength;
z *= invLength;
w = F(1.0);
if (length) if (length)
*length = w; *length = w;
w = F(1.0);
return *this; return *this;
} }