[Bf-blender-cvs] [bb32ecadb5b] blender-v2.93-release: GPencil: Fix unreported error exporting to PDF/SVG with animated camera

Antonio Vazquez noreply at git.blender.org
Mon May 17 13:06:32 CEST 2021


Commit: bb32ecadb5be0012fb0f06dcb83dce66fd5cd871
Author: Antonio Vazquez
Date:   Mon May 17 13:04:30 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rBbb32ecadb5be0012fb0f06dcb83dce66fd5cd871

GPencil: Fix unreported error exporting to PDF/SVG  with animated camera

Before, the camera parameters were calculated only for first frame. 

If the camera is animated, these values need to be recalculated in order to get the new camera view position and export the strokes as expected.

Also fixed the export of PDF when the view is not in camera view. PDF export, needs to be done in camera view.

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

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 bfa3abb1dcd..e79a2bc98ff 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc
@@ -68,6 +68,17 @@ GpencilIO::GpencilIO(const GpencilIOParams *iparams)
   gpd_ = (params_.ob != nullptr) ? (bGPdata *)params_.ob->data : nullptr;
   cfra_ = iparams->frame_cur;
 
+  /* Calculate camera matrix. */
+  prepare_camera_params(iparams);
+}
+
+void GpencilIO::prepare_camera_params(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;
+
   /* Calculate camera matrix. */
   Object *cam_ob = params_.v3d->camera;
   if (cam_ob != nullptr) {
@@ -96,7 +107,7 @@ GpencilIO::GpencilIO(const GpencilIOParams *iparams)
   winy_ = params_.region->winy;
 
   /* Camera rectangle. */
-  if (rv3d_->persp == RV3D_CAMOB) {
+  if ((rv3d_->persp == RV3D_CAMOB) || (force_camera_view)) {
     render_x_ = (scene_->r.xsch * scene_->r.size) / 100;
     render_y_ = (scene_->r.ysch * scene_->r.size) / 100;
 
diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.hh b/source/blender/io/gpencil/intern/gpencil_io_base.hh
index cbcd35e470d..2e1e1707c78 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.hh
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.hh
@@ -50,6 +50,7 @@ class GpencilIO {
   GpencilIO(const GpencilIOParams *iparams);
 
   void frame_number_set(const int value);
+  void prepare_camera_params(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 a710c175a77..8093ec3c52d 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_capi.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_capi.cc
@@ -121,6 +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->frame_number_set(i);
       exporter->add_newpage();
       exporter->add_body();
@@ -132,6 +133,7 @@ static bool gpencil_io_export_pdf(Depsgraph *depsgraph,
     BKE_scene_graph_update_for_newframe(depsgraph);
   }
   else {
+    exporter->prepare_camera_params(iparams);
     exporter->add_newpage();
     exporter->add_body();
     result = exporter->write();
@@ -151,6 +153,8 @@ static bool gpencil_io_export_frame_svg(GpencilExporterSVG *exporter,
 {
   bool result = false;
   exporter->frame_number_set(iparams->frame_cur);
+  exporter->prepare_camera_params(iparams);
+
   if (newpage) {
     result |= exporter->add_newpage();
   }



More information about the Bf-blender-cvs mailing list