mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-17 23:39:18 +02:00
Replace clamp with std::clamp
This commit is contained in:
@@ -55,7 +55,7 @@ static void ParseOneClamped(cParser& parser, T& out, T minValue, T maxValue, int
|
||||
{
|
||||
parser.getTokens(tokenCount, convert);
|
||||
parser >> out;
|
||||
out = clamp(out, minValue, maxValue);
|
||||
out = std::clamp(out, minValue, maxValue);
|
||||
}
|
||||
|
||||
void global_settings::FinalizeConfig()
|
||||
@@ -301,7 +301,7 @@ bool global_settings::ConfigParseGraphics(cParser& Parser, const std::string& to
|
||||
if (token == "dynamiclights")
|
||||
{
|
||||
ParseOne(Parser, DynamicLightCount, 1, false);
|
||||
DynamicLightCount = clamp(DynamicLightCount, 0, 7);
|
||||
DynamicLightCount = std::clamp(DynamicLightCount, 0, 7);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ bool global_settings::ConfigParseGraphics(cParser& Parser, const std::string& to
|
||||
if (token == "multisampling")
|
||||
{
|
||||
ParseOne(Parser, iMultisampling, 1, false);
|
||||
iMultisampling = clamp(iMultisampling, 0, 4);
|
||||
iMultisampling = std::clamp(iMultisampling, 0, 4);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -546,7 +546,7 @@ bool global_settings::ConfigParseSimulation(cParser& Parser, const std::string&
|
||||
stream >> ScenarioTimeOverride;
|
||||
}
|
||||
|
||||
ScenarioTimeOverride = clamp(ScenarioTimeOverride, 0.f, 24 * 1439 / 1440.f);
|
||||
ScenarioTimeOverride = std::clamp(ScenarioTimeOverride, 0.f, 24 * 1439 / 1440.f);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -578,7 +578,7 @@ bool global_settings::ConfigParseSimulation(cParser& Parser, const std::string&
|
||||
{
|
||||
float splinefidelity = 0.f;
|
||||
ParseOne(Parser, splinefidelity);
|
||||
SplineFidelity = clamp(splinefidelity, 1.f, 4.f);
|
||||
SplineFidelity = std::clamp(splinefidelity, 1.f, 4.f);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1317,7 +1317,7 @@ global_settings::ConfigParse_gfx( cParser &Parser, std::string_view const Token
|
||||
float smokefidelity;
|
||||
Parser.getTokens();
|
||||
Parser >> smokefidelity;
|
||||
SmokeFidelity = clamp(smokefidelity, 1.f, 4.f);
|
||||
SmokeFidelity = std::clamp(smokefidelity, 1.f, 4.f);
|
||||
}
|
||||
else if (Token == "gfx.resource.sweep")
|
||||
{
|
||||
@@ -1338,7 +1338,7 @@ global_settings::ConfigParse_gfx( cParser &Parser, std::string_view const Token
|
||||
{
|
||||
Parser.getTokens(1, false);
|
||||
Parser >> reflectiontune.fidelity;
|
||||
reflectiontune.fidelity = clamp(reflectiontune.fidelity, 0, 2);
|
||||
reflectiontune.fidelity = std::clamp(reflectiontune.fidelity, 0, 2);
|
||||
}
|
||||
else if (Token == "gfx.reflections.range_instances")
|
||||
{
|
||||
@@ -1462,13 +1462,13 @@ global_settings::ConfigParse_gfx( cParser &Parser, std::string_view const Token
|
||||
if( gfx_shadow_angle_min > 0 ) {
|
||||
gfx_shadow_angle_min *= -1;
|
||||
}
|
||||
gfx_shadow_angle_min = clamp(gfx_shadow_angle_min, -1.f, -0.2f);
|
||||
gfx_shadow_angle_min = std::clamp(gfx_shadow_angle_min, -1.f, -0.2f);
|
||||
}
|
||||
else if (Token == "gfx.shadow.rank.cutoff")
|
||||
{
|
||||
Parser.getTokens(1);
|
||||
Parser >> gfx_shadow_rank_cutoff;
|
||||
gfx_shadow_rank_cutoff = clamp(gfx_shadow_rank_cutoff, 1, 3);
|
||||
gfx_shadow_rank_cutoff = std::clamp(gfx_shadow_rank_cutoff, 1, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -52,7 +52,7 @@ struct global_settings {
|
||||
basic_light DayLight;
|
||||
float SunAngle{ 0.f }; // angle of the sun relative to horizon
|
||||
int trainThreads{0};
|
||||
double fLuminance{ 1.0 }; // jasność światła do automatycznego zapalania
|
||||
double fLuminance{ 1.0 }; // jasność światła do automatycznego zapalania // TODO: Why double?
|
||||
double fTimeAngleDeg{ 0.0 }; // godzina w postaci kąta
|
||||
float fClockAngleDeg[ 6 ]; // kąty obrotu cylindrów dla zegara cyfrowego
|
||||
std::string LastGLError;
|
||||
|
||||
@@ -251,21 +251,6 @@ template <typename T> bool is_equal(T const &Left, T const &Right, T const Epsil
|
||||
return (Left == Right);
|
||||
}
|
||||
|
||||
template <typename Type_> Type_ clamp(Type_ const Value, Type_ const Min, Type_ const Max)
|
||||
{
|
||||
|
||||
Type_ value = Value;
|
||||
if (value < Min)
|
||||
{
|
||||
value = Min;
|
||||
}
|
||||
if (value > Max)
|
||||
{
|
||||
value = Max;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// keeps the provided value in specified range 0-Range, as if the range was circular buffer
|
||||
template <typename Type_> Type_ clamp_circular(Type_ Value, Type_ const Range = static_cast<Type_>(360))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user