diff --git a/contrib/bobtoolz/DEntity.cpp b/contrib/bobtoolz/DEntity.cpp index 47e48d28..0d11e6f4 100644 --- a/contrib/bobtoolz/DEntity.cpp +++ b/contrib/bobtoolz/DEntity.cpp @@ -532,10 +532,10 @@ void DEntity::SpawnInt( const char* key, const char* defaultstring, int* out ){ void DEntity::SpawnFloat( const char* key, const char* defaultstring, float* out ){ DEPair* pEP = FindEPairByKey( key ); if ( pEP ) { - *out = static_cast( atof( pEP->value.c_str() ) ); + *out = atof( pEP->value.c_str() ); } else { - *out = static_cast( atof( defaultstring ) ); + *out = atof( defaultstring ); } } diff --git a/contrib/bobtoolz/DTreePlanter.h b/contrib/bobtoolz/DTreePlanter.h index f7766d7b..87d81cb5 100644 --- a/contrib/bobtoolz/DTreePlanter.h +++ b/contrib/bobtoolz/DTreePlanter.h @@ -171,12 +171,12 @@ public: GT; CT; - m_minScale = static_cast( atof( pToken ) ); + m_minScale = atof( pToken ); GT; CT; - m_maxScale = static_cast( atof( pToken ) ); + m_maxScale = atof( pToken ); m_useScale = true; } diff --git a/contrib/bobtoolz/cportals.cpp b/contrib/bobtoolz/cportals.cpp index 8e6efc08..055ee6e5 100644 --- a/contrib/bobtoolz/cportals.cpp +++ b/contrib/bobtoolz/cportals.cpp @@ -47,11 +47,11 @@ void ClampFloat( float* p ){ } if ( std::fabs( *p - ceil( *p ) ) < MAX_ROUND_ERROR ) { - *p = static_cast( ceil( *p ) ); + *p = ceil( *p ); } if ( std::fabs( *p - floor( *p ) ) < MAX_ROUND_ERROR ) { - *p = static_cast( floor( *p ) ); + *p = floor( *p ); } } diff --git a/libs/math/frustum.h b/libs/math/frustum.h index a59c3773..f25d2b4b 100644 --- a/libs/math/frustum.h +++ b/libs/math/frustum.h @@ -32,21 +32,21 @@ inline Matrix4 matrix4_frustum( float left, float right, float bottom, float top, float nearval, float farval ){ return Matrix4( - static_cast( ( 2 * nearval ) / ( right - left ) ), + ( 2 * nearval ) / ( right - left ), 0, 0, 0, 0, - static_cast( ( 2 * nearval ) / ( top - bottom ) ), + ( 2 * nearval ) / ( top - bottom ), 0, 0, - static_cast( ( right + left ) / ( right - left ) ), - static_cast( ( top + bottom ) / ( top - bottom ) ), - static_cast( -( farval + nearval ) / ( farval - nearval ) ), + ( right + left ) / ( right - left ), + ( top + bottom ) / ( top - bottom ), + -( farval + nearval ) / ( farval - nearval ), -1, 0, 0, - static_cast( -( 2 * farval * nearval ) / ( farval - nearval ) ), + -( 2 * farval * nearval ) / ( farval - nearval ), 0 ); } @@ -106,12 +106,12 @@ public: if ( b0 ^ b1 ) { *out = vector4_subtracted( *next, *i ); - double scale = ClipPlane::scale( *i, *out ); + const double scale = ClipPlane::scale( *i, *out ); - ( *out )[0] = static_cast( ( *i )[0] + scale * ( ( *out )[0] ) ); - ( *out )[1] = static_cast( ( *i )[1] + scale * ( ( *out )[1] ) ); - ( *out )[2] = static_cast( ( *i )[2] + scale * ( ( *out )[2] ) ); - ( *out )[3] = static_cast( ( *i )[3] + scale * ( ( *out )[3] ) ); + ( *out )[0] = ( *i )[0] + scale * ( ( *out )[0] ); + ( *out )[1] = ( *i )[1] + scale * ( ( *out )[1] ); + ( *out )[2] = ( *i )[2] + scale * ( ( *out )[2] ); + ( *out )[3] = ( *i )[3] + scale * ( ( *out )[3] ); ++out; } @@ -231,12 +231,12 @@ inline std::size_t homogenous_clip_line( Vector4 clipped[2] ){ if ( index ^ CLIP_X_LT_W( p1 ) ) { Vector4 clip( vector4_subtracted( p1, p0 ) ); - double scale = ( p0[0] - p0[3] ) / ( clip[3] - clip[0] ); + const double scale = ( p0[0] - p0[3] ) / ( clip[3] - clip[0] ); - clip[0] = static_cast( p0[0] + scale * clip[0] ); - clip[1] = static_cast( p0[1] + scale * clip[1] ); - clip[2] = static_cast( p0[2] + scale * clip[2] ); - clip[3] = static_cast( p0[3] + scale * clip[3] ); + clip[0] = p0[0] + scale * clip[0]; + clip[1] = p0[1] + scale * clip[1]; + clip[2] = p0[2] + scale * clip[2]; + clip[3] = p0[3] + scale * clip[3]; clipped[index] = clip; } @@ -250,12 +250,12 @@ inline std::size_t homogenous_clip_line( Vector4 clipped[2] ){ if ( index ^ CLIP_X_GT_W( p1 ) ) { Vector4 clip( vector4_subtracted( p1, p0 ) ); - double scale = ( p0[0] + p0[3] ) / ( -clip[3] - clip[0] ); + const double scale = ( p0[0] + p0[3] ) / ( -clip[3] - clip[0] ); - clip[0] = static_cast( p0[0] + scale * clip[0] ); - clip[1] = static_cast( p0[1] + scale * clip[1] ); - clip[2] = static_cast( p0[2] + scale * clip[2] ); - clip[3] = static_cast( p0[3] + scale * clip[3] ); + clip[0] = p0[0] + scale * clip[0]; + clip[1] = p0[1] + scale * clip[1]; + clip[2] = p0[2] + scale * clip[2]; + clip[3] = p0[3] + scale * clip[3]; clipped[index] = clip; } @@ -269,12 +269,12 @@ inline std::size_t homogenous_clip_line( Vector4 clipped[2] ){ if ( index ^ CLIP_Y_LT_W( p1 ) ) { Vector4 clip( vector4_subtracted( p1, p0 ) ); - double scale = ( p0[1] - p0[3] ) / ( clip[3] - clip[1] ); + const double scale = ( p0[1] - p0[3] ) / ( clip[3] - clip[1] ); - clip[0] = static_cast( p0[0] + scale * clip[0] ); - clip[1] = static_cast( p0[1] + scale * clip[1] ); - clip[2] = static_cast( p0[2] + scale * clip[2] ); - clip[3] = static_cast( p0[3] + scale * clip[3] ); + clip[0] = p0[0] + scale * clip[0]; + clip[1] = p0[1] + scale * clip[1]; + clip[2] = p0[2] + scale * clip[2]; + clip[3] = p0[3] + scale * clip[3]; clipped[index] = clip; } @@ -288,12 +288,12 @@ inline std::size_t homogenous_clip_line( Vector4 clipped[2] ){ if ( index ^ CLIP_Y_GT_W( p1 ) ) { Vector4 clip( vector4_subtracted( p1, p0 ) ); - double scale = ( p0[1] + p0[3] ) / ( -clip[3] - clip[1] ); + const double scale = ( p0[1] + p0[3] ) / ( -clip[3] - clip[1] ); - clip[0] = static_cast( p0[0] + scale * clip[0] ); - clip[1] = static_cast( p0[1] + scale * clip[1] ); - clip[2] = static_cast( p0[2] + scale * clip[2] ); - clip[3] = static_cast( p0[3] + scale * clip[3] ); + clip[0] = p0[0] + scale * clip[0]; + clip[1] = p0[1] + scale * clip[1]; + clip[2] = p0[2] + scale * clip[2]; + clip[3] = p0[3] + scale * clip[3]; clipped[index] = clip; } @@ -307,12 +307,12 @@ inline std::size_t homogenous_clip_line( Vector4 clipped[2] ){ if ( index ^ CLIP_Z_LT_W( p1 ) ) { Vector4 clip( vector4_subtracted( p1, p0 ) ); - double scale = ( p0[2] - p0[3] ) / ( clip[3] - clip[2] ); + const double scale = ( p0[2] - p0[3] ) / ( clip[3] - clip[2] ); - clip[0] = static_cast( p0[0] + scale * clip[0] ); - clip[1] = static_cast( p0[1] + scale * clip[1] ); - clip[2] = static_cast( p0[2] + scale * clip[2] ); - clip[3] = static_cast( p0[3] + scale * clip[3] ); + clip[0] = p0[0] + scale * clip[0]; + clip[1] = p0[1] + scale * clip[1]; + clip[2] = p0[2] + scale * clip[2]; + clip[3] = p0[3] + scale * clip[3]; clipped[index] = clip; } @@ -326,12 +326,12 @@ inline std::size_t homogenous_clip_line( Vector4 clipped[2] ){ if ( index ^ CLIP_Z_GT_W( p1 ) ) { Vector4 clip( vector4_subtracted( p1, p0 ) ); - double scale = ( p0[2] + p0[3] ) / ( -clip[3] - clip[2] ); + const double scale = ( p0[2] + p0[3] ) / ( -clip[3] - clip[2] ); - clip[0] = static_cast( p0[0] + scale * clip[0] ); - clip[1] = static_cast( p0[1] + scale * clip[1] ); - clip[2] = static_cast( p0[2] + scale * clip[2] ); - clip[3] = static_cast( p0[3] + scale * clip[3] ); + clip[0] = p0[0] + scale * clip[0]; + clip[1] = p0[1] + scale * clip[1]; + clip[2] = p0[2] + scale * clip[2]; + clip[3] = p0[3] + scale * clip[3]; clipped[index] = clip; } @@ -388,12 +388,12 @@ inline std::size_t matrix4_clip_line_by_nearplane( const Matrix4& self, Line& li if ( index ^ CLIP_Z_GT_W( p1 ) ) { Vector4 clip( vector4_subtracted( p1, p0 ) ); - double scale = ( p0[2] + p0[3] ) / ( -clip[3] - clip[2] ); + const double scale = ( p0[2] + p0[3] ) / ( -clip[3] - clip[2] ); - clip[0] = static_cast( p0[0] + scale * clip[0] ); - clip[1] = static_cast( p0[1] + scale * clip[1] ); - clip[2] = static_cast( p0[2] + scale * clip[2] ); - clip[3] = static_cast( p0[3] + scale * clip[3] ); + clip[0] = p0[0] + scale * clip[0]; + clip[1] = p0[1] + scale * clip[1]; + clip[2] = p0[2] + scale * clip[2]; + clip[3] = p0[3] + scale * clip[3]; points[index] = clip; } diff --git a/libs/math/matrix.h b/libs/math/matrix.h index e910215b..7da96bf6 100644 --- a/libs/math/matrix.h +++ b/libs/math/matrix.h @@ -448,24 +448,24 @@ inline Matrix4 matrix4_affine_inverse( const Matrix4& self ){ double det = self[0] * ( self[5] * self[10] - self[9] * self[6] ) - self[1] * ( self[4] * self[10] - self[8] * self[6] ) - + self[2] * ( self[4] * self[9] - self[8] * self[5] ); + + self[2] * ( self[4] * self[9] - self[8] * self[5] ); // throw exception here if (det*det < 1e-25) // invert rotation submatrix det = 1.0 / det; - result[0] = static_cast( ( self[5] * self[10] - self[6] * self[9] ) * det ); - result[1] = static_cast( -( self[1] * self[10] - self[2] * self[9] ) * det ); - result[2] = static_cast( ( self[1] * self[6] - self[2] * self[5] ) * det ); - result[3] = 0; - result[4] = static_cast( -( self[4] * self[10] - self[6] * self[8] ) * det ); - result[5] = static_cast( ( self[0] * self[10] - self[2] * self[8] ) * det ); - result[6] = static_cast( -( self[0] * self[6] - self[2] * self[4] ) * det ); - result[7] = 0; - result[8] = static_cast( ( self[4] * self[9] - self[5] * self[8] ) * det ); - result[9] = static_cast( -( self[0] * self[9] - self[1] * self[8] ) * det ); - result[10] = static_cast( ( self[0] * self[5] - self[1] * self[4] ) * det ); + result[0] = ( self[5] * self[10] - self[6] * self[9] ) * det; + result[1] = -( self[1] * self[10] - self[2] * self[9] ) * det; + result[2] = ( self[1] * self[6] - self[2] * self[5] ) * det; + result[3] = 0; + result[4] = -( self[4] * self[10] - self[6] * self[8] ) * det; + result[5] = ( self[0] * self[10] - self[2] * self[8] ) * det; + result[6] = -( self[0] * self[6] - self[2] * self[4] ) * det; + result[7] = 0; + result[8] = ( self[4] * self[9] - self[5] * self[8] ) * det; + result[9] = -( self[0] * self[9] - self[1] * self[8] ) * det; + result[10] = ( self[0] * self[5] - self[1] * self[4] ) * det; result[11] = 0; // multiply translation part by rotation @@ -535,25 +535,25 @@ inline double matrix4_determinant( const Matrix4& self ){ /// \brief Returns the inverse of \p self using the Adjoint method. /// \todo Throw an exception if the determinant is zero. inline Matrix4 matrix4_full_inverse( const Matrix4& self ){ - double determinant = 1.0 / matrix4_determinant( self ); + const double determinant = 1.0 / matrix4_determinant( self ); return Matrix4( - static_cast( Matrix4Cofactor< Cofactor4<0>, Cofactor4<0> >::apply( self ) * determinant ), - static_cast( -Matrix4Cofactor< Cofactor4<1>, Cofactor4<0> >::apply( self ) * determinant ), - static_cast( Matrix4Cofactor< Cofactor4<2>, Cofactor4<0> >::apply( self ) * determinant ), - static_cast( -Matrix4Cofactor< Cofactor4<3>, Cofactor4<0> >::apply( self ) * determinant ), - static_cast( -Matrix4Cofactor< Cofactor4<0>, Cofactor4<1> >::apply( self ) * determinant ), - static_cast( Matrix4Cofactor< Cofactor4<1>, Cofactor4<1> >::apply( self ) * determinant ), - static_cast( -Matrix4Cofactor< Cofactor4<2>, Cofactor4<1> >::apply( self ) * determinant ), - static_cast( Matrix4Cofactor< Cofactor4<3>, Cofactor4<1> >::apply( self ) * determinant ), - static_cast( Matrix4Cofactor< Cofactor4<0>, Cofactor4<2> >::apply( self ) * determinant ), - static_cast( -Matrix4Cofactor< Cofactor4<1>, Cofactor4<2> >::apply( self ) * determinant ), - static_cast( Matrix4Cofactor< Cofactor4<2>, Cofactor4<2> >::apply( self ) * determinant ), - static_cast( -Matrix4Cofactor< Cofactor4<3>, Cofactor4<2> >::apply( self ) * determinant ), - static_cast( -Matrix4Cofactor< Cofactor4<0>, Cofactor4<3> >::apply( self ) * determinant ), - static_cast( Matrix4Cofactor< Cofactor4<1>, Cofactor4<3> >::apply( self ) * determinant ), - static_cast( -Matrix4Cofactor< Cofactor4<2>, Cofactor4<3> >::apply( self ) * determinant ), - static_cast( Matrix4Cofactor< Cofactor4<3>, Cofactor4<3> >::apply( self ) * determinant ) + Matrix4Cofactor< Cofactor4<0>, Cofactor4<0> >::apply( self ) * determinant, + -Matrix4Cofactor< Cofactor4<1>, Cofactor4<0> >::apply( self ) * determinant, + Matrix4Cofactor< Cofactor4<2>, Cofactor4<0> >::apply( self ) * determinant, + -Matrix4Cofactor< Cofactor4<3>, Cofactor4<0> >::apply( self ) * determinant, + -Matrix4Cofactor< Cofactor4<0>, Cofactor4<1> >::apply( self ) * determinant, + Matrix4Cofactor< Cofactor4<1>, Cofactor4<1> >::apply( self ) * determinant, + -Matrix4Cofactor< Cofactor4<2>, Cofactor4<1> >::apply( self ) * determinant, + Matrix4Cofactor< Cofactor4<3>, Cofactor4<1> >::apply( self ) * determinant, + Matrix4Cofactor< Cofactor4<0>, Cofactor4<2> >::apply( self ) * determinant, + -Matrix4Cofactor< Cofactor4<1>, Cofactor4<2> >::apply( self ) * determinant, + Matrix4Cofactor< Cofactor4<2>, Cofactor4<2> >::apply( self ) * determinant, + -Matrix4Cofactor< Cofactor4<3>, Cofactor4<2> >::apply( self ) * determinant, + -Matrix4Cofactor< Cofactor4<0>, Cofactor4<3> >::apply( self ) * determinant, + Matrix4Cofactor< Cofactor4<1>, Cofactor4<3> >::apply( self ) * determinant, + -Matrix4Cofactor< Cofactor4<2>, Cofactor4<3> >::apply( self ) * determinant, + Matrix4Cofactor< Cofactor4<3>, Cofactor4<3> >::apply( self ) * determinant ); } @@ -608,24 +608,24 @@ inline Matrix4 matrix4_translated_by_vec3( const Matrix4& self, const Vector3& t /// \brief Returns \p angle modulated by the range [0, 360). /// \p angle must be in the range [-360, 360). inline float angle_modulate_degrees_range( float angle ){ - return static_cast( float_mod_range( angle, 360.0 ) ); + return float_mod_range( angle, 360.0 ); } /// \brief Returns \p euler angles converted from radians to degrees. inline Vector3 euler_radians_to_degrees( const Vector3& euler ){ return Vector3( - static_cast( radians_to_degrees( euler.x() ) ), - static_cast( radians_to_degrees( euler.y() ) ), - static_cast( radians_to_degrees( euler.z() ) ) + radians_to_degrees( euler.x() ), + radians_to_degrees( euler.y() ), + radians_to_degrees( euler.z() ) ); } /// \brief Returns \p euler angles converted from degrees to radians. inline Vector3 euler_degrees_to_radians( const Vector3& euler ){ return Vector3( - static_cast( degrees_to_radians( euler.x() ) ), - static_cast( degrees_to_radians( euler.y() ) ), - static_cast( degrees_to_radians( euler.z() ) ) + degrees_to_radians( euler.x() ), + degrees_to_radians( euler.y() ), + degrees_to_radians( euler.z() ) ); } @@ -643,7 +643,7 @@ inline Matrix4 matrix4_rotation_for_sincos_x( float s, float c ){ /// \brief Constructs a pure-rotation matrix about the x axis from an angle in radians. inline Matrix4 matrix4_rotation_for_x( double x ){ - return matrix4_rotation_for_sincos_x( static_cast( sin( x ) ), static_cast( cos( x ) ) ); + return matrix4_rotation_for_sincos_x( sin( x ), cos( x ) ); } /// \brief Constructs a pure-rotation matrix about the x axis from an angle in degrees. @@ -663,7 +663,7 @@ inline Matrix4 matrix4_rotation_for_sincos_y( float s, float c ){ /// \brief Constructs a pure-rotation matrix about the y axis from an angle in radians. inline Matrix4 matrix4_rotation_for_y( double y ){ - return matrix4_rotation_for_sincos_y( static_cast( sin( y ) ), static_cast( cos( y ) ) ); + return matrix4_rotation_for_sincos_y( sin( y ), cos( y ) ); } /// \brief Constructs a pure-rotation matrix about the y axis from an angle in degrees. @@ -683,7 +683,7 @@ inline Matrix4 matrix4_rotation_for_sincos_z( float s, float c ){ /// \brief Constructs a pure-rotation matrix about the z axis from an angle in radians. inline Matrix4 matrix4_rotation_for_z( double z ){ - return matrix4_rotation_for_sincos_z( static_cast( sin( z ) ), static_cast( cos( z ) ) ); + return matrix4_rotation_for_sincos_z( sin( z ), cos( z ) ); } /// \brief Constructs a pure-rotation matrix about the z axis from an angle in degrees. @@ -717,25 +717,25 @@ inline Matrix4 matrix4_rotation_for_z_degrees( float z ){ inline Matrix4 matrix4_rotation_for_euler_xyz( const Vector3& euler ){ #if 1 - double cx = cos( euler[0] ); - double sx = sin( euler[0] ); - double cy = cos( euler[1] ); - double sy = sin( euler[1] ); - double cz = cos( euler[2] ); - double sz = sin( euler[2] ); + const double cx = cos( euler[0] ); + const double sx = sin( euler[0] ); + const double cy = cos( euler[1] ); + const double sy = sin( euler[1] ); + const double cz = cos( euler[2] ); + const double sz = sin( euler[2] ); return Matrix4( - static_cast( cy * cz ), - static_cast( cy * sz ), - static_cast( -sy ), + cy * cz, + cy * sz, + -sy, 0, - static_cast( sx * sy * cz + cx * -sz ), - static_cast( sx * sy * sz + cx * cz ), - static_cast( sx * cy ), + sx * sy * cz + cx * -sz, + sx * sy * sz + cx * cz, + sx * cy, 0, - static_cast( cx * sy * cz + sx * sz ), - static_cast( cx * sy * sz + -sx * cz ), - static_cast( cx * cy ), + cx * sy * cz + sx * sz, + cx * sy * sz + -sx * cz, + cx * cy, 0, 0, 0, @@ -809,25 +809,25 @@ inline Matrix4 matrix4_rotation_for_euler_xzy_degrees( const Vector3& euler ){ inline Matrix4 matrix4_rotation_for_euler_yxz( const Vector3& euler ){ #if 1 - double cx = cos( euler[0] ); - double sx = sin( euler[0] ); - double cy = cos( euler[1] ); - double sy = sin( euler[1] ); - double cz = cos( euler[2] ); - double sz = sin( euler[2] ); + const double cx = cos( euler[0] ); + const double sx = sin( euler[0] ); + const double cy = cos( euler[1] ); + const double sy = sin( euler[1] ); + const double cz = cos( euler[2] ); + const double sz = sin( euler[2] ); return Matrix4( - static_cast( cy * cz + sx * sy * -sz ), - static_cast( cy * sz + sx * sy * cz ), - static_cast( -cx * sy ), + cy * cz + sx * sy * -sz, + cy * sz + sx * sy * cz, + -cx * sy, 0, - static_cast( cx * -sz ), - static_cast( cx * cz ), - static_cast( sx ), + cx * -sz, + cx * cz, + sx, 0, - static_cast( sy * cz + -sx * cy * -sz ), - static_cast( sy * sz + -sx * cy * cz ), - static_cast( cx * cy ), + sy * cz + -sx * cy * -sz, + sy * sz + -sx * cy * cz, + cx * cy, 0, 0, 0, @@ -876,25 +876,25 @@ inline Matrix4 matrix4_rotation_for_euler_zxy( const Vector3& euler ){ matrix4_rotation_for_y( euler[1] ) ); #else - double cx = cos( euler[0] ); - double sx = sin( euler[0] ); - double cy = cos( euler[1] ); - double sy = sin( euler[1] ); - double cz = cos( euler[2] ); - double sz = sin( euler[2] ); + const double cx = cos( euler[0] ); + const double sx = sin( euler[0] ); + const double cy = cos( euler[1] ); + const double sy = sin( euler[1] ); + const double cz = cos( euler[2] ); + const double sz = sin( euler[2] ); return Matrix4( - static_cast( cz * cy + sz * sx * sy ), - static_cast( sz * cx ), - static_cast( cz * -sy + sz * sx * cy ), + cz * cy + sz * sx * sy, + sz * cx, + cz * -sy + sz * sx * cy, 0, - static_cast( -sz * cy + cz * sx * sy ), - static_cast( cz * cx ), - static_cast( -sz * -sy + cz * cx * cy ), + -sz * cy + cz * sx * sy, + cz * cx, + -sz * -sy + cz * cx * cy, 0, - static_cast( cx * sy ), - static_cast( -sx ), - static_cast( cx * cy ), + cx * sy, + -sx, + cx * cy, 0, 0, 0, @@ -925,25 +925,25 @@ inline void matrix4_rotate_by_euler_zxy_degrees( Matrix4& self, const Vector3& e inline Matrix4 matrix4_rotation_for_euler_zyx( const Vector3& euler ){ #if 1 - double cx = cos( euler[0] ); - double sx = sin( euler[0] ); - double cy = cos( euler[1] ); - double sy = sin( euler[1] ); - double cz = cos( euler[2] ); - double sz = sin( euler[2] ); + const double cx = cos( euler[0] ); + const double sx = sin( euler[0] ); + const double cy = cos( euler[1] ); + const double sy = sin( euler[1] ); + const double cz = cos( euler[2] ); + const double sz = sin( euler[2] ); return Matrix4( - static_cast( cy * cz ), - static_cast( sx * sy * cz + cx * sz ), - static_cast( cx * -sy * cz + sx * sz ), + cy * cz, + sx * sy * cz + cx * sz, + cx * -sy * cz + sx * sz, 0, - static_cast( cy * -sz ), - static_cast( sx * sy * -sz + cx * cz ), - static_cast( cx * -sy * -sz + sx * cz ), + cy * -sz, + sx * sy * -sz + cx * cz, + cx * -sy * -sz + sx * cz, 0, - static_cast( sy ), - static_cast( -sx * cy ), - static_cast( cx * cy ), + sy, + -sx * cy, + cx * cy, 0, 0, 0, @@ -978,16 +978,16 @@ inline Vector3 matrix4_get_rotation_euler_xyz( const Matrix4& self ){ if ( std::fabs( ca ) > 0.005 ) { // Gimbal lock? return Vector3( - static_cast( atan2( self[6] / ca, self[10] / ca ) ), - static_cast( a ), - static_cast( atan2( self[1] / ca, self[0] / ca ) ) + atan2( self[6] / ca, self[10] / ca ), + a, + atan2( self[1] / ca, self[0] / ca ) ); } else // Gimbal lock has occurred { return Vector3( - static_cast( atan2( -self[9], self[5] ) ), - static_cast( a ), + atan2( -self[9], self[5] ), + a, 0 ); } @@ -1006,16 +1006,16 @@ inline Vector3 matrix4_get_rotation_euler_yxz( const Matrix4& self ){ if ( std::fabs( ca ) > 0.005 ) { // Gimbal lock? return Vector3( - static_cast( a ), - static_cast( atan2( -self[2] / ca, self[10] / ca ) ), - static_cast( atan2( -self[4] / ca, self[5] / ca ) ) + a, + atan2( -self[2] / ca, self[10] / ca ), + atan2( -self[4] / ca, self[5] / ca ) ); } else // Gimbal lock has occurred { return Vector3( - static_cast( a ), - static_cast( atan2( self[8], self[0] ) ), + a, + atan2( self[8], self[0] ), 0 ); } @@ -1029,22 +1029,22 @@ inline Vector3 matrix4_get_rotation_euler_yxz_degrees( const Matrix4& self ){ /// \brief Calculates and returns a set of euler angles that produce the rotation component of \p self when applied in the order (z, x, y). /// \p self must be affine and orthonormal (unscaled) to produce a meaningful result. inline Vector3 matrix4_get_rotation_euler_zxy( const Matrix4& self ){ - double a = asin( -self[9] ); - double ca = cos( a ); + const double a = asin( -self[9] ); + const double ca = cos( a ); if ( std::fabs( ca ) > 0.005 ) { // Gimbal lock? return Vector3( - static_cast( a ), - static_cast( atan2( self[8] / ca, self[10] / ca ) ), - static_cast( atan2( self[1] / ca, self[5] / ca ) ) + a, + atan2( self[8] / ca, self[10] / ca ), + atan2( self[1] / ca, self[5] / ca ) ); } else // Gimbal lock has occurred { return Vector3( - static_cast( a ), + a, 0, - static_cast( atan2( -self[4], self[0] ) ) + atan2( -self[4], self[0] ) ); } } @@ -1057,22 +1057,22 @@ inline Vector3 matrix4_get_rotation_euler_zxy_degrees( const Matrix4& self ){ /// \brief Calculates and returns a set of euler angles that produce the rotation component of \p self when applied in the order (z, y, x). /// \p self must be affine and orthonormal (unscaled) to produce a meaningful result. inline Vector3 matrix4_get_rotation_euler_zyx( const Matrix4& self ){ - double a = asin( self[8] ); - double ca = cos( a ); + const double a = asin( self[8] ); + const double ca = cos( a ); if ( std::fabs( ca ) > 0.005 ) { // Gimbal lock? return Vector3( - static_cast( atan2( -self[9] / ca, self[10] / ca ) ), - static_cast( a ), - static_cast( atan2( -self[4] / ca, self[0] / ca ) ) + atan2( -self[9] / ca, self[10] / ca ), + a, + atan2( -self[4] / ca, self[0] / ca ) ); } else // Gimbal lock has occurred { return Vector3( 0, - static_cast( a ), - static_cast( atan2( self[1], self[5] ) ) + a, + atan2( self[1], self[5] ) ); } } @@ -1105,9 +1105,9 @@ inline Matrix4 matrix4_scale_for_vec3( const Vector3& scale ){ /// \p self must be affine and orthogonal to produce a meaningful result. inline Vector3 matrix4_get_scale_vec3( const Matrix4& self ){ return Vector3( - static_cast( vector3_length( self.x().vec3() ) ), - static_cast( vector3_length( self.y().vec3() ) ), - static_cast( vector3_length( self.z().vec3() ) ) + vector3_length( self.x().vec3() ), + vector3_length( self.y().vec3() ), + vector3_length( self.z().vec3() ) ); } @@ -1116,9 +1116,9 @@ inline Vector3 matrix4_get_scale_vec3( const Matrix4& self ){ /// \p self must not contain rotation to produce meaningful signs. inline Vector3 matrix4_get_scale_vec3_signed( const Matrix4& self ){ return Vector3( - static_cast( std::copysign( vector3_length( self.x().vec3() ), vector3_dot( self.x().vec3(), g_vector3_axis_x ) ) ), - static_cast( std::copysign( vector3_length( self.y().vec3() ), vector3_dot( self.y().vec3(), g_vector3_axis_y ) ) ), - static_cast( std::copysign( vector3_length( self.z().vec3() ), vector3_dot( self.z().vec3(), g_vector3_axis_z ) ) ) + std::copysign( vector3_length( self.x().vec3() ), vector3_dot( self.x().vec3(), g_vector3_axis_x ) ), + std::copysign( vector3_length( self.y().vec3() ), vector3_dot( self.y().vec3(), g_vector3_axis_y ) ), + std::copysign( vector3_length( self.z().vec3() ), vector3_dot( self.z().vec3(), g_vector3_axis_z ) ) ); } diff --git a/libs/math/quaternion.h b/libs/math/quaternion.h index ba0ad984..3f6c2b1f 100644 --- a/libs/math/quaternion.h +++ b/libs/math/quaternion.h @@ -47,28 +47,28 @@ inline void quaternion_multiply_by_quaternion( Quaternion& quaternion, const Qua /// \brief Constructs a quaternion which rotates between two points on the unit-sphere, \p from and \p to. /// warning: wrong math! inline Quaternion quaternion_for_sphere_vectors( const Vector3& from, const Vector3& to ){ - return Quaternion( vector3_cross( from, to ), static_cast( vector3_dot( from, to ) ) ); + return Quaternion( vector3_cross( from, to ), vector3_dot( from, to ) ); } inline Quaternion quaternion_for_axisangle( const Vector3& axis, double angle ){ angle *= 0.5; - float sa = static_cast( sin( angle ) ); - return Quaternion( axis[0] * sa, axis[1] * sa, axis[2] * sa, static_cast( cos( angle ) ) ); + const float sa = sin( angle ); + return Quaternion( axis[0] * sa, axis[1] * sa, axis[2] * sa, cos( angle ) ); } inline Quaternion quaternion_for_x( double angle ){ angle *= 0.5; - return Quaternion( static_cast( sin( angle ) ), 0, 0, static_cast( cos( angle ) ) ); + return Quaternion( sin( angle ), 0, 0, cos( angle ) ); } inline Quaternion quaternion_for_y( double angle ){ angle *= 0.5; - return Quaternion( 0, static_cast( sin( angle ) ), 0, static_cast( cos( angle ) ) ); + return Quaternion( 0, sin( angle ), 0, cos( angle ) ); } inline Quaternion quaternion_for_z( double angle ){ angle *= 0.5; - return Quaternion( 0, 0, static_cast( sin( angle ) ), static_cast( cos( angle ) ) ); + return Quaternion( 0, 0, sin( angle ), cos( angle ) ); } inline Quaternion quaternion_inverse( const Quaternion& quaternion ){ @@ -82,10 +82,10 @@ inline void quaternion_conjugate( Quaternion& quaternion ){ inline Quaternion quaternion_normalised( const Quaternion& quaternion ){ const double n = ( 1.0 / sqrt( quaternion[0] * quaternion[0] + quaternion[1] * quaternion[1] + quaternion[2] * quaternion[2] + quaternion[3] * quaternion[3] ) ); return Quaternion( - static_cast( quaternion[0] * n ), - static_cast( quaternion[1] * n ), - static_cast( quaternion[2] * n ), - static_cast( quaternion[3] * n ) + quaternion[0] * n, + quaternion[1] * n, + quaternion[2] * n, + quaternion[3] * n ); } @@ -124,17 +124,17 @@ inline Matrix4 matrix4_rotation_for_quaternion( const Quaternion& quaternion ){ const double zw = quaternion[2] * quaternion[3]; return Matrix4( - static_cast( 1 - 2 * ( yy + zz ) ), - static_cast( 2 * ( xy + zw ) ), - static_cast( 2 * ( xz - yw ) ), + 1 - 2 * ( yy + zz ), + 2 * ( xy + zw ), + 2 * ( xz - yw ), 0, - static_cast( 2 * ( xy - zw ) ), - static_cast( 1 - 2 * ( xx + zz ) ), - static_cast( 2 * ( yz + xw ) ), + 2 * ( xy - zw ), + 1 - 2 * ( xx + zz ), + 2 * ( yz + xw ), 0, - static_cast( 2 * ( xz + yw ) ), - static_cast( 2 * ( yz - xw ) ), - static_cast( 1 - 2 * ( xx + yy ) ), + 2 * ( xz + yw ), + 2 * ( yz - xw ), + 1 - 2 * ( xx + yy ), 0, 0, 0, @@ -157,17 +157,17 @@ inline Matrix4 matrix4_rotation_for_quaternion( const Quaternion& quaternion ){ const double wz = quaternion[3] * z2; return Matrix4( - static_cast( 1.0 - ( yy + zz ) ), - static_cast( xy + wz ), - static_cast( xz - wy ), + 1.0 - ( yy + zz ), + xy + wz, + xz - wy, 0, - static_cast( xy - wz ), - static_cast( 1.0 - ( xx + zz ) ), - static_cast( yz + wx ), + xy - wz, + 1.0 - ( xx + zz ), + yz + wx, 0, - static_cast( xz + wy ), - static_cast( yz - wx ), - static_cast( 1.0 - ( xx + yy ) ), + xz + wy, + yz - wx, + 1.0 - ( xx + yy ), 0, 0, 0, @@ -211,46 +211,46 @@ inline Matrix4 matrix4_rotation_for_quaternion_quantised( const Quaternion& quat } inline Quaternion quaternion_for_matrix4_rotation( const Matrix4& matrix4 ){ - Matrix4 transposed = matrix4_transposed( matrix4 ); + const Matrix4 transposed = matrix4_transposed( matrix4 ); - double trace = transposed[0] + transposed[5] + transposed[10] + 1.0; + const double trace = transposed[0] + transposed[5] + transposed[10] + 1.0; if ( trace > 0.0001 ) { - double S = 0.5 / sqrt( trace ); + const double S = 0.5 / sqrt( trace ); return Quaternion( - static_cast( ( transposed[9] - transposed[6] ) * S ), - static_cast( ( transposed[2] - transposed[8] ) * S ), - static_cast( ( transposed[4] - transposed[1] ) * S ), - static_cast( 0.25 / S ) + ( transposed[9] - transposed[6] ) * S, + ( transposed[2] - transposed[8] ) * S, + ( transposed[4] - transposed[1] ) * S, + 0.25 / S ); } if ( transposed[0] >= transposed[5] && transposed[0] >= transposed[10] ) { - double S = 2.0 * sqrt( 1.0 + transposed[0] - transposed[5] - transposed[10] ); + const double S = 2.0 * sqrt( 1.0 + transposed[0] - transposed[5] - transposed[10] ); return Quaternion( - static_cast( 0.25 / S ), - static_cast( ( transposed[1] + transposed[4] ) / S ), - static_cast( ( transposed[2] + transposed[8] ) / S ), - static_cast( ( transposed[6] + transposed[9] ) / S ) + 0.25 / S, + ( transposed[1] + transposed[4] ) / S, + ( transposed[2] + transposed[8] ) / S, + ( transposed[6] + transposed[9] ) / S ); } if ( transposed[5] >= transposed[0] && transposed[5] >= transposed[10] ) { - double S = 2.0 * sqrt( 1.0 + transposed[5] - transposed[0] - transposed[10] ); + const double S = 2.0 * sqrt( 1.0 + transposed[5] - transposed[0] - transposed[10] ); return Quaternion( - static_cast( ( transposed[1] + transposed[4] ) / S ), - static_cast( 0.25 / S ), - static_cast( ( transposed[6] + transposed[9] ) / S ), - static_cast( ( transposed[2] + transposed[8] ) / S ) + ( transposed[1] + transposed[4] ) / S, + 0.25 / S, + ( transposed[6] + transposed[9] ) / S, + ( transposed[2] + transposed[8] ) / S ); } - double S = 2.0 * sqrt( 1.0 + transposed[10] - transposed[0] - transposed[5] ); + const double S = 2.0 * sqrt( 1.0 + transposed[10] - transposed[0] - transposed[5] ); return Quaternion( - static_cast( ( transposed[2] + transposed[8] ) / S ), - static_cast( ( transposed[6] + transposed[9] ) / S ), - static_cast( 0.25 / S ), - static_cast( ( transposed[1] + transposed[4] ) / S ) + ( transposed[2] + transposed[8] ) / S, + ( transposed[6] + transposed[9] ) / S, + 0.25 / S, + ( transposed[1] + transposed[4] ) / S ); } @@ -274,22 +274,22 @@ inline void matrix4_pivoted_rotate_by_quaternion( Matrix4& self, const Quaternio } inline Vector3 quaternion_transformed_point( const Quaternion& quaternion, const Vector3& point ){ - double xx = quaternion.x() * quaternion.x(); - double yy = quaternion.y() * quaternion.y(); - double zz = quaternion.z() * quaternion.z(); - double ww = quaternion.w() * quaternion.w(); + const double xx = quaternion.x() * quaternion.x(); + const double yy = quaternion.y() * quaternion.y(); + const double zz = quaternion.z() * quaternion.z(); + const double ww = quaternion.w() * quaternion.w(); - double xy2 = quaternion.x() * quaternion.y() * 2; - double xz2 = quaternion.x() * quaternion.z() * 2; - double xw2 = quaternion.x() * quaternion.w() * 2; - double yz2 = quaternion.y() * quaternion.z() * 2; - double yw2 = quaternion.y() * quaternion.w() * 2; - double zw2 = quaternion.z() * quaternion.w() * 2; + const double xy2 = quaternion.x() * quaternion.y() * 2; + const double xz2 = quaternion.x() * quaternion.z() * 2; + const double xw2 = quaternion.x() * quaternion.w() * 2; + const double yz2 = quaternion.y() * quaternion.z() * 2; + const double yw2 = quaternion.y() * quaternion.w() * 2; + const double zw2 = quaternion.z() * quaternion.w() * 2; return Vector3( - static_cast( ww * point.x() + yw2 * point.z() - zw2 * point.y() + xx * point.x() + xy2 * point.y() + xz2 * point.z() - zz * point.x() - yy * point.x() ), - static_cast( xy2 * point.x() + yy * point.y() + yz2 * point.z() + zw2 * point.x() - zz * point.y() + ww * point.y() - xw2 * point.z() - xx * point.y() ), - static_cast( xz2 * point.x() + yz2 * point.y() + zz * point.z() - yw2 * point.x() - yy * point.z() + xw2 * point.y() - xx * point.z() + ww * point.z() ) + ww * point.x() + yw2 * point.z() - zw2 * point.y() + xx * point.x() + xy2 * point.y() + xz2 * point.z() - zz * point.x() - yy * point.x(), + xy2 * point.x() + yy * point.y() + yz2 * point.z() + zw2 * point.x() - zz * point.y() + ww * point.y() - xw2 * point.z() - xx * point.y(), + xz2 * point.x() + yz2 * point.y() + zz * point.z() - yw2 * point.x() - yy * point.z() + xw2 * point.y() - xx * point.z() + ww * point.z() ); } diff --git a/libs/math/vector.h b/libs/math/vector.h index 55c80f4a..ffc29b71 100644 --- a/libs/math/vector.h +++ b/libs/math/vector.h @@ -545,9 +545,9 @@ inline void vector3_snap_to_zero( BasicVector3& self, const OtherElemen inline Vector3 vector3_for_spherical( double theta, double phi ){ return Vector3( - static_cast( cos( theta ) * cos( phi ) ), - static_cast( sin( theta ) * cos( phi ) ), - static_cast( sin( phi ) ) + cos( theta ) * cos( phi ), + sin( theta ) * cos( phi ), + sin( phi ) ); } diff --git a/libs/pivot.h b/libs/pivot.h index d32407b0..90e5c02e 100644 --- a/libs/pivot.h +++ b/libs/pivot.h @@ -139,9 +139,9 @@ inline void ConstructDevice2Object( Matrix4& device2object, const Matrix4& objec //! S = ( Inverse(Object2Screen *post ScaleOf(Object2Screen) ) *post Object2Screen inline void pivot_scale( Matrix4& scale, const Matrix4& pivot2screen ){ Matrix4 pre_scale( g_matrix4_identity ); - pre_scale[0] = static_cast( vector3_length( pivot2screen.x().vec3() ) ); - pre_scale[5] = static_cast( vector3_length( pivot2screen.y().vec3() ) ); - pre_scale[10] = static_cast( vector3_length( pivot2screen.z().vec3() ) ); + pre_scale[0] = vector3_length( pivot2screen.x().vec3() ); + pre_scale[5] = vector3_length( pivot2screen.y().vec3() ); + pre_scale[10] = vector3_length( pivot2screen.z().vec3() ); scale = pivot2screen; matrix4_multiply_by_matrix4( scale, pre_scale ); diff --git a/libs/profile/profile.cpp b/libs/profile/profile.cpp index 17f11bc7..0204f2df 100644 --- a/libs/profile/profile.cpp +++ b/libs/profile/profile.cpp @@ -270,7 +270,7 @@ float profile_load_float( const char *filename, const char *section, const char char value[1024]; if ( read_var( filename, section, key, value ) ) { - return static_cast( atof( value ) ); + return atof( value ); } else{ return default_value; diff --git a/libs/render.h b/libs/render.h index bcb38584..e0ca1fe1 100644 --- a/libs/render.h +++ b/libs/render.h @@ -676,9 +676,9 @@ inline spherical_t spherical_from_normal3f( const Normal3f& normal ){ inline Normal3f normal3f_from_spherical( const spherical_t& spherical ){ return Normal3f( - static_cast( cos( spherical.longditude ) * sin( spherical.latitude ) ), - static_cast( sin( spherical.longditude ) * sin( spherical.latitude ) ), - static_cast( cos( spherical.latitude ) ) + cos( spherical.longditude ) * sin( spherical.latitude ), + sin( spherical.longditude ) * sin( spherical.latitude ), + cos( spherical.latitude ) ); } @@ -1045,8 +1045,8 @@ inline void draw_circle( const std::size_t segments, const float radius, PointVe { const double theta = increment * count; - x = static_cast( radius * cos( theta ) ); - y = static_cast( radius * sin( theta ) ); + x = radius * cos( theta ); + y = radius * sin( theta ); } remap_policy::set( j->vertex, y,-x, 0 ); diff --git a/libs/stringio.h b/libs/stringio.h index c1c4729a..2e868676 100644 --- a/libs/stringio.h +++ b/libs/stringio.h @@ -30,7 +30,7 @@ #include "generic/callback.h" inline float string_read_float( const char* string ){ - return static_cast( atof( string ) ); + return atof( string ); } inline int string_read_int( const char* string ){ diff --git a/plugins/entity/angle.h b/plugins/entity/angle.h index 6bc0e6d6..f9e8ed94 100644 --- a/plugins/entity/angle.h +++ b/plugins/entity/angle.h @@ -33,7 +33,7 @@ inline void default_angle( float& angle ){ angle = ANGLEKEY_IDENTITY; } inline void normalise_angle( float& angle ){ - angle = static_cast( float_mod( angle, 360.0 ) ); + angle = float_mod( angle, 360.0 ); } inline void read_angle( float& angle, const char* value ){ if ( !string_parse_float( value, angle ) ) { diff --git a/plugins/entity/angles.h b/plugins/entity/angles.h index e051bb43..c6911f0b 100644 --- a/plugins/entity/angles.h +++ b/plugins/entity/angles.h @@ -37,9 +37,9 @@ inline void default_angles( Vector3& angles ){ angles = ANGLESKEY_IDENTITY; } inline void normalise_angles( Vector3& angles ){ - angles[0] = static_cast( float_mod( angles[0], 360 ) ); - angles[1] = static_cast( float_mod( angles[1], 360 ) ); - angles[2] = static_cast( float_mod( angles[2], 360 ) ); + angles[0] = float_mod( angles[0], 360 ); + angles[1] = float_mod( angles[1], 360 ); + angles[2] = float_mod( angles[2], 360 ); } inline void read_angle( Vector3& angles, const char* value ){ if ( !string_parse_float( value, angles[2] ) ) { diff --git a/plugins/entity/light.cpp b/plugins/entity/light.cpp index 5ac1b1b6..659f52c9 100644 --- a/plugins/entity/light.cpp +++ b/plugins/entity/light.cpp @@ -179,7 +179,7 @@ void cartesian( const double Long, const double Lat, float cart[3] ) { void sphere_construct_fill( Vector3 radiiPoints[SPHERE_FILL_POINTS] ){ float cart[3]; int k = 0; - const double step = c_pi / static_cast( SPHERE_FILL_SIDES ); + const double step = c_pi / SPHERE_FILL_SIDES; radiiPoints[k++] = Vector3( 0.0, 0.0, -1.0 ); for( int i = 0; i < SPHERE_FILL_SIDES * 2; i += 2 ) { @@ -408,40 +408,40 @@ void sphere_construct_wire( Vector3 radiiPoints[SPHERE_WIRE_POINTS] ){ for ( int i = 0; i < SPHERE_WIRE_SIDES; ++i ) { - double ds = sin( ( i * 2 * c_pi ) / SPHERE_WIRE_SIDES ); - double dc = cos( ( i * 2 * c_pi ) / SPHERE_WIRE_SIDES ); + const double ds = sin( ( i * 2 * c_pi ) / SPHERE_WIRE_SIDES ); + const double dc = cos( ( i * 2 * c_pi ) / SPHERE_WIRE_SIDES ); radiiPoints[k++] = Vector3( - static_cast( dc ), - static_cast( ds ), + dc, + ds, 0.f ); } for ( int i = 0; i < SPHERE_WIRE_SIDES; ++i ) { - double ds = sin( ( i * 2 * c_pi ) / SPHERE_WIRE_SIDES ); - double dc = cos( ( i * 2 * c_pi ) / SPHERE_WIRE_SIDES ); + const double ds = sin( ( i * 2 * c_pi ) / SPHERE_WIRE_SIDES ); + const double dc = cos( ( i * 2 * c_pi ) / SPHERE_WIRE_SIDES ); radiiPoints[k++] = Vector3( - static_cast( dc ), + dc, 0.f, - static_cast( ds ) + ds ); } for ( int i = 0; i < SPHERE_WIRE_SIDES; ++i ) { - double ds = sin( ( i * 2 * c_pi ) / SPHERE_WIRE_SIDES ); - double dc = cos( ( i * 2 * c_pi ) / SPHERE_WIRE_SIDES ); + const double ds = sin( ( i * 2 * c_pi ) / SPHERE_WIRE_SIDES ); + const double dc = cos( ( i * 2 * c_pi ) / SPHERE_WIRE_SIDES ); radiiPoints[k++] = Vector3( 0.f, - static_cast( dc ), - static_cast( ds ) + dc, + ds ); } } diff --git a/radiant/brush.h b/radiant/brush.h index 69e33f0d..3b01b27d 100644 --- a/radiant/brush.h +++ b/radiant/brush.h @@ -218,9 +218,9 @@ inline void planepts_snap( PlanePoints& planepts, double snap ){ inline PointVertex pointvertex_for_planept( const DoubleVector3& point, const Colour4b& colour ){ return PointVertex( Vertex3f( - static_cast( point.x() ), - static_cast( point.y() ), - static_cast( point.z() ) + point.x(), + point.y(), + point.z() ), colour ); diff --git a/radiant/brush_primit.cpp b/radiant/brush_primit.cpp index 3ffd12a6..de0ea8c4 100644 --- a/radiant/brush_primit.cpp +++ b/radiant/brush_primit.cpp @@ -100,12 +100,12 @@ inline void Texdef_toTransform( const texdef_t& texdef, float width, float heigh inverse_scale[1] = 1 / ( texdef.scale[1] * -height ); transform[12] = texdef.shift[0] / width; transform[13] = -texdef.shift[1] / -height; - double c = cos( degrees_to_radians( -texdef.rotate ) ); - double s = sin( degrees_to_radians( -texdef.rotate ) ); - transform[0] = static_cast( c * inverse_scale[0] ); - transform[1] = static_cast( s * inverse_scale[1] ); - transform[4] = static_cast( -s * inverse_scale[0] ); - transform[5] = static_cast( c * inverse_scale[1] ); + const double c = cos( degrees_to_radians( -texdef.rotate ) ); + const double s = sin( degrees_to_radians( -texdef.rotate ) ); + transform[0] = c * inverse_scale[0]; + transform[1] = s * inverse_scale[1]; + transform[4] = -s * inverse_scale[0]; + transform[5] = c * inverse_scale[1]; transform[2] = transform[3] = transform[6] = transform[7] = transform[8] = transform[9] = transform[11] = transform[14] = 0; transform[10] = transform[15] = 1; } @@ -158,10 +158,10 @@ inline double arctangent_yx( double y, double x ){ } inline void Texdef_fromTransform( texdef_t& texdef, float width, float height, const Matrix4& transform ){ - texdef.scale[0] = static_cast( ( 1.0 / vector2_length( Vector2( transform[0], transform[4] ) ) ) / width ); - texdef.scale[1] = static_cast( ( 1.0 / vector2_length( Vector2( transform[1], transform[5] ) ) ) / height ); + texdef.scale[0] = ( 1.0 / vector2_length( Vector2( transform[0], transform[4] ) ) ) / width; + texdef.scale[1] = ( 1.0 / vector2_length( Vector2( transform[1], transform[5] ) ) ) / height; - texdef.rotate = static_cast( -radians_to_degrees( arctangent_yx( -transform[4], transform[0] ) ) ); + texdef.rotate = -radians_to_degrees( arctangent_yx( -transform[4], transform[0] ) ); if ( texdef.rotate == -180.0f ) { texdef.rotate = 180.0f; @@ -279,7 +279,7 @@ void Texdef_EmitTextureCoordinates( const TextureProjection& projection, std::si Matrix4 local2tex; Texdef_toTransform( projection, (float)width, (float)height, local2tex ); - //globalOutputStream() << "texdef: " << static_cast( local2tex.x() ) << static_cast( local2tex.y() ) << '\n'; + //globalOutputStream() << "texdef: " << local2tex.x().vec3() << local2tex.y().vec3() << '\n'; #if 0 { @@ -295,7 +295,7 @@ void Texdef_EmitTextureCoordinates( const TextureProjection& projection, std::si Matrix4 xyz2st; // we don't care if it's not normalised... Texdef_basisForNormal( projection, matrix4_transformed_direction( localToWorld, normal ), xyz2st ); - //globalOutputStream() << "basis: " << static_cast( xyz2st.x() ) << static_cast( xyz2st.y() ) << static_cast( xyz2st.z() ) << '\n'; + //globalOutputStream() << "basis: " << xyz2st.x().vec3() << xyz2st.y().vec3() << xyz2st.z().vec3() << '\n'; matrix4_multiply_by_matrix4( local2tex, xyz2st ); } @@ -628,10 +628,10 @@ void ConvertTexMatWithQTexture( const brushprimit_texdef_t *texMat1, const qtext void TexMatToFakeTexCoords( const brushprimit_texdef_t& bp_texdef, texdef_t& texdef ){ #if 0 - texdef.scale[0] = static_cast( 1.0 / vector2_length( Vector2( bp_texdef.coords[0][0], bp_texdef.coords[1][0] ) ) ); - texdef.scale[1] = static_cast( 1.0 / vector2_length( Vector2( bp_texdef.coords[0][1], bp_texdef.coords[1][1] ) ) ); + texdef.scale[0] = 1.0 / vector2_length( Vector2( bp_texdef.coords[0][0], bp_texdef.coords[1][0] ) ); + texdef.scale[1] = 1.0 / vector2_length( Vector2( bp_texdef.coords[0][1], bp_texdef.coords[1][1] ) ); - texdef.rotate = -static_cast( radians_to_degrees( arctangent_yx( bp_texdef.coords[1][0], bp_texdef.coords[0][0] ) ) ); + texdef.rotate = -radians_to_degrees( arctangent_yx( bp_texdef.coords[1][0], bp_texdef.coords[0][0] ) ); texdef.shift[0] = -bp_texdef.coords[0][2]; texdef.shift[1] = bp_texdef.coords[1][2]; @@ -653,8 +653,8 @@ void TexMatToFakeTexCoords( const brushprimit_texdef_t& bp_texdef, texdef_t& tex } } #else - texdef.scale[0] = static_cast( 1.0 / vector2_length( Vector2( bp_texdef.coords[0][0], bp_texdef.coords[0][1] ) ) ); - texdef.scale[1] = static_cast( 1.0 / vector2_length( Vector2( bp_texdef.coords[1][0], bp_texdef.coords[1][1] ) ) ); + texdef.scale[0] = 1.0 / vector2_length( Vector2( bp_texdef.coords[0][0], bp_texdef.coords[0][1] ) ); + texdef.scale[1] = 1.0 / vector2_length( Vector2( bp_texdef.coords[1][0], bp_texdef.coords[1][1] ) ); if( bp_texdef.coords[0][0] < 0 ){ texdef.scale[0] = -texdef.scale[0]; } @@ -662,12 +662,12 @@ void TexMatToFakeTexCoords( const brushprimit_texdef_t& bp_texdef, texdef_t& tex texdef.scale[1] = -texdef.scale[1]; } #if 1 - texdef.rotate = static_cast( radians_to_degrees( acos( vector2_normalised( Vector2( bp_texdef.coords[0][0], bp_texdef.coords[0][1] ) )[0] ) ) ); + texdef.rotate = radians_to_degrees( acos( vector2_normalised( Vector2( bp_texdef.coords[0][0], bp_texdef.coords[0][1] ) )[0] ) ); if( bp_texdef.coords[0][1] > 0 ){ texdef.rotate = -texdef.rotate; } #else - texdef.rotate = static_cast( radians_to_degrees( arctangent_yx( bp_texdef.coords[0][1], bp_texdef.coords[0][0] ) ) ); + texdef.rotate = radians_to_degrees( arctangent_yx( bp_texdef.coords[0][1], bp_texdef.coords[0][0] ) ); #endif texdef.shift[0] = -bp_texdef.coords[0][2]; texdef.shift[1] = bp_texdef.coords[1][2]; @@ -681,10 +681,10 @@ void FakeTexCoordsToTexMat( const texdef_t& texdef, brushprimit_texdef_t& bp_tex double s = sin( r ); double x = 1.0f / texdef.scale[0]; double y = 1.0f / texdef.scale[1]; - bp_texdef.coords[0][0] = static_cast( x * c ); - bp_texdef.coords[1][0] = static_cast( x * s ); - bp_texdef.coords[0][1] = static_cast( y * -s ); - bp_texdef.coords[1][1] = static_cast( y * c ); + bp_texdef.coords[0][0] = x * c; + bp_texdef.coords[1][0] = x * s; + bp_texdef.coords[0][1] = y * -s; + bp_texdef.coords[1][1] = y * c; bp_texdef.coords[0][2] = -texdef.shift[0]; bp_texdef.coords[1][2] = texdef.shift[1]; // globalOutputStream() << "[ " << bp_texdef.coords[0][0] << ' ' << bp_texdef.coords[0][1] << " ][ " << bp_texdef.coords[1][0] << ' ' << bp_texdef.coords[1][1] << " ]\n"; @@ -2004,7 +2004,7 @@ void AP_from_BP( TextureProjection& projection, const Plane3& plane, std::size_t return; } - const Vector3 invariant( static_cast( plane.normal() * plane.dist() ) ); + const Vector3 invariant( plane.normal() * plane.dist() ); Matrix4 local2tex; Texdef_Construct_local2tex( projection, width, height, plane.normal(), local2tex ); @@ -2024,14 +2024,14 @@ void Valve220_from_BP( TextureProjection& projection, const Plane3& plane, std:: projection.m_texdef.scale[1] = 1.0 / ( vector2_length( Vector2( projection.m_brushprimit_texdef.coords[1][0], projection.m_brushprimit_texdef.coords[1][1] ) ) * (double)height ); projection.m_texdef.shift[0] = projection.m_brushprimit_texdef.coords[0][2] * (float)width; projection.m_texdef.shift[1] = projection.m_brushprimit_texdef.coords[1][2] * (float)height; - projection.m_texdef.rotate = static_cast( -radians_to_degrees( arctangent_yx( projection.m_brushprimit_texdef.coords[0][1], projection.m_brushprimit_texdef.coords[0][0] ) ) ); + projection.m_texdef.rotate = -radians_to_degrees( arctangent_yx( projection.m_brushprimit_texdef.coords[0][1], projection.m_brushprimit_texdef.coords[0][0] ) ); if( projection.m_brushprimit_texdef.coords[0][0] * projection.m_brushprimit_texdef.coords[1][1] < 0 ) projection.m_texdef.rotate = -projection.m_texdef.rotate; DoubleVector3 texX, texY; ComputeAxisBase( plane.normal(), texX, texY ); - projection.m_basis_s = vector3_normalised( texX * static_cast( projection.m_brushprimit_texdef.coords[0][0] ) + texY * static_cast( projection.m_brushprimit_texdef.coords[0][1] ) ); - projection.m_basis_t = vector3_normalised( texX * static_cast( projection.m_brushprimit_texdef.coords[1][0] ) + texY * static_cast( projection.m_brushprimit_texdef.coords[1][1] ) ); + projection.m_basis_s = vector3_normalised( texX * projection.m_brushprimit_texdef.coords[0][0] + texY * projection.m_brushprimit_texdef.coords[0][1] ); + projection.m_basis_t = vector3_normalised( texX * projection.m_brushprimit_texdef.coords[1][0] + texY * projection.m_brushprimit_texdef.coords[1][1] ); #else /* more reliable values this way */ DoubleVector3 texX, texY; @@ -2044,8 +2044,8 @@ void Valve220_from_BP( TextureProjection& projection, const Plane3& plane, std:: projection.m_texdef.scale[1] = Texdef_getDefaultTextureScale(); return; } - projection.m_basis_s = vector3_normalised( texX * static_cast( projection.m_brushprimit_texdef.coords[0][0] ) + texY * static_cast( projection.m_brushprimit_texdef.coords[0][1] ) ); - projection.m_basis_t = vector3_normalised( texX * static_cast( projection.m_brushprimit_texdef.coords[1][0] ) + texY * static_cast( projection.m_brushprimit_texdef.coords[1][1] ) ); + projection.m_basis_s = vector3_normalised( texX * projection.m_brushprimit_texdef.coords[0][0] + texY * projection.m_brushprimit_texdef.coords[0][1] ); + projection.m_basis_t = vector3_normalised( texX * projection.m_brushprimit_texdef.coords[1][0] + texY * projection.m_brushprimit_texdef.coords[1][1] ); projection.m_brushprimit_texdef.removeScale( width, height ); TexMatToFakeTexCoords( projection.m_brushprimit_texdef, projection.m_texdef ); projection.m_texdef.shift[0] *= -1.f; diff --git a/radiant/brushmodule.cpp b/radiant/brushmodule.cpp index eeee2f4c..5320e523 100644 --- a/radiant/brushmodule.cpp +++ b/radiant/brushmodule.cpp @@ -166,7 +166,7 @@ void Brush_Construct( EBrushType type ){ g_texdef_default_scale = 0.5f; const char* value = g_pGameDescription->getKeyValue( "default_scale" ); if ( !string_empty( value ) ) { - float scale = static_cast( atof( value ) ); + const float scale = atof( value ); if ( scale != 0 ) { g_texdef_default_scale = scale; } diff --git a/radiant/brushxml.h b/radiant/brushxml.h index 8f4dbb9f..1f09c6f6 100644 --- a/radiant/brushxml.h +++ b/radiant/brushxml.h @@ -29,21 +29,21 @@ inline void FaceTexdef_BP_importXML( FaceTexdef& texdef, const char* xmlContent ){ StringTokeniser content( xmlContent ); - texdef.m_projection.m_brushprimit_texdef.coords[0][0] = static_cast( atof( content.getToken() ) ); - texdef.m_projection.m_brushprimit_texdef.coords[0][1] = static_cast( atof( content.getToken() ) ); - texdef.m_projection.m_brushprimit_texdef.coords[0][2] = static_cast( atof( content.getToken() ) ); - texdef.m_projection.m_brushprimit_texdef.coords[1][0] = static_cast( atof( content.getToken() ) ); - texdef.m_projection.m_brushprimit_texdef.coords[1][1] = static_cast( atof( content.getToken() ) ); - texdef.m_projection.m_brushprimit_texdef.coords[1][2] = static_cast( atof( content.getToken() ) ); + texdef.m_projection.m_brushprimit_texdef.coords[0][0] = atof( content.getToken() ); + texdef.m_projection.m_brushprimit_texdef.coords[0][1] = atof( content.getToken() ); + texdef.m_projection.m_brushprimit_texdef.coords[0][2] = atof( content.getToken() ); + texdef.m_projection.m_brushprimit_texdef.coords[1][0] = atof( content.getToken() ); + texdef.m_projection.m_brushprimit_texdef.coords[1][1] = atof( content.getToken() ); + texdef.m_projection.m_brushprimit_texdef.coords[1][2] = atof( content.getToken() ); } inline void FaceTexdef_importXML( FaceTexdef& texdef, const char* xmlContent ){ StringTokeniser content( xmlContent ); - texdef.m_projection.m_texdef.shift[0] = static_cast( atof( content.getToken() ) ); - texdef.m_projection.m_texdef.shift[1] = static_cast( atof( content.getToken() ) ); - texdef.m_projection.m_texdef.rotate = static_cast( atof( content.getToken() ) ); - texdef.m_projection.m_texdef.scale[0] = static_cast( atof( content.getToken() ) ); - texdef.m_projection.m_texdef.scale[1] = static_cast( atof( content.getToken() ) ); + texdef.m_projection.m_texdef.shift[0] = atof( content.getToken() ); + texdef.m_projection.m_texdef.shift[1] = atof( content.getToken() ); + texdef.m_projection.m_texdef.rotate = atof( content.getToken() ); + texdef.m_projection.m_texdef.scale[0] = atof( content.getToken() ); + texdef.m_projection.m_texdef.scale[1] = atof( content.getToken() ); ASSERT_MESSAGE( texdef_sane( texdef.m_projection.m_texdef ), "FaceTexdef_importXML: bad texdef" ); } diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 3a29e3b1..9196c2d7 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -267,7 +267,7 @@ const float camera_t::near_z = 1.f; camera_draw_mode camera_t::draw_mode = cd_texture; inline Matrix4 projection_for_camera( float near_z, float far_z, float fieldOfView, int width, int height ){ - float half_width = static_cast( near_z * tan( degrees_to_radians( fieldOfView * 0.5 ) ) ); + float half_width = near_z * tan( degrees_to_radians( fieldOfView * 0.5 ) ); const bool swap = height > width; if( swap ) std::swap( width, height ); @@ -329,8 +329,8 @@ void Camera_Move_updateAxes( camera_t& camera ){ double ya = degrees_to_radians( camera.angles[CAMERA_YAW] ); // the movement matrix is kept 2d - camera.forward[0] = static_cast( cos( ya ) ); - camera.forward[1] = static_cast( sin( ya ) ); + camera.forward[0] = cos( ya ); + camera.forward[1] = sin( ya ); camera.forward[2] = 0; camera.right[0] = camera.forward[1]; camera.right[1] = -camera.forward[0]; @@ -1217,7 +1217,7 @@ static void selection_button_release_freemove( QWidget* widget, const QMouseEven } void CamWnd::selection_motion_freemove( const MotionDeltaValues& delta ){ - m_rightClickMove += sqrt( static_cast( delta.x * delta.x + delta.y * delta.y ) ); + m_rightClickMove += sqrt( delta.x * delta.x + delta.y * delta.y ); m_window_observer->incMouseMove( WindowVector( delta.x, delta.y ) ); m_window_observer->onMouseMotion( windowvector_for_widget_centre( m_gl_widget ), modifiers_for_state( delta.mouseMoveEvent.modifiers() ) ); } @@ -1231,7 +1231,7 @@ void camera_orbit_scroll( camera_t& camera ){ float offset = vector3_length( camera.m_orbit_center - camera.m_orbit_initial_pos ); const int off = camera.m_orbit_offset; if( off < 0 || off > 16 ){ - offset -= offset * off / 8 * pow( 2.0f, static_cast( off < 0 ? -off : off - 16 ) / 8.f ); + offset -= offset * off / 8 * pow( 2.0f, ( off < 0 ? -off : off - 16 ) / 8.f ); } else if( off == 8 ){ offset = std::min( 8.f, offset / 16.f ); //prevent zero offset, resulting in NAN viewvector in the next scroll step @@ -2105,12 +2105,12 @@ void CamWnd::Cam_Draw(){ } if ( g_camwindow_globals.m_showStats ) { - gl().glRasterPos3f( 1.0f, static_cast( m_Camera.height ), 0.0f ); + gl().glRasterPos3f( 1.0f, m_Camera.height, 0.0f ); extern const char* Renderer_GetStats( int frame2frame ); GlobalOpenGL().drawString( Renderer_GetStats( m_render_time.elapsed_msec() ) ); m_render_time.start(); - gl().glRasterPos3f( 1.0f, static_cast( m_Camera.height ) - GlobalOpenGL().m_font->getPixelHeight(), 0.0f ); + gl().glRasterPos3f( 1.0f, m_Camera.height - GlobalOpenGL().m_font->getPixelHeight(), 0.0f ); extern const char* Cull_GetStats(); GlobalOpenGL().drawString( Cull_GetStats() ); } @@ -2139,7 +2139,7 @@ void CamWnd::BenchMark(){ Vector3 angles; angles[CAMERA_ROLL] = 0; angles[CAMERA_PITCH] = 0; - angles[CAMERA_YAW] = static_cast( i * ( 360.0 / 100.0 ) ); + angles[CAMERA_YAW] = i * ( 360.0 / 100.0 ); Camera_setAngles( *this, angles ); } globalOutputStream() << timer.elapsed_msec() << " milliseconds\n"; @@ -2150,7 +2150,7 @@ void GlobalCamera_ResetAngles(){ CamWnd& camwnd = *g_camwnd; Vector3 angles; angles[CAMERA_ROLL] = angles[CAMERA_PITCH] = 0; - angles[CAMERA_YAW] = static_cast( 22.5 * floor( ( Camera_getAngles( camwnd )[CAMERA_YAW] + 11 ) / 22.5 ) ); + angles[CAMERA_YAW] = 22.5 * floor( ( Camera_getAngles( camwnd )[CAMERA_YAW] + 11 ) / 22.5 ); Camera_setAngles( camwnd, angles ); } @@ -2198,7 +2198,7 @@ Vector3 Camera_getFocusPos( camera_t& camera ){ const int off = camera.m_focus_offset; if( off < 0 || off > 16 ){ - offset -= offset * off / 8 * pow( 2.0f, static_cast( off < 0 ? -off : off - 16 ) / 8.f ); + offset -= offset * off / 8 * pow( 2.0f, ( off < 0 ? -off : off - 16 ) / 8.f ); } else{ offset -= offset * off / 8; diff --git a/radiant/modelwindow.cpp b/radiant/modelwindow.cpp index 22922a93..3bd8050b 100644 --- a/radiant/modelwindow.cpp +++ b/radiant/modelwindow.cpp @@ -789,8 +789,8 @@ void ModelBrowser_render(){ Matrix4 m_projection; - m_projection[0] = 1.0f / static_cast( W / 2.f ); - m_projection[5] = 1.0f / static_cast( H / 2.f ); + m_projection[0] = 1.0f / ( W / 2.f ); + m_projection[5] = 1.0f / ( H / 2.f ); m_projection[10] = 1.0f / ( 9999 ); m_projection[12] = 0.0f; diff --git a/radiant/patch.cpp b/radiant/patch.cpp index c121693b..a129f3f1 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -528,8 +528,8 @@ void Patch::ScaleTexture( float s, float t ){ void Patch::RotateTexture( float angle ){ undoSave(); - const float s = static_cast( sin( degrees_to_radians( angle ) ) ); - const float c = static_cast( cos( degrees_to_radians( angle ) ) ); + const float s = sin( degrees_to_radians( angle ) ); + const float c = cos( degrees_to_radians( angle ) ); for ( PatchControlIter i = m_ctrl.data(); i != m_ctrl.data() + m_ctrl.size(); ++i ) { @@ -699,7 +699,7 @@ void Patch::NaturalTexture(){ { PatchControl* pHeight = pWidth; for ( std::size_t h = 0; h < m_height; ++h, pHeight += m_width ) - pHeight->m_texcoord[0] = static_cast( tex ); + pHeight->m_texcoord[0] = tex; } if ( w + 1 == m_width ) { @@ -732,7 +732,7 @@ void Patch::NaturalTexture(){ { PatchControl* pWidth = pHeight; for ( std::size_t w = 0; w < m_width; ++w, ++pWidth ) - pWidth->m_texcoord[1] = static_cast( tex ); + pWidth->m_texcoord[1] = tex; } if ( h + 1 == m_height ) { diff --git a/radiant/points.cpp b/radiant/points.cpp index 2b7f9f1a..e29259da 100644 --- a/radiant/points.cpp +++ b/radiant/points.cpp @@ -178,8 +178,8 @@ void Pointfile_UpdateViews( CPointfile::const_iterator i ){ { Vector3 dir( vector3_normalised( vector3_subtracted( *( ++i ), Camera_getOrigin( camwnd ) ) ) ); Vector3 angles( Camera_getAngles( camwnd ) ); - angles[CAMERA_YAW] = static_cast( radians_to_degrees( atan2( dir[1], dir[0] ) ) ); - angles[CAMERA_PITCH] = static_cast( radians_to_degrees( asin( dir[2] ) ) ); + angles[CAMERA_YAW] = radians_to_degrees( atan2( dir[1], dir[0] ) ); + angles[CAMERA_PITCH] = radians_to_degrees( asin( dir[2] ) ); Camera_setAngles( camwnd, angles ); } } diff --git a/radiant/selection.cpp b/radiant/selection.cpp index dfbbe7c8..04da8f46 100644 --- a/radiant/selection.cpp +++ b/radiant/selection.cpp @@ -143,10 +143,10 @@ inline Vector3 point_on_plane( const Plane3& plane, const Matrix4& object2device //! a and b are unit vectors .. returns angle in radians inline float angle_between( const Vector3& a, const Vector3& b ){ - return static_cast( 2.0 * atan2( - vector3_length( vector3_subtracted( a, b ) ), - vector3_length( vector3_added( a, b ) ) - ) ); + return 2.0 * atan2( + vector3_length( vector3_subtracted( a, b ) ), + vector3_length( vector3_added( a, b ) ) + ); } @@ -180,7 +180,7 @@ inline float angle_for_axis( const Vector3& a, const Vector3& b, const Vector3& } inline float distance_for_axis( const Vector3& a, const Vector3& b, const Vector3& axis ){ - return static_cast( vector3_dot( b, axis ) - vector3_dot( a, axis ) ); + return vector3_dot( b, axis ) - vector3_dot( a, axis ); } @@ -1370,7 +1370,7 @@ enum clipcull_t inline SelectionIntersection select_point_from_clipped( Vector4& clipped ){ - return SelectionIntersection( clipped[2] / clipped[3], static_cast( vector3_length_squared( Vector3( clipped[0] / clipped[3], clipped[1] / clipped[3], 0 ) ) ) ); + return SelectionIntersection( clipped[2] / clipped[3], vector3_length_squared( Vector3( clipped[0] / clipped[3], clipped[1] / clipped[3], 0 ) ) ); } void BestPoint( std::size_t count, Vector4 clipped[9], SelectionIntersection& best, clipcull_t cull, const Plane3* plane = 0 ){ @@ -1409,9 +1409,9 @@ void BestPoint( std::size_t count, Vector4 clipped[9], SelectionIntersection& be for ( point_iterator_t previous = end - 1, current = normalised; current != end; previous = current, ++current ) { Vector3 point = line_closest_point( Line( *previous, *current ), Vector3( 0, 0, 0 ) ); - float depth = point.z(); + const float depth = point.z(); point.z() = 0; - float distance = static_cast( vector3_length_squared( point ) ); + const float distance = vector3_length_squared( point ); if( plane->c == 0 ){ assign_if_closer( best, SelectionIntersection( depth, distance ) ); @@ -1421,10 +1421,10 @@ void BestPoint( std::size_t count, Vector4 clipped[9], SelectionIntersection& be Ray( Vector3( 0, 0, 0 ), Vector3( 0, 0, 1 ) ), *plane ) ) ); -// globalOutputStream() << static_cast( ray_distance_to_plane( +// globalOutputStream() << ray_distance_to_plane( // Ray( Vector3( 0, 0, 0 ), Vector3( 0, 0, 1 ) ), // plane -// ) ) << '\n'; +// ) << '\n'; } } } @@ -1920,8 +1920,8 @@ inline void draw_semicircle( const std::size_t segments, const float radius, Poi { const double theta = increment * count; - x = static_cast( radius * cos( theta ) ); - y = static_cast( radius * sin( theta ) ); + x = radius * cos( theta ); + y = radius * sin( theta ); } remap_policy::set( j->vertex, y,-x, 0 ); @@ -2234,11 +2234,11 @@ inline void draw_arrowhead( const std::size_t segments, const float length, Flat { FlatShadedVertex& point = vertices[i * 6 + 0]; VertexRemap::x( point.vertex ) = length - arrowhead_length; - VertexRemap::y( point.vertex ) = arrowhead_radius * static_cast( cos( i * head_segment ) ); - VertexRemap::z( point.vertex ) = arrowhead_radius * static_cast( sin( i * head_segment ) ); + VertexRemap::y( point.vertex ) = arrowhead_radius * cos( i * head_segment ); + VertexRemap::z( point.vertex ) = arrowhead_radius * sin( i * head_segment ); NormalRemap::x( point.normal ) = arrowhead_radius / arrowhead_length; - NormalRemap::y( point.normal ) = static_cast( cos( i * head_segment ) ); - NormalRemap::z( point.normal ) = static_cast( sin( i * head_segment ) ); + NormalRemap::y( point.normal ) = cos( i * head_segment ); + NormalRemap::z( point.normal ) = sin( i * head_segment ); } { FlatShadedVertex& point = vertices[i * 6 + 1]; @@ -2246,17 +2246,17 @@ inline void draw_arrowhead( const std::size_t segments, const float length, Flat VertexRemap::y( point.vertex ) = 0; VertexRemap::z( point.vertex ) = 0; NormalRemap::x( point.normal ) = arrowhead_radius / arrowhead_length; - NormalRemap::y( point.normal ) = static_cast( cos( ( i + 0.5 ) * head_segment ) ); - NormalRemap::z( point.normal ) = static_cast( sin( ( i + 0.5 ) * head_segment ) ); + NormalRemap::y( point.normal ) = cos( ( i + 0.5 ) * head_segment ); + NormalRemap::z( point.normal ) = sin( ( i + 0.5 ) * head_segment ); } { FlatShadedVertex& point = vertices[i * 6 + 2]; VertexRemap::x( point.vertex ) = length - arrowhead_length; - VertexRemap::y( point.vertex ) = arrowhead_radius * static_cast( cos( ( i + 1 ) * head_segment ) ); - VertexRemap::z( point.vertex ) = arrowhead_radius * static_cast( sin( ( i + 1 ) * head_segment ) ); + VertexRemap::y( point.vertex ) = arrowhead_radius * cos( ( i + 1 ) * head_segment ); + VertexRemap::z( point.vertex ) = arrowhead_radius * sin( ( i + 1 ) * head_segment ); NormalRemap::x( point.normal ) = arrowhead_radius / arrowhead_length; - NormalRemap::y( point.normal ) = static_cast( cos( ( i + 1 ) * head_segment ) ); - NormalRemap::z( point.normal ) = static_cast( sin( ( i + 1 ) * head_segment ) ); + NormalRemap::y( point.normal ) = cos( ( i + 1 ) * head_segment ); + NormalRemap::z( point.normal ) = sin( ( i + 1 ) * head_segment ); } { @@ -2271,8 +2271,8 @@ inline void draw_arrowhead( const std::size_t segments, const float length, Flat { FlatShadedVertex& point = vertices[i * 6 + 4]; VertexRemap::x( point.vertex ) = length - arrowhead_length; - VertexRemap::y( point.vertex ) = arrowhead_radius * static_cast( cos( i * head_segment ) ); - VertexRemap::z( point.vertex ) = arrowhead_radius * static_cast( sin( i * head_segment ) ); + VertexRemap::y( point.vertex ) = arrowhead_radius * cos( i * head_segment ); + VertexRemap::z( point.vertex ) = arrowhead_radius * sin( i * head_segment ); NormalRemap::x( point.normal ) = -1; NormalRemap::y( point.normal ) = 0; NormalRemap::z( point.normal ) = 0; @@ -2280,8 +2280,8 @@ inline void draw_arrowhead( const std::size_t segments, const float length, Flat { FlatShadedVertex& point = vertices[i * 6 + 5]; VertexRemap::x( point.vertex ) = length - arrowhead_length; - VertexRemap::y( point.vertex ) = arrowhead_radius * static_cast( cos( ( i + 1 ) * head_segment ) ); - VertexRemap::z( point.vertex ) = arrowhead_radius * static_cast( sin( ( i + 1 ) * head_segment ) ); + VertexRemap::y( point.vertex ) = arrowhead_radius * cos( ( i + 1 ) * head_segment ); + VertexRemap::z( point.vertex ) = arrowhead_radius * sin( ( i + 1 ) * head_segment ); NormalRemap::x( point.normal ) = -1; NormalRemap::y( point.normal ) = 0; NormalRemap::z( point.normal ) = 0; diff --git a/radiant/surfacedialog.cpp b/radiant/surfacedialog.cpp index b3d030a4..92d328ed 100644 --- a/radiant/surfacedialog.cpp +++ b/radiant/surfacedialog.cpp @@ -305,8 +305,8 @@ si_globals_t g_si_globals; // For regular it's 0.5f (128 pixels cover 64 world units), for BP it's simply 1.0f // see fenris #2810 void DoSnapTToGrid( float hscale, float vscale ){ - g_si_globals.shift[0] = static_cast( float_to_integer( static_cast( GetGridSize() ) / hscale ) ); - g_si_globals.shift[1] = static_cast( float_to_integer( static_cast( GetGridSize() ) / vscale ) ); + g_si_globals.shift[0] = float_to_integer( GetGridSize() / hscale ); + g_si_globals.shift[1] = float_to_integer( GetGridSize() / vscale ); getSurfaceInspector().queueDraw(); } @@ -1072,7 +1072,7 @@ void SurfaceInspector::ApplyTexdef_VScale(){ void SurfaceInspector::ApplyTexdef_Rotation(){ const float value = m_rotateIncrement.m_spin->value(); - const auto command = StringStream<64>( "textureProjectionSetSelected -rotation ", static_cast( float_to_integer( value * 100.f ) ) / 100.f ); + const auto command = StringStream<64>( "textureProjectionSetSelected -rotation ", float_to_integer( value * 100.f ) / 100.f ); UndoableCommand undo( command ); Select_SetTexdef( 0, 0, 0, 0, &value ); Patch_SetTexdef( 0, 0, 0, 0, &value ); diff --git a/radiant/textures.cpp b/radiant/textures.cpp index 3ea8f1ad..1776c9d1 100644 --- a/radiant/textures.cpp +++ b/radiant/textures.cpp @@ -134,23 +134,15 @@ bool g_TextureAnisotropy = true; byte g_gammatable[256]; void ResampleGamma( float fGamma ){ - int i, inf; if ( fGamma == 1.0 ) { - for ( i = 0; i < 256; ++i ) + for ( int i = 0; i < 256; ++i ) g_gammatable[i] = i; } else { - for ( i = 0; i < 256; ++i ) + for ( int i = 0; i < 256; ++i ) { - inf = (int)( 255 * pow( static_cast( ( i + 0.5 ) / 255.5 ), static_cast( fGamma ) ) + 0.5 ); - if ( inf < 0 ) { - inf = 0; - } - if ( inf > 255 ) { - inf = 255; - } - g_gammatable[i] = inf; + g_gammatable[i] = std::clamp( (int)( 255 * pow( ( i + 0.5 ) / 255.5, fGamma ) + 0.5 ), 0, 255 ); } } } diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 5c9cdbee..950bb7e5 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -646,7 +646,7 @@ void XYWnd_OrientCamera( XYWnd* xywnd, int x, int y, CamWnd& camwnd ){ const int nAngle = ( viewtype == XY ) ? CAMERA_YAW : CAMERA_PITCH; if ( point[nDim2] || point[nDim1] ) { Vector3 angles( Camera_getAngles( camwnd ) ); - angles[nAngle] = static_cast( radians_to_degrees( atan2( point[nDim2], point[nDim1] ) ) ); + angles[nAngle] = radians_to_degrees( atan2( point[nDim2], point[nDim1] ) ); if( angles[CAMERA_YAW] < 0 ) angles[CAMERA_YAW] += 360; if ( nAngle == CAMERA_PITCH ){ @@ -1585,9 +1585,9 @@ void XYWnd::DrawCameraIcon( const Vector3& origin, const Vector3& angles ){ gl().glEnd(); gl().glBegin( GL_LINE_STRIP ); - gl().glVertex3f( x + static_cast( fov * cos( a + c_pi / 4 ) ), y + static_cast( fov * sin( a + c_pi / 4 ) ), 0 ); + gl().glVertex3f( x + fov * cos( a + c_pi / 4 ), y + fov * sin( a + c_pi / 4 ), 0 ); gl().glVertex3f( x, y, 0 ); - gl().glVertex3f( x + static_cast( fov * cos( a - c_pi / 4 ) ), y + static_cast( fov * sin( a - c_pi / 4 ) ), 0 ); + gl().glVertex3f( x + fov * cos( a - c_pi / 4 ), y + fov * sin( a - c_pi / 4 ), 0 ); gl().glEnd(); } @@ -1713,8 +1713,8 @@ private: }; void XYWnd::updateProjection(){ - m_projection[0] = 1.0f / static_cast( m_nWidth / 2 ); - m_projection[5] = 1.0f / static_cast( m_nHeight / 2 ); + m_projection[0] = 1.0f / ( m_nWidth / 2 ); + m_projection[5] = 1.0f / ( m_nHeight / 2 ); m_projection[10] = 1.0f / ( g_MaxWorldCoord * m_fScale ); m_projection[12] = 0.0f;