PDA

View Full Version : Storing node references in CA's of the rootNode prohibits reparenting of those nodes


Jon-Huhn
01-08-2008, 05:35 AM
For the past couple of years, I've been getting depedency loop errors from time to time when I try to unlink an object from its parent or otherwise reparent it it some way.

And I've just discovered why. Some of the tools I've made store node references in custom attributes of the scene's rootNode, and evidently when this is done, Max doesn't like you to parent an object stored in the rootNode TO the rootNode. Once the node is removed from the CA, it's free to be reparented at will.

Also, if you store the node references in CA's of other objects instead of the rootNode, there's no problem reparenting (unless you're reparenting to the node that the CA is attahced to, I'm guessing).

Does anyone know of a way around this limitation other than not storing data in the rootNode? I really want to be able to continue storing my data there since it's neat and safe from users inadvertantly deleting the data by deleting a node.

RustyKnight
01-08-2008, 06:02 AM
Could use weak references as outlined by PEN??

Shane

Jon-Huhn
01-08-2008, 11:37 AM
By weak references, do you mean just save the name of the objects? Or is it something more than that?

Jon-Huhn
01-08-2008, 12:47 PM
<edited from original>

Ah, never mind, I found the stuff you were talking about here:

Paul's discussion:
http://forums.cgsociety.org/showthread.php?f=98&t=535988&highlight=weak+references

And the tutorial on his webisite:
http://paulneale.com/tutorials/Scripting/weakReferences/weakReferences.htm

Very helpful. Thanks for the tip!

Ruramuq
01-08-2008, 01:08 PM
since max8(I guess), Max uses Weak references inside "Script Controllers", when a node is assigned to a variable.

Using Weak References inside a CA, would be like replicating the Script Controller behaviour.
Not using it, I suppose, would easily lead to Dependency Loop errors(a Nightmare).

PEN
01-08-2008, 01:48 PM
Thanks for pointing to my site Shane.

What weak referencing does is store a reference to the node that is in a container of sorts. What this does is allow you to stop the transform change messages from being passed to the dependents. If they are passed you will get dependancy loop errors just like if you tried to have a.parent=b;b.parent=a.

Just as a note in some recent tests on an old character file, Maxine from the Max 8 samples disc. In this character I used a fairly complex rig and stored as weak references all the control objects in the rig in a CA def that was instanced around all the controls. On play back of animation I noticed that with the attribute holder modifier that holds the CA def instanced on all the controls the play back was about 5fps slower then without them and only having the attribute holder on the root of the character.

There are three properties of the nodeTransformMonitor that you can set. Only the first is outlined in the help as you really don't to change the others I have found. I do need to do more testing on them with different settings to see if anything affects speed.

forwardTransformChangeMsgs: This you want to set to false to stop the transform change messages being passed to the dependents.

forwardFlagNodesMessages: If set to false messages are not passed to the dependents of the INodeTransformMonitor. If true, those messages are passed to the dependents. If it is set to false and you try to get dependents of a node that is dependent on the transformMonitor it will not show it. It would need to be set to true for this to happen.

forwardEnumDependents: Similar to forwardFlagNodesMessages, except instead of a message it's a virtual method call being blocked.

Jon-Huhn
01-08-2008, 02:33 PM
Paul,

Thanks for the extra info. I think the examples you've shown on your site and in your forum discussion are enough to get me going.

Looks like I have a LOT of re-coding to do :)

CGTalk Moderation
01-08-2008, 02:33 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.