Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Data flow between custom nodes (Maya API)

Data flow between custom nodes (Maya API)

danilopeixoto8
Contributor Contributor
729 Views
1 Reply
Message 1 of 2

Data flow between custom nodes (Maya API)

danilopeixoto8
Contributor
Contributor

Hi,

 

Is the only way to ensure a large data flow between custom nodes is passing it by copy? Not expensive for memory? How does Maya manage that (i.e., data precomputation "node 1" and data processing "node 2")?

 

Thanks.

0 Likes
Accepted solutions (1)
730 Views
1 Reply
Reply (1)
Message 2 of 2

kevin.picott
Alumni
Alumni
Accepted solution

Internally Maya uses a data management system that works somewhat like copy-on-write. When data is passed through a connection or extracted from a datablock the owner has a handle to it (like MFnData objects in the API world) on which they declare themselves to be readers or writers. Typically anything extracted from MDataBlock::inputValue will want to be read and anything being put in through MDataBlock::outputValue will want to be written.

 

In the default case in a chain of N operations on the same large object there will be N-1 copies of the original made. e.g. for the two operation chain A -> B -> Mesh there will be the original mesh on the input of A, A(original) on both the output of A and input of B, and A(B(original)) on the output of B and input of C.

 

There's also an internal optimization in the case of deformer chains that makes only one extra copy in an arbitrary length chain. One for the original undeformed object and one for the final object with the entire chain applied to it. It does this by immediately relinquishing writer status on the output of the deformer chain after it has computed the result, something which is unfortunately not available through the API. The nearest equivalent is to call MFnAttribute::setCached(false) on the output attributes so that the Maya internals will release the writer status when the value is returned to the datablock.



Kevin "Father of the DG" Picott

Senior Principal Engineer