Plasma Engine  2.0
Loading...
Searching...
No Matches
Interval_inl.h
1
2template <class Type>
3constexpr plInterval<Type>::plInterval(Type startAndEndValue)
4 : m_StartValue(startAndEndValue)
5 , m_EndValue(startAndEndValue)
6{
7}
8
9template <class Type>
10constexpr plInterval<Type>::plInterval(Type start, Type end)
11 : m_StartValue(start)
12 , m_EndValue(plMath::Max(start, end))
13{
14}
15
16template <class Type>
18{
19 m_StartValue = value;
20 m_EndValue = plMath::Max(m_EndValue, m_StartValue);
21}
22
23template <class Type>
25{
26 m_EndValue = value;
27 m_StartValue = plMath::Min(m_StartValue, m_EndValue);
28}
29
30template <class Type>
31void plInterval<Type>::ClampToIntervalAdjustEnd(Type minValue, Type maxValue, Type minimumSeparation /*= Type()*/)
32{
33 // clamp the start value to the valid range, leave minimumSeparation at the end
34 m_StartValue = plMath::Clamp(m_StartValue, minValue, maxValue - minimumSeparation);
35
36 // clamp the start value to the remaining range
37 m_EndValue = plMath::Clamp(m_EndValue, m_StartValue, maxValue);
38}
39
40template <class Type>
41void plInterval<Type>::ClampToIntervalAdjustStart(Type minValue, Type maxValue, Type minimumSeparation /*= Type()*/)
42{
43 // clamp the end value to the valid range, leave minimumSeparation at the start
44 m_EndValue = plMath::Clamp(m_EndValue, minValue + minimumSeparation, maxValue);
45
46 // clamp the start value to the remaining range
47 m_StartValue = plMath::Clamp(m_StartValue, minValue, m_EndValue);
48}
49
50template <class Type>
52{
53 return m_EndValue - m_StartValue;
54}
55
56template <class Type>
58{
59 return m_StartValue == rhs.m_StartValue && m_EndValue == rhs.m_EndValue;
60}
61
62template <class Type>
64{
65 return !operator==(rhs);
66}
Represents an interval with a start and an end value.
Definition Interval.h:8
constexpr plInterval()=default
The default constructor initializes the two values to zero.
void ClampToIntervalAdjustEnd(Type minValue, Type maxValue, Type minimumSeparation=Type())
Adjusts the start and end value to be within the given range. Prefers to adjust the end value,...
Definition Interval_inl.h:31
void SetStartAdjustEnd(Type value)
Sets the start value. If necessary, the end value will adjusted to not be lower than the start value.
Definition Interval_inl.h:17
void ClampToIntervalAdjustStart(Type minValue, Type maxValue, Type minimumSeparation=Type())
Adjusts the start and end value to be within the given range. Prefers to adjust the start value,...
Definition Interval_inl.h:41
void SetEndAdjustStart(Type value)
Sets the end value. If necessary, the start value will adjusted to not be higher than the end value.
Definition Interval_inl.h:24
Type GetSeparation() const
Returns how much the start and and value are separated from each other.
Definition Interval_inl.h:51
This namespace provides common math-functionality as functions.
Definition Constants.h:6
constexpr PL_ALWAYS_INLINE T Min(T f1, T f2)
Returns the smaller value, f1 or f2.
Definition Math_inl.h:27
constexpr PL_ALWAYS_INLINE T Clamp(T value, T min_val, T max_val)
Clamps "value" to the range [min; max]. Returns "value", if it is inside the range already.
Definition Math_inl.h:51
constexpr PL_ALWAYS_INLINE T Max(T f1, T f2)
Returns the greater value, f1 or f2.
Definition Math_inl.h:39