implemented the ability to modify bezier points in the curve editor
This commit is contained in:
+1
-2
@@ -479,8 +479,7 @@ void NodeInput::CopyValues(NodeInput *source, NodeInput *dest, bool include_conn
|
||||
// Copy keyframes
|
||||
dest->keyframes_.clear();
|
||||
foreach (NodeKeyframePtr key, source->keyframes_) {
|
||||
NodeKeyframePtr copy = std::make_shared<NodeKeyframe>(key->time(), key->value(), key->type());
|
||||
dest->keyframes_.append(copy);
|
||||
dest->keyframes_.append(key->copy());
|
||||
}
|
||||
|
||||
// Copy keyframing state
|
||||
|
||||
+65
-8
@@ -20,20 +20,28 @@
|
||||
|
||||
#include "keyframe.h"
|
||||
|
||||
NodeKeyframe::NodeKeyframe() :
|
||||
time_(0),
|
||||
value_(0),
|
||||
type_(kLinear)
|
||||
{
|
||||
}
|
||||
|
||||
NodeKeyframe::NodeKeyframe(const rational &time, const QVariant &value, const NodeKeyframe::Type &type) :
|
||||
time_(time),
|
||||
value_(value),
|
||||
type_(type)
|
||||
type_(type),
|
||||
bezier_control_in_(QPointF(-1.0, 0.0)),
|
||||
bezier_control_out_(QPointF(1.0, 0.0))
|
||||
{
|
||||
}
|
||||
|
||||
NodeKeyframePtr NodeKeyframe::Create(const rational &time, const QVariant &value, const NodeKeyframe::Type &type)
|
||||
{
|
||||
return std::make_shared<NodeKeyframe>(time, value, type);
|
||||
}
|
||||
|
||||
NodeKeyframePtr NodeKeyframe::copy() const
|
||||
{
|
||||
NodeKeyframePtr copy = std::make_shared<NodeKeyframe>(time_, value_, type_);
|
||||
copy->bezier_control_in_ = bezier_control_in_;
|
||||
copy->bezier_control_out_ = bezier_control_out_;
|
||||
return copy;
|
||||
}
|
||||
|
||||
const rational &NodeKeyframe::time() const
|
||||
{
|
||||
return time_;
|
||||
@@ -66,3 +74,52 @@ void NodeKeyframe::set_type(const NodeKeyframe::Type &type)
|
||||
type_ = type;
|
||||
emit TypeChanged(type_);
|
||||
}
|
||||
|
||||
const QPointF &NodeKeyframe::bezier_control_in() const
|
||||
{
|
||||
return bezier_control_in_;
|
||||
}
|
||||
|
||||
void NodeKeyframe::set_bezier_control_in(const QPointF &control)
|
||||
{
|
||||
bezier_control_in_ = control;
|
||||
emit BezierControlInChanged(bezier_control_in_);
|
||||
}
|
||||
|
||||
const QPointF &NodeKeyframe::bezier_control_out() const
|
||||
{
|
||||
return bezier_control_out_;
|
||||
}
|
||||
|
||||
void NodeKeyframe::set_bezier_control_out(const QPointF &control)
|
||||
{
|
||||
bezier_control_out_ = control;
|
||||
emit BezierControlOutChanged(bezier_control_out_);
|
||||
}
|
||||
|
||||
const QPointF &NodeKeyframe::bezier_control(NodeKeyframe::BezierType type) const
|
||||
{
|
||||
if (type == kInHandle) {
|
||||
return bezier_control_in();
|
||||
} else {
|
||||
return bezier_control_out();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeKeyframe::set_bezier_control(NodeKeyframe::BezierType type, const QPointF &control)
|
||||
{
|
||||
if (type == kInHandle) {
|
||||
set_bezier_control_in(control);
|
||||
} else {
|
||||
set_bezier_control_out(control);
|
||||
}
|
||||
}
|
||||
|
||||
NodeKeyframe::BezierType NodeKeyframe::get_opposing_bezier_type(NodeKeyframe::BezierType type)
|
||||
{
|
||||
if (type == kInHandle) {
|
||||
return kOutHandle;
|
||||
} else {
|
||||
return kInHandle;
|
||||
}
|
||||
}
|
||||
|
||||
+45
-5
@@ -36,7 +36,6 @@ class NodeKeyframe : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Methods of interpolation to use with this keyframe
|
||||
*/
|
||||
@@ -46,18 +45,25 @@ public:
|
||||
kBezier
|
||||
};
|
||||
|
||||
static const Type kDefaultType = kLinear;
|
||||
|
||||
/**
|
||||
* @brief NodeKeyframe Constructor
|
||||
* @brief The two types of bezier handles that are available on bezier keyframes
|
||||
*/
|
||||
NodeKeyframe();
|
||||
enum BezierType {
|
||||
kInHandle,
|
||||
kOutHandle
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief NodeKeyframe Constructor
|
||||
*/
|
||||
NodeKeyframe(const rational& time, const QVariant& value, const Type& type);
|
||||
|
||||
static const Type kDefaultType = kLinear;
|
||||
|
||||
static NodeKeyframePtr Create(const rational& time, const QVariant& value, const Type& type);
|
||||
|
||||
NodeKeyframePtr copy() const;
|
||||
|
||||
/**
|
||||
* @brief The time this keyframe is set at
|
||||
*/
|
||||
@@ -76,6 +82,26 @@ public:
|
||||
const Type& type() const;
|
||||
void set_type(const Type& type);
|
||||
|
||||
/**
|
||||
* @brief For bezier interpolation, the control point leading into this keyframe
|
||||
*/
|
||||
const QPointF &bezier_control_in() const;
|
||||
void set_bezier_control_in(const QPointF& control);
|
||||
|
||||
/**
|
||||
* @brief For bezier interpolation, the control point leading out of this keyframe
|
||||
*/
|
||||
const QPointF& bezier_control_out() const;
|
||||
void set_bezier_control_out(const QPointF& control);
|
||||
|
||||
/**
|
||||
* @brief Convenience functions for retrieving/setting bezier handle information with a BezierType
|
||||
*/
|
||||
const QPointF& bezier_control(BezierType type) const;
|
||||
void set_bezier_control(BezierType type, const QPointF& control);
|
||||
|
||||
static BezierType get_opposing_bezier_type(BezierType type);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when this keyframe's time is changed
|
||||
@@ -92,12 +118,26 @@ signals:
|
||||
*/
|
||||
void TypeChanged(const Type& type);
|
||||
|
||||
/**
|
||||
* @brief Signal emitted when this keyframe's bezier in control point is changed
|
||||
*/
|
||||
void BezierControlInChanged(const QPointF& d);
|
||||
|
||||
/**
|
||||
* @brief Signal emitted when this keyframe's bezier out control point is changed
|
||||
*/
|
||||
void BezierControlOutChanged(const QPointF& d);
|
||||
|
||||
private:
|
||||
rational time_;
|
||||
|
||||
QVariant value_;
|
||||
|
||||
Type type_;
|
||||
|
||||
QPointF bezier_control_in_;
|
||||
|
||||
QPointF bezier_control_out_;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(NodeKeyframe::Type)
|
||||
|
||||
Reference in New Issue
Block a user