Skip to content

Commit

Permalink
Merge pull request #35 from SuperSimon81/master
Browse files Browse the repository at this point in the history
Improved panning
  • Loading branch information
cwensley authored Oct 17, 2019
2 parents c95545a + 9b167c4 commit 533f283
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions TestEtoOpenTK/TestViewport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,14 @@ void dragHandler(object sender, MouseEventArgs e)
{
object locking = new object();
lock (locking)
{
// Scaling factor is arbitrary - just based on testing to avoid insane panning speeds.
float new_X = (ovpSettings.cameraPosition.X - (((float)e.Location.X - x_orig) / 100.0f));
float new_Y = (ovpSettings.cameraPosition.Y + (((float)e.Location.Y - y_orig) / 100.0f));
ovpSettings.cameraPosition = new PointF(new_X, new_Y);
}
{
// Scaling factor is arbitrary - just based on testing to avoid insane panning speeds.
float new_X = (ovpSettings.cameraPosition.X - (((float)e.Location.X - x_orig) * ovpSettings.zoomFactor));
float new_Y = (ovpSettings.cameraPosition.Y + (((float)e.Location.Y - y_orig) * ovpSettings.zoomFactor));
ovpSettings.cameraPosition = new PointF(new_X, new_Y);
x_orig = e.Location.X;
y_orig = e.Location.Y;
}
}
updateViewport();
//e.Handled = true;
Expand Down

0 comments on commit 533f283

Please sign in to comment.