Fix potential divide by 0 in vector2
This commit is contained in:
parent
5c837b68a5
commit
a70feefe17
1 changed files with 4 additions and 1 deletions
|
@ -135,7 +135,10 @@ func Vector2Divide(v1, v2 Vector2) Vector2 {
|
|||
|
||||
// Vector2Normalize - Normalize provided vector
|
||||
func Vector2Normalize(v Vector2) Vector2 {
|
||||
return Vector2Scale(v, 1/Vector2Length(v))
|
||||
if l := Vector2Length(v); l > 0 {
|
||||
return Vector2Scale(v, 1/l)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Vector2Transform - Transforms a Vector2 by a given Matrix
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue