Skip to content

Commit

Permalink
skybox settings class and related slots/signals
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem committed Jul 31, 2020
1 parent 2d4346c commit 4ec0042
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 271 deletions.
1 change: 1 addition & 0 deletions src/3d/CMakeLists.txt
Expand Up @@ -97,6 +97,7 @@ SET(QGIS_3D_HDRS
qgsvectorlayer3drenderer.h
qgswindow3dengine.h
qgsskyboxentity.h
qgsskyboxsettings.h
symbols/qgsbillboardgeometry.h
symbols/qgsline3dsymbol.h
symbols/qgsmesh3dsymbol.h
Expand Down
18 changes: 17 additions & 1 deletion src/3d/qgs3dmapscene.cpp
Expand Up @@ -69,6 +69,7 @@
#include "qgslinematerial_p.h"

#include "qgsskyboxentity.h"
#include "qgsskyboxsettings.h"

Qgs3DMapScene::Qgs3DMapScene( const Qgs3DMapSettings &map, QgsAbstract3DEngine *engine )
: mMap( map )
Expand Down Expand Up @@ -205,11 +206,12 @@ Qgs3DMapScene::Qgs3DMapScene( const Qgs3DMapSettings &map, QgsAbstract3DEngine *
// {
// mSkybox = new QgsSkyboxEntity("file:///home/nedjima/dev/cpp/qt3d/examples/qt3d/exampleresources/assets/cubemaps/default/default_specular", ".dds", this);
mSkybox = new QgsSkyboxEntity( "file:///home/nedjima/dev/cpp/Standard-Cube-Map2/cube_map", ".png", this );
// mSkybox->setEnabled(false);

// docs say frustum culling must be disabled for skybox.
// it _somehow_ works even when frustum culling is enabled with some camera positions,
// but then when zoomed in more it would disappear - so let's keep frustum culling disabled
mEngine->setFrustumCullingEnabled( false );
// mEngine->setFrustumCullingEnabled( false );
mEngine->setClearColor( QColor( 255, 0, 0 ) );

// cppcheck wrongly believes skyBox will leak
Expand Down Expand Up @@ -863,3 +865,17 @@ void Qgs3DMapScene::updateSceneState()

setSceneState( Ready );
}

void Qgs3DMapScene::onSkyboxSettingsChanged( const QgsSkyboxSettings &settings )
{
qDebug() << __FUNCTION__;
if ( mSkybox != nullptr )
{
delete mSkybox;
mSkybox = nullptr;
}
if ( settings.getIsSkyboxEnabled() )
{
mSkybox = new QgsSkyboxEntity( settings.getSkyboxBaseName(), settings.getSkyboxExtension() );
}
}
4 changes: 4 additions & 0 deletions src/3d/qgs3dmapscene.h
Expand Up @@ -50,6 +50,7 @@ class Qgs3DMapSettings;
class QgsTerrainEntity;
class QgsChunkedEntity;
class QgsSkyboxEntity;
class QgsSkyboxSettings;

#define SIP_NO_FILE

Expand Down Expand Up @@ -121,6 +122,7 @@ class _3D_EXPORT Qgs3DMapScene : public Qt3DCore::QEntity
public slots:
//! Updates the temporale entities
void updateTemporal();
void onSkyboxSettingsChanged( const QgsSkyboxSettings &settings );

private slots:
void onCameraChanged();
Expand All @@ -134,6 +136,7 @@ class _3D_EXPORT Qgs3DMapScene : public Qt3DCore::QEntity
void updateLights();
void updateCameraLens();
void onRenderersChanged();

private:
void addLayerEntity( QgsMapLayer *layer );
void removeLayerEntity( QgsMapLayer *layer );
Expand Down Expand Up @@ -168,6 +171,7 @@ class _3D_EXPORT Qgs3DMapScene : public Qt3DCore::QEntity
QList<Qt3DCore::QEntity *> mLightOriginEntities;
QList<QgsMapLayer *> mModelVectorLayers;
QgsSkyboxEntity *mSkybox = nullptr;

};

#endif // QGS3DMAPSCENE_H
2 changes: 0 additions & 2 deletions src/3d/qgsskyboxentity.cpp
Expand Up @@ -129,7 +129,6 @@ void QgsSkyboxEntity::reloadTexture()
if ( !mHasPendingReloadTextureCall )
{
mHasPendingReloadTextureCall = true;
// QTimer::singleShot(10, [this] {
if ( mExtension == QStringLiteral( ".dds" ) )
{
mLoadedTexture->setSource( QUrl( mBaseName + mExtension ) );
Expand All @@ -146,7 +145,6 @@ void QgsSkyboxEntity::reloadTexture()
mTextureParameter->setValue( QVariant::fromValue( mSkyboxTexture ) );
}
mHasPendingReloadTextureCall = false;
// });
}
}

Expand Down
175 changes: 0 additions & 175 deletions src/3d/qgsskyboxentity.cpp.bom

This file was deleted.

64 changes: 0 additions & 64 deletions src/3d/qgsskyboxentity.h.bom

This file was deleted.

24 changes: 24 additions & 0 deletions src/3d/qgsskyboxsettings.h
@@ -0,0 +1,24 @@
#ifndef QGSSKYBOXSETTINGS_H
#define QGSSKYBOXSETTINGS_H

#include <QString>

class QgsSkyboxSettings
{
public:
bool getIsSkyboxEnabled() const { return mIsSkyboxEnabled; }
void setIsSkyboxEnabled( bool enabled ) { mIsSkyboxEnabled = enabled; }

QString getSkyboxBaseName() const { return mSkyboxBaseName; }
void setSkyboxBaseName( const QString &baseName ) { mSkyboxBaseName = baseName; }

QString getSkyboxExtension() const { return mSkyboxExt; }
void setSkyboxExtension( const QString &extension ) { mSkyboxExt = extension; }

private:
bool mIsSkyboxEnabled = false;
QString mSkyboxBaseName;
QString mSkyboxExt;
};

#endif // QGSSKYBOXSETTINGS_H
2 changes: 1 addition & 1 deletion src/app/3d/qgs3dmapcanvasdockwidget.cpp
Expand Up @@ -254,7 +254,7 @@ void Qgs3DMapCanvasDockWidget::configure()
QgsGui::instance()->enableAutoGeometryRestore( &dlg );

Qgs3DMapSettings *map = mCanvas->map();
Qgs3DMapConfigWidget *w = new Qgs3DMapConfigWidget( map, mMainCanvas, &dlg );
Qgs3DMapConfigWidget *w = new Qgs3DMapConfigWidget( map, mMainCanvas, mCanvas, &dlg );
QDialogButtonBox *buttons = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, &dlg );
connect( buttons, &QDialogButtonBox::accepted, &dlg, &QDialog::accept );
connect( buttons, &QDialogButtonBox::rejected, &dlg, &QDialog::reject );
Expand Down

0 comments on commit 4ec0042

Please sign in to comment.