//
// Created by martin on 12.11.21.
//

#ifndef ANIMTESTBED_ANIMATIONCONTROLLER_H
#define ANIMTESTBED_ANIMATIONCONTROLLER_H

#include <ozz/animation/runtime/animation.h>
#include <ozz/animation/runtime/sampling_job.h>
#include <ozz/base/containers/vector.h>
#include <ozz/base/maths/soa_transform.h>
#include <ozz/base/maths/vec_float.h>

struct SkinnedMesh;
struct AnimNode;

struct AnimationController {
  explicit AnimationController(SkinnedMesh* skinned_mesh);
  virtual ~AnimationController();

  void SetBlendAnims(
      ozz::animation::Animation* blend_anim_A,
      ozz::animation::Animation* blend_anim_B) {
  }
  void ResetAnims();

  void Update(float dt);
  void Evaluate();

  void DrawDebugUi();

  float m_current_time;

  ozz::vector<ozz::math::SoaTransform> m_local_matrices;
  ozz::vector<ozz::math::SoaTransform> m_local_matrices_blended;

  ozz::animation::SamplingCache m_sampling_cache_A;

  SkinnedMesh* m_skinned_mesh = nullptr;

  AnimNode* m_output_node;

  std::vector<AnimNode*> m_anim_nodes;
  std::vector<AnimNode*> m_ordered_nodes;
};

#endif  //ANIMTESTBED_ANIMATIONCONTROLLER_H
