Radium Engine  1.5.20
Loading...
Searching...
No Matches
AnimationTime.hpp
1#pragma once
2
3#include <Core/RaCore.hpp>
4#include <algorithm>
5#include <limits>
6
7namespace Ra {
8namespace Core {
9namespace Asset {
10
14class RA_CORE_API AnimationTime
15{
16 public:
20 using Time = Scalar;
21
23 const Time& end = -std::numeric_limits<Time>::max() ) :
24 m_start( start ), m_end( end ) {}
25
26 AnimationTime( const AnimationTime& time ) = default;
27
29
32
36 inline Time getStart() const { return m_start; }
37
41 inline void setStart( const Time& start ) { m_start = std::min( start, m_end ); }
42
46 inline Time getEnd() const { return m_end; }
47
51 inline void setEnd( const Time& end ) { m_end = std::max( end, m_start ); }
52
56 inline void extends( const Time& t ) {
57 setStart( t );
58 setEnd( t );
59 }
60
65 inline void extends( const AnimationTime& time ) {
66 m_start = std::min( m_start, time.m_start );
67 m_end = std::max( m_end, time.m_end );
68 }
70
73
77 inline bool isValid() const { return m_start < m_end; }
78
83 inline Time duration() const { return isValid() ? m_end - m_start : 0; }
84
88 inline bool contains( const Time& t ) const { return ( ( t >= m_start ) && ( t <= m_end ) ); }
89
93 inline bool intersect( const AnimationTime& time ) const {
94 return ( contains( time.m_start ) || contains( time.m_end ) || time.contains( m_start ) ||
95 time.contains( m_end ) );
96 }
98
101
105 inline bool operator==( const AnimationTime& time ) const {
106 return ( ( m_start == time.m_start ) && ( m_end == time.m_end ) );
107 }
108
112 inline bool operator!=( const AnimationTime& time ) const { return !( *this == time ); }
113
117 inline bool operator==( const Time& t ) const { return ( t == m_start ) && ( t == m_end ); }
118
122 inline bool operator<( const Time& t ) const { return ( t < m_end ); }
123
127 inline bool operator>( const Time& t ) const { return ( t > m_start ); }
128
129 protected:
132
135};
136
137} // namespace Asset
138} // namespace Core
139} // namespace Ra
Time m_start
Animation starting time.
void setStart(const Time &start)
void extends(const AnimationTime &time)
bool operator<(const Time &t) const
void setEnd(const Time &end)
bool operator==(const Time &t) const
bool intersect(const AnimationTime &time) const
bool operator==(const AnimationTime &time) const
bool operator!=(const AnimationTime &time) const
bool operator>(const Time &t) const
Time m_end
Animation ending time.
bool contains(const Time &t) const
T max(T... args)
T min(T... args)
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3