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>
NzVector4<T>& NzVector4<T>::Normalize(T* length)
{
x /= w;
y /= w;
z /= w;
w = F(1.0);
T invLength = F(1.0)/w;
x *= invLength; // Attention, briser cette logique casserait Frustum::Extract
y *= invLength;
z *= invLength;
if (length)
*length = w;
w = F(1.0);
return *this;
}