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

Added support for multiple animated nodes in a .gltf file #8038

Merged
merged 8 commits into from Sep 28, 2023
Merged

Conversation

JCash
Copy link
Contributor

@JCash JCash commented Sep 24, 2023

Previously, we assumed that the first model in the scene was the one that was used for skinning.
However, that didn't cover all the use cases, and instead we now render all the models in the scene.

Additionally, we now also list all the animations from a .gltf/.glb file when it's selected as the animation set for a .model component. Previously, it always only selected the longest animation in the file.
The previous behavior for .animationset's is not changed, any animation files used in an animation set will only pick one animation (the longest), just as before.

Also, if there is a mesh in the model, that isn't skinned, but is a child to a bone, then that model will not be skinned at runtime, but get assigned a non-skinned material (if it didn't already have one)

Added model.set_mesh_enabled() and model.get_mesh_enabled() to control visibility of meshes within a scene.

PR checklist

  • Code
    • Add engine and/or editor unit tests.
    • New and changed code follows the overall code style of existing code
    • Add comments where needed
  • Documentation
    • Make sure that API documentation is updated in code comments
    • Make sure that manuals are updated (in github.com/defold/doc)
  • Prepare pull request and affected issue for automatic release notes generator
    • Pull request - Write a message that explains what this pull request does. What was the problem? How was it solved? What are the changes to APIs or the new APIs introduced? This message will be used in the generated release notes. Make sure it is well written and understandable for a user of Defold.
    • Pull request - Write a pull request title that in a sentence summarises what the pull request does. Do not include "Issue-1234 ..." in the title. This text will be used in the generated release notes.
    • Pull request - Link the pull request to the issue(s) it is closing. Use on of the approved closing keywords.
    • Affected issue - Assign the issue to a project. Do not assign the pull request to a project if there is an issue which the pull request closes.
    • Affected issue - Assign the "breaking change" label to the issue if introducing a breaking change.
    • Affected issue - Assign the "skip release notes" is the issue should not be included in the generated release notes.

@JCash JCash requested a review from Jhonnyg September 26, 2023 08:17
Comment on lines +353 to +356
if (selectLongest)
{
break;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug fix.
Previously, we stored all animations (just renaming them all to the same name).
Now we only store the longest.

(let [is-single-anim (or (empty? animation-set)
(not (animation-set/is-animation-set? animations-resource)))]
(if is-single-anim
(if animations-resource
[(resource/base-name animations-resource)] ; single animation file
animation-ids
Copy link
Contributor Author

Choose a reason for hiding this comment

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

While technically "breaking" the api here, I also consider it a bug fix.
Also, I believe few users actually set a single .gltf file here, and they got the longest animation in the file.

At most, they'll get a build error, which is easy to fix.

Note, I haven't change any code for the Collada code path, as we have deprecated that. So that should remain the same.

Comment on lines +638 to +640
// If the mesh wasn't skinned, but uses same material as other skinned meshes, we need to create a duplicate
// We also insert a bone index for the mesh (i.e. the parent)
static void FixupNonSkinnedModels(Scene* scene, Bone* parent, Node* node)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the test case, both skinned and non-skinned models use the same material.

In the Defold editor, these materials will later be assigned .material files, with different vertex formats.

If the user wanted these to have the same material, they can 1) assign the same .material twice to the model, or 2) skin all the models.

@@ -651,6 +667,25 @@ namespace dmGameSystem
}
}

// static void OutputVector4(const dmVMath::Vector4& v)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

for debugging every now and then.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe wrap these under a #if 0 ... #endif or something? Otherwise someone who isn't aware it's debug code might just remove it

@JCash JCash marked this pull request as ready for review September 26, 2023 08:24
Jhonnyg
Jhonnyg previously approved these changes Sep 27, 2023
Copy link
Contributor

@Jhonnyg Jhonnyg left a comment

Choose a reason for hiding this comment

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

I think it looks good. Do we want a unit test for the case you originally had issues with?

@@ -651,6 +667,25 @@ namespace dmGameSystem
}
}

// static void OutputVector4(const dmVMath::Vector4& v)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe wrap these under a #if 0 ... #endif or something? Otherwise someone who isn't aware it's debug code might just remove it

@JCash JCash merged commit dd46d94 into dev Sep 28, 2023
22 checks passed
@JCash JCash deleted the model-nodes branch September 28, 2023 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants