Coder Social home page Coder Social logo

hai-vr / av3-animator-as-code Goto Github PK

View Code? Open in Web Editor NEW
181.0 181.0 14.0 346 KB

Generate animator layers and animations from a fluent builder syntax. Initially designed for use in VRChat, this is now a generic package that does not require it.

Home Page: https://docs.hai-vr.dev/docs/products/animator-as-code

License: MIT License

C# 100.00%

av3-animator-as-code's Introduction

av3-animator-as-code's People

Contributors

bdunderscore avatar galister avatar hai-vr avatar suzuryg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

av3-animator-as-code's Issues

Calling Or() on a TransitionsFromEntry() fails with an exception

var mainSubStateMachine = layer.NewSubStateMachine("Main");
mainSubStateMachine.Restarts();

var state = mainSubStateMachine.NewState("S1");

state.TransitionsFromEntry()
    .When(rightTrackPadParamBool.IsFalse())
    .Or()
    .When(rightAButtonParamBool.IsTrue());

InvalidOperationException: _sourceNullableIfAny is not null but does not contain an AnimatorStateMachine

Reported on: https://discord.com/channels/923123027879813150/946570418892988457/1205619208822591579

Please add support for copying a parameter

Currently there's a state .Drives idiom, but there's no way to drive a parameter to be a copy of another currently. This would be handy to have in a gimmick I'm currently developing; I think I can work around it by manually constructing the parameter driver, but it'd be nice not to have to do so.

Animator introspection functionnality

Many of the functionality in AAC is bound to the active animator sublayer created within it, but some may be reaching out to other layers or outside the animator:

  • Getting the layer index for sub-layer blending behaviours
  • Reordering layers
  • Removing unused parameters
  • Creating an avatar mask for the base Gesture layer
  • Creating an avatar mask for FX sub-layers

Some of these operations require introspecting the entire animator's state machine and animations, which can be expensive depending on the size of the animator.

There may be a need to expose a dedicated API in AAC that is specialized in animator introspection.

Add RemoveParameters

There is RemoveAllMainLayers() and RemoveAllSupportingLayers(string suffix) but, no method to remove parameter.
I can understand that there is danger of removing parameter used by layers that were added by hand, but I don't think removing the parameters that are not used by the Animator Controller would do much harm.

Speed issue (oninvalidateanimatorcontroller)

im noticing the main reason large animators take a while to generate, is every single operation that is called seems to invoke AnimatorControllerCallback.OnInvalidateAnimatorController()

if there was a way to avoid this invoke till we are done completely editing the graph, then call it do do it all at once, I think itd singificantly speed up large graph generation. Right now im working on a project where this is 50% of the profiled time, and it is called over 21039 times

Sometimes animator states get named "\x01"

This is probably a unity bug: When a state name is passed in to unity's StateMachine.NewState, sometimes it's ignored and the state is given the name "\x01" instead. This could be worked around in AAC (I'll probably put together a PR later)

Let the user instantiate custom assets inside a container

Let the user instantiate custom assets inside a container.

This can let the user generate assets of their own that will be cleaned on every generation.

Example:

MeshRenderer mr;

Material modifiedAsset = aac.CopyAsset(mr.materials[0]);
modifiedAsset.SetColor("_Color", Color.green);

aac.NewClip().SwappingMaterial(mr, 0, modifiedAsset);

BlendTree builder

Something along these lines:

aac.NewBlendTree() // AacFlUnconstructedBlendTree
    .Cartesian(fx.FloatParameter("X"), fx.FloatParameter("Y")) // AacFlBlendTree2D : AacFlBlendTree
    .Blending(blend -> { // AacFlEditBlendTree2D
        blend.At(0f, 0f).WithAnimation(aac.NewBlendTree()/*...*/);
    });

[Enhancement] Allow taking arbitrary boolean expressions

From this limitation, conditions with nested OR cannot be expressed easily, such as:

  • ๐Ÿšซ (F && (G || H) && (J || K))

As I understand it, state transitions naturally follow/allow for Sum Of Products boolean expressions. (each transition contains a number of ANDs between different conditions, and then you can OR the result of each transition together). Since any boolean expression can be rewritten into a Sum Of Products (SOP) form, we should be able to take any expression, rewrite it in SOP form, then generate the transitions accordingly.

Finding a SOP expression given an arbitrary expression shouldn't be too difficult, i think. Finding the optimal SOP expression is likely out of scope.

Keep track of created states

Keeping track of created state to clean them afterwards is tedious, so why not make AacFlBase keep track of them?
Having mutable state in AacFlBase class might have some consequences of unintuitive behavior, so this feature might need some discussion.

Storing AnimatorControllers in a non-persistent asset container is problematic

Storing AnimatorControllers in an asset container is problematic:

  • Non-animator controllers should continue to be added to the asset container, regardless of whether it is persistent
  • Animator controller should be able to be added to a persistent asset container, or be created individually as garbage asset otherwise

Reconsider the use of `void` returning functions

Some functions return void.

  • For some of them, it can be argued that returning void marks the effective consumption of what precedes it (i.e. AacFlSettingCurve).
  • For others, it may be justified to continue allow chaining.

Reconsider the use of void returning functions for cases where chaining could be justified.

[Issue]: Too many Assets in a single Container

https://github.com/hai-vr/av3-animator-as-code/blob/main/Framework/Editor/V0/Aac.cs#L33
https://github.com/hai-vr/av3-animator-as-code/blob/main/Framework/Editor/V0/Aac.cs#L42
https://github.com/hai-vr/av3-animator-as-code/blob/main/Framework/Editor/V0/Aac.cs#L238

There appears to be only a certain amount of assets that can be packed into 1 another.
Somewhere around the neighborhood of 20+ assets.
When there is too many assets in a container the engine starts culling them out by destroying them thereby breaking the setup.

A workaround to this is manually creating the assets in a folder on their own rather than containerizing them.
When I started doing this for AnimationClip creation everything worked properly once again.

An idea for a solution would be doing a size comparison and splitting the 1 container into multiple containers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.