public: initial fix of double promotion

This commit is contained in:
Alibek Omarov 2019-10-05 03:10:13 +03:00
parent 880dd2546f
commit 0577ecbccf
4 changed files with 23 additions and 12 deletions

View File

@ -662,7 +662,7 @@ char *Q_pretifymem( float value, int digitsafterdecimal )
// otherwise, create a format string for the decimals
Q_sprintf( fmt, "%%.%if%s", digitsafterdecimal, suffix );
Q_sprintf( val, fmt, value );
Q_sprintf( val, fmt, (double)value );
}
// copy from in to out

View File

@ -17,6 +17,9 @@ GNU General Public License for more details.
#include "const.h"
#include "com_model.h"
#include <math.h>
#ifdef HAVE_TGMATH_H
#include <tgmath.h>
#endif
#include "mathlib.h"
#include "eiface.h"
@ -50,7 +53,7 @@ anglemod
*/
float anglemod( float a )
{
a = (360.0 / 65536) * ((int)(a*(65536/360.0)) & 65535);
a = (360.0f / 65536) * ((int)(a*(65536/360.0f)) & 65535);
return a;
}
@ -444,11 +447,11 @@ void VectorAngles( const float *forward, float *angles )
}
else
{
yaw = ( atan2( forward[1], forward[0] ) * 180 / M_PI );
yaw = ( atan2( forward[1], forward[0] ) * 180 / M_PI_F );
if( yaw < 0 ) yaw += 360;
tmp = sqrt( forward[0] * forward[0] + forward[1] * forward[1] );
pitch = ( atan2( forward[2], tmp ) * 180 / M_PI );
pitch = ( atan2( forward[2], tmp ) * 180 / M_PI_F );
if( pitch < 0 ) pitch += 360;
}
@ -737,8 +740,8 @@ void QuaternionSlerpNoAlign( const vec4_t p, const vec4_t q, float t, vec4_t qt
qt[1] = q[0];
qt[2] = -q[3];
qt[3] = q[2];
sclp = sin(( 1.0f - t ) * ( 0.5f * M_PI ));
sclq = sin( t * ( 0.5f * M_PI ));
sclp = sin(( 1.0f - t ) * ( 0.5f * M_PI_F ));
sclq = sin( t * ( 0.5f * M_PI_F ));
for( i = 0; i < 3; i++ )
{
@ -800,7 +803,7 @@ void V_AdjustFov( float *fov_x, float *fov_y, float width, float height, qboolea
if( lock_x )
{
*fov_y = 2 * atan((width * 3) / (height * 4) * tan( *fov_y * M_PI / 360.0 * 0.5 )) * 360 / M_PI;
*fov_y = 2 * atan((width * 3) / (height * 4) * tan( *fov_y * M_PI_F / 360.0f * 0.5f )) * 360 / M_PI_F;
return;
}

View File

@ -36,8 +36,8 @@ GNU General Public License for more details.
#define M_PI_F ((float)(M_PI))
#define M_PI2_F ((float)(M_PI2))
#define RAD2DEG( x ) ((float)(x) * (float)(180.f / M_PI))
#define DEG2RAD( x ) ((float)(x) * (float)(M_PI / 180.f))
#define RAD2DEG( x ) ((float)(x) * (float)(180.f / M_PI_F))
#define DEG2RAD( x ) ((float)(x) * (float)(M_PI_F / 180.f))
#define NUMVERTEXNORMALS 162
@ -69,7 +69,7 @@ GNU General Public License for more details.
#define Q_recip( a ) ((float)(1.0f / (float)(a)))
#define Q_floor( a ) ((float)(int)(a))
#define Q_ceil( a ) ((float)(int)((a) + 1))
#define Q_round( x, y ) (floor( x / y + 0.5 ) * y )
#define Q_round( x, y ) (floor( x / y + 0.5f ) * y )
#define Q_rint(x) ((x) < 0 ? ((int)((x)-0.5f)) : ((int)((x)+0.5f)))
#define IS_NAN(x) (((*(int *)&x) & (255<<23)) == (255<<23))
@ -97,8 +97,8 @@ GNU General Public License for more details.
#define VectorLength2(a) (DotProduct( a, a ))
#define VectorDistance(a, b) (sqrt( VectorDistance2( a, b )))
#define VectorDistance2(a, b) (((a)[0] - (b)[0]) * ((a)[0] - (b)[0]) + ((a)[1] - (b)[1]) * ((a)[1] - (b)[1]) + ((a)[2] - (b)[2]) * ((a)[2] - (b)[2]))
#define Vector2Average(a,b,o) ((o)[0]=((a)[0]+(b)[0])*0.5,(o)[1]=((a)[1]+(b)[1])*0.5)
#define VectorAverage(a,b,o) ((o)[0]=((a)[0]+(b)[0])*0.5,(o)[1]=((a)[1]+(b)[1])*0.5,(o)[2]=((a)[2]+(b)[2])*0.5)
#define Vector2Average(a,b,o) ((o)[0]=((a)[0]+(b)[0])*0.5f,(o)[1]=((a)[1]+(b)[1])*0.5f)
#define VectorAverage(a,b,o) ((o)[0]=((a)[0]+(b)[0])*0.5f,(o)[1]=((a)[1]+(b)[1])*0.5f,(o)[2]=((a)[2]+(b)[2])*0.5f)
#define Vector2Set(v, x, y) ((v)[0]=(x),(v)[1]=(y))
#define VectorSet(v, x, y, z) ((v)[0]=(x),(v)[1]=(y),(v)[2]=(z))
#define Vector4Set(v, a, b, c, d) ((v)[0]=(a),(v)[1]=(b),(v)[2]=(c),(v)[3] = (d))

View File

@ -176,6 +176,7 @@ def configure(conf):
'-Werror=duplicated-branches', # BEWARE: buggy
'-Werror=bool-compare',
'-Werror=bool-operation',
'-Werror=double-promotion',
'-Wstrict-aliasing',
]
@ -230,6 +231,13 @@ def configure(conf):
conf.env.append_unique('CXXFLAGS', cxxflags)
conf.env.append_unique('LINKFLAGS', linkflags)
try:
conf.check_cc(header_name='tgmath.h')
except:
pass
else:
conf.env.append_unique('DEFINES', 'HAVE_TGMATH_H')
conf.env.DEDICATED = conf.options.DEDICATED
# we don't need game launcher on dedicated
conf.env.SINGLE_BINARY = conf.options.SINGLE_BINARY or conf.env.DEDICATED