Skip to content

Commit

Permalink
disable camera movement when the clicked position is void
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Jan 26, 2022
1 parent e7f3bf4 commit c57b3af
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/3d/qgscameracontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ void QgsCameraController::onPositionChangedTerrainNavigation( Qt3DInput::QMouseE
if ( !mRotationCenterCalculated )
{
double depth = Qgs3DUtils::decodeDepth( mDepthBufferImage.pixelColor( mMiddleButtonClickPos.x(), mMiddleButtonClickPos.y() ) );
if ( depth >= 1 )
return;

mRotationCenter = Qgs3DUtils::screenPointToWorldPos( mMiddleButtonClickPos, depth, mViewport.size(), mCameraBeforeRotation.get() );

Expand Down Expand Up @@ -453,6 +455,9 @@ void QgsCameraController::onPositionChangedTerrainNavigation( Qt3DInput::QMouseE
if ( !mDragPointCalculated )
{
mDragDepth = Qgs3DUtils::decodeDepth( mDepthBufferImage.pixelColor( mDragButtonClickPos.x(), mDragButtonClickPos.y() ) );
if ( mDragDepth >= 1 )
return;

mDragPoint = Qgs3DUtils::screenPointToWorldPos( mDragButtonClickPos, mDragDepth, mViewport.size(), mCameraBeforeDrag.get() );
mDragPointCalculated = true;
}
Expand Down Expand Up @@ -495,6 +500,9 @@ void QgsCameraController::onPositionChangedTerrainNavigation( Qt3DInput::QMouseE
if ( !mDragPointCalculated )
{
double depth = Qgs3DUtils::decodeDepth( mDepthBufferImage.pixelColor( mDragButtonClickPos.x(), mDragButtonClickPos.y() ) );
if ( depth >= 1 )
return;

mDragPoint = Qgs3DUtils::screenPointToWorldPos( mDragButtonClickPos, depth, mViewport.size(), mCameraBeforeDrag.get() );
mDragPointCalculated = true;
}
Expand Down Expand Up @@ -565,6 +573,9 @@ void QgsCameraController::handleTerrainNavigationWheelZoom()
if ( !mZoomPointCalculated )
{
double depth = Qgs3DUtils::decodeDepth( mDepthBufferImage.pixelColor( mMousePos.x(), mMousePos.y() ) );
if ( depth >= 1 )
return;

mZoomPoint = Qgs3DUtils::screenPointToWorldPos( mMousePos, depth, mViewport.size(), mCameraBeforeZoom.get() );
mZoomPointCalculated = true;
}
Expand Down

0 comments on commit c57b3af

Please sign in to comment.