@@ -70,6 +70,7 @@ class JniUserModel : public CubismUserModel {
7070 void update (float dt) {
7171 if (!_model) return ;
7272
73+ // Cleanup finished motions safely
7374 {
7475 std::lock_guard<std::mutex> lock (_pendingMutex);
7576 for (auto * m : _pendingDeletion) {
@@ -83,7 +84,13 @@ class JniUserModel : public CubismUserModel {
8384 }
8485
8586 _model->LoadParameters ();
86- _motionManager->UpdateMotion (_model, dt);
87+
88+ // Update motion and check if we are idle
89+ bool isMotionPlaying = !_motionManager->IsFinished ();
90+ if (isMotionPlaying) {
91+ _motionManager->UpdateMotion (_model, dt);
92+ }
93+
8794 _model->SaveParameters ();
8895
8996 if (_pose) _pose->UpdateParameters (_model, dt);
@@ -101,6 +108,10 @@ class JniUserModel : public CubismUserModel {
101108 _model->Update ();
102109 }
103110
111+ bool isMotionFinished () {
112+ return _motionManager->IsFinished ();
113+ }
114+
104115 void notifyFinished () {
105116 JNIEnv* env = getEnv ();
106117 if (!env || !_javaObj) return ;
@@ -205,6 +216,10 @@ JNIEXPORT void JNICALL Java_dev_eatgrapes_live2d_CubismUserModel_startMotionNati
205216 env->ReleaseByteArrayElements (buffer, data, JNI_ABORT);
206217}
207218
219+ JNIEXPORT jboolean JNICALL Java_dev_eatgrapes_live2d_CubismUserModel_isMotionFinishedNative (JNIEnv*, jclass, jlong ptr) {
220+ return ((JniUserModel*)ptr)->isMotionFinished ();
221+ }
222+
208223JNIEXPORT void JNICALL Java_dev_eatgrapes_live2d_CubismUserModel_updateNative (JNIEnv*, jclass, jlong ptr, jfloat dt) {
209224 ((JniUserModel*)ptr)->update (dt);
210225}
@@ -243,4 +258,4 @@ JNIEXPORT void JNICALL Java_dev_eatgrapes_live2d_CubismUserModel_drawNative(JNIE
243258 env->ReleaseFloatArrayElements (matrix, m_ptr, JNI_ABORT);
244259}
245260
246- }
261+ }
0 commit comments