-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAnimatorSystem.cpp
More file actions
68 lines (59 loc) · 2.52 KB
/
Copy pathAnimatorSystem.cpp
File metadata and controls
68 lines (59 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "AnimatorSystem.h"
#include "LifecycleTrace.h"
#include "Animator.h"
#include "AnimationController.h"
#include "ConditionParameter.h"
#include "Entity.h"
#include <algorithm>
void AnimatorSystem::Register(Animator* animator)
{
if (nullptr == animator) return;
if (std::ranges::find(m_animators, animator) != m_animators.end()) return;
m_animators.push_back(animator);
}
void AnimatorSystem::Unregister(Animator* animator)
{
if (nullptr == animator) return;
// swap-and-pop — SystemSchedule_Internal::RemoveFromList과 같은 규약
// (같은 축의 여러 리스트에 걸쳐 있지 않은 단일 조밀 벡터라 순서 보존은
// 애초에 불필요하고, erase는 O(n) 시프트라 씬 전환마다 비용이 쌓인다).
for (size_t i = 0; i < m_animators.size(); ++i)
{
if (m_animators[i] != animator) continue;
m_animators[i] = m_animators.back();
m_animators.pop_back();
return;
}
}
void AnimatorSystem::Update(float tick)
{
// 옛 Scene::RegistryTick이 공통으로 해주던 가드(owner 없음/파괴 표시/
// 비활성 스킵)를 이 시스템이 대신 적용한다 — Animator가 더 이상
// m_schedule.UpdateList()를 거치지 않으므로 그 가드도 함께 옮겨왔다.
for (Animator* animator : m_animators)
{
if (nullptr == animator) continue;
Entity* owner = animator->GetOwner();
if (nullptr == owner || owner->IsDestroyMark()) continue;
if (!animator->IsEnabled()) continue;
// C3 — 틱이 시스템으로 옮겨오면서 생명주기 트레이스의 발생지도 함께 옮긴다.
// 안 남기면 이관할수록 기준선의 커버리지가 조용히 준다(같은 문자열을 써야
// 대조가 성립하므로 Lifecycle::Trace::TypeNameOf 공용 함수를 쓴다).
LIFECYCLE_TRACE(Lifecycle::Phase::Update, Lifecycle::Trace::TypeNameOf(animator),
owner->m_name.ToString().c_str(), animator->GetInstanceID());
// ── 이하 옛 Animator::Update 본문 그대로(트랙 C3 이관) ──
if (animator->m_animationControllers.empty()) continue;
for (auto& animationController : animator->m_animationControllers)
{
animationController->Update(tick);
}
std::unique_lock lock(animator->m_paramMutex);
for (auto& param : animator->Parameters)
{
if (param->vType == ValueType::Trigger)
{
param->ResetTrigger();
}
}
}
}