Skip to content

Commit e35ec2d

Browse files
committedJun 29, 2018
Prevent going up when rotating camera with ctrl and reaching pitch limits
1 parent e073a4c commit e35ec2d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed
 

‎src/3d/qgscameracontroller.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ QPointF screen_point_to_point_on_plane( const QPointF &pt, const QRect &viewport
241241

242242
void QgsCameraController::rotateCamera( float diffPitch, float diffYaw )
243243
{
244+
if ( mCameraData.pitch + diffPitch > 80 )
245+
diffPitch = 80 - mCameraData.pitch; // prevent going under the plane
246+
if ( mCameraData.pitch + diffPitch < 0 )
247+
diffPitch = 0 - mCameraData.pitch; // prevent going over the head
248+
244249
// Is it always going to be love/hate relationship with quaternions???
245250
// This quaternion combines two rotations:
246251
// - first it undoes the previously applied rotation so we have do not have any rotation compared to world coords

0 commit comments

Comments
 (0)
Please sign in to comment.