[Bf-blender-cvs] [24004e74fa4] master: Fix T88524: GPencil PDF does not take into account the marker camera

Antonio Vazquez noreply at git.blender.org
Mon May 24 12:36:25 CEST 2021


Commit: 24004e74fa442a1b817180e62aefe5d4d526f406
Author: Antonio Vazquez
Date:   Mon May 24 12:36:13 2021 +0200
Branches: master
https://developer.blender.org/rB24004e74fa442a1b817180e62aefe5d4d526f406

Fix T88524: GPencil PDF does not take into account the marker camera

The camera was not checked before doing the export.

===================================================================

M	source/blender/io/gpencil/intern/gpencil_io_base.cc
M	source/blender/io/gpencil/intern/gpencil_io_base.hh
M	source/blender/io/gpencil/intern/gpencil_io_capi.cc

===================================================================

diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.cc b/source/blender/io/gpencil/intern/gpencil_io_base.cc
index e79a2bc98ff..a2c1b8f5af6 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc
@@ -41,6 +41,7 @@
 #include "BKE_gpencil_geom.h"
 #include "BKE_main.h"
 #include "BKE_material.h"
+#include "BKE_scene.h"
 
 #include "UI_view2d.h"
 
@@ -69,18 +70,21 @@ GpencilIO::GpencilIO(const GpencilIOParams *iparams)
   cfra_ = iparams->frame_cur;
 
   /* Calculate camera matrix. */
-  prepare_camera_params(iparams);
+  prepare_camera_params(scene_, iparams);
 }
 
-void GpencilIO::prepare_camera_params(const GpencilIOParams *iparams)
+void GpencilIO::prepare_camera_params(Scene *scene, const GpencilIOParams *iparams)
 {
   params_ = *iparams;
   const bool is_pdf = params_.mode == GP_EXPORT_TO_PDF;
   const bool any_camera = (params_.v3d->camera != nullptr);
   const bool force_camera_view = is_pdf && any_camera;
 
+  /* Ensure camera switch is applied. */
+  BKE_scene_camera_switch_update(scene);
+
   /* Calculate camera matrix. */
-  Object *cam_ob = params_.v3d->camera;
+  Object *cam_ob = scene->camera;
   if (cam_ob != nullptr) {
     /* Set up parameters. */
     CameraParams params;
diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.hh b/source/blender/io/gpencil/intern/gpencil_io_base.hh
index 2e1e1707c78..c3c6f1156bb 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.hh
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.hh
@@ -50,7 +50,7 @@ class GpencilIO {
   GpencilIO(const GpencilIOParams *iparams);
 
   void frame_number_set(const int value);
-  void prepare_camera_params(const GpencilIOParams *iparams);
+  void prepare_camera_params(Scene *scene, const GpencilIOParams *iparams);
 
  protected:
   GpencilIOParams params_;
diff --git a/source/blender/io/gpencil/intern/gpencil_io_capi.cc b/source/blender/io/gpencil/intern/gpencil_io_capi.cc
index 8093ec3c52d..544c51e0b4f 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_capi.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_capi.cc
@@ -121,7 +121,7 @@ static bool gpencil_io_export_pdf(Depsgraph *depsgraph,
 
       CFRA = i;
       BKE_scene_graph_update_for_newframe(depsgraph);
-      exporter->prepare_camera_params(iparams);
+      exporter->prepare_camera_params(scene, iparams);
       exporter->frame_number_set(i);
       exporter->add_newpage();
       exporter->add_body();
@@ -130,10 +130,11 @@ static bool gpencil_io_export_pdf(Depsgraph *depsgraph,
     /* Back to original frame. */
     exporter->frame_number_set(iparams->frame_cur);
     CFRA = iparams->frame_cur;
+    BKE_scene_camera_switch_update(scene);
     BKE_scene_graph_update_for_newframe(depsgraph);
   }
   else {
-    exporter->prepare_camera_params(iparams);
+    exporter->prepare_camera_params(scene, iparams);
     exporter->add_newpage();
     exporter->add_body();
     result = exporter->write();
@@ -146,6 +147,7 @@ static bool gpencil_io_export_pdf(Depsgraph *depsgraph,
 /* Export current frame in SVG. */
 #ifdef WITH_PUGIXML
 static bool gpencil_io_export_frame_svg(GpencilExporterSVG *exporter,
+                                        Scene *scene,
                                         const GpencilIOParams *iparams,
                                         const bool newpage,
                                         const bool body,
@@ -153,7 +155,7 @@ static bool gpencil_io_export_frame_svg(GpencilExporterSVG *exporter,
 {
   bool result = false;
   exporter->frame_number_set(iparams->frame_cur);
-  exporter->prepare_camera_params(iparams);
+  exporter->prepare_camera_params(scene, iparams);
 
   if (newpage) {
     result |= exporter->add_newpage();
@@ -189,7 +191,7 @@ bool gpencil_io_export(const char *filename, GpencilIOParams *iparams)
 #ifdef WITH_PUGIXML
     case GP_EXPORT_TO_SVG: {
       GpencilExporterSVG exporter = GpencilExporterSVG(filename, iparams);
-      return gpencil_io_export_frame_svg(&exporter, iparams, true, true, true);
+      return gpencil_io_export_frame_svg(&exporter, scene_, iparams, true, true, true);
       break;
     }
 #endif



More information about the Bf-blender-cvs mailing list