A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
AnmObj.hh
Go to the documentation of this file.
1#pragma once
2
3#include <Common.hh>
4
5// Credit: kiwi515/ogws
6
7namespace Kinoko::Abstract::g3d {
8
9enum class AnmPolicy : u32 {
11 Loop = 1,
12 Max = 2,
13};
14
15[[nodiscard]] f32 PlayPolicy_Onetime(f32 start, f32 end, f32 frame);
16[[nodiscard]] f32 PlayPolicy_Loop(f32 start, f32 end, f32 frame);
17
18typedef f32 (*PlayPolicyFunc)(f32 start, f32 end, f32 frame);
19
20[[nodiscard]] inline PlayPolicyFunc GetAnmPlayPolicy(AnmPolicy policy) {
21 constexpr size_t count = static_cast<size_t>(AnmPolicy::Max);
22 static constexpr PlayPolicyFunc POLICY_TABLE[count] = {
25 };
26
27 size_t idx = static_cast<size_t>(policy);
28 ASSERT(idx < count);
29 return POLICY_TABLE[idx];
30}
31
32class FrameCtrl {
33 friend class Host::Context;
34
35public:
36 FrameCtrl(f32 start, f32 end, PlayPolicyFunc policy)
37 : m_frame(0.0f), m_updateRate(1.0f), m_startFrame(start), m_endFrame(end),
38 m_playPolicy(policy) {
40 }
41
45
47 [[nodiscard]] f32 frame() const {
48 return m_frame;
49 }
50
51 [[nodiscard]] f32 rate() const {
52 return m_updateRate;
53 }
54
55 [[nodiscard]] PlayPolicyFunc playPolicy() const {
56 return m_playPolicy;
57 }
58
59
64
67 }
68
70 ASSERT(func);
71 m_playPolicy = func;
72 }
73
74
75private:
81
83};
84
85} // namespace Kinoko::Abstract::g3d
This header houses common data types such as our integral types and enums.
#define ASSERT(e)
Definition Logger.hh:25
PlayPolicyFunc playPolicy() const
Definition AnmObj.hh:55
void setPlayPolicy(PlayPolicyFunc func)
Definition AnmObj.hh:69
FrameCtrl(f32 start, f32 end, PlayPolicyFunc policy)
Definition AnmObj.hh:36
Contexts can be used to restore a previous memory state for the current session.
Definition Context.hh:71
f32(*) PlayPolicyFunc(f32 start, f32 end, f32 frame)
Definition AnmObj.hh:18
f32 PlayPolicy_Onetime(f32, f32, f32 frame)
Definition AnmObj.cc:8
f32 PlayPolicy_Loop(f32 start, f32 end, f32 frame)
Definition AnmObj.cc:13
PlayPolicyFunc GetAnmPlayPolicy(AnmPolicy policy)
Definition AnmObj.hh:20
float f32
Definition Memory.hh:21
uint32_t u32
Definition Memory.hh:18