Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reconstruct curve totals for corrupt/old models #57

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

@wada-at-live2d-com wada-at-live2d-com self-requested a review April 11, 2024 10:06
@wada-at-live2d-com
Copy link
Contributor

@pillowtrucker

Thank you for pull request and investigation!

I have reviewed the background of this pull request. It's understood that there's a crash when invalid data is present in motion3.json. However, as a premise, why would there be invalid motion3.json files? The motion3.json file is generated from Cubism Editor, and by directly loading it without any modifications, it should reproduce the curve information.

Is it possible that the motion3.json files generated from Cubism Editor are incorrect? Cubism SDK typically assumes that it's loading the original data outputted from Cubism Editor without any modifications.

Do you have the moc3 files corresponding to the cmo3 files that were outputted? If there are issues, we would like to investigate from the output process in Cubism Editor.

@pillowtrucker
Copy link
Author

I've investigated this a little bit and it seems that they were generated by 3rd party tools to recover live2d assets from unity games https://github.com/Perfare/UnityLive2DExtractor/blob/ab37d53b99cf34641305704e93e2e0b9098f80c4/UnityLive2DExtractor/Program.cs#L161. What's surprising is that the Cubism Viewer opens them without crashing. That made me think it's a version incompatibility, but I'm fairly sure now that it's just an issue with the 3rd party utility doing the calculations wrong.

@wada-at-live2d-com
Copy link
Contributor

wada-at-live2d-com commented Apr 30, 2024

@pillowtrucker

I was puzzled as to why such files existed, but I understand now if they weren't directly exported from Cubism Editor. After internal discussions and reaching a conclusion, we do not guarantee the functionality of Live2D models extracted from Unity AssetBundle using unofficial tools, nor do we guarantee the recovery process.

As for why these motion3.json files can be read in Cubism Viewer, it's because Cubism Viewer simply loads and reflects the curve values written in the JSON without strictly checking parameters like curvetotalcount. However, in Cubism SDK, we check curvetotalcount under the assumption that the JSON was exported from Cubism Editor and allocate data accordingly.

Therefore, this fix will not be accepted unless the JSON was exported from Cubism Editor. If you intend to correct this behavior, it would be advisable to first export JSON from Cubism Editor and confirm whether it can be read by Cubism SDK or other Cubism tools.

@wada-at-live2d-com
Copy link
Contributor

wada-at-live2d-com commented May 10, 2024

We have reconfirmed our approach to the fix internally.
We are planning to provide an API for validating motion3.json to ensure its correctness, and we also want SDK users to check the consistency of motion3.json within the SDK.
In case of any irregularities in motion3.json, this API will be highly effective in preventing parsing errors or memory violations beforehand. In the near future, we intend to implement this API to prevent any irregular data from entering.
We also plan to follow the same approach for Cubism Viewer.

@pillowtrucker
Copy link
Author

That's great news! Thank you.

aelurum added a commit to aelurum/AssetStudio that referenced this pull request Oct 29, 2024
- Fixed calculation of totalPointCount and totalSegmentCount in Live2D motions.
Live2D/CubismNativeFramework#57
aelurum added a commit to aelurum/UnityLive2DExtractor that referenced this pull request Oct 29, 2024
- Fixed calculation of totalPointCount and totalSegmentCount in Live2D motions.
github.com/Live2D/CubismNativeFramework/pull/57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Godot/live2d crash when loading models other than samples..
2 participants