Fix T88524: GPencil PDF does not take into account the marker camera
The camera was not checked before doing the export.
This commit is contained in:
parent
43153e2324
commit
24004e74fa
Notes:
blender-bot
2023-02-13 18:36:25 +01:00
Referenced by issue #88524, GPencil: Export to PDF does not take into account the marker camera switching
|
@ -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;
|
||||
|
|
|
@ -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_;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue