浏览代码

REVIEWED: Issue with camera jump on first frame

pull/2925/head
Ray 2 年前
父节点
当前提交
5dedb27ce0
共有 1 个文件被更改,包括 6 次插入7 次删除
  1. +6
    -7
      src/rcore.c

+ 6
- 7
src/rcore.c 查看文件

@ -2017,6 +2017,8 @@ void EnableCursor(void)
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_exit_pointerlock(); emscripten_exit_pointerlock();
#endif #endif
// Set cursor position in the middle
SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2);
CORE.Input.Mouse.cursorHidden = false; CORE.Input.Mouse.cursorHidden = false;
} }
@ -2026,17 +2028,12 @@ void DisableCursor(void)
{ {
#if defined(PLATFORM_DESKTOP) #if defined(PLATFORM_DESKTOP)
glfwSetInputMode(CORE.Window.handle, GLFW_CURSOR, GLFW_CURSOR_DISABLED); glfwSetInputMode(CORE.Window.handle, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
// Set cursor position in the middle of screen and update delta accordingly
SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2);
CORE.Input.Mouse.currentPosition.x = CORE.Window.screen.width/2;
CORE.Input.Mouse.currentPosition.y = CORE.Window.screen.width/2;
CORE.Input.Mouse.previousPosition.x = CORE.Input.Mouse.currentPosition.x;
CORE.Input.Mouse.previousPosition.y = CORE.Input.Mouse.currentPosition.y;
#endif #endif
#if defined(PLATFORM_WEB) #if defined(PLATFORM_WEB)
emscripten_request_pointerlock("#canvas", 1); emscripten_request_pointerlock("#canvas", 1);
#endif #endif
// Set cursor position in the middle
SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2);
CORE.Input.Mouse.cursorHidden = true; CORE.Input.Mouse.cursorHidden = true;
} }
@ -3809,6 +3806,8 @@ Vector2 GetMouseDelta(void)
void SetMousePosition(int x, int y) void SetMousePosition(int x, int y)
{ {
CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y }; CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y };
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB) #if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
// NOTE: emscripten not implemented // NOTE: emscripten not implemented
glfwSetCursorPos(CORE.Window.handle, CORE.Input.Mouse.currentPosition.x, CORE.Input.Mouse.currentPosition.y); glfwSetCursorPos(CORE.Window.handle, CORE.Input.Mouse.currentPosition.x, CORE.Input.Mouse.currentPosition.y);

正在加载...
取消
保存