Avoid warping the mouse cursor more than necessary

Apparently, the SDL_WarpMouseInWindow can be very expensive (anywhere from 0.1-5ms) due to XSync() in the implementation.

This was causing no-grab=1 configurations to suffer from terrible stuttering when turning the view.
pull/185/head
scrawl 7 years ago
parent a8517c34eb
commit c1fe9f2a89

@ -329,8 +329,8 @@ InputWrapper::InputWrapper(SDL_Window* window, osg::ref_ptr<osgViewer::Viewer> v
SDL_GetWindowSize(mSDLWindow, &width, &height);
const int FUDGE_FACTOR_X = width;
const int FUDGE_FACTOR_Y = height;
const int FUDGE_FACTOR_X = width/4;
const int FUDGE_FACTOR_Y = height/4;
//warp the mouse if it's about to go outside the window
if(evt.x - FUDGE_FACTOR_X < 0 || evt.x + FUDGE_FACTOR_X > width

Loading…
Cancel
Save