Add celmath::clamp(val, low, high)
parent
74144a85bc
commit
93c4a3b55c
|
@ -7877,10 +7877,9 @@ void Renderer::updateBodyVisibilityMask()
|
|||
bodyVisibilityMask = flags;
|
||||
}
|
||||
|
||||
void Renderer::setSolarSystemMaxDistance(float t)
|
||||
void Renderer::setSolarSystemMaxDistance(float t)
|
||||
{
|
||||
if (t >= 1.0f && t <= 10.0f)
|
||||
SolarSystemMaxDistance = t;
|
||||
SolarSystemMaxDistance = clamp(t, 1.0f, 10.0f);
|
||||
}
|
||||
|
||||
void Renderer::getScreenSize(int* x, int* y, int* w, int* h) const
|
||||
|
|
|
@ -47,6 +47,12 @@ template<typename T> constexpr T clamp(T t)
|
|||
return (t < 0) ? 0 : ((t > 1) ? 1 : t);
|
||||
}
|
||||
|
||||
// return t clamped to [low, high]
|
||||
template<typename T> constexpr T clamp(T t, T low, T high)
|
||||
{
|
||||
return (t < low) ? low : ((t > high) ? high : t);
|
||||
}
|
||||
|
||||
template<typename T> inline constexpr T degToRad(T d)
|
||||
{
|
||||
return d / 180 * static_cast<T>(PI);
|
||||
|
|
Loading…
Reference in New Issue