mirror of
https://github.com/recp/cglm.git
synced 2026-01-02 05:28:15 +00:00
fix scale_as for zero length vector
* return zero if vector length is zero
This commit is contained in:
@@ -247,8 +247,8 @@ glm_vec_scale_as(vec3 v, float s, vec3 dest) {
|
||||
float norm;
|
||||
norm = glm_vec_norm(v);
|
||||
|
||||
if (norm == 0) {
|
||||
glm_vec_copy(v, dest);
|
||||
if (norm == 0.0f) {
|
||||
glm_vec_zero(dest);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -291,8 +291,8 @@ glm_vec4_scale_as(vec4 v, float s, vec4 dest) {
|
||||
float norm;
|
||||
norm = glm_vec4_norm(v);
|
||||
|
||||
if (norm == 0) {
|
||||
glm_vec4_copy(v, dest);
|
||||
if (norm == 0.0f) {
|
||||
glm_vec4_zero(dest);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user