In the Value Processor and FX-Map, after using While Loop and Distance_vec2 for cumulative calculations, addition, subtraction, multiplication, and division produce incorrect results.
Thank you for reaching out, as well as providing files for assessing the problem accurately.
The use of Random nodes in the loops means each will provide a different result, which is expected.
If you need to produce 4 random values then use them in the loops, and those values should remain constant, then you may store them in a variable before executing the loops – the 'before' is ensured by using a Sequence node. Then, retrieve that variable in both loops:
Also, I do not recommend using the same variables in both loops with no Sequence node to control when these variables should be used and reset.
In other words, you have two loops which both initialize i and l variables to 0 then update them on every iteration. However you cannot be sure about when these loops will be computed. The Sequence node is there to provide that control over flow and order or computations.
To illustrate my point, I have modified the function in two different ways so we can compare the results:
Each loop use different variables;
Each loop use the same variables, but a Sequence node makes sure one is entirely computed before the other.
Both methods provide the same result for the same random seeds:
I hope this is helpful!
Best regards.
Luca Giarrizzo | Quality Engineer, 3D & Immersive | Adobe
Apologies, using the Random node is not my actual intention. My real need is to calculate the length differences between different segments of a curve. I am using a While loop and Distance_vec2 for cumulative length calculations along the curve. When performing addition, subtraction, multiplication, and division on the cumulative results, incorrect outcomes occur. If you need the original project, I can send it to you via email.
I used the method you provided, setting the values as variables using the 'set' node and performing addition, subtraction, multiplication, and division operations with the 'sequence' node in the 'last' input. As a result, the correct outcome is displayed in the 'Value Processor' node, but the calculations in the FX Map are still incorrect.
I have sent my project to you via private message.
I attempted to send the project file to you via private message, but I couldn't find where to attach the file. So, I uploaded the project to Google Drive. Please retrieve it from there.