# Optimizing a Shortest Walk Animation

Hello dear community, can someone please shed some light as I am a prisoner of my own limited understanding. I am creating a coral growth animation by using Daniel Piker’s shortest walk component combined with a plethora of recursive strategies, so far so good. I landed on multipipe because it gets me a bare minimum for what I need, I managed to get a visually better result with dendro and volume points but it is woefully slow due to the amount of duplicate points. Can someone pleeease have a look at the definition and kindly suggest ways I can improve its efficiency? Eventually I’d like to successfully animate much larger clusters of coral. I can also foresee other applications for different projects.

I have been trying for the last three days to cull redundant geometry to minimize computation (there is A LOT of duplicates), my strategy has been to compute the longest path for each coral (4 in this file) sort all the paths by length, and the recursively remove duplicates by testing the longest against the second longest path, add the two together then test them against the third, and so on… to obtain a sequence of all the longest paths while removing duplicates. I have been failing miserably.

Any help or insight would be very much appreciated! Surely there would be a fantastic way to do this in python or C# (I am learning as we speak but it’s a steep learning curve) unfortunately my knowledge is very limited, therefor an optimization within GH which I could fully understand and perhaps learn a thing or two from would be my preference, please.

Cheers
230222_Animated Coral Growth_V01 Multipipe.gh (49.7 KB)
230222_Animated Coral Growth_V02 Dendro.gh (47.3 KB)

Would you be able to post a picture of what the effect is? and where it starts to get slow which is where Im assuming you are having ussues? Im unsure of what the other mystery plug in is besides dendro. Are you trying to animate the whole process or just the final curve? Ie to show the final path slowly growing, or are you trying to show the whole thing growing.

Hi Alex, here is an animation from keyframes (not realtime)

What I’m asking is for ways of removing duplicates for a few reasons: reduce computation, identify longest sequences on shortest walks while avoiding duplicates (I am using the SW algorithm on a separate project where eventually I will assign objects to said points, I need to maintain sequencing and avoid duplicates) and last and not least to advance my knowledge and understanding of data manipulation and working with complex trees.

Cheers

Ah further to your question, I am computing the walk first and then animating the growth and thickening afterwards - an “abstraction” rather than a true simulation

Thanks for the video, that helped alot and Im understanding that you are trying to do this simulation, output the group of curves, and then pass them into another that does the ‘simulation’ of them growing but trimming them based on length?. So I think your issue isnt in these two scripts you posted, but in how you are generating the ‘tree thing’. Are you growing it with anemone?. Would you be able to post that script?

A funny thing about these simulation animations, and done in other programs like hudini, is you can solve them backwards and then animate backwards, so instead of going from 4 points to 20 points, you solve 20 points to 4 points, this will give you a set of 20 curves which you can flip (so the base of each is at one of the 4 points) and then trim them based on length that way. I would then flatten everything and sort duplicate curves with lunchbox, and then pass that into Dendro.

1 Like

Thank you Alex, what you are suggesting sounds really interesting and I will definitely try it. However, the thing I am most interested in is the data tree manipulation aspect. Here is the file, also included at the start of this post, where you will also find the “multipipe” version.

cheers

Ooooo I think I just got what you meant, what a clever solution! It’s bloody perfect for what Im trying to do

1 Like

Awesome! Glad you were able to figure something out! Let me know if you get stuck and I’ll take a look at the rest of your process and see if can help.

Hi Alex, I would appreciate the help actually, if possible, could you please implement what you described on the definition I shared? It would be a great learning opportunity.

Cheers

Hello
your definitions is not very good, I had to kill the process.
Instead of anemone it could be better you have a slider, say it is for the time. It will control the growth. I just did it here in order to make a gif.

The only thing to do is to use the animate command of the slider to make images.

The other trick you could use is to not draw radiuses that are less than a threshold.

Giulio Piacentino made the shortest walk component, not me.

My apologies to both of you I will amend!

Hello Laurent, yes I am painfully aware it could be better It has been crashing my machine repeatedly. The animation aspect has definitely raised the bar… I am using this as an opportunity to advance my understanding of data tree manipulation. Also, I have used the sliders for outputting diagrams before as well, however in this case I will need the geometry eventually.
Thank you for all your contributions on the topic of coral modelling, your work is stunning and has been inspirational!

Here a way to get the geometry.
I took one of my script, but it is the same on yours.
So make a slider to pilot the growth.
Plug Data Recorder component after the mesh output component of Dendro
The click right click to animate

Choose the frame count (number of images)

You have now all the geometries in data recorder

Thank you Laurent! Out of curiosity, is a slider radically different from a loop that outputs a number sequence? I haven’t used the data recorder before, thank you for the tip, looks like it will come useful for a lot of things! Cheers

For the output there are no differences. A loop will trigger the calculation of many simulations. You will have some more challenges to control the output of a slider when using animate but the math are simple. Here a slider between 0 and 1 with 10 frames and 11 results

(1-0)/10 = 0.1 = steps.
If slider is with integers the steps are not regular due to the division process and transformation to double to int.

The data recorder is amazing, where has it been all my life. May I ask why are you saying that I should replace the anemone sections with animated sliders if they are the same? I might be missing something

Are you referring to the Dendro remapped values for the volume points? As in check my ranges to make sure they don’t fall out of the thresholds?

I just found useless (summation of 1) and painful here as it triggers all the calculations and it is not easy to stop. You could make summation using series, mass addition and have a list of values that could be then selected with a List Item.

Anemone is more often use for more complex loop (cutting objects, true recursion like a fractal …).

1 Like

Yes you could check radiuses and if there are less than a certain radius not draw them.
I say that because I have some tools which calculate the radiuses of branches. Or you specify radiuses at the end of branch that are all the sames, or you specify the radius of root. In all calculation you have