AnimNode.inl
Go to the documentation of this file.
1 namespace iv
2 {
3 
4 template< class T >
5 AnimNode< T >::AnimNode( Instance * inst, T const & initial_value ) :
6  AnimNodeI( inst ),
7  cm( inst, this, "AnimNode", ClientMarker::Status() ),
8  _target( initial_value ),
9  _last_target( initial_value )
10 {
11  static_assert( !std::is_pointer<T>::value, "I don't think that AnimNode should have a pointer as template argument." );
12  this->cm.inherits( this->AnimNodeI::cm );
13 }
14 
15 template< class T >
17 {
18  static TableId DebugTable = TableId::create( "AnimNode" );
19 
20  auto row = view->Table( AnimNode_DebugTable ).Row( this );
21  row.Column( "target", this->_target );
22  row.Column( "last_target", this->_last_target );
23 }
24 
25 template< class T >
26 AnimNode< T > * AnimNode< T >::label( std::string const & val )
27 {
28  this->AnimNodeI::label( val );
29  return this;
30 }
31 
32 template< class T >
33 std::string const & AnimNode< T >::label() const
34 {
35  return this->AnimNodeI::label();
36 }
37 
38 template< class T >
39 void AnimNode< T >::StringIO_SetTarget( const char * source, Context const * context )
40 {
41  this->Target( iv::StringIO_Read< T >( source, context ) );
42 }
43 
44 template< class T >
45 std::string AnimNode< T >::StringIO_GetTarget( Context const * context )
46 {
47  return iv::StringIO_Write< T >( this->Target(), context );
48 }
49 
50 template< class T >
52 {
53  return this->AnimNodeI::Speed();
54 }
55 
56 template< class T >
58 {
59  this->AnimNodeI::Speed( val );
60  return this;
61 }
62 
63 template< class T >
65 {
66  this->AnimNodeI::Speed_inf();
67  return this;
68 }
69 
70 template< class T >
71 AnimNode< T > * AnimNode< T >::Target( T const & target )
72 {
73  if( this->_target == target )
74  return this;
75 
76  this->Activate();
77  this->_target = target;
78 
79  // next time node arrives to destination, connector should be notified again
80  this->in_target_notified = false;
81 
82  // inform children that target changed
83  this->anim_eachChild(
84  [&]( AnimConnector * child )
85  {
86  child->parentChanged_Set();
87  }
88  );
89 
90  return this;
91 }
92 
93 template< class T >
95 {
96  return this->_target;
97 }
98 
99 template< class T >
101 {
102  return this->_last_target;
103 }
104 
105 template< class T >
107 {
108  return this->Distance() == Anim_float( 0.0 ) && this->_last_target == this->_target;
109 }
110 
111 template< class T >
112 bool AnimNode< T >::IsInTarget( T const & target )
113 {
114  return this->Distance() == Anim_float( 0.0 ) && this->_last_target == this->_target && this->_last_target == target;
115 }
116 
117 template< class T >
119 {
120  this->_last_target = this->_target;
121 }
122 
123 template< class T >
124 bool AnimNode< T >::TargetStabilized()
125 {
126  return this->_last_target == this->_target;
127 }
128 
129 }