[Bf-blender-cvs] [a86f40deb0e] temp-gpencil-fill: GPencil: Fix bug in Bound box calculation

Antonio Vazquez noreply at git.blender.org
Wed Feb 3 22:51:38 CET 2021


Commit: a86f40deb0ec3711ff7851daab55cc78a1021795
Author: Antonio Vazquez
Date:   Wed Feb 3 22:51:34 2021 +0100
Branches: temp-gpencil-fill
https://developer.blender.org/rBa86f40deb0ec3711ff7851daab55cc78a1021795

GPencil: Fix bug in Bound box calculation

The size was wrongly calculated because was not using the window size, only stroke size.

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

M	source/blender/editors/gpencil/gpencil_fill.c

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

diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 534cba55a87..b97c2ee927c 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -1904,8 +1904,24 @@ static void gpencil_zoom_level_set(tGPDfill *tgpf)
   BLI_rctf_clamp(&rect_bound, &rect_max, r_xy);
 
   /* Calculate total width used. */
-  float width = ceilf(rect_bound.xmax - rect_bound.xmin);
-  float height = ceilf(rect_bound.ymax - rect_bound.ymin);
+  float width = tgpf->region->winx;
+  if (rect_bound.xmin < 0.0f) {
+    width -= rect_bound.xmin;
+  }
+  if (rect_bound.xmax > tgpf->region->winx) {
+    width += rect_bound.xmax - tgpf->region->winx;
+  }
+  /* Calculate total height used. */
+  float height = tgpf->region->winy;
+  if (rect_bound.ymin < 0.0f) {
+    height -= rect_bound.ymin;
+  }
+  if (rect_bound.ymax > tgpf->region->winy) {
+    height += rect_bound.ymax - tgpf->region->winy;
+  }
+
+  width = ceilf(width);
+  height = ceilf(height);
 
   float zoomx = (width > tgpf->region->winx) ? width / (float)tgpf->region->winx : 1.0f;
   float zoomy = (height > tgpf->region->winy) ? height / (float)tgpf->region->winy : 1.0f;



More information about the Bf-blender-cvs mailing list