1
0
forked from mirrors/0ad

Removes duplication of Clamp function.

Reviewed By: wraitii
Commented By: Stan
Differential Revision: https://code.wildfiregames.com/D1763
This was SVN commit r23002.
This commit is contained in:
vladislavbelov
2019-09-26 21:14:21 +00:00
parent 5d88955e14
commit 7790fd7d29
4 changed files with 20 additions and 24 deletions
+1
View File
@@ -20,6 +20,7 @@
#include "CSlider.h"
#include "gui/CGUI.h"
#include "maths/MathUtil.h"
CSlider::CSlider(CGUI& pGUI)
: IGUIObject(pGUI), m_IsPressed(false), m_ButtonSide(0)
+1 -9
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games.
/* Copyright (C) 2019 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -63,14 +63,6 @@ scope
#include <cmath> // fabsf
#include <limits> // numeric_limits
#include <stdexcept> // out_of_range
#include <algorithm> // min, max
template<typename T>
T Clamp(T val, T min, T max)
{
ASSERT(min <= max);
return std::max(min, std::min(val, max));
}
template<typename T>
T DivideRoundUp(T dividend, T divisor)
+14 -10
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2010 Wildfire Games.
/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -23,24 +23,28 @@
#define SQR(x) ((x) * (x))
template <typename T>
inline T Interpolate(const T& a, const T& b, float l)
inline T Interpolate(const T& a, const T& b, float t)
{
return a + (b - a) * l;
return a + (b - a) * t;
}
template <typename T>
inline T clamp(T value, T min, T max)
inline T Clamp(T value, T min, T max)
{
if (value <= min) return min;
else if (value >= max) return max;
else return value;
if (value <= min)
return min;
else if (value >= max)
return max;
return value;
}
inline float sgn(float a)
{
if (a > 0.0f) return 1.0f;
if (a < 0.0f) return -1.0f;
if (a > 0.0f)
return 1.0f;
if (a < 0.0f)
return -1.0f;
return 0.0f;
}
#endif
#endif // INCLUDED_MATHUTIL
+4 -5
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2012 Wildfire Games.
/* Copyright (C) 2019 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -20,14 +20,13 @@
#if CONFIG2_AUDIO
#include "lib/byte_order.h"
#include "lib/external_libraries/openal.h"
#include "lib/external_libraries/vorbis.h"
#include "lib/byte_order.h"
#include "lib/file/io/io.h"
#include "lib/file/file_system.h"
#include "lib/file/io/io.h"
#include "lib/file/vfs/vfs_util.h"
#include "maths/MathUtil.h"
#include "ps/CLogger.h"
#include "ps/Filesystem.h"