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

Different boneWeights accuracy in edit mode and run mode #693

Open
ijinfeng opened this issue Apr 29, 2024 · 0 comments
Open

Different boneWeights accuracy in edit mode and run mode #693

ijinfeng opened this issue Apr 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ijinfeng
Copy link

Describe the bug
I found a problem, the same glb, previewed in edit mode, and dragged into the scene, the model behaves normally, but the dynamically loaded glb behaves abnormally. Through tracking, I found that the boneWeights of the two are slightly different, so far it seems that the difference is in precision.

Files

Below is a comparison of boneWeights between the two glb loads.

0F28874DCB86D8AC1825DBDFA5C3FA78

image

And you can try this by use this glb file.
uplimbs001.glb.zip

Code

async void Update()
    {
        if(Input.GetKeyDown(KeyCode.A))
        {
            string path = HaiSdkManager.GetPersistentPath();
            path = Path.Combine(path, "uplimbs001.glb");
            Dowork(Path.GetFullPath(path));
        }
    }

async void Dowork(string filePath)
    {
        var downloadProvider = new GLTFast.Loading.DefaultDownloadProvider();

        var m_Gltf = new GltfImport(
            downloadProvider,
            new UninterruptedDeferAgent(),
            null,
            null
            );


        var importSettings = new ImportSettings
        {
            // Avoid naming conflicts by default
            NodeNameMethod = NameImportMethod.OriginalUnique,
            GenerateMipMaps = true,
            AnimationMethod = AnimationMethod.Mecanim,
        };

        var instantiationSettings = new InstantiationSettings();

        bool success = await m_Gltf.Load(filePath, importSettings);

        if (success)
        {

            if (instantiationSettings.SceneObjectCreation == SceneObjectCreation.Never)
            {

                // There *has* to be a common parent GameObject that gets
                // added to the ScriptedImporter, so we overrule this
                // setting.

                instantiationSettings.SceneObjectCreation = SceneObjectCreation.WhenMultipleRootNodes;
                Debug.LogWarning("SceneObjectCreation setting \"Never\" is not available for Editor (design-time) imports. Falling back to WhenMultipleRootNodes.", this);
            }

            for (var sceneIndex = 0; sceneIndex < m_Gltf.SceneCount; sceneIndex++)
            {
                var scene = m_Gltf.GetSourceScene(sceneIndex);
                var sceneName = m_Gltf.GetSceneName(sceneIndex);
                var go = new GameObject(sceneName);
                var instantiator = new GameObjectInstantiator(m_Gltf, go.transform, null, instantiationSettings);
                var index = sceneIndex;
                success = await m_Gltf.InstantiateSceneAsync(instantiator, index);
            }
        }
    }

Looking forward to your reply!

@ijinfeng ijinfeng added the bug Something isn't working label Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant