[Bf-blender-cvs] [a119282161b] greasepencil-object: GPencil: Fix SVG export zdepth issues using other views.

Antonio Vazquez noreply at git.blender.org
Sat Aug 1 21:06:26 CEST 2020


Commit: a119282161b83e918ae3b59c677876380d08bb5f
Author: Antonio Vazquez
Date:   Sat Aug 1 21:06:18 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rBa119282161b83e918ae3b59c677876380d08bb5f

GPencil: Fix SVG export zdepth issues using other views.

It was working only in camera view.

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

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

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

diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.cc b/source/blender/io/gpencil/intern/gpencil_io_base.cc
index 5a9df648338..328b859a5af 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc
@@ -124,16 +124,31 @@ GpencilExporter::GpencilExporter(const struct GpencilExportParams *iparams)
     }
 
     if (base->flag & BASE_SELECTED) {
-      /* Save zdepth from view to sort from back to front. */
-      float camera_z = dot_v3v3(camera_z_axis, object->obmat[3]);
-      ObjectZ obz = {camera_z, object};
-      ob_list_.push_back(obz);
+      /* Save z-depth from view to sort from back to front. */
+      if (is_camera) {
+        float camera_z = dot_v3v3(camera_z_axis, object->obmat[3]);
+        ObjectZ obz = {camera_z, object};
+        ob_list_.push_back(obz);
+      }
+      else {
+        float zdepth = 0;
+        if (rv3d) {
+          if (rv3d->is_persp) {
+            zdepth = ED_view3d_calc_zfac(rv3d, object->obmat[3], NULL);
+          }
+          else {
+            zdepth = -dot_v3v3(rv3d->viewinv[2], object->obmat[3]);
+          }
+          ObjectZ obz = {zdepth * -1.0f, object};
+          ob_list_.push_back(obz);
+        }
+      }
     }
-  }
 
-  /* Sort list of objects from point of view. */
-  ob_list_.sort(
-      [](const ObjectZ &obz1, const ObjectZ &obz2) { return obz1.zdepth < obz2.zdepth; });
+    /* Sort list of objects from point of view. */
+    ob_list_.sort(
+        [](const ObjectZ &obz1, const ObjectZ &obz2) { return obz1.zdepth < obz2.zdepth; });
+  }
 }
 
 /**



More information about the Bf-blender-cvs mailing list