Skip to content

Commit

Permalink
Merge pull request CedricGuillemet#209 from VictorFouquet/fix_normalize
Browse files Browse the repository at this point in the history
Fix division by zero in normalize when view and model matrices are identity
  • Loading branch information
CedricGuillemet authored Nov 7, 2021
2 parents 7c16cac + 0a0268b commit 82a626f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ImGuizmo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ namespace IMGUIZMO_NAMESPACE
const vec_t& operator + () const { return (*this); }
float Length() const { return sqrtf(x * x + y * y + z * z); };
float LengthSq() const { return (x * x + y * y + z * z); };
vec_t Normalize() { (*this) *= (1.f / Length()); return (*this); }
vec_t Normalize() { (*this) *= (1.f / ( Length() > FLT_EPSILON ? Length() : FLT_EPSILON ) ); return (*this); }
vec_t Normalize(const vec_t& v) { this->Set(v.x, v.y, v.z, v.w); this->Normalize(); return (*this); }
vec_t Abs() const;

Expand Down

0 comments on commit 82a626f

Please sign in to comment.