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
107
108
109
110
111
112
|
/*
Copyright (c) 7244339 Canada Inc. (Mecanim)
All Rights Reserved.
*/
#pragma once
#include "Runtime/mecanim/defs.h"
#include "Runtime/mecanim/memory.h"
#include "Runtime/mecanim/types.h"
#include "Runtime/mecanim/object.h"
#include "Runtime/Math/Simd/float4.h"
#include "Runtime/mecanim/graph/plug.h"
namespace mecanim
{
namespace graph
{
template <typename TYPE, typename RESULT, typename UnaryPolicies> class UnaryNode : public Node
{
public:
TypePlug<TYPE> mA;
TypePlug<RESULT> mResult;
UnaryNode()
:mA(true,CRCKey(eA)),
mResult(false,CRCKey(eResult))
{
mA.m_Owner = this;
mResult.m_Owner = this;
}
virtual ~UnaryNode(){}
virtual uint32_t GetPlugCount()const
{
return 2;
}
virtual GraphPlug& GetPlug(uint32_t aIndex)
{
switch(aIndex)
{
case 0: return mA;
case 1:
default: return mResult;
}
}
virtual GraphPlug const& GetPlug(uint32_t aIndex)const
{
switch(aIndex)
{
case 0: return mA;
case 1:
default: return mResult;
}
}
virtual void Evaluate(EvaluationInfo& arEvaluationInfo)
{
TYPE a;
RESULT result;
mA.ReadData(&a, arEvaluationInfo);
result = UnaryPolicies::Operation(a);
mResult.WriteData(&result, arEvaluationInfo);
}
};
template< typename TYPE, typename RESULT > class NegationOp
{
public:
static RESULT Operation( TYPE const& l){ return -l; }
};
template<> class NegationOp<bool, bool>
{
public:
static bool Operation(bool const &l) { return !l; }
};
class NegationFloat : public UnaryNode<float, float, NegationOp<float, float> >
{
public:
static const eNodeType mId = NegationFloatId;
virtual eNodeType NodeType(){return mId;}
};
class NegationInt : public UnaryNode<int32_t, int32_t, NegationOp<int32_t, int32_t> >
{
public:
static const eNodeType mId = NegationIntId;
virtual eNodeType NodeType(){return mId;}
};
class NegationFloat4 : public UnaryNode<math::float4, math::float4, NegationOp<math::float4, math::float4> >
{
public:
static const eNodeType mId = NegationFloat4Id;
virtual eNodeType NodeType(){return mId;}
};
class NegationBool : public UnaryNode<bool, bool, NegationOp<bool, bool> >
{
public:
static const eNodeType mId = NegationBoolId;
virtual eNodeType NodeType(){return mId;}
};
}
}
|