Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
AnimationSystem.cpp
Go to the documentation of this file.
1
2
4
6
7namespace Divide {
10 ECSSystem(parentEngine)
11 {
12 }
13
15 {
17
19
21 {
22 if (comp->animationIndex() == U32_MAX)
23 {
24 comp->playAnimation(0);
25 }
26
27 comp->_parentTimeStamp += comp->playAnimations() ? dt * comp->animationSpeed() : 0.0;
28 }
29 }
30
32 {
34
36
38 {
39 const SceneAnimator* animator = comp->animator();
40
41 if (!animator || COMPARE(comp->_parentTimeStamp, comp->_currentTimeStamp))
42 {
43 return;
44 }
45
46 comp->_currentTimeStamp = comp->_parentTimeStamp;
47 const D64 timeStampS = Time::MillisecondsToSeconds<D64>(comp->_currentTimeStamp);
48
49 if (comp->playAnimations())
50 {
51 // Update Animations
52 comp->_frameIndex = animator->frameIndexForTimeStamp(comp->animationIndex(), timeStampS);
53
54 if (comp->animationIndex() != comp->previousAnimationIndex() && comp->animationIndex() != U32_MAX)
55 {
56 comp->previousAnimationIndex(comp->animationIndex());
57 }
58 }
59
60 // Resolve IK
61 //if (comp->_resolveIK)
62 //{
64 //}
65
66 // Resolve ragdoll
67 // if (comp->_resolveRagdoll)
68 //{
71 //}
72 }
73 }
74
76 {
78 for (AnimationComponent* const comp : _componentCache)
79 {
80 if (comp->frameTicked())
81 {
82 comp->parentSGN()->SendEvent(
84 {
86 ._sourceCmp = comp
87 }
88 );
89 }
90 }
91 }
92
94 {
95 if (Parent::saveCache(sgn, outputBuffer))
96 {
98 if (aComp != nullptr && !aComp->saveCache(outputBuffer))
99 {
100 return false;
101 }
102
103 return true;
104 }
105
106 return false;
107 }
108
110 {
111 if (Parent::loadCache(sgn, inputBuffer))
112 {
114 if (aComp != nullptr && !aComp->loadCache(inputBuffer))
115 {
116 return false;
117 }
118 return true;
119 }
120
121 return false;
122 }
123
124 void AnimationSystem::toggleAnimationState(const bool state) noexcept
125 {
127 }
128
130 {
132 }
133
134}//namespace Divide
#define PROFILE_SCOPE_AUTO(CATEGORY)
Definition: Profiler.h:87
static bool GlobalAnimationState() noexcept
bool saveCache(const SceneGraphNode *sgn, ByteBuffer &outputBuffer) override
AnimationSystem(ECS::ECSEngine &parentEngine, PlatformContext &context)
void PostUpdate(F32 dt) override
void Update(F32 dt) override
void toggleAnimationState(bool state) noexcept
bool loadCache(SceneGraphNode *sgn, ByteBuffer &inputBuffer) override
void PreUpdate(F32 dt) override
bool getAnimationState() const noexcept
virtual bool saveCache(const SceneGraphNode *sgn, ByteBuffer &outputBuffer)
Definition: ECSSystem.inl:50
virtual bool loadCache(SceneGraphNode *sgn, ByteBuffer &inputBuffer)
Definition: ECSSystem.inl:57
vector< AnimationComponent * > _componentCache
Definition: ECSSystem.h:92
AnimEvaluator::FrameIndex frameIndexForTimeStamp(const U32 animationIndex, const D64 dt) const
T * GetComponent() const
Definition: IEntity.h:54
constexpr Optick::Category::Type Scene
Definition: Profiler.h:66
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
constexpr U32 U32_MAX
double D64
bool COMPARE(T X, U Y) noexcept