@@ -789,38 +789,8 @@ std::string Clip::PropertiesJSON(int64_t requested_frame) const {
789789 root[" waveform" ][" choices" ].append (add_property_choice_json (" Yes" , true , waveform));
790790 root[" waveform" ][" choices" ].append (add_property_choice_json (" No" , false , waveform));
791791
792- // Add the parentTrackedObject's properties
793- if (parentTrackedObject && parentClipObject)
794- {
795- // Convert Clip's frame position to Timeline's frame position
796- long clip_start_position = round (Position () * info.fps .ToDouble ()) + 1 ;
797- long clip_start_frame = (Start () * info.fps .ToDouble ()) + 1 ;
798- double timeline_frame_number = requested_frame + clip_start_position - clip_start_frame;
799-
800- // Get attached object's parent clip properties
801- std::map< std::string, float > trackedObjectParentClipProperties = parentTrackedObject->GetParentClipProperties (timeline_frame_number);
802- double parentObject_frame_number = trackedObjectParentClipProperties[" frame_number" ];
803- // Get attached object properties
804- std::map< std::string, float > trackedObjectProperties = parentTrackedObject->GetBoxValues (parentObject_frame_number);
805-
806- // Correct the parent Tracked Object properties by the clip's reference system
807- float parentObject_location_x = trackedObjectProperties[" cx" ] - 0.5 + trackedObjectParentClipProperties[" cx" ];
808- float parentObject_location_y = trackedObjectProperties[" cy" ] - 0.5 + trackedObjectParentClipProperties[" cy" ];
809- float parentObject_scale_x = trackedObjectProperties[" w" ]*trackedObjectProperties[" sx" ];
810- float parentObject_scale_y = trackedObjectProperties[" h" ]*trackedObjectProperties[" sy" ];
811- float parentObject_rotation = trackedObjectProperties[" r" ] + trackedObjectParentClipProperties[" r" ];
812-
813- // Add the parent Tracked Object properties to JSON
814- root[" location_x" ] = add_property_json (" Location X" , parentObject_location_x, " float" , " " , &location_x, -1.0 , 1.0 , false , requested_frame);
815- root[" location_y" ] = add_property_json (" Location Y" , parentObject_location_y, " float" , " " , &location_y, -1.0 , 1.0 , false , requested_frame);
816- root[" scale_x" ] = add_property_json (" Scale X" , parentObject_scale_x, " float" , " " , &scale_x, 0.0 , 1.0 , false , requested_frame);
817- root[" scale_y" ] = add_property_json (" Scale Y" , parentObject_scale_y, " float" , " " , &scale_y, 0.0 , 1.0 , false , requested_frame);
818- root[" rotation" ] = add_property_json (" Rotation" , parentObject_rotation, " float" , " " , &rotation, -360 , 360 , false , requested_frame);
819- root[" shear_x" ] = add_property_json (" Shear X" , shear_x.GetValue (requested_frame), " float" , " " , &shear_x, -1.0 , 1.0 , false , requested_frame);
820- root[" shear_y" ] = add_property_json (" Shear Y" , shear_y.GetValue (requested_frame), " float" , " " , &shear_y, -1.0 , 1.0 , false , requested_frame);
821- }
822792 // Add the parentClipObject's properties
823- else if (parentClipObject)
793+ if (parentClipObject)
824794 {
825795 // Convert Clip's frame position to Timeline's frame position
826796 long clip_start_position = round (Position () * info.fps .ToDouble ()) + 1 ;
@@ -1345,7 +1315,7 @@ void Clip::apply_waveform(std::shared_ptr<Frame> frame, QSize timeline_size) {
13451315 frame->AddImage (source_image);
13461316}
13471317
1348- // Apply keyframes to the source frame (if any)
1318+ // Get QTransform from keyframes
13491319QTransform Clip::get_transform (std::shared_ptr<Frame> frame, int width, int height)
13501320{
13511321 // Get image from clip
@@ -1440,62 +1410,41 @@ QTransform Clip::get_transform(std::shared_ptr<Frame> frame, int width, int heig
14401410
14411411 // Get the parentClipObject properties
14421412 if (parentClipObject){
1443-
1444- // Convert Clip's frame position to Timeline's frame position
1445- long clip_start_position = round (Position () * info.fps .ToDouble ()) + 1 ;
1446- long clip_start_frame = (Start () * info.fps .ToDouble ()) + 1 ;
1447- double timeline_frame_number = frame->number + clip_start_position - clip_start_frame;
1413+ // Get the start trim position of the parent clip
1414+ long parent_start_offset = parentClipObject->Start () * info.fps .ToDouble ();
1415+ long parent_frame_number = frame->number + parent_start_offset;
14481416
14491417 // Get parent object's properties (Clip)
1450- parentObject_location_x = parentClipObject->location_x .GetValue (timeline_frame_number );
1451- parentObject_location_y = parentClipObject->location_y .GetValue (timeline_frame_number );
1452- parentObject_scale_x = parentClipObject->scale_x .GetValue (timeline_frame_number );
1453- parentObject_scale_y = parentClipObject->scale_y .GetValue (timeline_frame_number );
1454- parentObject_shear_x = parentClipObject->shear_x .GetValue (timeline_frame_number );
1455- parentObject_shear_y = parentClipObject->shear_y .GetValue (timeline_frame_number );
1456- parentObject_rotation = parentClipObject->rotation .GetValue (timeline_frame_number );
1418+ parentObject_location_x = parentClipObject->location_x .GetValue (parent_frame_number );
1419+ parentObject_location_y = parentClipObject->location_y .GetValue (parent_frame_number );
1420+ parentObject_scale_x = parentClipObject->scale_x .GetValue (parent_frame_number );
1421+ parentObject_scale_y = parentClipObject->scale_y .GetValue (parent_frame_number );
1422+ parentObject_shear_x = parentClipObject->shear_x .GetValue (parent_frame_number );
1423+ parentObject_shear_y = parentClipObject->shear_y .GetValue (parent_frame_number );
1424+ parentObject_rotation = parentClipObject->rotation .GetValue (parent_frame_number );
14571425 }
14581426
1459- // Get the parentTrackedObject properties
1460- if (parentTrackedObject){
1461- // Convert Clip's frame position to Timeline's frame position
1462- long clip_start_position = round (Position () * info.fps .ToDouble ()) + 1 ;
1463- long clip_start_frame = (Start () * info.fps .ToDouble ()) + 1 ;
1464- double timeline_frame_number = frame->number + clip_start_position - clip_start_frame;
1465-
1466- // Get parentTrackedObject's parent clip's properties
1467- std::map<std::string, float > trackedObjectParentClipProperties =
1468- parentTrackedObject->GetParentClipProperties (timeline_frame_number);
1469-
1470- // Get the attached object's parent clip's properties
1471- if (!trackedObjectParentClipProperties.empty ())
1472- {
1473- // Get parent object's properties (Tracked Object)
1474- float parentObject_frame_number = trackedObjectParentClipProperties[" frame_number" ];
1475-
1476- // Access the parentTrackedObject's properties
1477- std::map<std::string, float > trackedObjectProperties = parentTrackedObject->GetBoxValues (parentObject_frame_number);
1478-
1479- // Get the Tracked Object's properties and correct them by the clip's reference system
1480- parentObject_location_x = trackedObjectProperties[" cx" ] - 0.5 + trackedObjectParentClipProperties[" location_x" ];
1481- parentObject_location_y = trackedObjectProperties[" cy" ] - 0.5 + trackedObjectParentClipProperties[" location_y" ];
1482- parentObject_scale_x = trackedObjectProperties[" w" ]*trackedObjectProperties[" sx" ];
1483- parentObject_scale_y = trackedObjectProperties[" h" ]*trackedObjectProperties[" sy" ];
1484- parentObject_rotation = trackedObjectProperties[" r" ] + trackedObjectParentClipProperties[" rotation" ];
1485- }
1486- else
1487- {
1488- // Access the parentTrackedObject's properties
1489- std::map<std::string, float > trackedObjectProperties = parentTrackedObject->GetBoxValues (timeline_frame_number);
1490-
1491- // Get the Tracked Object's properties and correct them by the clip's reference system
1492- parentObject_location_x = trackedObjectProperties[" cx" ] - 0.5 ;
1493- parentObject_location_y = trackedObjectProperties[" cy" ] - 0.5 ;
1494- parentObject_scale_x = trackedObjectProperties[" w" ]*trackedObjectProperties[" sx" ];
1495- parentObject_scale_y = trackedObjectProperties[" h" ]*trackedObjectProperties[" sy" ];
1496- parentObject_rotation = trackedObjectProperties[" r" ];
1497- }
1498- }
1427+ // Get the parentTrackedObject properties
1428+ if (parentTrackedObject){
1429+ // Get the attached object's parent clip's properties
1430+ Clip* parentClip = (Clip*) parentTrackedObject->ParentClip ();
1431+ if (parentClip)
1432+ {
1433+ // Get the start trim position of the parent clip
1434+ long parent_start_offset = parentClip->Start () * info.fps .ToDouble ();
1435+ long parent_frame_number = frame->number + parent_start_offset;
1436+
1437+ // Access the parentTrackedObject's properties
1438+ std::map<std::string, float > trackedObjectProperties = parentTrackedObject->GetBoxValues (parent_frame_number);
1439+
1440+ // Get the Tracked Object's properties and correct them by the clip's reference system
1441+ parentObject_location_x = parentClip->location_x .GetValue (parent_frame_number) + ((trackedObjectProperties[" cx" ] - 0.5 ) * parentClip->scale_x .GetValue (parent_frame_number));
1442+ parentObject_location_y = parentClip->location_y .GetValue (parent_frame_number) + ((trackedObjectProperties[" cy" ] - 0.5 ) * parentClip->scale_y .GetValue (parent_frame_number));
1443+ parentObject_scale_x = trackedObjectProperties[" w" ] * trackedObjectProperties[" sx" ] * parentClip->scale_x .GetValue (parent_frame_number);
1444+ parentObject_scale_y = trackedObjectProperties[" h" ] * trackedObjectProperties[" sy" ] * parentClip->scale_y .GetValue (parent_frame_number);
1445+ parentObject_rotation = trackedObjectProperties[" r" ] + parentClip->rotation .GetValue (parent_frame_number);
1446+ }
1447+ }
14991448
15001449 /* GRAVITY LOCATION - Initialize X & Y to the correct values (before applying location curves) */
15011450 float x = 0.0 ; // left
@@ -1561,8 +1510,8 @@ QTransform Clip::get_transform(std::shared_ptr<Frame> frame, int width, int heig
15611510
15621511 /* LOCATION, ROTATION, AND SCALE */
15631512 float r = rotation.GetValue (frame->number ) + parentObject_rotation; // rotate in degrees
1564- x += ( width * (location_x.GetValue (frame->number ) + parentObject_location_x ) ); // move in percentage of final width
1565- y += ( height * (location_y.GetValue (frame->number ) + parentObject_location_y ) ); // move in percentage of final height
1513+ x += width * (location_x.GetValue (frame->number ) + parentObject_location_x); // move in percentage of final width
1514+ y += height * (location_y.GetValue (frame->number ) + parentObject_location_y); // move in percentage of final height
15661515 float shear_x_value = shear_x.GetValue (frame->number ) + parentObject_shear_x;
15671516 float shear_y_value = shear_y.GetValue (frame->number ) + parentObject_shear_y;
15681517 float origin_x_value = origin_x.GetValue (frame->number );
0 commit comments