@@ -1058,6 +1058,7 @@ parseMarkerSequence(const ofbx::IScene* scene, const ofbx::Object* root, const f
10581058
10591059 markersRoot = findMarkersRoot (root);
10601060 if (!markersRoot) {
1061+ // Return empty sequence with no frames
10611062 return result;
10621063 }
10631064
@@ -1076,12 +1077,14 @@ parseMarkerSequence(const ofbx::IScene* scene, const ofbx::Object* root, const f
10761077 }
10771078
10781079 if (markerNodes.empty ()) {
1080+ // Return empty sequence with no frames
10791081 return result;
10801082 }
10811083
10821084 // Get animation data for all marker nodes
10831085 const ofbx::AnimationStack* animStack = scene->getAnimationStack (0 );
10841086 if (!animStack) {
1087+ // Return empty sequence with no frames
10851088 return result;
10861089 }
10871090
@@ -1105,6 +1108,7 @@ parseMarkerSequence(const ofbx::IScene* scene, const ofbx::Object* root, const f
11051108 }
11061109
11071110 if (markerAnimCurves.empty ()) {
1111+ // Return empty sequence with no frames
11081112 return result;
11091113 }
11101114
@@ -1131,35 +1135,46 @@ parseMarkerSequence(const ofbx::IScene* scene, const ofbx::Object* root, const f
11311135 }
11321136
11331137 if (translationCurve) {
1134- // Collect all unique keyframe times across X, Y, Z channels
1138+ // Get the individual animation curves for X, Y, Z components
1139+ const ofbx::AnimationCurve* curveX = translationCurve->getCurve (0 );
1140+ const ofbx::AnimationCurve* curveY = translationCurve->getCurve (1 );
1141+ const ofbx::AnimationCurve* curveZ = translationCurve->getCurve (2 );
1142+
1143+ // Collect all unique keyframe times from all three curves
11351144 std::set<ofbx::i64 > keyframeTimes;
1136- for (int iChannel = 0 ; iChannel < 3 ; ++iChannel) {
1137- const ofbx::AnimationCurve* channel = translationCurve->getCurve (iChannel);
1138- if (channel == nullptr ) {
1139- continue ;
1145+ if (curveX) {
1146+ const int keyCount = curveX->getKeyCount ();
1147+ const ofbx::i64 * times = curveX->getKeyTime ();
1148+ for (int i = 0 ; i < keyCount; ++i) {
1149+ keyframeTimes.insert (times[i]);
11401150 }
1141- const int keyCount = channel->getKeyCount ();
1142- if (keyCount <= 0 ) {
1143- continue ;
1151+ }
1152+ if (curveY) {
1153+ const int keyCount = curveY->getKeyCount ();
1154+ const ofbx::i64 * times = curveY->getKeyTime ();
1155+ for (int i = 0 ; i < keyCount; ++i) {
1156+ keyframeTimes.insert (times[i]);
11441157 }
1145- const ofbx::i64 * times = channel->getKeyTime ();
1158+ }
1159+ if (curveZ) {
1160+ const int keyCount = curveZ->getKeyCount ();
1161+ const ofbx::i64 * times = curveZ->getKeyTime ();
11461162 for (int i = 0 ; i < keyCount; ++i) {
11471163 keyframeTimes.insert (times[i]);
11481164 }
11491165 }
11501166
1151- // For each unique keyframe time, add a marker at that frame
1152- // This matches GLTF behavior: only add markers at explicitly keyed frames
1153- for (ofbx::i64 fbxTime : keyframeTimes) {
1167+ // Add markers only at frames where keyframes exist
1168+ for (const ofbx::i64 fbxTime : keyframeTimes) {
11541169 const double timeInSeconds = ofbx::fbxTimeToSeconds (fbxTime);
1155- const auto frameIndex = static_cast < size_t >( std::lround (timeInSeconds * fps) );
1170+ const size_t frameIndex = std::round (timeInSeconds * fps);
11561171
11571172 // Skip if frame index is out of bounds
11581173 if (frameIndex >= numFrames) {
11591174 continue ;
11601175 }
11611176
1162- // Evaluate position at this specific keyframe time
1177+ // Evaluate position at this keyframe time
11631178 const ofbx::DVec3 position = translationCurve->getNodeLocalTransform (timeInSeconds);
11641179
11651180 Marker marker;
0 commit comments