Skip to content

Commit

Permalink
remove mTerrainEntity from QgsCameraController
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros authored and wonder-sk committed Jan 31, 2023
1 parent dfb5a0a commit 07b01fe
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 33 deletions.
3 changes: 0 additions & 3 deletions src/3d/qgs3dmapscene.cpp
Expand Up @@ -632,8 +632,6 @@ void Qgs3DMapScene::createTerrainDeferred()
mTerrain->setParent( this );
mTerrain->setShowBoundingBoxes( mMap.showTerrainBoundingBoxes() );

mCameraController->setTerrainEntity( mTerrain );

mChunkEntities << mTerrain;

connect( mTerrain, &QgsChunkedEntity::pendingJobsCountChanged, this, &Qgs3DMapScene::totalPendingJobsCountChanged );
Expand All @@ -642,7 +640,6 @@ void Qgs3DMapScene::createTerrainDeferred()
else
{
mTerrain = nullptr;
mCameraController->setTerrainEntity( mTerrain );
}

// make sure that renderers for layers are re-created as well
Expand Down
19 changes: 3 additions & 16 deletions src/3d/qgscameracontroller.cpp
Expand Up @@ -104,14 +104,6 @@ void QgsCameraController::setVerticalAxisInversion( QgsCameraController::Vertica
mVerticalAxisInversion = inversion;
}

void QgsCameraController::setTerrainEntity( QgsTerrainEntity *te )
{
mTerrainEntity = te;
// object picker for terrain for correct map panning
if ( mTerrainEntity )
connect( te->terrainPicker(), &Qt3DRender::QObjectPicker::pressed, this, &QgsCameraController::onPickerMousePressed );
}

void QgsCameraController::rotateCamera( float diffPitch, float diffYaw )
{
const float pitch = mCameraPose.pitchAngle();
Expand Down Expand Up @@ -157,8 +149,9 @@ void QgsCameraController::resetView( float distance )
void QgsCameraController::setViewFromTop( float worldX, float worldY, float distance, float yaw )
{
QgsCameraPose camPose;
if ( mTerrainEntity )
camPose.setCenterPoint( QgsVector3D( worldX, mTerrainEntity->terrainElevationOffset(), worldY ) );
QgsTerrainEntity *terrain = mScene->terrainEntity();
if ( terrain )
camPose.setCenterPoint( QgsVector3D( worldX, terrain->terrainElevationOffset(), worldY ) );
else
camPose.setCenterPoint( QgsVector3D( worldX, 0.0f, worldY ) );
camPose.setDistanceFromCenterPoint( distance );
Expand Down Expand Up @@ -972,12 +965,6 @@ void QgsCameraController::onKeyReleased( Qt3DInput::QKeyEvent *event )
mDepressedKeys.remove( event->key() );
}

void QgsCameraController::onPickerMousePressed( Qt3DRender::QPickEvent *pick )
{
mLastPressedHeight = pick->worldIntersection().y();
}


void QgsCameraController::tiltUpAroundViewCenter( float deltaPitch )
{
// Tilt up the view by deltaPitch around the view center (camera moves)
Expand Down
14 changes: 0 additions & 14 deletions src/3d/qgscameracontroller.h
Expand Up @@ -47,7 +47,6 @@ class QDomDocument;
class QDomElement;

class QgsCameraPose;
class QgsTerrainEntity;
class QgsVector3D;
class QgsWindow3DEngine;
class Qgs3DMapScene;
Expand Down Expand Up @@ -119,13 +118,6 @@ class _3D_EXPORT QgsCameraController : public Qt3DCore::QEntity
*/
void setVerticalAxisInversion( QgsCameraController::VerticalAxisInversion inversion );

/**
* Connects to object picker attached to terrain entity. Called internally from 3D scene.
* This allows camera controller understand how far from the camera is the terrain under mouse cursor.
* Also it allows adjustment of camera's view center to a point on terrain.
*/
void setTerrainEntity( QgsTerrainEntity *te );

//! Called internally from 3D scene when a new frame is generated. Updates camera according to keyboard/mouse input
void frameTriggered( float dt );

Expand Down Expand Up @@ -260,7 +252,6 @@ class _3D_EXPORT QgsCameraController : public Qt3DCore::QEntity
void onMouseReleased( Qt3DInput::QMouseEvent *mouse );
void onKeyPressed( Qt3DInput::QKeyEvent *event );
void onKeyReleased( Qt3DInput::QKeyEvent *event );
void onPickerMousePressed( Qt3DRender::QPickEvent *pick );
void applyFlyModeKeyMovements();

private:
Expand All @@ -286,11 +277,6 @@ class _3D_EXPORT QgsCameraController : public Qt3DCore::QEntity
//! Camera that is being controlled
Qt3DRender::QCamera *mCamera = nullptr;

//! height of terrain when mouse button was last pressed - for camera control
float mLastPressedHeight = 0;

QPointer<QgsTerrainEntity> mTerrainEntity;

//! Keeps definition of the camera's position and towards where it is looking
QgsCameraPose mCameraPose;

Expand Down

0 comments on commit 07b01fe

Please sign in to comment.