-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
fix: Morphtarget Export and Import #1267
Conversation
Vertex diff mappings are stored contiguously in the RE4 buffer, 2 bytes per. Because the mapping count is for some reason stored as half the actual count, it needs to be padded by an extra empty 2byte when the diff count is odd. Tried to make the logic a bit more explicitly laid out, too.
Bounds are calculated from maximum morphed or unmorphed dimensions, and passed along for not only the morph but also the baseblob. The quantization needs to have a scale wider than the possible values in its range including the morphs, so that the quantized value is always `1.0 >= q <= -1.0`.
Much of this is restructuring the logic and making it more explicit, but the bookkeeping and data buffer construction now produce 1:1 results compared against vanilla. Should support: 1. Vanilla reimports with unchanged morphtargets 2. Modified vanilla 3. Custom morphtargets (although the *game* doesn't do anything with these) BREAKING CHANGE: Relies on the new, fixed export logic. Will fail at least on some previously exported (and thus broken) morphtargets. Might be able to add fixes for some cases, but needs to be flagged to users.
I still need to tidy some things up a bit but I think the logic is there and uncluttered enough to review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest looks goot to me
In some cases it looks like the diff count is recorded incorrectly for Vanilla morphs. The data buffers are set up as though there's 0 diffs so using the mapping count is correct.
This and the one in mappings were hiding the incorrect calculations earlier. We want to fail if for some reason the calculation is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve this message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Highlights
Export: produces correct data so that it actually can be imported correctly*
Import: produces working morphtargets for vanilla/modified/custom morphs**
Breaking
Previously exported and/or imported morphtargets are likely to have at least some issues. Users may need to re-export and port their work on top of that.
More
The commits are kinda split up and the commit messages worth reading but, YMMV, it may be easier to actually review the code by reading the entire file instead of a diff.
*,** I mean, like, probably? I haven't tested that extensively.
Evidence for the defense: sculpted neck on a head morph (with still-working customization & expressions)