Evaluation of very simple graphs works.
This commit is contained in:
@@ -197,6 +197,11 @@ struct AnimSamplerNode : public AnimNode {
|
||||
|
||||
virtual ~AnimSamplerNode();
|
||||
virtual bool Init(AnimGraphContext& context) override;
|
||||
void UpdateTime(float time_last, float time_now) override {
|
||||
m_time_last = time_last;
|
||||
m_time_now = fmodf(time_last + (time_now - time_last), m_animation->duration());
|
||||
m_state = AnimNodeEvalState::TimeUpdated;
|
||||
}
|
||||
virtual void Evaluate(AnimGraphContext& context) override;
|
||||
};
|
||||
|
||||
@@ -210,6 +215,27 @@ struct NodeSocketAccessor<AnimSamplerNode> : public NodeSocketAccessorBase {
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// ConstScalarNode
|
||||
//
|
||||
struct ConstScalarNode : public AnimNode {
|
||||
float* o_value = nullptr;
|
||||
float value = 0.f;
|
||||
|
||||
virtual void Evaluate(AnimGraphContext& context){
|
||||
*o_value = value;
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct NodeSocketAccessor<ConstScalarNode> : public NodeSocketAccessorBase {
|
||||
NodeSocketAccessor(AnimNode* node_) {
|
||||
ConstScalarNode* node = dynamic_cast<ConstScalarNode*>(node_);
|
||||
RegisterOutput("ScalarOutput", &node->o_value);
|
||||
RegisterProperty("ScalarValue", &node->value);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// MathAddNode
|
||||
//
|
||||
@@ -236,7 +262,6 @@ struct NodeSocketAccessor<MathAddNode> : public NodeSocketAccessorBase {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// MathFloatToVec3Node
|
||||
//
|
||||
@@ -282,6 +307,8 @@ static inline AnimNode* AnimNodeFactory(const std::string& name) {
|
||||
result = new MathAddNode;
|
||||
} else if (name == "MathFloatToVec3Node") {
|
||||
result = new MathFloatToVec3Node;
|
||||
} else if (name == "ConstScalarNode") {
|
||||
result = new ConstScalarNode;
|
||||
}
|
||||
|
||||
if (result != nullptr) {
|
||||
@@ -308,6 +335,8 @@ static inline NodeSocketAccessorBase* AnimNodeAccessorFactory(
|
||||
return new NodeSocketAccessor<MathAddNode>(node);
|
||||
} else if (node_type_name == "MathFloatToVec3Node") {
|
||||
return new NodeSocketAccessor<MathFloatToVec3Node>(node);
|
||||
} else if (node_type_name == "ConstScalarNode") {
|
||||
return new NodeSocketAccessor<ConstScalarNode>(node);
|
||||
} else {
|
||||
std::cerr << "Invalid node type name " << node_type_name << "."
|
||||
<< std::endl;
|
||||
|
||||
Reference in New Issue
Block a user