Skeleton fattener + mesh cage morph

MVC.gh (2.2 MB)

Hello All

Thought ill drop an optimized version of what the man the myth the legend Daniel has created.
18ms compared to sometimes mins!!

As far as I can go with c#, switched out the heavy functions (weights) for SIMD accelerated operations, Ops like subtraction, scaling, normalization, cross product, and dot product are now single method calls that leverage hardware acceleration heap.

Also cashing design weights this results in all subsequent deforms to be lightning fast. so semi manual operation moving the cage on large meshes now become easy work.
This works on mesh but have other code that works on points, from there you can move any geometry.

Code is Open and free free to play around with it.
Each one teach one.

Hi Peter,

As I already explained to you when you showed me this before - you’re only seeing dramatic speed differences by comparing it to using Mesh Cage Morph in the wrong way.

When using it correctly, even the not particularly optimised version of what I first posted back in 2018 is comparable in performance what you’ve shared here - differences on the order of a few milliseconds, not orders of magnitude like you’re claiming. The new version in the WIP is faster (and works with multiple geometry types, and when the inputs use data trees, but more on that later).

To clarify what is going on - at some point after sharing the original MCM component, someone asked about a version that would also work on Breps.

When applying any sort of morph to NURBS geometry which can include trimmed faces, it gets more complicated than simply morphing each individual control point as we can for simple types like meshes, because if we did this, the trimmed parts would no longer match up along the seams and the Brep breaks.

Deformations in Rhino (such as Twist, Bend etc) make use of something called ‘Universal Deformation Technology’ (UDT), which performs an iterative fitting process as part of the deformation, adding new control points when needed.

So the version MCM2 I shared later was making use of this UDT, to allow it to work on Breps. However, this process is relatively costly, and because the control point can change during the process, the weightings cannot be cached. Therefore this version is not suitable for use with very large meshes, where the original version is orders of magnitude faster (for simple geometry with hundreds of control points, it doesn’t matter as performance is unlikely to be an issue here).

You also need to make sure you are using the W input for ‘Calculate Weightings’ correctly when looking at speed. When either the thing being morphed or the reference cage changes, weightings need to be recalculated. When applying the deformation with a different or changing target cage, the already calculated weightings can be reused, so W should be set to false. It makes sense to use a button input here rather than a toggle, to avoid accidentally leaving it on and recalculating when not needed.

In the Rhino WIP there is now a component included in Grasshopper which switches between these 2 approaches, so it will use the faster method with caching for types such as Meshes, Subds and PointClouds, while also working with Breps (which will always be slower than for meshes, but now with an adjustable tolerance for the fitting, which can make it faster than before). It also works when the input is a list or tree of items, which required a slightly different approach to the caching.

This has actually in been in for a while, but we’ll be making a proper post about it soon.

There’s also an experimental component in there, dedicated to morphing only meshes when performance is important, using multithreaded C++.

W toggle, Left this out, mainy my scripts never have human interaction so the W is a bottleneck for full automation on instances, why your MCM2 was a great short term solution.

The dino model here isnt that heavy (in mesh vertex weight) so even a small change in speed with larger models really helps a LOT.

Pulled up the two MCM types here for speed comparison, (mcm2 being the desired verion for headless)
Maybe mine its not done correctly and could be even more optimized but for me even judging in the “wrong way” the results work faster for daily tasks.
Even for mcm with the w toggle on ten branches into T value it takes a long time 20secs to compute then mentions 290ms.
Mainly most of my work is for AM and mesh related so this little tool helps, wanted to post here not to be contentious but to help others (large sub set of users) that are working with large / heavy meshes.

Also as a feature request for the future, looking forward to whats being worked on at McNeel. Hopefully there will be a version with no W toggle for the weirdos like me who want to automate production and eradicate human comp design ego bottlenecks.

Add “Compute” for correct visualization of the mesh.

Gnew.FaceNormals.ComputeFaceNormals();
Gnew.Normals.ComputeNormals();

Hi @DanielPiker thank you for a fab component.

I have a question about the design of the cage. Is it okay in the demo that the dino mesh and the cage intersect?

I ask because the following quote is from, An automated method for generating customizable cages using barycentric coordinates by Ákos Tóth, Roland Kunkli (2018) https://publikacio.uni-eszterhazy.hu/2471/1/AMI_49_from167to180.pdf.

"The cage has to be closed and surround the model to be deformed, without any intersection." (Top of page 168)

and from Interactive Cage Generation for Mesh Deformation by Binh Huy Le & Zhigang Deng

"A high-quality cage for mesh deformation… needs to fully and often tightly bound the enveloped model."

Something like this:

Maybe:

  • Yes. Those papers don’t quite apply here. or
  • Yes, it’s not ideal, but it’s ok, we can get away with it. or
  • Yes, but make sure all the points of the cage are outside the mesh. or
  • No, it’s not best practice; this is an alpha prototype demo, and it’s good enough for a demo.

It turns out cage design is a huge topic, and it’s sent me down a rabbit hole of research.

Thanks again,

Drew

(And, hi Pete :waving_hand: )