1
0
Fork 0

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:
timoore 2007-08-18 22:07:11 +00:00
parent e038ca1d76
commit 3f41c9f91b

View file

@ -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