@antoine-unity Got two questions regarding optimizations, if you could help me out.
First about UsageHints, the documentation says that you shuld not be able to change them after a VE is added to a panel:
This property can only be set when the VisualElement is not yet part of a Panel. Once part of a Panel, this property becomes effectively read-only, and attempts to change it will throw an exception.
However this does not appear to be the case. If I delay the start of my graph to after the panel is initialized / rendered, and set usageHints on the visual elements it’s animating (in OnGraphStart), I don’t get any errors.
Does this mean that setting usageHints after an element is part of a panel doesn’t work and the error just isn’t showing up properly, or that you can set usageHints after an element is added, and the documentation is incorrect?
Second questions is, is there any performance downside in setting style values on every frame, even if the value doesn’t change? I’m wondering if I should check if the value changes from what’s currently set on the element, before setting it, or if visual elements do that internally. The more style values I support the bigger the problem gets. Currently I just set everything on every frame, even if you don’t have that specific clip in your track, but that will need to change sooner rather than later, especially as I start adding support for more styles.
For transform specifically, I can see that, e.g. VisualElement.transform.position is basically just a shortcut for style.translate:
this.style.translate = (StyleTranslate) new Translate((Length) value.x, (Length) value.y, value.z);
I can improve my mixer there so that I set style.translate directly instead of going via transform.position, for example, and create / reuse the Translate struct myself. But even with that, if I set the same Translate struct without any changes to its values on every frame, is that bad?