Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Vazquez <blendergit@gmail.com>2021-05-17 14:04:30 +0300
committerAntonio Vazquez <blendergit@gmail.com>2021-05-17 14:05:38 +0300
commitbb32ecadb5be0012fb0f06dcb83dce66fd5cd871 (patch)
tree08fd5b2e167b252d77e5745ccfb9884834085622
parente3a76feeefa9ff7278a6f79fd5905f762462b485 (diff)
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.
-rw-r--r--source/blender/io/gpencil/intern/gpencil_io_base.cc13
-rw-r--r--source/blender/io/gpencil/intern/gpencil_io_base.hh1
-rw-r--r--source/blender/io/gpencil/intern/gpencil_io_capi.cc4
3 files changed, 17 insertions, 1 deletions
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
@@ -69,6 +69,17 @@ GpencilIO::GpencilIO(const GpencilIOParams *iparams)
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) {
/* Set up parameters. */
@@ -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();
}