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

Support ZAPD bone enums for skeleton import #396

Merged

Conversation

m000z0rz
Copy link
Contributor

@m000z0rz m000z0rz commented Jul 28, 2024

The Majora's Mask decomp uses limb enums on their assets, which changes the generated .c files for objects enough that skeletons won't import. This patch series adds a script to check how many files import skeletons from a decomp folder (currently only 3/176 or 1.7% successful) and adds handling for parsing these limb enums and using their when adding limbs. After these changes, 166/174 (95.4%) import skeletons without throwing exceptions.

I did most of my manual testing by:

  1. Open blender
  2. In Fast64, set the game to OOT
  3. In the OOT settings under OOT File Settings, set the decomp path to a checkout of the Majora's Mask decomp (with make setup complete) so assets are extracted
  4. Under the OOT Skeleton Exporter section, import a skeleton from the MM decomp.
    1. I typically tested with the Deku Buter using
      1. Skeleton: gDekuButlerSkel
      2. Object: object_dnj
      3. Actor Overlay: ovl_En_Dno

Alternatively, you can use the test script introduced in the first commit.
cd to scripts/oot and run

python3 make_all_skeletons.py <path to your mm decomp> <output dir> ["1" to import animations too]

For example, with the MM decomp checked out to ~/git/mm and with make setup complete there, I run

python3 make_all_skeletons.py ~/git/mm test-out 1

And when it completes, I can open the blend file generated at scripts/oot/test-out/assets/objects/object_dnj/object_dnj.blend to see the Deku Butler successfully imported with all its animations.

Copy link
Contributor

@Yanis42 Yanis42 left a comment

Choose a reason for hiding this comment

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

thanks for the PR! just small comments (also idk how to test this, like do I just import skeletons? and which one(s)?)

idk what the other contributors will think but imo we should start to introduce snake case for newer code from now (and change the existing one to make it consistent), just a detail though

also make sure there's no useless imports added in here


note that I don't know much about skeletons

fast64_internal/oot/oot_utility.py Show resolved Hide resolved
fast64_internal/oot/oot_utility.py Outdated Show resolved Hide resolved
@Yanis42 Yanis42 added the oot Has to do with the Ocarina of Time 64 side label Jul 28, 2024
@Yanis42
Copy link
Contributor

Yanis42 commented Jul 28, 2024

oh also you should add a oot subfolder for the content of the scripts folder I think

In preparation for fixing skeleton imports from the MM decomp, make a
script for testing skeleton imports.

Running `python3 scripts/make_all_skeletons.py <decomp path> <output
folder>` will attempt to import all skeletons from every file in the
decomp that appears to contain a skeleton, and report on how many
files raised exceptions during the import. The generated .blend files
are stored in the output folder. Including a third argument of ` will
attempt to import all animations for files that contain a single
skeleton as well.

Running this on the mm decomp at commit
803ff1fb1593cdc0c62d14882973af04dc0f988e (from 2024-07-13) results in
only 3/174 (1.7%) of files with skeletons importing them without exceptions.
The MM decomp specifies `EnumName` values for limbs in the asset XML,
which generates an enum naming bone indicies. These enum values are
also generated in comments in the limb list:

  void* gDekuButlerSkelLimbs[] = {
    &gDekuButlerRootLimb, /* DEKU_BUTLER_LIMB_ROOT */

Fast64's current limb list parsing does not expect comments here,
which causes the limb list parse to fail.

Add a function to strip comments of this style, and strip them before
parsing limb list entires.
The MM decomp defines EnumNames for limbs in asset XML, which causes
ZAPD to generate limb definitions that use these enum values for the
next child and next sibling (with an offset of 1).

  StandardLimb gDekuButlerRootLimb = {
    { 0, 2775, 0 }, DEKU_BUTLER_LIMB_PELVIS - 1, LIMB_DONE,

ootGetLimb currently only supports int values, hex values, or
LIMB_DONE here.

In preparation for supporting limb enum values of this form, add the
object's header file to skeletonData and parse all enums found during
skeleton import. The next patch in this series will use the parsed
enums to handle limb definitions of this form.
@m000z0rz m000z0rz force-pushed the m000z0rz/support-zapd-bone-enums-for-import branch from 2ed6383 to 452c0ed Compare July 28, 2024 21:58
@m000z0rz
Copy link
Contributor Author

Thanks for the review @Yanis42 ! I added testing instructions to the PR description and pushed updates that I think should resove the issues you found.

Use the parsed enums to support next child and next sibling
definitions of the form `<limb enum value> - 1`.

With this change and the others from this patch series,
`make_all_skeletons.py` goes from just 3/174 (1.1%) of MM decomp files
with successful skeleton imports to 169/174 (97.1%).
@m000z0rz m000z0rz force-pushed the m000z0rz/support-zapd-bone-enums-for-import branch from 452c0ed to 764c9b6 Compare July 28, 2024 23:43
Copy link
Contributor

@Yanis42 Yanis42 left a comment

Choose a reason for hiding this comment

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

seems to work properly

@Yanis42 Yanis42 added the merge soon Will be merged in a few days at most if nothing else comes up label Aug 1, 2024
@Yanis42 Yanis42 merged commit a3ca8cf into Fast-64:main Aug 2, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge soon Will be merged in a few days at most if nothing else comes up oot Has to do with the Ocarina of Time 64 side
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants