Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make Qgs3dMapScene really exportable #57718

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions src/3d/qgs3dmapscene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,18 +293,6 @@ float Qgs3DMapScene::worldSpaceError( float epsilon, float distance ) const
return err;
}

Qgs3DMapSceneEntity::SceneContext Qgs3DMapScene::buildSceneContext( ) const
{
Qt3DRender::QCamera *camera = mEngine->camera();
Qgs3DMapSceneEntity::SceneContext sceneContext;
sceneContext.cameraFov = camera->fieldOfView();
sceneContext.cameraPos = camera->position();
const QSize size = mEngine->size();
sceneContext.screenSizePx = std::max( size.width(), size.height() ); // TODO: is this correct?
sceneContext.viewProjectionMatrix = camera->projectionMatrix() * camera->viewMatrix();
return sceneContext;
}

void Qgs3DMapScene::onCameraChanged()
{
if ( mMap.projectionType() == Qt3DRender::QCameraLens::OrthographicProjection )
Expand Down Expand Up @@ -337,7 +325,15 @@ void Qgs3DMapScene::updateScene( bool forceUpdate )
if ( forceUpdate )
QgsEventTracing::addEvent( QgsEventTracing::Instant, QStringLiteral( "3D" ), QStringLiteral( "Update Scene" ) );

Qgs3DMapSceneEntity::SceneContext sceneContext = buildSceneContext();
Qgs3DMapSceneEntity::SceneContext sceneContext;
Qt3DRender::QCamera *camera = mEngine->camera();
sceneContext.cameraFov = camera->fieldOfView();
sceneContext.cameraPos = camera->position();
const QSize size = mEngine->size();
sceneContext.screenSizePx = std::max( size.width(), size.height() ); // TODO: is this correct?
sceneContext.viewProjectionMatrix = camera->projectionMatrix() * camera->viewMatrix();


for ( Qgs3DMapSceneEntity *entity : std::as_const( mSceneEntities ) )
{
if ( forceUpdate || ( entity->isEnabled() && entity->needsUpdate() ) )
Expand Down
3 changes: 1 addition & 2 deletions src/3d/qgs3dmapscene.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include "qgsrectangle.h"
#include "qgscameracontroller.h"
#include "qgs3dmapsceneentity_p.h"

#ifndef SIP_RUN
namespace Qt3DRender
Expand Down Expand Up @@ -57,6 +56,7 @@ class Qgs3DMapExportSettings;
class QgsPostprocessingEntity;
class QgsChunkNode;
class QgsDoubleRange;
class Qgs3DMapSceneEntity;


/**
Expand Down Expand Up @@ -277,7 +277,6 @@ class _3D_EXPORT Qgs3DMapScene : public QObject
void updateScene( bool forceUpdate = false );
void finalizeNewEntity( Qt3DCore::QEntity *newEntity );
int maximumTextureSize() const;
Qgs3DMapSceneEntity::SceneContext buildSceneContext( ) const;

private:
Qgs3DMapSettings &mMap;
Expand Down
Loading