ContinuouslyChanging

From Resonite Wiki

ContinuouslyChanging is an attribute applied to ProtoFlux nodes (or outputs to said node) that forces evaluation of any connected listener nodes every update.

Listener nodes are nodes that listen for changes of any kind in the node group it's connected to, updating their state when such changes are made. As of the time of writing, the only listener nodes in a ProtoFlux ExecutionContext are drives and displays.

Usually, listener nodes only evaluate the node chain every time they register a change propagated from an input. These changes are either captured from the Data Model's own change handler (such as when one directly changes a field in an inspector) or by forcibly changing the nodes in the node group (such as by adding a new node). However, when any node in the node group connected to the listener is marked as ContinuouslyChanging, the listener will forcibly update all inputs every update.

Inspecting a ProtoFlux node in an inspector will provide more information on what nodes are being evaluated every update. Listener nodes will be marked with ContinuouslyChanging: True in the inspector to indicate that it is evaluating its input every update. If the Group that any given node is part of has ContinuousChanges set to True, then that node is being evaluated every update.

Not all listener nodes in a chain will be marked ContinuouslyChanging, even if the entire node group is being evaluated from another listener node. See the example to the right.

In this example, a Continuously Changing Relay is connected to one root slot, getting its name, and plugged into an Add node with a Find Child By Name. The string display is flagged as ContinuouslyChanging due to being a listener of a node with the ContinuouslyChanging attribute. Because of this, the Find Child By Name node is evaluated every frame, even if its output itself is not being plugged into its own ContinuouslyChanging node. Additionally, despite the node chain being evaluated every frame, the slot display will not be evaluated every frame, and is not marked ContinuouslyChanging

Practical Usage

The existence of ContinuouslyChanging nodes is generally not necessary knowledge to excel at ProtoFlux (as a Core Concept). However, there are a few cases where knowing its existence can be useful:

  • Node groups that are not marked with ContinuousChanges can be forced into such by using a Continuously Changing Relay node. This is only useful in niche cases where the output of a non-ContinuouslyChanging node can be changed irrespective of its inputs, such as a Find Child By Name node, or if the node exists outside of the data model, such as a Store node.
  • Because a single ContinuouslyChanging node forces the entire node group to evaluate every frame, it can cause innocent-looking code to cause major performance loss in certain contexts.
    • One nasty example might be a large Find Child By Name being combined into a Get Forward node. Because Get Forward is marked as ContinuouslyChanging, it will force the Find Child By Name to evaluate every update, which can exceptionally hurt framerate. A way to avoid this frame loss would be writing the result of the Find Child By Name into a Store whenever necessary.