MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / setKnobKeyframesFromMarker

Method setKnobKeyframesFromMarker

Engine/TrackerContextPrivate.cpp:707–767  ·  view source on GitHub ↗

* @brief Set keyframes on knobs from Marker data **/

Source from the content-addressed store, hash-verified

705 * @brief Set keyframes on knobs from Marker data
706 **/
707void
708TrackerContextPrivate::setKnobKeyframesFromMarker(const mv::Marker& mvMarker,
709 int /*formatHeight*/,
710 const libmv::TrackRegionResult* result,
711 const TrackMarkerPtr& natronMarker)
712{
713 int time = mvMarker.frame;
714 KnobDoublePtr errorKnob = natronMarker->getErrorKnob();
715
716 if (result) {
717 double corr = result->correlation;
718 if (corr != corr) {
719 corr = 1.;
720 }
721 errorKnob->setValueAtTime(time, 1. - corr, ViewSpec::current(), 0);
722 } else {
723 errorKnob->setValueAtTime(time, 0., ViewSpec::current(), 0);
724 }
725
726 // Blender also adds 0.5 to coordinates
727 Point center;
728 center.x = (double)mvMarker.center(0);
729 center.y = (double)mvMarker.center(1);
730
731 KnobDoublePtr offsetKnob = natronMarker->getOffsetKnob();
732 Point offset;
733 offset.x = offsetKnob->getValueAtTime(time, 0);
734 offset.y = offsetKnob->getValueAtTime(time, 1);
735
736 Point centerPlusOffset;
737 centerPlusOffset.x = center.x + offset.x;
738 centerPlusOffset.y = center.y + offset.y;
739
740 // Set the center
741 KnobDoublePtr centerKnob = natronMarker->getCenterKnob();
742 centerKnob->setValuesAtTime(time, center.x + 0.5, center.y + 0.5, ViewSpec::current(), eValueChangedReasonNatronInternalEdited);
743
744 Point topLeftCorner, topRightCorner, btmRightCorner, btmLeftCorner;
745 topLeftCorner.x = mvMarker.patch.coordinates(3, 0) - centerPlusOffset.x;
746 topLeftCorner.y = mvMarker.patch.coordinates(3, 1) - centerPlusOffset.y;
747
748 topRightCorner.x = mvMarker.patch.coordinates(2, 0) - centerPlusOffset.x;
749 topRightCorner.y = mvMarker.patch.coordinates(2, 1) - centerPlusOffset.y;
750
751 btmRightCorner.x = mvMarker.patch.coordinates(1, 0) - centerPlusOffset.x;
752 btmRightCorner.y = mvMarker.patch.coordinates(1, 1) - centerPlusOffset.y;
753
754 btmLeftCorner.x = mvMarker.patch.coordinates(0, 0) - centerPlusOffset.x;
755 btmLeftCorner.y = mvMarker.patch.coordinates(0, 1) - centerPlusOffset.y;
756
757 KnobDoublePtr pntTopLeftKnob = natronMarker->getPatternTopLeftKnob();
758 KnobDoublePtr pntTopRightKnob = natronMarker->getPatternTopRightKnob();
759 KnobDoublePtr pntBtmLeftKnob = natronMarker->getPatternBtmLeftKnob();
760 KnobDoublePtr pntBtmRightKnob = natronMarker->getPatternBtmRightKnob();
761
762 // Set the pattern Quad
763 pntTopLeftKnob->setValuesAtTime(time, topLeftCorner.x, topLeftCorner.y, ViewSpec::current(), eValueChangedReasonNatronInternalEdited);
764 pntTopRightKnob->setValuesAtTime(time, topRightCorner.x, topRightCorner.y, ViewSpec::current(), eValueChangedReasonNatronInternalEdited);

Callers

nothing calls this directly

Calls 12

currentFunction · 0.85
getErrorKnobMethod · 0.80
centerMethod · 0.80
getOffsetKnobMethod · 0.80
setValuesAtTimeMethod · 0.80
getPatternTopLeftKnobMethod · 0.80
getPatternBtmLeftKnobMethod · 0.80
setValueAtTimeMethod · 0.45
getValueAtTimeMethod · 0.45
getCenterKnobMethod · 0.45

Tested by

no test coverage detected