Recast: don't apply keyboard movement if imgui wants it

Fix a bug where causing the camera to still move while using the keyboard on the GUI.
This commit is contained in:
Kawe Mazidjatari 2024-07-15 00:26:44 +02:00
parent 3f2de9ac6d
commit 22e25964c6

View File

@ -852,6 +852,8 @@ int not_main(int argc, char** argv)
rayEnd[1] = (float)y;
rayEnd[2] = (float)z;
if (!mouseOverMenu)
{
// Handle keyboard movement.
const Uint8* keystate = SDL_GetKeyboardState(NULL);
moveFront = rcClamp(moveFront + dt * 4 * ((keystate[SDL_SCANCODE_W] || keystate[SDL_SCANCODE_UP ]) ? 1 : -1), 0.0f, 1.0f);
@ -880,6 +882,7 @@ int not_main(int argc, char** argv)
cameraPos[2] += movey * static_cast<float>(modelviewMatrix[10]);
cameraPos[2] += (moveUp - moveDown) * keybSpeed * dt;
}
glEnable(GL_FOG);
@ -899,7 +902,7 @@ int not_main(int argc, char** argv)
glLoadIdentity();
ImGuiIO& io = ImGui::GetIO();
mouseOverMenu = io.WantCaptureMouse;
mouseOverMenu = io.WantCaptureMouse||io.WantCaptureKeyboard;
ImGui_ImplOpenGL2_NewFrame();
ImGui_ImplSDL2_NewFrame();