Fix MSVC compiler warnings (replace most M_PI with (float)M_PI)
This was SVN commit r7404.
This commit is contained in:
parent
5dce8a2d8c
commit
49eb176b25
@ -205,7 +205,7 @@ float CCinemaPath::EaseCircle(float t) const
|
||||
|
||||
float CCinemaPath::EaseSine(float t) const
|
||||
{
|
||||
t = 1.0f - cos(t * M_PI/2);
|
||||
t = 1.0f - cos(t * (float)M_PI/2);
|
||||
if(m_GrowthCount > 1.0f)
|
||||
{
|
||||
m_GrowthCount--;
|
||||
|
@ -1110,7 +1110,7 @@ int CXMLReader::ReadNonEntities(XMBElement parent, double end_time)
|
||||
if (unit)
|
||||
{
|
||||
CMatrix3D m;
|
||||
m.SetYRotation(Orientation + M_PI);
|
||||
m.SetYRotation(Orientation + (float)M_PI);
|
||||
m.Translate(Position);
|
||||
unit->GetModel()->SetTransform(m);
|
||||
|
||||
|
@ -265,7 +265,7 @@ void CMapWriter::WriteXML(const VfsPath& filename,
|
||||
CVector3D in = pCamera->m_Orientation.GetIn();
|
||||
// Convert to spherical coordinates
|
||||
float rotation = atan2(in.X, in.Z);
|
||||
float declination = atan2(sqrt(in.X*in.X + in.Z*in.Z), in.Y) - M_PI/2;
|
||||
float declination = atan2(sqrt(in.X*in.X + in.Z*in.Z), in.Y) - (float)M_PI/2;
|
||||
|
||||
{
|
||||
XML_Element("Rotation");
|
||||
|
@ -1017,5 +1017,5 @@ bool ogl_tex_has_s3tc()
|
||||
// ogl_tex_upload must be called before this
|
||||
debug_assert(have_s3tc != -1);
|
||||
|
||||
return have_s3tc;
|
||||
return (have_s3tc != 0);
|
||||
}
|
||||
|
@ -18,8 +18,8 @@
|
||||
#ifndef INCLUDED_MATHUTIL
|
||||
#define INCLUDED_MATHUTIL
|
||||
|
||||
#define DEGTORAD(a) ((a) * (M_PI/180.0f))
|
||||
#define RADTODEG(a) ((a) * (180.0f/M_PI))
|
||||
#define DEGTORAD(a) ((a) * ((float)M_PI/180.0f))
|
||||
#define RADTODEG(a) ((a) * (180.0f/(float)M_PI))
|
||||
#define SQR(x) ((x) * (x))
|
||||
|
||||
template <typename T>
|
||||
|
@ -54,7 +54,7 @@ Noise2D::Noise2D(int f)
|
||||
grads[i] = new CVector2D_Maths[freq];
|
||||
for(int j=0; j<freq; j++)
|
||||
{
|
||||
float a = randFloat() * 2 * M_PI;
|
||||
float a = randFloat() * 2 * (float)M_PI;
|
||||
grads[i][j] = CVector2D_Maths(cos(a), sin(a));
|
||||
}
|
||||
}
|
||||
|
@ -132,13 +132,13 @@ CVector3D CQuaternion::ToEulerAngles()
|
||||
if (test > (.5f-EPSILON)*unit)
|
||||
{ // singularity at north pole
|
||||
heading = 2 * atan2( m_V.X, m_W);
|
||||
attitude = M_PI/2;
|
||||
attitude = (float)M_PI/2;
|
||||
bank = 0;
|
||||
}
|
||||
else if (test < (-.5f+EPSILON)*unit)
|
||||
{ // singularity at south pole
|
||||
heading = -2 * atan2(m_V.X, m_W);
|
||||
attitude = -M_PI/2;
|
||||
attitude = -(float)M_PI/2;
|
||||
bank = 0;
|
||||
}
|
||||
else
|
||||
|
@ -1371,7 +1371,7 @@ void ResetInteraction()
|
||||
customSelectionMode = false;
|
||||
}
|
||||
|
||||
static const float angleBias = 3*M_PI/4; // Atlas does the same
|
||||
static const float angleBias = 3*(float)M_PI/4; // Atlas does the same
|
||||
|
||||
bool CBuildingPlacer::Activate(CStrW& templateName)
|
||||
{
|
||||
@ -1480,7 +1480,7 @@ void CBuildingPlacer::Update( float timeStep )
|
||||
if(x*x + z*z < 3*3)
|
||||
{
|
||||
if(m_dragged || m_timeSinceClick > 0.2f)
|
||||
m_angle += timeStep * M_PI;
|
||||
m_angle += timeStep * (float)M_PI;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1517,7 +1517,7 @@ void CBuildingPlacer::Update( float timeStep )
|
||||
|
||||
// Set position and angle to the location we decided on
|
||||
CMatrix3D m;
|
||||
m.SetYRotation(m_angle + M_PI);
|
||||
m.SetYRotation(m_angle + (float)M_PI);
|
||||
m.Translate(pos);
|
||||
m_actor->GetModel()->SetTransform( m );
|
||||
m_bounds->SetPosition(pos.X, pos.Z);
|
||||
@ -1540,7 +1540,7 @@ void CBuildingPlacer::Update( float timeStep )
|
||||
}
|
||||
else
|
||||
{
|
||||
float add = ( sin(4*M_PI*m_totalTime) + 1.0f ) * 0.08f;
|
||||
float add = ( sin(4*(float)M_PI*m_totalTime) + 1.0f ) * 0.08f;
|
||||
col = CColor( 1.4f+add, 0.4f+add, 0.4f+add, 1.0f );
|
||||
}
|
||||
m_actor->GetModel()->SetShadingColor( col );
|
||||
|
@ -96,7 +96,7 @@ void CBoundingCircle::Render( float height )
|
||||
|
||||
for( int i = 0; i < 10; i++ )
|
||||
{
|
||||
float ang = i * 2 * M_PI / 10.0f;
|
||||
float ang = i * 2 * (float)M_PI / 10.0f;
|
||||
float x = m_pos.x + m_radius * sin( ang );
|
||||
float y = m_pos.y + m_radius * cos( ang );
|
||||
glVertex3f( x, height, y );
|
||||
|
@ -53,7 +53,7 @@
|
||||
|
||||
#include "ps/GameSetup/Config.h"
|
||||
|
||||
const float MAX_ROTATION_RATE = 2*M_PI; // radians per second
|
||||
const float MAX_ROTATION_RATE = 2*(float)M_PI; // radians per second
|
||||
|
||||
CEntity::CEntity( CEntityTemplate* base, CVector3D position, float orientation, const std::set<CStr8>& actorSelections, const CStrW* building )
|
||||
{
|
||||
@ -235,7 +235,7 @@ void CEntity::initAuraData()
|
||||
|
||||
for ( int j=0; j<AURA_CIRCLE_POINTS; ++j )
|
||||
{
|
||||
float val = j * 2*M_PI / (float)AURA_CIRCLE_POINTS;
|
||||
float val = j * 2*(float)M_PI / AURA_CIRCLE_POINTS;
|
||||
m_unsnappedPoints[i][j] = CVector2D( cosf(val)*radius,
|
||||
sinf(val)*radius );
|
||||
}
|
||||
@ -461,9 +461,9 @@ void CEntity::Update( int timestep )
|
||||
|
||||
float delta = m_orientation.Y - m_orientation_smoothed.Y;
|
||||
// Wrap delta to -M_PI..M_PI
|
||||
delta = fmod(delta + M_PI, 2*M_PI); // range -2PI..2PI
|
||||
if (delta < 0) delta += 2*M_PI; // range 0..2PI
|
||||
delta -= M_PI; // range -M_PI..M_PI
|
||||
delta = fmod(delta + (float)M_PI, 2*(float)M_PI); // range -2PI..2PI
|
||||
if (delta < 0) delta += 2*(float)M_PI; // range 0..2PI
|
||||
delta -= (float)M_PI; // range -M_PI..M_PI
|
||||
// Clamp to max rate
|
||||
float deltaClamped = clamp(delta, -MAX_ROTATION_RATE*timestep/1000.f, +MAX_ROTATION_RATE*timestep/1000.f);
|
||||
// Calculate new orientation, in a peculiar way in order to make sure the
|
||||
@ -1039,24 +1039,24 @@ void CEntity::Interpolate( float relativeoffset )
|
||||
|
||||
// Avoid wraparound glitches for interpolating angles.
|
||||
|
||||
m_orientation.X = fmodf(m_orientation.X, 2*M_PI); // (ensure the following loops can't take forever)
|
||||
m_orientation.Y = fmodf(m_orientation.Y, 2*M_PI);
|
||||
m_orientation.Z = fmodf(m_orientation.Z, 2*M_PI);
|
||||
m_orientation.X = fmodf(m_orientation.X, 2*(float)M_PI); // (ensure the following loops can't take forever)
|
||||
m_orientation.Y = fmodf(m_orientation.Y, 2*(float)M_PI);
|
||||
m_orientation.Z = fmodf(m_orientation.Z, 2*(float)M_PI);
|
||||
|
||||
while( m_orientation.Y < m_orientation_previous.Y - M_PI )
|
||||
m_orientation_previous.Y -= 2 * M_PI;
|
||||
while( m_orientation.Y > m_orientation_previous.Y + M_PI )
|
||||
m_orientation_previous.Y += 2 * M_PI;
|
||||
while( m_orientation.Y < m_orientation_previous.Y - (float)M_PI )
|
||||
m_orientation_previous.Y -= 2 * (float)M_PI;
|
||||
while( m_orientation.Y > m_orientation_previous.Y + (float)M_PI )
|
||||
m_orientation_previous.Y += 2 * (float)M_PI;
|
||||
|
||||
while( m_orientation.X < m_orientation_previous.X - M_PI )
|
||||
m_orientation_previous.X -= 2 * M_PI;
|
||||
while( m_orientation.X > m_orientation_previous.X + M_PI )
|
||||
m_orientation_previous.X += 2 * M_PI;
|
||||
while( m_orientation.X < m_orientation_previous.X - (float)M_PI )
|
||||
m_orientation_previous.X -= 2 * (float)M_PI;
|
||||
while( m_orientation.X > m_orientation_previous.X + (float)M_PI )
|
||||
m_orientation_previous.X += 2 * (float)M_PI;
|
||||
|
||||
while( m_orientation.Z < m_orientation_previous.Z - M_PI )
|
||||
m_orientation_previous.Z -= 2 * M_PI;
|
||||
while( m_orientation.Z > m_orientation_previous.Z + M_PI )
|
||||
m_orientation_previous.Z += 2 * M_PI;
|
||||
while( m_orientation.Z < m_orientation_previous.Z - (float)M_PI )
|
||||
m_orientation_previous.Z -= 2 * (float)M_PI;
|
||||
while( m_orientation.Z > m_orientation_previous.Z + (float)M_PI )
|
||||
m_orientation_previous.Z += 2 * (float)M_PI;
|
||||
|
||||
UpdateXZOrientation();
|
||||
|
||||
|
@ -162,7 +162,7 @@ void CEntity::RenderSelectionOutline( float alpha )
|
||||
float radius = ((CBoundingCircle*)m_bounds)->m_radius;
|
||||
for( int i = 0; i < SELECTION_CIRCLE_POINTS; i++ )
|
||||
{
|
||||
float ang = i * 2 * M_PI / (float)SELECTION_CIRCLE_POINTS;
|
||||
float ang = i * 2 * (float)M_PI / SELECTION_CIRCLE_POINTS;
|
||||
float x = pos.X + radius * sin( ang );
|
||||
float y = pos.Z + radius * cos( ang );
|
||||
#ifdef SELECTION_TERRAIN_CONFORMANCE
|
||||
|
@ -154,7 +154,7 @@ JSBool CEntity::Construct( JSContext* cx, JSObject* UNUSED(obj), uintN argc, jsv
|
||||
debug_assert( argc >= 2 );
|
||||
|
||||
CVector3D position;
|
||||
float orientation = g_Game->GetSimulation()->RandFloat() * 2 * M_PI;
|
||||
float orientation = g_Game->GetSimulation()->RandFloat() * 2 * (float)M_PI;
|
||||
|
||||
JSObject* jsEntityTemplate = JSVAL_TO_OBJECT( argv[0] );
|
||||
CStrW templateName;
|
||||
@ -502,10 +502,10 @@ jsval_t CEntity::GetSpawnPoint( JSContext* UNUSED(cx), uintN argc, jsval* argv )
|
||||
else if( m_bounds->m_type == CBoundingObject::BOUND_CIRCLE )
|
||||
{
|
||||
float ang;
|
||||
ang = g_Game->GetSimulation()->RandFloat() * 2 * M_PI;
|
||||
ang = g_Game->GetSimulation()->RandFloat() * 2 * (float)M_PI;
|
||||
float radius = m_bounds->m_radius + 1.0f + spawn_clearance;
|
||||
float d_ang = spawn_clearance / ( 2.0f * radius );
|
||||
float ang_end = ang + 2.0f * M_PI;
|
||||
float ang_end = ang + 2.0f * (float)M_PI;
|
||||
float x = 0.0f, y = 0.0f; // make sure they're initialized
|
||||
for( ; ang < ang_end; ang += d_ang )
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ float CEntity::ChooseMovementSpeed( float distance )
|
||||
|
||||
// Modify the speed based on the slope of the terrain in our direction (obtained from our x orientation)
|
||||
float angle = m_orientation_unclamped.x;
|
||||
int sector = rintf( angle / (M_PI/2) * m_base->m_pitchDivs );
|
||||
int sector = rintf( angle / ((float)M_PI/2) * m_base->m_pitchDivs );
|
||||
speed -= sector * m_base->m_pitchValue;
|
||||
|
||||
entf_set_to(ENTF_IS_RUNNING, should_run);
|
||||
@ -130,8 +130,8 @@ int CEntity::ProcessGotoHelper( CEntityOrder* current, int timestep_millis, HEnt
|
||||
|
||||
m_targetorientation = atan2( delta.x, delta.y );
|
||||
float deltatheta = m_targetorientation - (float)m_orientation.Y;
|
||||
while( deltatheta > M_PI ) deltatheta -= 2 * M_PI;
|
||||
while( deltatheta < -M_PI ) deltatheta += 2 * M_PI;
|
||||
while( deltatheta > (float)M_PI ) deltatheta -= 2 * (float)M_PI;
|
||||
while( deltatheta < -(float)M_PI ) deltatheta += 2 * (float)M_PI;
|
||||
|
||||
if( fabs( deltatheta ) > 0.01f )
|
||||
{
|
||||
@ -336,7 +336,7 @@ bool CEntity::ProcessGotoNoPathing( CEntityOrder* current, int timestep_millis )
|
||||
{
|
||||
delta = interval / r;
|
||||
theta += delta;
|
||||
r += ( interval * delta ) / ( 2 * M_PI );
|
||||
r += ( interval * delta ) / ( 2 * (float)M_PI );
|
||||
destinationObs.SetPosition( _x + r * cosf( theta ), _y + r * sinf( theta ) );
|
||||
if( !GetCollisionObject( &destinationObs ) ) break;
|
||||
}
|
||||
|
@ -334,9 +334,9 @@ public:
|
||||
float rotY = m_RotY.ToFloat();
|
||||
float delta = rotY - m_InterpolatedRotY;
|
||||
// Wrap delta to -M_PI..M_PI
|
||||
delta = fmod(delta + M_PI, 2*M_PI); // range -2PI..2PI
|
||||
if (delta < 0) delta += 2*M_PI; // range 0..2PI
|
||||
delta -= M_PI; // range -M_PI..M_PI
|
||||
delta = fmod(delta + (float)M_PI, 2*(float)M_PI); // range -2PI..2PI
|
||||
if (delta < 0) delta += 2*(float)M_PI; // range 0..2PI
|
||||
delta -= (float)M_PI; // range -M_PI..M_PI
|
||||
// Clamp to max rate
|
||||
float deltaClamped = clamp(delta, -m_RotYSpeed*msgData.frameTime, +m_RotYSpeed*msgData.frameTime);
|
||||
// Calculate new orientation, in a peculiar way in order to make sure the
|
||||
|
@ -38,7 +38,7 @@ void SimRender::ConstructCircleOnGround(const CSimContext& context, float x, flo
|
||||
|
||||
for (size_t i = 0; i <= RENDER_CIRCLE_POINTS; ++i) // use '<=' so it's a closed loop
|
||||
{
|
||||
float a = i * 2 * M_PI / RENDER_CIRCLE_POINTS;
|
||||
float a = i * 2 * (float)M_PI / RENDER_CIRCLE_POINTS;
|
||||
float px = x + radius * sin(a);
|
||||
float pz = z + radius * cos(a);
|
||||
float py = cmpTerrain->GetGroundLevel(px, pz) + RENDER_HEIGHT_DELTA;
|
||||
|
@ -184,9 +184,9 @@ void ActorViewer::SetActor(const CStrW& name, const CStrW& animation)
|
||||
if (! m.Unit)
|
||||
return;
|
||||
|
||||
float angle = M_PI;
|
||||
float angle = (float)M_PI;
|
||||
CMatrix3D mat;
|
||||
mat.SetYRotation(angle + M_PI);
|
||||
mat.SetYRotation(angle + (float)M_PI);
|
||||
mat.Translate(CELL_SIZE * PATCH_SIZE/2, 0.f, CELL_SIZE * PATCH_SIZE/2);
|
||||
m.Unit->GetModel()->SetTransform(mat);
|
||||
m.Unit->GetModel()->ValidatePosition();
|
||||
|
@ -50,8 +50,8 @@ sEnvironmentSettings GetSettings()
|
||||
#undef COLOUR
|
||||
|
||||
float sunrotation = g_LightEnv.GetRotation();
|
||||
if (sunrotation > M_PI)
|
||||
sunrotation -= M_PI*2;
|
||||
if (sunrotation > (float)M_PI)
|
||||
sunrotation -= (float)M_PI*2;
|
||||
s.sunrotation = sunrotation;
|
||||
s.sunelevation = g_LightEnv.GetElevation();
|
||||
|
||||
|
@ -85,7 +85,7 @@ CUnit* SimState::Nonentity::Thaw()
|
||||
if (! unit)
|
||||
return NULL;
|
||||
CMatrix3D m;
|
||||
m.SetYRotation(angle + M_PI);
|
||||
m.SetYRotation(angle + (float)M_PI);
|
||||
m.Translate(position);
|
||||
unit->GetModel()->SetTransform(m);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user