Skip to content

Commit 78c0c36

Browse files
committed
chore: cleanup source code comments and finalize stability fixes
1 parent 89e01a6 commit 78c0c36

2 files changed

Lines changed: 7 additions & 15 deletions

File tree

binding/src/main/java/dev/eatgrapes/live2d/CubismUserModel.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ public void startMotion(byte[] buffer, int priority, boolean loop, Consumer<Stri
4343
}
4444
private static native void startMotionNative(long ptr, byte[] buffer, int priority, boolean loop);
4545

46+
public boolean isMotionFinished() { return isMotionFinishedNative(_ptr); }
47+
private static native boolean isMotionFinishedNative(long ptr);
48+
4649
private void onMotionFinished(String name) {
4750
if (motionFinishedCallback != null) {
4851
motionFinishedCallback.accept(name);
4952
}
5053
}
5154

52-
public boolean isMotionFinished() { return isMotionFinishedNative(_ptr); }
53-
private static native boolean isMotionFinishedNative(long ptr);
54-
5555
public void update(float deltaTime) { updateNative(_ptr, deltaTime); }
5656
private static native void updateNative(long ptr, float deltaTime);
5757

@@ -73,4 +73,4 @@ private void onMotionFinished(String name) {
7373
@Override
7474
public void close() { deleteNative(_ptr); }
7575
private static native void deleteNative(long ptr);
76-
}
76+
}

native/src/CubismUserModel_JNI.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class JniUserModel : public CubismUserModel {
3131
void loadModelCopy(const csmByte* buffer, csmSizeInt size) {
3232
_mocBuffer.assign(buffer, buffer + size);
3333
LoadModel(_mocBuffer.data(), (csmSizeInt)_mocBuffer.size());
34+
if (_model) _model->SaveParameters();
3435
}
3536

3637
void loadPhysicsCopy(const csmByte* buffer, csmSizeInt size) {
@@ -70,7 +71,6 @@ class JniUserModel : public CubismUserModel {
7071
void update(float dt) {
7172
if (!_model) return;
7273

73-
// Cleanup finished motions safely
7474
{
7575
std::lock_guard<std::mutex> lock(_pendingMutex);
7676
for (auto* m : _pendingDeletion) {
@@ -84,13 +84,7 @@ class JniUserModel : public CubismUserModel {
8484
}
8585

8686
_model->LoadParameters();
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-
87+
_motionManager->UpdateMotion(_model, dt);
9488
_model->SaveParameters();
9589

9690
if (_pose) _pose->UpdateParameters(_model, dt);
@@ -108,9 +102,7 @@ class JniUserModel : public CubismUserModel {
108102
_model->Update();
109103
}
110104

111-
bool isMotionFinished() {
112-
return _motionManager->IsFinished();
113-
}
105+
bool isMotionFinished() { return _motionManager->IsFinished(); }
114106

115107
void notifyFinished() {
116108
JNIEnv* env = getEnv();

0 commit comments

Comments
 (0)