mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Handle zero-length vectors when normalizing
This commit is contained in:
parent
d91f2c9fd2
commit
9027e5018b
1 changed files with 6 additions and 2 deletions
|
@ -114,10 +114,14 @@ public:
|
|||
return Vec3(other-(*this)).Length2();
|
||||
}
|
||||
Vec3 Normalized() const {
|
||||
return (*this) / Length();
|
||||
float len = Length();
|
||||
if( len == 0.0f)
|
||||
return (*this);
|
||||
return (*this) / len;
|
||||
}
|
||||
float Normalize() { //returns the previous length, is often useful
|
||||
float len = Length();
|
||||
if( len != 0.0f )
|
||||
(*this) = (*this)/len;
|
||||
return len;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue