Clean up math functions

- Remove checking for standard functions from the build system
- Prefix all invocations with std::
- Replace suffixed functions with unprefixed versions
- Include <cmath> in all files that use it and remove the global include

e.g. floorf(x) -> std::floor(x)
This commit is contained in:
Martin Natano
2023-04-19 14:22:59 +02:00
parent f39ed52dbf
commit b68ca517e6
111 changed files with 1831 additions and 1785 deletions
+21 -19
View File
@@ -10,6 +10,8 @@
#include "ActorUtil.h"
#include "LuaBinding.h"
#include <cmath>
REGISTER_ACTOR_CLASS( BitmapText );
@@ -19,7 +21,7 @@ REGISTER_ACTOR_CLASS( BitmapText );
*
* Better, we could go all the way, drop all of the actor-specific font aliases,
* and do "font=header2;valign=top;...". */
/* XXX: Changing a whole array of diffuse colors every frame (several times) is
* a waste, when we're usually setting them all to the same value. Rainbow and
* fading are annoying to optimize, but rarely used. Iterating over every
@@ -277,7 +279,7 @@ void BitmapText::BuildChars()
m_size.y += iPadding * int(m_wTextLines.size()-1);
// the top position of the first row of characters
int iY = lrintf(-m_size.y/2.0f);
int iY = std::lrint(-m_size.y/2.0f);
for( unsigned i=0; i<m_wTextLines.size(); i++ ) // foreach line
{
@@ -289,7 +291,7 @@ void BitmapText::BuildChars()
const int iLineWidth = m_iLineWidths[i];
float fX = SCALE( m_fHorizAlign, 0.0f, 1.0f, -m_size.x/2.0f, +m_size.x/2.0f - iLineWidth );
int iX = lrintf( fX );
int iX = std::lrint( fX );
for( unsigned j = 0; j < sLine.size(); ++j )
{
@@ -326,7 +328,7 @@ void BitmapText::BuildChars()
if( m_bUsingDistortion )
{
int iSeed = lrintf( RageTimer::GetTimeSinceStartFast()*500000.0f );
int iSeed = std::lrint( RageTimer::GetTimeSinceStartFast()*500000.0f );
RandomGen rnd( iSeed );
for(unsigned int i= 0; i < m_aVertices.size(); i+=4)
{
@@ -344,13 +346,13 @@ void BitmapText::BuildChars()
void BitmapText::DrawChars( bool bUseStrokeTexture )
{
// bail if cropped all the way
if( m_pTempState->crop.left + m_pTempState->crop.right >= 1 ||
m_pTempState->crop.top + m_pTempState->crop.bottom >= 1 )
return;
if( m_pTempState->crop.left + m_pTempState->crop.right >= 1 ||
m_pTempState->crop.top + m_pTempState->crop.bottom >= 1 )
return;
const int iNumGlyphs = m_vpFontPageTextures.size();
int iStartGlyph = lrintf( SCALE( m_pTempState->crop.left, 0.f, 1.f, 0, (float) iNumGlyphs ) );
int iEndGlyph = lrintf( SCALE( m_pTempState->crop.right, 0.f, 1.f, (float) iNumGlyphs, 0 ) );
int iStartGlyph = std::lrint( SCALE( m_pTempState->crop.left, 0.f, 1.f, 0, (float) iNumGlyphs ) );
int iEndGlyph = std::lrint( SCALE( m_pTempState->crop.right, 0.f, 1.f, (float) iNumGlyphs, 0 ) );
iStartGlyph = clamp( iStartGlyph, 0, iNumGlyphs );
iEndGlyph = clamp( iEndGlyph, 0, iNumGlyphs );
@@ -414,7 +416,7 @@ void BitmapText::DrawChars( bool bUseStrokeTexture )
m_aVertices[i+j].c.a = (unsigned char)( m_aVertices[i+j].c.a * fAlpha );
}
}
bool bDistanceField = m_pFont->IsDistanceField();
if( bDistanceField )
DISPLAY->SetEffectMode( EffectMode_DistanceField );
@@ -435,10 +437,10 @@ void BitmapText::DrawChars( bool bUseStrokeTexture )
DISPLAY->SetTexture( TextureUnit_1, m_vpFontPageTextures[start]->m_pTextureMain->GetTexHandle() );
// Don't bother setting texture render states for text. We never go outside of 0..1.
/* We should call SetTextureRenderStates because it does more than just setting
* the texture wrapping state. If setting the wrapping state is found to be slow,
/* We should call SetTextureRenderStates because it does more than just setting
* the texture wrapping state. If setting the wrapping state is found to be slow,
* there should probably be a "don't care" texture wrapping mode set in Actor. -Chris */
// This is SLOW. We need to do something else about this. -Colby
//Actor::SetTextureRenderStates();
@@ -612,7 +614,7 @@ void BitmapText::UpdateBaseZoom()
} \
if(dimension != 0) \
{ \
const float zoom= fmin(1, dimension_max / dimension); \
const float zoom= std::fmin(1, dimension_max / dimension); \
base_zoom_set(zoom); \
} \
}
@@ -766,7 +768,7 @@ void BitmapText::DrawPrimitives()
std::vector<RageVector3> vGlyphJitter;
if( m_bJitter )
{
int iSeed = lrintf( RageTimer::GetTimeSinceStartFast()*8 );
int iSeed = std::lrint( RageTimer::GetTimeSinceStartFast()*8 );
RandomGen rnd( iSeed );
for( unsigned i=0; i<m_aVertices.size(); i+=4 )
@@ -877,7 +879,7 @@ void BitmapText::AddAttribute( size_t iPos, const Attribute &attr )
// Fixup position for new lines.
int iLines = 0;
size_t iAdjustedPos = iPos;
for (std::wstring const & line : m_wTextLines)
{
size_t length = line.length();
@@ -940,7 +942,7 @@ void BitmapText::Attribute::FromStack( lua_State *L, int iPos )
// lua start
#include "FontCharAliases.h"
/** @brief Allow Lua to have access to the BitmapText. */
/** @brief Allow Lua to have access to the BitmapText. */
class LunaBitmapText: public Luna<BitmapText>
{
public:
@@ -1032,7 +1034,7 @@ LUA_REGISTER_DERIVED_CLASS( BitmapText, Actor )
/*
* (c) 2003-2007 Chris Danford, Charles Lohr, Steve Checkoway
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -1042,7 +1044,7 @@ LUA_REGISTER_DERIVED_CLASS( BitmapText, Actor )
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF