MCPcopy Create free account
hub / github.com/Illation/ETEngine / Process

Method Process

Projects/Demo/source/Runtime/LightControlSystem.cpp:27–91  ·  view source on GitHub ↗

------------------------------ LightControlSystem::Process

Source from the content-addressed store, hash-verified

25// LightControlSystem::Process
26//
27void LightControlSystem::Process(fw::ComponentRange<LightControlSystemView>& range)
28{
29 // common vars
30 core::InputManager* const input = core::InputManager::GetInstance();
31 float const dt = core::ContextManager::GetInstance()->GetActiveContext()->time->DeltaTime();
32
33 // since input is likely to be rarer than the entity count in the range, we check it once and iterate multiple times
34
35 // move about
36 if (input->GetKeyState(E_KbdKey::KP_2) == E_KeyState::Down)
37 {
38 for (LightControlSystemView& view : range)
39 {
40 view.transf->Rotate(quat(vec3(1.f, 0.f, 0.f), dt));
41 }
42 }
43
44 if (input->GetKeyState(E_KbdKey::KP_8) == E_KeyState::Down)
45 {
46 for (LightControlSystemView& view : range)
47 {
48 view.transf->Rotate(quat(vec3(1.f, 0.f, 0.f), -dt));
49 }
50 }
51
52 if (input->GetKeyState(E_KbdKey::KP_4) == E_KeyState::Down)
53 {
54 for (LightControlSystemView& view : range)
55 {
56 view.transf->Rotate(quat(vec3(0.f, 1.f, 0.f), dt));
57 }
58 }
59
60 if (input->GetKeyState(E_KbdKey::KP_6) == E_KeyState::Down)
61 {
62 for (LightControlSystemView& view : range)
63 {
64 view.transf->Rotate(quat(vec3(0.f, 1.f, 0.f), -dt));
65 }
66 }
67
68 // #note: this could be optimized by splitting this system in two: one updates the transform and the other the brightness
69 // Change light settings
70 if (input->GetKeyState(E_KbdKey::KP_3) == E_KeyState::Down)
71 {
72 for (LightControlSystemView& view : range)
73 {
74 float const b = view.light->GetBrightness();
75 float const nB = b * 4.f;
76 view.light->SetBrightness(b - (nB - b) * dt);
77 LOG("Linear: " + std::to_string(view.light->GetBrightness()));
78 }
79 }
80
81 if (input->GetKeyState(E_KbdKey::KP_9) == E_KeyState::Down)
82 {
83 for (LightControlSystemView& view : range)
84 {

Callers

nothing calls this directly

Calls 6

DeltaTimeMethod · 0.80
GetActiveContextMethod · 0.80
GetKeyStateMethod · 0.80
RotateMethod · 0.80
GetBrightnessMethod · 0.80
SetBrightnessMethod · 0.80

Tested by

no test coverage detected