diff --git a/include/cglm/plane.h b/include/cglm/plane.h index 7a5291d..15ae580 100644 --- a/include/cglm/plane.h +++ b/include/cglm/plane.h @@ -30,7 +30,14 @@ CGLM_INLINE void glm_plane_normalize(vec4 plane) { - glm_vec4_scale(plane, 1.0f / glm_vec3_norm(plane), plane); + float norm; + + if ((norm = glm_vec3_norm(plane)) == 0.0f) { + glm_vec4_zero(plane); + return; + } + + glm_vec4_scale(plane, 1.0f / norm, plane); } #endif /* cglm_plane_h */