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

fix: Morphtarget Export and Import #1267

Merged
merged 11 commits into from
Apr 9, 2023
Merged

Conversation

effs
Copy link
Contributor

@effs effs commented Apr 7, 2023

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)
image

effs added 6 commits April 7, 2023 22:48
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.
@effs
Copy link
Contributor Author

effs commented Apr 7, 2023

I still need to tidy some things up a bit but I think the logic is there and uncluttered enough to review.

Copy link
Contributor

@seberoth seberoth left a 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

WolvenKit.Modkit/RED4/Tools/MorphTargetTools.cs Outdated Show resolved Hide resolved
effs added 3 commits April 9, 2023 10:29
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.
Copy link
Member

@paishoexpert paishoexpert left a 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.

Copy link
Contributor

@seberoth seberoth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@seberoth seberoth merged commit 729919a into main Apr 9, 2023
2 checks passed
@effs effs deleted the fix/1167/morphtarget-import-export branch April 9, 2023 16:38
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.

None yet

3 participants