[Bf-blender-cvs] [5b34d11b55e] master: Fix add-object tools cursor distorted drawing on save

Campbell Barton noreply at git.blender.org
Fri Nov 20 02:16:42 CET 2020


Commit: 5b34d11b55e06efa17cd5e717380e78d5e0e8d8b
Author: Campbell Barton
Date:   Fri Nov 20 12:13:18 2020 +1100
Branches: master
https://developer.blender.org/rB5b34d11b55e06efa17cd5e717380e78d5e0e8d8b

Fix add-object tools cursor distorted drawing on save

Generating the thumbnail left the view matrices set to values
that couldn't be used for cursor drawing.

Backup/restore the matrices for off-screen drawing.

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

M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/python/gpu/gpu_py_offscreen.c

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

diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 02afe60d578..3b5dc3f57b9 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1685,12 +1685,21 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph,
     /* #Region */
     int region_winx, region_winy;
     rcti region_winrct;
+
+    /* #RegionView3D */
+    /**
+     * Needed so the value won't be left overwritten,
+     * Without this the #wmPaintCursor can't use the pixel size & view matrices for drawing.
+     */
+    struct RV3DMatrixStore *rv3d_mats;
   } orig = {
       .v3d_shading_type = v3d->shading.type,
 
       .region_winx = region->winx,
       .region_winy = region->winy,
       .region_winrct = region->winrct,
+
+      .rv3d_mats = ED_view3d_mats_rv3d_backup(region->regiondata),
   };
 
   UI_Theme_Store(&orig.theme_state);
@@ -1748,6 +1757,9 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph,
   region->winy = orig.region_winy;
   region->winrct = orig.region_winrct;
 
+  ED_view3d_mats_rv3d_restore(region->regiondata, orig.rv3d_mats);
+  MEM_freeN(orig.rv3d_mats);
+
   UI_Theme_Restore(&orig.theme_state);
 
   v3d->shading.type = orig.v3d_shading_type;
diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c
index aa85b130888..6d14dd0de5f 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.c
+++ b/source/blender/python/gpu/gpu_py_offscreen.c
@@ -220,7 +220,6 @@ static PyObject *bpygpu_offscreen_draw_view3d(BPyGPUOffScreen *self,
   struct ViewLayer *view_layer;
   View3D *v3d;
   ARegion *region;
-  struct RV3DMatrixStore *rv3d_mats;
 
   BPY_GPU_OFFSCREEN_CHECK_OBJ(self);
 
@@ -250,8 +249,6 @@ static PyObject *bpygpu_offscreen_draw_view3d(BPyGPUOffScreen *self,
 
   depsgraph = BKE_scene_ensure_depsgraph(G_MAIN, scene, view_layer);
 
-  rv3d_mats = ED_view3d_mats_rv3d_backup(region->regiondata);
-
   GPU_offscreen_bind(self->ofs, true);
 
   ED_view3d_draw_offscreen(depsgraph,
@@ -272,9 +269,6 @@ static PyObject *bpygpu_offscreen_draw_view3d(BPyGPUOffScreen *self,
 
   GPU_offscreen_unbind(self->ofs, true);
 
-  ED_view3d_mats_rv3d_restore(region->regiondata, rv3d_mats);
-  MEM_freeN(rv3d_mats);
-
   Py_RETURN_NONE;
 }



More information about the Bf-blender-cvs mailing list