GPencil: Fix unreported PDF export offset
When exporting a PDF, the image was displaced towards top right a few pixels. Also removed is_orthographic variable because is not needed now.
This commit is contained in:
@@ -100,11 +100,9 @@ void GpencilIO::prepare_camera_params(Scene *scene, const GpencilIOParams *ipara
|
|||||||
invert_m4_m4(viewmat, cam_ob->obmat);
|
invert_m4_m4(viewmat, cam_ob->obmat);
|
||||||
|
|
||||||
mul_m4_m4m4(persmat_, params.winmat, viewmat);
|
mul_m4_m4m4(persmat_, params.winmat, viewmat);
|
||||||
is_ortho_ = params.is_ortho;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unit_m4(persmat_);
|
unit_m4(persmat_);
|
||||||
is_ortho_ = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
winx_ = params_.region->winx;
|
winx_ = params_.region->winx;
|
||||||
@@ -129,7 +127,6 @@ void GpencilIO::prepare_camera_params(Scene *scene, const GpencilIOParams *ipara
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
is_camera_ = false;
|
is_camera_ = false;
|
||||||
is_ortho_ = false;
|
|
||||||
/* Calc selected object boundbox. Need set initial value to some variables. */
|
/* Calc selected object boundbox. Need set initial value to some variables. */
|
||||||
camera_ratio_ = 1.0f;
|
camera_ratio_ = 1.0f;
|
||||||
offset_.x = 0.0f;
|
offset_.x = 0.0f;
|
||||||
@@ -248,19 +245,14 @@ bool GpencilIO::gpencil_3D_point_to_screen_space(const float3 co, float2 &r_co)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Convert to render space. */
|
/** Convert to render space. */
|
||||||
float2 GpencilIO::gpencil_3D_point_to_render_space(const float3 co, const bool is_ortho)
|
float2 GpencilIO::gpencil_3D_point_to_render_space(const float3 co)
|
||||||
{
|
{
|
||||||
float3 parent_co = diff_mat_ * co;
|
float3 parent_co = diff_mat_ * co;
|
||||||
mul_m4_v3(persmat_, parent_co);
|
|
||||||
|
|
||||||
if (!is_ortho) {
|
|
||||||
parent_co.x = parent_co.x / max_ff(FLT_MIN, parent_co.z);
|
|
||||||
parent_co.y = parent_co.y / max_ff(FLT_MIN, parent_co.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
float2 r_co;
|
float2 r_co;
|
||||||
r_co.x = (parent_co.x + 1.0f) / 2.0f * (float)render_x_;
|
mul_v2_project_m4_v3(&r_co.x, persmat_, &parent_co.x);
|
||||||
r_co.y = (parent_co.y + 1.0f) / 2.0f * (float)render_y_;
|
r_co.x = (r_co.x + 1.0f) / 2.0f * (float)render_x_;
|
||||||
|
r_co.y = (r_co.y + 1.0f) / 2.0f * (float)render_y_;
|
||||||
|
|
||||||
/* Invert X axis. */
|
/* Invert X axis. */
|
||||||
if (invert_axis_[0]) {
|
if (invert_axis_[0]) {
|
||||||
@@ -279,7 +271,7 @@ float2 GpencilIO::gpencil_3D_point_to_2D(const float3 co)
|
|||||||
{
|
{
|
||||||
const bool is_camera = (bool)(rv3d_->persp == RV3D_CAMOB);
|
const bool is_camera = (bool)(rv3d_->persp == RV3D_CAMOB);
|
||||||
if (is_camera) {
|
if (is_camera) {
|
||||||
return gpencil_3D_point_to_render_space(co, is_orthographic());
|
return gpencil_3D_point_to_render_space(co);
|
||||||
}
|
}
|
||||||
float2 result;
|
float2 result;
|
||||||
gpencil_3D_point_to_screen_space(co, result);
|
gpencil_3D_point_to_screen_space(co, result);
|
||||||
@@ -346,11 +338,6 @@ bool GpencilIO::is_camera_mode()
|
|||||||
return is_camera_;
|
return is_camera_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GpencilIO::is_orthographic()
|
|
||||||
{
|
|
||||||
return is_ortho_;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Calculate selected strokes boundbox. */
|
/* Calculate selected strokes boundbox. */
|
||||||
void GpencilIO::selected_objects_boundbox_calc()
|
void GpencilIO::selected_objects_boundbox_calc()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -88,14 +88,13 @@ class GpencilIO {
|
|||||||
|
|
||||||
/* Geometry functions. */
|
/* Geometry functions. */
|
||||||
bool gpencil_3D_point_to_screen_space(const float3 co, float2 &r_co);
|
bool gpencil_3D_point_to_screen_space(const float3 co, float2 &r_co);
|
||||||
float2 gpencil_3D_point_to_render_space(const float3 co, const bool is_ortho);
|
float2 gpencil_3D_point_to_render_space(const float3 co);
|
||||||
float2 gpencil_3D_point_to_2D(const float3 co);
|
float2 gpencil_3D_point_to_2D(const float3 co);
|
||||||
|
|
||||||
float stroke_point_radius_get(struct bGPDlayer *gpl, struct bGPDstroke *gps);
|
float stroke_point_radius_get(struct bGPDlayer *gpl, struct bGPDstroke *gps);
|
||||||
void create_object_list();
|
void create_object_list();
|
||||||
|
|
||||||
bool is_camera_mode();
|
bool is_camera_mode();
|
||||||
bool is_orthographic();
|
|
||||||
|
|
||||||
float stroke_average_opacity_get();
|
float stroke_average_opacity_get();
|
||||||
|
|
||||||
@@ -109,7 +108,6 @@ class GpencilIO {
|
|||||||
private:
|
private:
|
||||||
float avg_opacity_;
|
float avg_opacity_;
|
||||||
bool is_camera_;
|
bool is_camera_;
|
||||||
bool is_ortho_;
|
|
||||||
rctf select_boundbox_;
|
rctf select_boundbox_;
|
||||||
|
|
||||||
/* Camera matrix. */
|
/* Camera matrix. */
|
||||||
|
|||||||
Reference in New Issue
Block a user