Mango request: added an input node to use track's position in compositor
[blender-staging.git] / source / blender / compositor / operations / COM_TrackPositionOperation.cpp
index 359e973adc7f50fc41cc3027de4eefc74037ec6b..cf516401a3c5d013b42fd0bb4592ceea7f123a2e 100644 (file)
@@ -44,6 +44,7 @@ TrackPositionOperation::TrackPositionOperation() : NodeOperation()
        this->trackingObject[0] = 0;
        this->trackName[0] = 0;
        this->axis = 0;
+       this->relative = false;
 }
 
 void TrackPositionOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -72,6 +73,20 @@ void TrackPositionOperation::executePixel(float *outputValue, float x, float y,
 
        outputValue[0] = marker->pos[this->axis];
 
+       if (this->relative) {
+               int i;
+
+               for (i = 0; i < track->markersnr; i++) {
+                       marker = &track->markers[i];
+
+                       if ((marker->flag & MARKER_DISABLED) == 0) {
+                               outputValue[0] -= marker->pos[this->axis];
+
+                               break;
+                       }
+               }
+       }
+
        if (this->axis == 0)
                outputValue[0] *= width;
        else