Really implement fgWarpMouse for osgviewer
This fixes a bug that caused both the x and y values of the mouse to be reset when the cursor was recentered due to hitting the screen edge. Based on a suggested patch from Stuart Buchanan
This commit is contained in:
parent
e038ca1d76
commit
3f41c9f91b
1 changed files with 11 additions and 2 deletions
|
@ -250,8 +250,17 @@ int fgGetKeyModifiers()
|
|||
|
||||
void fgWarpMouse(int x, int y)
|
||||
{
|
||||
// Hack, currently the pointer is just recentered. So, we know the relative coordinates ...
|
||||
// Hack, currently the pointer is just recentered. So, we know the
|
||||
// relative coordinates ...
|
||||
if (!mainCamera.valid()) {
|
||||
viewer->requestWarpPointer(0, 0);
|
||||
return;
|
||||
}
|
||||
float xsize = (float)mainCamera->getGraphicsContext()->getTraits()->width;
|
||||
float ysize = (float)mainCamera->getGraphicsContext()->getTraits()->height;
|
||||
viewer->requestWarpPointer(2.0f * (float)x / xsize - 1.0f,
|
||||
1.0f - 2.0f * (float)y / ysize);
|
||||
|
||||
}
|
||||
|
||||
// Noop
|
||||
|
|
Loading…
Add table
Reference in a new issue