If multiple splines are branching off the same output pin of a function, is the function recalculated for each branch or do they simply refer to an implicity stored local variable?
I know that for functions that have an exec pin, having multiple branches off of an output pin does not recalculate the function (for example, having multiple branches off of the hit result of a line trace won't run the trace multiple times). On the other hand, functions that do not have exec pins but have a non-deterministic output based on the input will re-run the function again (for example, if you have two branches coming off of GetActorLocation, but SetActorLocation is called before the second branch is used, then sensibly each branch will return a different value). What I want to know is if a function does not have an exec pin but its output is deterministic based on its input (adding the same two vectors will always yield the same result), will it follow the first behavior type or the second?
The reason for this question is that my current project contains many complex vector calculations that are done every tick, in which I have many instances of multiple splines branching off of the same output pins and have realized that if the functions are recalculated for every branch then many unnecessary calculations are occurring. This situation is very solvable with the implementation of local variables, but I want to know if it is necessary because refactoring most of my current blueprints will take a while.
(In case its not clear, whenever I talk about branching, I am referring to pulling multiple splines off the same (non-exec) output pin, rather than the "Branch" flow control node)
Few times I have checked source files after packaging with enabled blueprint nativization, and result of every function is always stored in some variable, so yes, function called once and result used for all further calculations.
You can check it by yourself. Enable blueprint nativization in project settings and package it. Source files will be located in Intermediate folder.
answered Dec 15 '18 at 06:27 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here