-
Notifications
You must be signed in to change notification settings - Fork 1
/
VecNode.hpp
108 lines (88 loc) · 2.56 KB
/
VecNode.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#pragma once
#include "cinder/CinderGlm.h"
#include "libnodes/Node.h"
#include "libnodes/ValueNode.h"
namespace cinder {
namespace frame_graph {
template< typename T = vec2, typename V = typename T::value_type >
class Vec2Node : public nodes::ValueNode< T, V, V >
{
public:
Vec2Node( const std::string &label, const T & v ) :
nodes::ValueNode< T, V, V >( label, v )
{
// listen();
}
Vec2Node( const T & v ) :
nodes::ValueNode< T, V, V >( v )
{
// listen();
}
V & x() { return this->get().x; }
const V & x() const { return this->get().x; }
V & y() { return this->get().y; }
const V & y() const { return this->get().y; }
protected:
void listen() override
{
nodes::ValueNode< T, V, V >::listen();
this->template in< 1 >().onReceive( [&] ( const V & v ) {
T cp = (*this)();
cp.x = v;
this->set( cp );
this->template out< 1 >().update( v );
});
this->template in< 2 >().onReceive( [&] ( const V & v ) {
T cp = (*this)();
cp.y = v;
this->set( cp );
this->template out< 2 >().update( v );
});
}
};
template< typename T = vec3, typename V = typename T::value_type >
class Vec3Node : public nodes::ValueNode< T, V, V, V >
{
public:
Vec3Node( const std::string &label, const T & v ) :
nodes::ValueNode< T, V, V, V >( label, v )
{
// listen();
}
Vec3Node( const T & v ) :
nodes::ValueNode< T, V, V, V >( v )
{
// listen();
}
V & x() { return this->get().x; }
const V & x() const { return this->get().x; }
V & y() { return this->get().y; }
const V & y() const { return this->get().y; }
V & z() { return this->get().z; }
const V & z() const { return this->get().z; }
protected:
void listen() override
{
nodes::ValueNode< T, V, V, V >::listen();
this->template in< 1 >().onReceive( [&] ( const V & v ) {
T cp = (*this)();
cp.x = v;
this->set( cp );
this->template out< 1 >().update( v );
});
this->template in< 2 >().onReceive( [&] ( const V & v ) {
T cp = (*this)();
cp.y = v;
this->set( cp );
this->template out< 2 >().update( v );
});
this->template in< 3 >().onReceive( [&] ( const V & v ) {
T cp = (*this)();
cp.z = v;
this->set( cp );
this->template out< 3 >().update( v );
});
}
};
}
}