Skip to content

Commit

Permalink
Create output directory for 3D animation if it does not exist
Browse files Browse the repository at this point in the history
Previously the animation would still get exported, but saving of all
frames would silently fail...
  • Loading branch information
wonder-sk authored and nyalldawson committed Oct 21, 2022
1 parent bc221cc commit 8d6c04b
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/3d/qgs3dutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,6 @@ bool Qgs3DUtils::exportAnimation( const Qgs3DAnimationSettings &animationSetting
QgsFeedback *feedback
)
{
QgsOffscreen3DEngine engine;
engine.setSize( outputSize );
Qgs3DMapScene *scene = new Qgs3DMapScene( mapSettings, &engine );
engine.setRootEntity( scene );
// We need to change render policy to RenderPolicy::Always, since otherwise render capture node won't work
engine.renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::Always );

if ( animationSettings.keyFrames().size() < 2 )
{
error = QObject::tr( "Unable to export 3D animation. Add at least 2 keyframes" );
Expand Down Expand Up @@ -191,6 +184,22 @@ bool Qgs3DUtils::exportAnimation( const Qgs3DAnimationSettings &animationSetting
return false;
}

if ( !QDir().exists( outputDirectory ) )
{
if ( !QDir().mkpath( outputDirectory ) )
{
error = QObject::tr( "Output directory could not be created." );
return false;
}
}

QgsOffscreen3DEngine engine;
engine.setSize( outputSize );
Qgs3DMapScene *scene = new Qgs3DMapScene( mapSettings, &engine );
engine.setRootEntity( scene );
// We need to change render policy to RenderPolicy::Always, since otherwise render capture node won't work
engine.renderSettings()->setRenderPolicy( Qt3DRender::QRenderSettings::RenderPolicy::Always );

while ( time <= duration )
{

Expand Down

0 comments on commit 8d6c04b

Please sign in to comment.