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

[Max] Bug: IAnimatable.GetGuid() extension function incorrectly reassigns Guid #376

Closed
Selmar opened this issue Nov 13, 2018 · 2 comments
Closed

Comments

@Selmar
Copy link
Contributor

Selmar commented Nov 13, 2018

Hi,

I've just found a bug.. well, I guess ... not really?

The problem is, I think, a guid conflict or something sneakier. There is one node that is exported, however, when calling maxNode.GetGuid() for retrieving the guid of the node, the node gets assigned a new guid.

This expression in this function is false: guids[uid].Equals(node as IInterfaceServer

            if (uidData != null)
            {
                uid = new Guid(uidData.Data);

                if (guids.ContainsKey(uid))
                {
                    // If the uid is already used by another node
                    if (guids[uid].Equals(node as IInterfaceServer) == false)
                    {
                        // Create a new uid for current node
                        uid = CreateGuid(node);
                    }
                }
                else
                {
                    guids.Add(uid, node);
                }
            }

However, this is really strange, because the node exists in the list of nodes with this guid. Maybe you have seen something similar before? I'm still investigating. If I can isolate the issue I might send you the .max file.

@Selmar
Copy link
Contributor Author

Selmar commented Nov 13, 2018

Okay, so in fact it looks like the CreateGuid function does not correctly overwrite the data in the AppDataChunk, because every time this is called, the same guid is returned (which is a conflicting value): var uidData = node.GetAppDataChunk(Loader.Class_ID, SClass_ID.Basenode, 0);

As a result, it creats a new guid for this node every time GetGuid is called.

        private static Guid CreateGuid(this IAnimatable node)
        {
            Guid uid = Guid.NewGuid();
            guids.Add(uid, node);
            node.AddAppDataChunk(Loader.Class_ID, SClass_ID.Basenode, 0, uid.ToByteArray());
            return uid;
        }

@Selmar Selmar changed the title [Max] Bug: IAnimatable.GetGuid() extension function incorrectly reassignes Guid [Max] Bug: IAnimatable.GetGuid() extension function incorrectly reassigns Guid Nov 13, 2018
kcoley pushed a commit that referenced this issue Nov 13, 2018
* fix a bug where uid appdata chunks were not correctly overwritten

* whitespace
@kcoley
Copy link
Contributor

kcoley commented Nov 13, 2018

@Selmar thanks for the PR!

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

No branches or pull requests

2 participants