Compositor: Expose track velocity via the Track Position node
velocity is measured in pixels per frame. It is basically a coordinate difference of track coordinate at current frame and previous one (no future prediction happens). It's not really most intuitive place for such a things, but historically the node was called this way.. Track velocity could be used to face effects like motion blur bu piping it to the vector blur node. Reviewers: campbellbarton Reviewed By: campbellbarton Subscribers: hype, sebastian_k Differential Revision: https://developer.blender.org/D1591
This commit is contained in:
parent
879889c47c
commit
2339a84443
|
@ -44,6 +44,8 @@ void TrackPositionNode::convertToOperations(NodeConverter &converter, const Comp
|
|||
|
||||
NodeOutput *outputX = this->getOutputSocket(0);
|
||||
NodeOutput *outputY = this->getOutputSocket(1);
|
||||
NodeOutput *outputSpeedX = this->getOutputSocket(2);
|
||||
NodeOutput *outputSpeedY = this->getOutputSocket(3);
|
||||
|
||||
int frame_number;
|
||||
if (editorNode->custom1 == CMP_TRACKPOS_ABSOLUTE_FRAME) {
|
||||
|
@ -62,7 +64,7 @@ void TrackPositionNode::convertToOperations(NodeConverter &converter, const Comp
|
|||
operationX->setPosition(editorNode->custom1);
|
||||
operationX->setRelativeFrame(editorNode->custom2);
|
||||
converter.addOperation(operationX);
|
||||
|
||||
|
||||
TrackPositionOperation *operationY = new TrackPositionOperation();
|
||||
operationY->setMovieClip(clip);
|
||||
operationY->setTrackingObject(trackpos_data->tracking_object);
|
||||
|
@ -72,7 +74,31 @@ void TrackPositionNode::convertToOperations(NodeConverter &converter, const Comp
|
|||
operationY->setPosition(editorNode->custom1);
|
||||
operationY->setRelativeFrame(editorNode->custom2);
|
||||
converter.addOperation(operationY);
|
||||
|
||||
|
||||
TrackPositionOperation *operationSpeedX = new TrackPositionOperation();
|
||||
operationSpeedX->setMovieClip(clip);
|
||||
operationSpeedX->setTrackingObject(trackpos_data->tracking_object);
|
||||
operationSpeedX->setTrackName(trackpos_data->track_name);
|
||||
operationSpeedX->setFramenumber(frame_number);
|
||||
operationSpeedX->setAxis(0);
|
||||
operationSpeedX->setPosition(editorNode->custom1);
|
||||
operationSpeedX->setRelativeFrame(editorNode->custom2);
|
||||
operationSpeedX->setSpeedOutput(true);
|
||||
converter.addOperation(operationSpeedX);
|
||||
|
||||
TrackPositionOperation *operationSpeedY = new TrackPositionOperation();
|
||||
operationSpeedY->setMovieClip(clip);
|
||||
operationSpeedY->setTrackingObject(trackpos_data->tracking_object);
|
||||
operationSpeedY->setTrackName(trackpos_data->track_name);
|
||||
operationSpeedY->setFramenumber(frame_number);
|
||||
operationSpeedY->setAxis(1);
|
||||
operationSpeedY->setPosition(editorNode->custom1);
|
||||
operationSpeedY->setRelativeFrame(editorNode->custom2);
|
||||
operationSpeedY->setSpeedOutput(true);
|
||||
converter.addOperation(operationSpeedY);
|
||||
|
||||
converter.mapOutputSocket(outputX, operationX->getOutputSocket());
|
||||
converter.mapOutputSocket(outputY, operationY->getOutputSocket());
|
||||
converter.mapOutputSocket(outputSpeedX, operationSpeedX->getOutputSocket());
|
||||
converter.mapOutputSocket(outputSpeedY, operationSpeedY->getOutputSocket());
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ TrackPositionOperation::TrackPositionOperation() : NodeOperation()
|
|||
this->m_axis = 0;
|
||||
this->m_position = CMP_TRACKPOS_ABSOLUTE;
|
||||
this->m_relativeFrame = 0;
|
||||
this->m_speed_output = false;
|
||||
}
|
||||
|
||||
void TrackPositionOperation::initExecution()
|
||||
|
@ -78,7 +79,16 @@ void TrackPositionOperation::initExecution()
|
|||
|
||||
copy_v2_v2(this->m_markerPos, marker->pos);
|
||||
|
||||
if (this->m_position == CMP_TRACKPOS_RELATIVE_START) {
|
||||
if (this->m_speed_output) {
|
||||
marker = BKE_tracking_marker_get(track, clip_framenr - 1);
|
||||
if ((marker->flag & MARKER_DISABLED) == 0) {
|
||||
copy_v2_v2(this->m_relativePos, marker->pos);
|
||||
}
|
||||
else {
|
||||
copy_v2_v2(this->m_relativePos, this->m_markerPos);
|
||||
}
|
||||
}
|
||||
else if (this->m_position == CMP_TRACKPOS_RELATIVE_START) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < track->markersnr; i++) {
|
||||
|
|
|
@ -47,6 +47,7 @@ protected:
|
|||
int m_axis;
|
||||
int m_position;
|
||||
int m_relativeFrame;
|
||||
bool m_speed_output;
|
||||
|
||||
int m_width, m_height;
|
||||
float m_markerPos[2];
|
||||
|
@ -67,6 +68,7 @@ public:
|
|||
void setAxis(int value) {this->m_axis = value;}
|
||||
void setPosition(int value) {this->m_position = value;}
|
||||
void setRelativeFrame(int value) {this->m_relativeFrame = value;}
|
||||
void setSpeedOutput(bool speed_output) {this->m_speed_output = speed_output;};
|
||||
|
||||
void initExecution();
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
static bNodeSocketTemplate cmp_node_trackpos_out[] = {
|
||||
{ SOCK_FLOAT, 0, N_("X")},
|
||||
{ SOCK_FLOAT, 0, N_("Y")},
|
||||
{ SOCK_FLOAT, 0, N_("Speed X")},
|
||||
{ SOCK_FLOAT, 0, N_("Speed Y")},
|
||||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue