top of page

Maya Node - dhPointWrangle - Update 001

  • Writer: Dominik Haase
    Dominik Haase
  • Jul 5, 2020
  • 3 min read

Updated: Oct 10, 2023

A few weeks have passed, issues came up and have been solved, more issues came up and I finally solved them as well (thanks to Marco Giordano for helping me out there!), so here we go! The first major update to my dhPointWrangle node for Maya. If you missed part 1, check it out here.

Today's demo is a simple particle goal solver for transform nodes to show some capabilities of simulation as well as a custom IK solver relying on an analytical solving method which is faster than iterative methods. (Also, my IK has no problems with the undo command :p)



The first update is an overall performance increase by a little over 200% by rewriting some of my code. This also came with a few minor downsides but I found the performance increase to be more valuable. Previously, I was converting all incoming MPoints, MFloatPoints, MColors, MFloatVectors and also tuples (Float3s) into MVectors to make working with colors, points and normals easier as MVectors support vector operations. Converting all incoming data into MVectors and converting them back into their specific types took quite a bit of time.

To make up for the 'loss' of functionality, I ended up writing my own vector operations and added them to the MPoint and MColor classes. Therefore, the following operations are perfectly valid (though these examples have no practical use lol):


The second big update is the addition of a couple of new attribute types. For the input attributes, I added 4 plugs for input curves whereas for the output plugs, I added 3 more mesh outputs, 4 float outputs, 4 float3 outputs, 4 curve outputs, 4 matrix outputs and an outputData attribute (more on that later).

Adding multiple attributes comes with the challenge of avoiding the node to compute multiple times. If the node is computationally expensive and has multiple output plugs, I want under all circumstances to avoid the node to compute multiple times. The solution for that is to run a check on each compute() call to check if there is valid and up-to-date data in another plug. The code looks similar to this:

One issue I found with multiple outputs is that if you through them into a compound attribute and the nodes input data is somehow modified by keyframes (eg. transform above a mesh), the node will not compute in parallel evaluation mode. As it does in DG mode, I assume this is not me messing something up, though that's not entirely off the table (:


The third big update, even though it was just a minor thing to implement, is the support to write dynamic solvers. The only thing I added was a variable that allows me to carry data from one evaluation to another. To make my life easier, the variable can be reached through @DATA and is of type dict. Simulating a simple particle with forces might look like this:

You might notice that @Vector is used to get the input gravity and also to output the position. This is because the input and output data listen to the same name. Similar to @P for point data.

Now that I can do simulations, it would be bummer if I couldn't store the caches. Therefore I introduced the output plug outputData. I am using the json module to serialize my @DATA dictionary and output my node internal cache as a string. This data can be read and written out and at any point reapplied.


The minor updates I did include adding more functions such as SETMATRIXELEMENT(matrix, (m,n), value) to set a value at position (m,n) in a matrix, custom vector operations, __str__() methods for MVectors, MPoints, MColors to make print statements for mentioned types readable. I also started implementing a new variable naming convention to avoid clashing names between user-defined and node internal variables.


That's it for my first update, there will definitely be more as I do not have the full functionality I wanted to have yet. It is quite fun to experiment with the node in its current state though as I can write whatever node I can think of inside this node without making new plugins. That speeds up the testing and debugging process quite a bit.

Cheers!

Comments


  • Schwarz LinkedIn Icon
  • Schwarz Vimeo Icon
  • iconfinder_imdb-2048-black_167622_edited
  • Schwarz Instagram Icon
  • Schwarz Facebook Icon
bottom of page