Anecoz / AneRend

Prototyping Vulkan engine
16 stars 1 forks source link

Add an Animator interface for application use #19

Closed Anecoz closed 1 year ago

Anecoz commented 1 year ago

As of right now, animations do not really have a clear usage interface for applications.

It would be nice to have an actual Animator to use in applications. I.e. so you could do the following

// In application code:
Animator animator = <get from somewhere>
// animator is now owned by applicatioon

// This needs to propagate all the way to the engine
animator.set(skeletonId, animationId);
animator.setPlaybackMultiplier(0.5f);
animator.play();

// later
animator.stop();

And so on. The question is how to make the application-level Animator state propagate all the way to the engine. Maybe it would be the cleanest to add Animators to AssetUpdate? Added, updated and deleted animators. The objects themselves should be very thin and just hold some state, so it should be ok to copy them into an assetUpdate call.

So, something like this:

render::anim::Animator animator{};
animator.set(skeletonId, animationId);
animator.setPlaybackMultiplier(0.5f);
animator.play();

render::AssetUpdate upd{};
upd._addedAnimators.emplace_back(animator);
renderer.assetUpdate(std::move(upd));
Anecoz commented 1 year ago

Solved through use of the AssetUpdate, much like the rest of all assets.