15 if (event.type == SDL_EVENT_KEY_DOWN || event.type == SDL_EVENT_KEY_UP) {
16 bool isPressed = (
event.type == SDL_EVENT_KEY_DOWN);
17 const SDL_KeyboardEvent& keyEvent =
event.key;
18 keyStates[keyEvent.scancode] = isPressed;
21 if (event.type == SDL_EVENT_MOUSE_WHEEL && m_isFlying) {
22 if (event.wheel.y > 0) {
23 m_movementSpeed *= 1.2f;
24 }
else if (event.wheel.y < 0) {
25 m_movementSpeed *= 0.8f;
29 if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
30 if (event.button.button == SDL_BUTTON_RIGHT && m_viewportHovered) {
32 SDL_SetWindowRelativeMouseMode(m_window,
true);
36 if (event.type == SDL_EVENT_MOUSE_BUTTON_UP) {
37 if (event.button.button == SDL_BUTTON_RIGHT) {
39 SDL_SetWindowRelativeMouseMode(m_window,
false);
43 if (event.type == SDL_EVENT_MOUSE_MOTION && m_isFlying) {
46 float deltaYaw = -
event.motion.xrel * m_mouseSensitivity;
47 float deltaPitch = -
event.motion.yrel * m_mouseSensitivity;
50 tc.addPitch(deltaPitch);
56 bool isShiftHeld = keyStates[SDL_SCANCODE_LSHIFT] || keyStates[SDL_SCANCODE_RSHIFT];
62 if (keyStates[SDL_SCANCODE_W] && (m_viewportHovered || m_isFlying)) {
63 tc.setLocalPosition(tc.getLocalPosition()+(tc.getForwardVector()*
float(deltaTime*m_movementSpeed)));
66 if (keyStates[SDL_SCANCODE_S] && (m_viewportHovered || m_isFlying)) {
67 tc.setLocalPosition(tc.getLocalPosition()+(tc.getForwardVector()*
float(deltaTime*-m_movementSpeed)));
70 if (keyStates[SDL_SCANCODE_D] && (m_viewportHovered || m_isFlying)) {
71 tc.setLocalPosition(tc.getLocalPosition()+(tc.getRightVector()*
float(deltaTime*m_movementSpeed)));
74 if (keyStates[SDL_SCANCODE_A] && (m_viewportHovered || m_isFlying)) {
75 tc.setLocalPosition(tc.getLocalPosition()+(tc.getRightVector()*
float(deltaTime*-m_movementSpeed)));
78 if (keyStates[SDL_SCANCODE_E] && (m_viewportHovered || m_isFlying)) {
79 tc.setLocalPosition(tc.getLocalPosition() + (tc.getUpVector() * (deltaTime * m_movementSpeed)));
82 if (keyStates[SDL_SCANCODE_Q] && (m_viewportHovered || m_isFlying)) {
83 tc.setLocalPosition(tc.getLocalPosition() + (tc.getUpVector() * (deltaTime * -m_movementSpeed)));
void processEvent(const SDL_Event &event, float deltaTime)
Processes SDL events specific to the editor camera (e.g., mouse movement, key presses).