[mutter/gbsneto/untransformed-graphene-box-picking: 2/2] clutter/pick-stack: Move triangle check to else block
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/untransformed-graphene-box-picking: 2/2] clutter/pick-stack: Move triangle check to else block
- Date: Mon, 23 Nov 2020 16:34:39 +0000 (UTC)
commit 88726a1a2d02f73485b3af70ad4dab4a9fccce63
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Mon Nov 23 13:00:06 2020 -0300
clutter/pick-stack: Move triangle check to else block
Just to improve the legibility of this part of the code. We
go either through box, or triangle, but never both.
clutter/clutter/clutter-pick-stack.c | 63 ++++++++++++++++++------------------
1 file changed, 31 insertions(+), 32 deletions(-)
---
diff --git a/clutter/clutter/clutter-pick-stack.c b/clutter/clutter/clutter-pick-stack.c
index 71d6798332..5a2260a8ea 100644
--- a/clutter/clutter/clutter-pick-stack.c
+++ b/clutter/clutter/clutter-pick-stack.c
@@ -120,8 +120,6 @@ ray_intersects_input_region (Record *rec,
const graphene_ray_t *ray,
const graphene_point3d_t *point)
{
- graphene_triangle_t t0, t1;
-
maybe_project_record (rec);
if (G_LIKELY (is_axis_aligned_2d_rectangle (rec->vertices)))
@@ -132,36 +130,37 @@ ray_intersects_input_region (Record *rec,
return graphene_box_contains_point (&box, point) ||
graphene_ray_intersects_box (ray, &box);
}
-
- /*
- * Degrade the projected quad into the following triangles:
- *
- * 0 -------------- 1
- * | • |
- * | • t0 |
- * | • |
- * | t1 • |
- * | • |
- * 3 -------------- 2
- */
-
- graphene_triangle_init_from_point3d (&t0,
- &rec->vertices[0],
- &rec->vertices[1],
- &rec->vertices[2]);
-
- graphene_triangle_init_from_point3d (&t1,
- &rec->vertices[0],
- &rec->vertices[2],
- &rec->vertices[3]);
-
- if (graphene_triangle_contains_point (&t0, point) ||
- graphene_triangle_contains_point (&t1, point) ||
- graphene_ray_intersects_triangle (ray, &t0) ||
- graphene_ray_intersects_triangle (ray, &t1))
- return TRUE;
-
- return FALSE;
+ else
+ {
+ graphene_triangle_t t0, t1;
+
+ /*
+ * Degrade the projected quad into the following triangles:
+ *
+ * 0 -------------- 1
+ * | • |
+ * | • t0 |
+ * | • |
+ * | t1 • |
+ * | • |
+ * 3 -------------- 2
+ */
+
+ graphene_triangle_init_from_point3d (&t0,
+ &rec->vertices[0],
+ &rec->vertices[1],
+ &rec->vertices[2]);
+
+ graphene_triangle_init_from_point3d (&t1,
+ &rec->vertices[0],
+ &rec->vertices[2],
+ &rec->vertices[3]);
+
+ return graphene_triangle_contains_point (&t0, point) ||
+ graphene_triangle_contains_point (&t1, point) ||
+ graphene_ray_intersects_triangle (ray, &t0) ||
+ graphene_ray_intersects_triangle (ray, &t1);
+ }
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]