diff --git a/contrib/bobtoolz/DBobView.cpp b/contrib/bobtoolz/DBobView.cpp index e221f635..f6825bb7 100644 --- a/contrib/bobtoolz/DBobView.cpp +++ b/contrib/bobtoolz/DBobView.cpp @@ -137,7 +137,7 @@ bool DBobView::CalculateTrajectory( vec3_t start, vec3_t apex, float multiplier, vec3_t dist, speed; VectorSubtract( apex, start, dist ); - vec_t speed_z = (float)sqrt( -2 * LOCAL_GRAVITY * dist[2] ); + vec_t speed_z = sqrt( -2 * LOCAL_GRAVITY * dist[2] ); float flight_time = -speed_z / LOCAL_GRAVITY; diff --git a/contrib/bobtoolz/DBrush.cpp b/contrib/bobtoolz/DBrush.cpp index 732a7280..fb4eeff0 100644 --- a/contrib/bobtoolz/DBrush.cpp +++ b/contrib/bobtoolz/DBrush.cpp @@ -750,7 +750,7 @@ bool DBrush::ResetTextures( const char* textureName, const float fScale[2], } if ( bResetRotation ) { - plane->texInfo.m_texdef.rotate = (float)rotation; + plane->texInfo.m_texdef.rotate = rotation; } changed = true; @@ -781,7 +781,7 @@ bool DBrush::ResetTextures( const char* textureName, const float fScale[2], } if ( bResetRotation ) { - plane->texInfo.m_texdef.rotate = (float)rotation; + plane->texInfo.m_texdef.rotate = rotation; } } return true; diff --git a/contrib/bobtoolz/DWinding.cpp b/contrib/bobtoolz/DWinding.cpp index 2db093b6..c94ae3dd 100644 --- a/contrib/bobtoolz/DWinding.cpp +++ b/contrib/bobtoolz/DWinding.cpp @@ -495,7 +495,7 @@ void DWinding::ClipWindingEpsilon( DPlane* chopPlane, vec_t epsilon, DWinding ** bool DWinding::ChopWinding( DPlane* chopPlane ){ DWinding *f, *b; - ClipWindingEpsilon( chopPlane, (float)ON_EPSILON, &f, &b ); + ClipWindingEpsilon( chopPlane, (vec_t)ON_EPSILON, &f, &b ); if ( b ) { delete ( b ); diff --git a/contrib/bobtoolz/funchandlers-GTK.cpp b/contrib/bobtoolz/funchandlers-GTK.cpp index f3fede66..550cac5d 100644 --- a/contrib/bobtoolz/funchandlers-GTK.cpp +++ b/contrib/bobtoolz/funchandlers-GTK.cpp @@ -303,7 +303,7 @@ void DoBuildStairs(){ { // Get Step Dimensions - float stairHeight = (float)rs.stairHeight; + float stairHeight = rs.stairHeight; float stairWidth; if ( ( rs.direction == MOVE_EAST ) || ( rs.direction == MOVE_WEST ) ) { stairWidth = ( size[0] ) / numSteps; diff --git a/contrib/bobtoolz/shapes.cpp b/contrib/bobtoolz/shapes.cpp index 708a03ec..e8bf7a2e 100644 --- a/contrib/bobtoolz/shapes.cpp +++ b/contrib/bobtoolz/shapes.cpp @@ -71,7 +71,7 @@ extern bool bFacesAll[]; ************************/ float Deg2Rad( float angle ){ - return (float)( angle * Q_PI / 180 ); + return angle * Q_PI / 180; } // points in CCW order void AddFaceWithTexture( scene::Node& brush, const vec3_accu_t va, const vec3_accu_t vb, const vec3_accu_t vc, const char* texture, bool detail ){ @@ -107,14 +107,14 @@ void AddFaceWithTextureScaled( scene::Node& brush, vec3_t va, vec3_t vb, vec3_t float width = maxX - minX; scale[0] = width / pqtTexInfo->width; - shift[0] = -(float)( (int)maxX % (int)width ) / scale[0]; + shift[0] = -( (int)maxX % (int)width ) / scale[0]; } if ( bVertScale ) { float height = maxY - minY; scale[1] = height / pqtTexInfo->height; - shift[1] = (float)( (int)minY % (int)height ) / scale[1]; + shift[1] = ( (int)minY % (int)height ) / scale[1]; } _QERFaceData addFace; diff --git a/libs/mathlib.h b/libs/mathlib.h index 7697cecd..cb467e71 100644 --- a/libs/mathlib.h +++ b/libs/mathlib.h @@ -84,7 +84,7 @@ extern const vec3_t g_vec3_axis_z; #define FLOAT_SNAP( f, snap ) ( (float)( floor( ( f ) / ( snap ) + 0.5 ) * ( snap ) ) ) #define FLOAT_TO_INTEGER( f ) ( (float)( floor( ( f ) + 0.5 ) ) ) -#define RGBTOGRAY( x ) ( (float)( ( x )[0] ) * 0.2989f + (float)( ( x )[1] ) * 0.5870f + (float)( ( x )[2] ) * 0.1140f ) +#define RGBTOGRAY( x ) ( ( ( x )[0] ) * 0.2989f + ( ( x )[1] ) * 0.5870f + ( ( x )[2] ) * 0.1140f ) #define Q_rint( in ) ( (vec_t)floor( in + 0.5 ) ) diff --git a/libs/mathlib/bbox.c b/libs/mathlib/bbox.c index d7e105c8..8fce0dd0 100644 --- a/libs/mathlib/bbox.c +++ b/libs/mathlib/bbox.c @@ -267,22 +267,22 @@ int aabb_test_ray( const aabb_t* aabb, const ray_t* ray ){ return 0; } - ray_absolute[0] = (float)fabs( ray->direction[0] ); - ray_absolute[1] = (float)fabs( ray->direction[1] ); - ray_absolute[2] = (float)fabs( ray->direction[2] ); + ray_absolute[0] = fabs( ray->direction[0] ); + ray_absolute[1] = fabs( ray->direction[1] ); + ray_absolute[2] = fabs( ray->direction[2] ); f = ray->direction[1] * displacement[2] - ray->direction[2] * displacement[1]; - if ( (float)fabs( f ) > aabb->extents[1] * ray_absolute[2] + aabb->extents[2] * ray_absolute[1] ) { + if ( fabs( f ) > aabb->extents[1] * ray_absolute[2] + aabb->extents[2] * ray_absolute[1] ) { return 0; } f = ray->direction[2] * displacement[0] - ray->direction[0] * displacement[2]; - if ( (float)fabs( f ) > aabb->extents[0] * ray_absolute[2] + aabb->extents[2] * ray_absolute[0] ) { + if ( fabs( f ) > aabb->extents[0] * ray_absolute[2] + aabb->extents[2] * ray_absolute[0] ) { return 0; } f = ray->direction[0] * displacement[1] - ray->direction[1] * displacement[0]; - if ( (float)fabs( f ) > aabb->extents[0] * ray_absolute[1] + aabb->extents[1] * ray_absolute[0] ) { + if ( fabs( f ) > aabb->extents[0] * ray_absolute[1] + aabb->extents[1] * ray_absolute[0] ) { return 0; } diff --git a/libs/mathlib/m4x4.c b/libs/mathlib/m4x4.c index 5723d7f4..1c7dde53 100644 --- a/libs/mathlib/m4x4.c +++ b/libs/mathlib/m4x4.c @@ -1505,12 +1505,12 @@ void quat_normalise( vec4_t quat ){ void quat_for_axisangle( vec4_t quat, const vec3_t axis, double angle ){ angle *= 0.5; - quat[3] = (float)sin( angle ); + quat[3] = sin( angle ); quat[0] = axis[0] * quat[3]; quat[1] = axis[1] * quat[3]; quat[2] = axis[2] * quat[3]; - quat[3] = (float)cos( angle ); + quat[3] = cos( angle ); } void m3x3_multiply_by_m3x3( m3x3_t matrix, const m3x3_t matrix_src ){ @@ -1760,7 +1760,7 @@ int matrix_solve_ge( vec_t* matrix, vec_t* aug, vec3_t x ){ for ( c = 0; c < N; ++c, ++p ) { if ( fabs( *p ) > scale[r] ) { - scale[r] = (float)fabs( *p ); + scale[r] = fabs( *p ); } } } @@ -1771,7 +1771,7 @@ int matrix_solve_ge( vec_t* matrix, vec_t* aug, vec3_t x ){ best = -1; for ( r = c; r < N; ++r ) { - f = (float)fabs( matrix[( indx[r] * N ) + c] ) / scale[indx[r]]; + f = fabs( matrix[( indx[r] * N ) + c] ) / scale[indx[r]]; if ( f > pivot ) { pivot = f; best = r; diff --git a/libs/mathlib/mathlib.c b/libs/mathlib/mathlib.c index a68b376b..da6989b7 100644 --- a/libs/mathlib/mathlib.c +++ b/libs/mathlib/mathlib.c @@ -99,7 +99,7 @@ vec_t VectorLength( const vec3_t v ){ for ( int i = 0; i < 3; ++i ) length += v[i] * v[i]; - length = (float)sqrt( length ); + length = sqrt( length ); return length; } @@ -158,9 +158,9 @@ vec_t VectorAccurateNormalize( const vec3_t in, vec3_t out ) { double x, y, z, length; - x = (double) in[0]; - y = (double) in[1]; - z = (double) in[2]; + x = in[0]; + y = in[1]; + z = in[2]; length = sqrt( ( x * x ) + ( y * y ) + ( z * z ) ); if ( length == 0 ) { @@ -271,9 +271,9 @@ void VectorRotateOrigin( vec3_t vIn, vec3_t vRotation, vec3_t vOrigin, vec3_t ou } void VectorPolar( vec3_t v, float radius, float theta, float phi ){ - v[0] = (float)( radius * cos( theta ) * cos( phi ) ); - v[1] = (float)( radius * sin( theta ) * cos( phi ) ); - v[2] = (float)( radius * sin( phi ) ); + v[0] = radius * cos( theta ) * cos( phi ); + v[1] = radius * sin( theta ) * cos( phi ); + v[2] = radius * sin( phi ); } void VectorSnap( vec3_t v ){ @@ -618,7 +618,7 @@ void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, memset( zrot, 0, sizeof( zrot ) ); zrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F; - rad = (float)DEG2RAD( degrees ); + rad = DEG2RAD( degrees ); zrot[0][0] = (vec_t)cos( rad ); zrot[0][1] = (vec_t)sin( rad ); zrot[1][0] = (vec_t)-sin( rad ); diff --git a/radiant/brush_primit.cpp b/radiant/brush_primit.cpp index fce21737..0f08b12b 100644 --- a/radiant/brush_primit.cpp +++ b/radiant/brush_primit.cpp @@ -263,7 +263,7 @@ void Texdef_basisForNormal( const TextureProjection& projection, const Vector3& } void Texdef_Construct_local2tex( const TextureProjection& projection, std::size_t width, std::size_t height, const Vector3& normal, Matrix4& local2tex ){ - Texdef_toTransform( projection, (float)width, (float)height, local2tex ); + Texdef_toTransform( projection, width, height, local2tex ); { Matrix4 xyz2st; Texdef_basisForNormal( projection, normal, xyz2st ); @@ -278,15 +278,15 @@ void Texdef_EmitTextureCoordinates( const TextureProjection& projection, std::si //globalOutputStream() << "normal: " << normal << '\n'; Matrix4 local2tex; - Texdef_toTransform( projection, (float)width, (float)height, local2tex ); + Texdef_toTransform( projection, width, height, local2tex ); //globalOutputStream() << "texdef: " << local2tex.x().vec3() << local2tex.y().vec3() << '\n'; #if 0 { TextureProjection tmp; - Texdef_fromTransform( tmp, (float)width, (float)height, local2tex ); + Texdef_fromTransform( tmp, width, height, local2tex ); Matrix4 tmpTransform; - Texdef_toTransform( tmp, (float)width, (float)height, tmpTransform ); + Texdef_toTransform( tmp, width, height, tmpTransform ); ASSERT_MESSAGE( matrix4_equal_epsilon( local2tex, tmpTransform, 0.0001f ), "bleh" ); } #endif @@ -1207,7 +1207,7 @@ void Texdef_FitTexture( TextureProjection& projection, std::size_t width, std::s } Matrix4 st2tex; - Texdef_toTransform( projection, (float)width, (float)height, st2tex ); + Texdef_toTransform( projection, width, height, st2tex ); // the current texture transform Matrix4 local2tex = st2tex; @@ -1268,12 +1268,12 @@ void Texdef_FitTexture( TextureProjection& projection, std::size_t width, std::s // apply the difference to the current texture transform matrix4_premultiply_by_matrix4( st2tex, matrix ); - Texdef_fromTransform( projection, (float)width, (float)height, st2tex ); - //Texdef_normalise( projection, (float)width, (float)height ); + Texdef_fromTransform( projection, width, height, st2tex ); + //Texdef_normalise( projection, width, height ); if ( g_bp_globals.m_texdefTypeId == TEXDEFTYPEID_BRUSHPRIMITIVES ) BPTexdef_normalise( projection.m_brushprimit_texdef, 1, 1 ); /* scaleApplied is! */ else - Texdef_normalise( projection.m_texdef, (float)width, (float)height ); + Texdef_normalise( projection.m_texdef, width, height ); } float Texdef_getDefaultTextureScale(){ @@ -1679,7 +1679,7 @@ void AP_from_axes( const Vector3& axisX, const Vector3& axisY, const DoubleVecto texdef.scale[0] = scale[0]; texdef.scale[1] = scale[1]; texdef.rotate = radians_to_degrees( rad ); - Texdef_normalise( texdef, (float)width, (float)height ); + Texdef_normalise( texdef, width, height ); } @@ -1808,13 +1808,13 @@ void Texdef_transformLocked( TextureProjection& projection, std::size_t width, s Matrix4 stTransformed2identity( matrix4_affine_inverse( matrix4_multiplied_by_matrix4( transformed2stTransformed, identity2transformed ) ) ); //QNAN here, if some scale = 0 Matrix4 stIdentity2stOriginal; - Texdef_toTransform( projection, (float)width, (float)height, stIdentity2stOriginal ); + Texdef_toTransform( projection, width, height, stIdentity2stOriginal ); Matrix4 identity2stOriginal( matrix4_multiplied_by_matrix4( stIdentity2stOriginal, identity2stIdentity ) ); Matrix4 stTransformed2stOriginal = matrix4_multiplied_by_matrix4( identity2stOriginal, stTransformed2identity ); if( stTransformed2stOriginal[0] == stTransformed2stOriginal[0] ){ /* catch QNAN: happens when projecting along plane */ - Texdef_fromTransform( projection, (float)width, (float)height, stTransformed2stOriginal ); - Texdef_normalise( projection, (float)width, (float)height ); + Texdef_fromTransform( projection, width, height, stTransformed2stOriginal ); + Texdef_normalise( projection, width, height ); projection.m_texdef.scale[0] /= vector3_length( projection.m_basis_s ); projection.m_texdef.scale[1] /= vector3_length( projection.m_basis_t ); @@ -1903,7 +1903,7 @@ void Q3_to_BP( const texdef_t& texdef, float width, float height, const Vector3& /// for arbitrary texture projections void Texdef_Construct_local2tex4projection( const texdef_t& texdef, std::size_t width, std::size_t height, const Vector3& normal, const Vector3* direction, Matrix4& local2tex ){ - Texdef_toTransform( texdef, (float)width, (float)height, local2tex ); + Texdef_toTransform( texdef, width, height, local2tex ); { if( direction ){ //arbitrary Matrix4 basis = g_matrix4_identity; @@ -2022,8 +2022,8 @@ void Valve220_from_BP( TextureProjection& projection, const Plane3& plane, std:: #if 0 projection.m_texdef.scale[0] = 1.0 / ( vector2_length( Vector2( projection.m_brushprimit_texdef.coords[0][0], projection.m_brushprimit_texdef.coords[0][1] ) ) * (double)width ); 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.shift[0] = projection.m_brushprimit_texdef.coords[0][2] * width; + projection.m_texdef.shift[1] = projection.m_brushprimit_texdef.coords[1][2] * height; 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; diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index 2b6d625c..b885fb24 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -2063,9 +2063,9 @@ void CamWnd::Cam_Draw(){ gl().glDisable( GL_BLEND ); gl().glMatrixMode( GL_PROJECTION ); gl().glLoadIdentity(); - gl().glOrtho( 0, (float)m_Camera.width, 0, (float)m_Camera.height, -100, 100 ); + gl().glOrtho( 0, m_Camera.width, 0, m_Camera.height, -100, 100 ); gl().glScalef( 1, -1, 1 ); - gl().glTranslatef( 0, -(float)m_Camera.height, 0 ); + gl().glTranslatef( 0, -m_Camera.height, 0 ); gl().glMatrixMode( GL_MODELVIEW ); gl().glLoadIdentity(); diff --git a/radiant/patch.cpp b/radiant/patch.cpp index 3008d4f1..1ca3ee80 100644 --- a/radiant/patch.cpp +++ b/radiant/patch.cpp @@ -1268,8 +1268,8 @@ void Patch::constructPlane( const AABB& aabb, int axis, std::size_t width, std:: vStart[y] = aabb.origin[y] - aabb.extents[y]; vStart[z] = aabb.origin[z] + aabb.extents[z]; - float xAdj = fabsf( ( vStart[x] - ( aabb.origin[x] + aabb.extents[x] ) ) / (float)( m_width - 1 ) ); - float yAdj = fabsf( ( vStart[y] - ( aabb.origin[y] + aabb.extents[y] ) ) / (float)( m_height - 1 ) ); + const float xAdj = std::fabs( ( vStart[x] - ( aabb.origin[x] + aabb.extents[x] ) ) / ( m_width - 1 ) ); + const float yAdj = std::fabs( ( vStart[y] - ( aabb.origin[y] + aabb.extents[y] ) ) / ( m_height - 1 ) ); Vector3 vTmp; vTmp[z] = vStart[z]; @@ -1456,14 +1456,13 @@ void Patch::ConstructPrefab( const AABB& aabb, EPatchPrefab eType, int axis, std float f = 1 / cos( M_PI / n ); for ( i = 0; i < width; ++i ) { - float angle = ( M_PI * i ) / n; // 0 to 2pi - float x_ = vPos[1][x] + ( vPos[2][x] - vPos[1][x] ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f ); - float y_ = vPos[1][y] + ( vPos[2][y] - vPos[1][y] ) * sin( angle ) * ( ( i & 1 ) ? f : 1.0f ); + const float angle = ( M_PI * i ) / n; // 0 to 2pi + const float x_ = vPos[1][x] + ( vPos[2][x] - vPos[1][x] ) * cos( angle ) * ( ( i & 1 ) ? f : 1.0f ); + const float y_ = vPos[1][y] + ( vPos[2][y] - vPos[1][y] ) * sin( angle ) * ( ( i & 1 ) ? f : 1.0f ); for ( j = 0; j < height; ++j ) { - float z_ = vPos[0][z] + ( vPos[2][z] - vPos[0][z] ) * ( j / (float)( height - 1 ) ); - PatchControl *v; - v = &m_ctrl.data()[j * width + i]; + const float z_ = vPos[0][z] + ( vPos[2][z] - vPos[0][z] ) * ( j / (float)( height - 1 ) ); + PatchControl *v = &m_ctrl.data()[j * width + i]; v->m_vertex[x] = x_; v->m_vertex[y] = y_; v->m_vertex[z] = z_; @@ -3160,7 +3159,7 @@ void Patch::createThickenedOpposite( const Patch& sourcePatch, if ( vector3_length_squared( vector3_cross( rowTangent[0], colTangent[0] ) ) > 0 ){ normal = vector3_normalised( vector3_cross( rowTangent[0], colTangent[0] ) ); /*globalOutputStream() << "3\n"; - globalOutputStream() << (float)vector3_length_squared( vector3_cross( rowTangent[0], colTangent[0] ) ) << '\n'; + globalOutputStream() << vector3_length_squared( vector3_cross( rowTangent[0], colTangent[0] ) ) << '\n'; globalOutputStream() << normal << '\n';*/ } else{ diff --git a/radiant/selection.cpp b/radiant/selection.cpp index 651302ff..0679809e 100644 --- a/radiant/selection.cpp +++ b/radiant/selection.cpp @@ -1348,7 +1348,7 @@ bool point_test_polygon_2d( const point_t& P, point_iterator_t start, point_iter if ( ( ( ( *prev )[1] <= P[1] ) && ( ( *cur )[1] > P[1] ) ) // an upward crossing || ( ( ( *prev )[1] > P[1] ) && ( ( *cur )[1] <= P[1] ) ) ) { // a downward crossing // compute the actual edge-ray intersect x-coordinate - float vt = (float)( P[1] - ( *prev )[1] ) / ( ( *cur )[1] - ( *prev )[1] ); + const float vt = ( P[1] - ( *prev )[1] ) / ( ( *cur )[1] - ( *prev )[1] ); if ( P[0] < ( *prev )[0] + vt * ( ( *cur )[0] - ( *prev )[0] ) ) { // P[0] < intersect ++crossings; // a valid crossing of y=P[1] right of P[0] } diff --git a/radiant/texmanip.cpp b/radiant/texmanip.cpp index c9dab33b..112a2ec6 100644 --- a/radiant/texmanip.cpp +++ b/radiant/texmanip.cpp @@ -41,7 +41,7 @@ void R_ResampleTextureLerpLine( const byte *in, byte *out, int inwidth, int outw int j, xi, oldx = 0, f, fstep, endx, lerp; #define LERPBYTE( i ) out[i] = (byte) ( ( ( ( row2[i] - row1[i] ) * lerp ) >> 16 ) + row1[i] ) - fstep = (int) ( inwidth * 65536.0f / outwidth ); + fstep = inwidth * 65536.0f / outwidth; endx = ( inwidth - 1 ); if ( bytesperpixel == 4 ) { for ( j = 0, f = 0; j < outwidth; ++j, f += fstep ) @@ -121,7 +121,7 @@ void R_ResampleTexture( const void *indata, int inwidth, int inheight, void *out const byte *inrow; byte *out; out = (byte *)outdata; - fstep = (int) ( inheight * 65536.0f / outheight ); + fstep = inheight * 65536.0f / outheight; #define LERPBYTE( i ) out[i] = (byte) ( ( ( ( row2[i] - row1[i] ) * lerp ) >> 16 ) + row1[i] ) inrow = (const byte *)indata; @@ -218,7 +218,7 @@ void R_ResampleTexture( const void *indata, int inwidth, int inheight, void *out const byte *inrow; byte *out; out = (byte *)outdata; - fstep = (int) ( inheight * 65536.0f / outheight ); + fstep = inheight * 65536.0f / outheight; #define LERPBYTE( i ) out[i] = (byte) ( ( ( ( row2[i] - row1[i] ) * lerp ) >> 16 ) + row1[i] ) inrow = (const byte *)indata; diff --git a/radiant/winding.cpp b/radiant/winding.cpp index 46be1cf1..1da7aeb5 100644 --- a/radiant/winding.cpp +++ b/radiant/winding.cpp @@ -47,10 +47,10 @@ void windingTestInfinity(){ while( windingTestInfinityI < iterations ) { Plane3 plane; - plane.d = ( (double)rand() / (double)RAND_MAX ) * maxWorldCoord * 2; - plane.a = ( (double)rand() / (double)RAND_MAX ); - plane.b = ( (double)rand() / (double)RAND_MAX ); - plane.c = ( (double)rand() / (double)RAND_MAX ); + plane.d = ( (double)rand() / RAND_MAX ) * maxWorldCoord * 2; + plane.a = ( (double)rand() / RAND_MAX ); + plane.b = ( (double)rand() / RAND_MAX ); + plane.c = ( (double)rand() / RAND_MAX ); if( vector3_length( plane.normal() ) != 0 ){ vector3_normalise( plane.normal() ); } diff --git a/tools/quake3/common/polylib.cpp b/tools/quake3/common/polylib.cpp index 3242961b..7c9ba068 100644 --- a/tools/quake3/common/polylib.cpp +++ b/tools/quake3/common/polylib.cpp @@ -186,7 +186,7 @@ winding_accu_t BaseWindingForPlaneAccu( const Plane3& plane ){ // We're relying on the fact that MAX_WORLD_COORD is a power of 2 to keep // our calculation precise and relatively free of floating point error. // [However, the code will still work fine if that's not the case.] - vright *= ( (double) MAX_WORLD_COORD ) * 4.0; + vright *= MAX_WORLD_COORD * 4.0; // At time time of this writing, MAX_WORLD_COORD was 65536 (2^16). Therefore // the length of vright at this point is at least 185364. In comparison, a @@ -461,7 +461,7 @@ void ChopWindingInPlaceAccu( winding_accu_t& inout, const Plane3& plane, float c // VEC_SMALLEST_EPSILON_AROUND_ONE, you would be guaranteed at least 2000 "ticks" in // 64-bit land inside of the epsilon for all numbers we're dealing with. - static const double smallestEpsilonAllowed = ( (double) VEC_SMALLEST_EPSILON_AROUND_ONE ) * 0.5; + constexpr double smallestEpsilonAllowed = ( (double) VEC_SMALLEST_EPSILON_AROUND_ONE ) * 0.5; const double fineEpsilon = std::max( smallestEpsilonAllowed, (double) crudeEpsilon ); for ( size_t i = 0; i < inout.size(); ++i ) diff --git a/tools/quake3/common/qmath.h b/tools/quake3/common/qmath.h index 85db1e29..d39e6162 100644 --- a/tools/quake3/common/qmath.h +++ b/tools/quake3/common/qmath.h @@ -5,7 +5,7 @@ #include "math/plane.h" -#define RGBTOGRAY( x ) ( (float)( ( x )[0] ) * 0.2989f + (float)( ( x )[1] ) * 0.5870f + (float)( ( x )[2] ) * 0.1140f ) +#define RGBTOGRAY( x ) ( ( ( x )[0] ) * 0.2989f + ( ( x )[1] ) * 0.5870f + ( ( x )[2] ) * 0.1140f ) #define VectorFastNormalize VectorNormalize diff --git a/tools/quake3/q3map2/convert_bsp.cpp b/tools/quake3/q3map2/convert_bsp.cpp index 8b2b6e4d..82647470 100644 --- a/tools/quake3/q3map2/convert_bsp.cpp +++ b/tools/quake3/q3map2/convert_bsp.cpp @@ -186,8 +186,8 @@ int AnalyzeBSP( Args& args ){ /* extract data */ lump = (byte*) header + offset; - lumpInt = LittleLong( (int) *( (int*) lump ) ); - lumpFloat = LittleFloat( (float) *( (float*) lump ) ); + lumpInt = LittleLong( *( (int*) lump ) ); + lumpFloat = LittleFloat( *( (float*) lump ) ); memcpy( lumpString, (char*) lump, std::min( (size_t)length, std::size( lumpString ) - 1 ) ); lumpString[ std::size( lumpString ) - 1 ] = '\0'; diff --git a/tools/quake3/q3map2/light_bounce.cpp b/tools/quake3/q3map2/light_bounce.cpp index 011a0e0a..1e82bd16 100644 --- a/tools/quake3/q3map2/light_bounce.cpp +++ b/tools/quake3/q3map2/light_bounce.cpp @@ -177,9 +177,9 @@ bool RadSampleImage( const byte *pixels, int width, int height, const Vector2& s } /* get offsets */ - x = ( (float) width * Modulo1IfNegative( st[ 0 ] ) ) + 0.5f; + x = width * Modulo1IfNegative( st[ 0 ] ) + 0.5f; x %= width; - y = ( (float) height * Modulo1IfNegative( st[ 1 ] ) ) + 0.5f; + y = height * Modulo1IfNegative( st[ 1 ] ) + 0.5f; y %= height; /* get pixel */ diff --git a/tools/quake3/q3map2/lightmaps_ydnar.cpp b/tools/quake3/q3map2/lightmaps_ydnar.cpp index 04cc3f19..f9a15298 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.cpp +++ b/tools/quake3/q3map2/lightmaps_ydnar.cpp @@ -506,7 +506,7 @@ static bool AddPatchToRawLightmap( int num, rawLightmap_t& lm ){ lm.w = lm.sampleSize != 0 ? ceil( length / lm.sampleSize ) + 1 : 0; value_maximize( lm.w, ds.patchWidth ); value_minimize( lm.w, lm.customWidth ); - sBasis = (float) ( lm.w - 1 ) / (float) ( ds.patchWidth - 1 ); + sBasis = (float) ( lm.w - 1 ) / ( ds.patchWidth - 1 ); /* determine lightmap height */ length = 0; @@ -515,7 +515,7 @@ static bool AddPatchToRawLightmap( int num, rawLightmap_t& lm ){ lm.h = lm.sampleSize != 0 ? ceil( length / lm.sampleSize ) + 1 : 0; value_maximize( lm.h, ds.patchHeight ); value_minimize( lm.h, lm.customHeight ); - tBasis = (float) ( lm.h - 1 ) / (float) ( ds.patchHeight - 1 ); + tBasis = (float) ( lm.h - 1 ) / ( ds.patchHeight - 1 ); /* free the temporary mesh */ FreeMesh( mesh ); @@ -754,7 +754,7 @@ static bool AddSurfaceToRawLightmap( int num, rawLightmap_t& lm ){ verts[ i ].lightmap[ 0 ][ 0 ] = s * superSample; verts[ i ].lightmap[ 0 ][ 1 ] = t * superSample; - if ( s > (float) lm.w || t > (float) lm.h ) { + if ( s > lm.w || t > lm.h ) { Sys_FPrintf( SYS_WRN | SYS_VRBflag, "WARNING: Lightmap texture coords out of range: S %1.4f > %3d || T %1.4f > %3d\n", s, lm.w, t, lm.h ); } @@ -3125,8 +3125,8 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ } /* calc lightmap origin in texture space */ - lmx = (float) lm->lightmapX[ lightmapNum ] / (float) olm->customWidth; - lmy = (float) lm->lightmapY[ lightmapNum ] / (float) olm->customHeight; + lmx = (float) lm->lightmapX[ lightmapNum ] / olm->customWidth; + lmy = (float) lm->lightmapY[ lightmapNum ] / olm->customHeight; /* calc lightmap st coords */ dv = &bspDrawVerts[ ds->firstVert ]; @@ -3134,8 +3134,8 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ for ( j = 0; j < ds->numVerts; ++j ) { if ( lm->solid[ lightmapNum ] ) { - dv[ j ].lightmap[ lightmapNum ][ 0 ] = lmx + ( 0.5f / (float) olm->customWidth ); - dv[ j ].lightmap[ lightmapNum ][ 1 ] = lmy + ( 0.5f / (float) olm->customWidth ); + dv[ j ].lightmap[ lightmapNum ][ 0 ] = lmx + ( 0.5f / olm->customWidth ); + dv[ j ].lightmap[ lightmapNum ][ 1 ] = lmy + ( 0.5f / olm->customWidth ); } else { @@ -3330,7 +3330,7 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ numStored = bspLightBytes.size() / 3; efficiency = ( numStored <= 0 ) ? 0 - : (float) numUsed / (float) numStored; + : (float) numUsed / numStored; /* print stats */ Sys_Printf( "%9d luxels used\n", numUsed ); diff --git a/tools/quake3/q3map2/map.cpp b/tools/quake3/q3map2/map.cpp index aa8b1acf..3ebdef9d 100644 --- a/tools/quake3/q3map2/map.cpp +++ b/tools/quake3/q3map2/map.cpp @@ -1723,7 +1723,7 @@ void LoadMapFile( const char *filename, bool onlyLights, bool noCollapseGroups ) /* get brush counts */ const int numMapBrushes = entities[ 0 ].brushes.size(); - if ( (float) c_detail / (float) numMapBrushes < 0.10f && numMapBrushes > 500 ) { + if ( (float) c_detail / numMapBrushes < 0.10f && numMapBrushes > 500 ) { Sys_Warning( "Over 90 percent structural map detected. Compile time may be adversely affected.\n" ); } diff --git a/tools/quake3/q3map2/minimap.cpp b/tools/quake3/q3map2/minimap.cpp index c577e4b0..25d0dab6 100644 --- a/tools/quake3/q3map2/minimap.cpp +++ b/tools/quake3/q3map2/minimap.cpp @@ -146,8 +146,8 @@ static void MiniMapRandomlySupersampled( int y ){ int x, i; float *p = &minimap.data1f[y * minimap.width]; float ymin = minimap.mins[1] + minimap.size[1] * ( y / (float) minimap.height ); - float dx = minimap.size[0] / (float) minimap.width; - float dy = minimap.size[1] / (float) minimap.height; + float dx = minimap.size[0] / (float) minimap.width; + float dy = minimap.size[1] / (float) minimap.height; float uv[2]; float thisval; @@ -174,8 +174,8 @@ static void MiniMapSupersampled( int y ){ int x, i; float *p = &minimap.data1f[y * minimap.width]; float ymin = minimap.mins[1] + minimap.size[1] * ( y / (float) minimap.height ); - float dx = minimap.size[0] / (float) minimap.width; - float dy = minimap.size[1] / (float) minimap.height; + float dx = minimap.size[0] / (float) minimap.width; + float dy = minimap.size[1] / (float) minimap.height; for ( x = 0; x < minimap.width; ++x ) { @@ -198,11 +198,11 @@ static void MiniMapSupersampled( int y ){ static void MiniMapNoSupersampling( int y ){ int x; float *p = &minimap.data1f[y * minimap.width]; - float ymin = minimap.mins[1] + minimap.size[1] * ( ( y + 0.5 ) / (float) minimap.height ); + float ymin = minimap.mins[1] + minimap.size[1] * ( ( y + 0.5 ) / minimap.height ); for ( x = 0; x < minimap.width; ++x ) { - float xmin = minimap.mins[0] + minimap.size[0] * ( ( x + 0.5 ) / (float) minimap.width ); + float xmin = minimap.mins[0] + minimap.size[0] * ( ( x + 0.5 ) / minimap.width ); *p++ = MiniMapSample( xmin, ymin ) / minimap.size[2]; } } diff --git a/tools/quake3/q3map2/surface.cpp b/tools/quake3/q3map2/surface.cpp index 3c18a907..d14e9ffe 100644 --- a/tools/quake3/q3map2/surface.cpp +++ b/tools/quake3/q3map2/surface.cpp @@ -492,7 +492,7 @@ void ClassifySurface( mapDrawSurface_t& ds ){ ds.sampleSize = sampleSize; /* otherwise use global default */ } if ( ds.lightmapScale > 0 ) { /* apply surface lightmap scaling factor */ - ds.sampleSize = ds.lightmapScale * (float)ds.sampleSize; + ds.sampleSize = ds.lightmapScale * ds.sampleSize; ds.lightmapScale = 0; /* applied */ } diff --git a/tools/quake3/q3map2/vis.cpp b/tools/quake3/q3map2/vis.cpp index 357427a5..f8025f00 100644 --- a/tools/quake3/q3map2/vis.cpp +++ b/tools/quake3/q3map2/vis.cpp @@ -311,8 +311,8 @@ static void CalcVis(){ Sys_FPrintf( SYS_VRB, "%4i clusters have exactly %4i visible clusters\n", clustersizehistogram[i], i ); } /* cast is to prevent integer overflow */ - totalvis += ( (double) i ) * ( (double) clustersizehistogram[i] ); - totalvis2 += ( (double) i ) * ( (double) i ) * ( (double) clustersizehistogram[i] ); + totalvis += (double) i * clustersizehistogram[i]; + totalvis2 += (double) i * i * clustersizehistogram[i]; if ( minvis < 0 ) { minvis = i;