PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
animation_clip_asset.h
1#pragma once
2
3#include "pixelbullet/filesystem/virtual_path.h"
4
5#include "ozz/animation/runtime/animation.h"
6
7#include <memory>
8#include <string_view>
9
10namespace pixelbullet
11{
12class Filesystem;
13
14class AnimationClipAsset
15{
16public:
17 AnimationClipAsset() = default;
18 AnimationClipAsset(AnimationClipAsset&&) noexcept = default;
19 AnimationClipAsset& operator=(AnimationClipAsset&&) noexcept = default;
20
21 AnimationClipAsset(const AnimationClipAsset&) = delete;
22 AnimationClipAsset& operator=(const AnimationClipAsset&) = delete;
23
24 AnimationClipAsset(const Filesystem& filesystem, const VirtualPath& asset_path)
25 {
26 Load(filesystem, asset_path);
27 }
28
29 bool Load(const Filesystem& filesystem, const VirtualPath& asset_path);
30
31 explicit operator bool() const noexcept
32 {
33 return animation_ != nullptr;
34 }
35
36 [[nodiscard]] const VirtualPath& GetFilename() const noexcept
37 {
38 return filename_;
39 }
40
41 [[nodiscard]] const ozz::animation::Animation* GetRuntimeAnimation() const noexcept
42 {
43 return animation_.get();
44 }
45
46 [[nodiscard]] float GetDurationSeconds() const noexcept
47 {
48 return animation_ != nullptr ? animation_->duration() : 0.0f;
49 }
50
51 [[nodiscard]] std::string_view GetClipName() const noexcept
52 {
53 return animation_ != nullptr ? std::string_view(animation_->name()) : std::string_view{};
54 }
55
56private:
57 void Clear() noexcept;
58
59 VirtualPath filename_;
60 std::unique_ptr<ozz::animation::Animation> animation_;
61};
62} // namespace pixelbullet
Definition filesystem.h:19
Definition virtual_path.h:10