[Bf-blender-cvs] [e457e6fd05a] greasepencil-object: GPencil: Set collision box aligned to axis

Antonio Vazquez noreply at git.blender.org
Sat Feb 15 16:15:38 CET 2020


Commit: e457e6fd05aecf52d643a9428384967057c9bb20
Author: Antonio Vazquez
Date:   Sat Feb 15 16:15:27 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rBe457e6fd05aecf52d643a9428384967057c9bb20

GPencil: Set collision box aligned to axis

If the box was not aligned, the detection fails.

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

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

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

diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index de53f23e815..9245c55336e 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -2593,6 +2593,20 @@ bool ED_gpencil_stroke_check_collision(GP_SpaceConversion *gsc,
   gp_point_to_parent_space(&pt_dummy, diff_mat, &pt_dummy_ps);
   gp_point_to_xy_fl(gsc, gps, &pt_dummy_ps, &boundbox_max[0], &boundbox_max[1]);
 
+  /* Ensure the bounding box is oriented to axis. */
+  if (boundbox_max[0] < boundbox_min[0]) {
+    float box;
+    box = boundbox_min[0];
+    boundbox_min[0] = boundbox_max[0];
+    boundbox_max[0] = box;
+  }
+  if (boundbox_max[1] < boundbox_min[1]) {
+    float box;
+    box = boundbox_max[1];
+    boundbox_max[1] = boundbox_min[1];
+    boundbox_min[1] = box;
+  }
+
   rcti rect_stroke = {boundbox_min[0], boundbox_max[0], boundbox_min[1], boundbox_max[1]};
 
   /* For mouse, add a small offet to avoid false negative in corners. */



More information about the Bf-blender-cvs mailing list