From dd2fa12d57345a0c9a55c758facf1b2ce0e4cf7f Mon Sep 17 00:00:00 2001 From: vsonnier Date: Sun, 28 May 2017 14:57:17 +0200 Subject: [PATCH] There is no need for operator bool conversion: - it was there for != NULL checks when convert-to-pointer existed, which is no longer the case. --- external/cubicvr2/math/mat4.h | 28 ++++++++-------------------- external/cubicvr2/math/transform.h | 8 ++------ external/cubicvr2/math/vec3.h | 6 ------ 3 files changed, 10 insertions(+), 32 deletions(-) diff --git a/external/cubicvr2/math/mat4.h b/external/cubicvr2/math/mat4.h index 43edc45..04c2098 100644 --- a/external/cubicvr2/math/mat4.h +++ b/external/cubicvr2/math/mat4.h @@ -39,15 +39,6 @@ namespace CubicVR { return (as_array[i]); } - //compare to ZERO-filled matrix - inline operator bool() const { - - return (a != 0.0f || b != 0.0f || c != 0.0f || d != 0.0f || - e != 0.0f || f != 0.0f || g != 0.0f || h != 0.0f || - i != 0.0f || j != 0.0f || k != 0.0f || l != 0.0f || - m != 0.0f || n != 0.0f || o != 0.0f || p != 0.0f); - } - //To be accessed by GL API directly, accessed by pointer. //operator* overloading is way too dangerous, especially in ptr != NULL //tests. @@ -286,22 +277,19 @@ namespace CubicVR { static mat4 transform(vec3 position, vec3 rotation, vec3 scale) { mat4 m = mat4::identity(); - if (!position) { - m *= mat4::translate(position[0],position[1],position[2]); + m *= mat4::translate(position[0],position[1],position[2]); + + if (!(rotation[0] == 0 && rotation[1] == 0 && rotation[2] == 0)) { + m *= mat4::rotate(rotation[0], rotation[1], rotation[2]); } - if (!rotation) { - if (!(rotation[0] == 0 && rotation[1] == 0 && rotation[2] == 0)) { - m *= mat4::rotate(rotation[0],rotation[1],rotation[2]); - } - } - if (!scale) { - if (!(scale[0] == 1 && scale[1] == 1 && scale[2] == 1)) { - m *= mat4::scale(scale[0],scale[1],scale[2]); - } + + if (!(scale[0] == 1 && scale[1] == 1 && scale[2] == 1)) { + m *= mat4::scale(scale[0],scale[1],scale[2]); } return m; }; + static vec4 vec4_multiply(vec4 m1, mat4 m2) { vec4 mOut; diff --git a/external/cubicvr2/math/transform.h b/external/cubicvr2/math/transform.h index ac223a3..9037128 100644 --- a/external/cubicvr2/math/transform.h +++ b/external/cubicvr2/math/transform.h @@ -73,7 +73,7 @@ namespace CubicVR { void pushMatrix(mat4 m) { c_stack++; - m_stack[c_stack] = (m ? m : getIdentity()); + m_stack[c_stack] = m; } void popMatrix() { @@ -91,11 +91,7 @@ namespace CubicVR { result = mat4::identity(); - if (!init_mat) { - m_stack[0] = init_mat; - } else { - setIdentity(); - } + m_stack[0] = init_mat; } void translate(__float x, __float y, __float z) { diff --git a/external/cubicvr2/math/vec3.h b/external/cubicvr2/math/vec3.h index 2675cee..33bc652 100644 --- a/external/cubicvr2/math/vec3.h +++ b/external/cubicvr2/math/vec3.h @@ -39,12 +39,6 @@ namespace CubicVR { return (as_array[i]); } - //compare to ZERO-filled vector - inline operator bool() const { - - return (x != 0.0f || y != 0.0f || z != 0.0f); - } - vec3 (__float xi,__float yi,__float zi) { x = xi; y = yi; z = zi; } vec3 () { x = y = z = 0.0f; }