------------------------------ LightControlSystem::Process
| 25 | // LightControlSystem::Process |
| 26 | // |
| 27 | void 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 | { |
nothing calls this directly
no test coverage detected