[mutter/gbsneto/graphene-frustrum: 1/16] clutter/stage: Simplify view setup
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/graphene-frustrum: 1/16] clutter/stage: Simplify view setup
- Date: Sat, 10 Oct 2020 14:31:20 +0000 (UTC)
commit 683644606d01d64ea27e28b6d872ec9f5c583121
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Oct 9 15:54:18 2020 -0300
clutter/stage: Simplify view setup
ClutterStage defines the 8 vertices of a frustum:
4 ----------------------------- 5
| \ / |
| \ / |
| 0 --------------------- 1 |
| | | |
| | | |
| 3 --------------------- 2 |
| / \ |
| / \ |
7 ----------------------------- 6
Then, it uses triplets of vertices to create each clipping plane.
It only sets up 4 planes (it doesn't clip based on depth), defined
by the following vertices:
* 0 - 4 - 5
* 1 - 5 - 6
* 2 - 6 - 7
* 0 - 7 - 4
The first 3 triplets are selected using the for-loop. However, the
last triplet is different, and is done out of the loop. It could
have been made simpler by using the "3 - 7 - 4" triplet.
Simplify the current code by using the suggested triplet, calculated
inside the for-loop.
clutter/clutter/clutter-stage.c | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index c9680388b6..e9d06cbd23 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -674,7 +674,6 @@ _cogl_util_get_eye_planes_for_screen_poly (float *polygon,
graphene_vec3_t b;
graphene_vec3_t c;
float zw, ww;
- int count;
tmp_poly = g_alloca (sizeof (Vector4) * n_vertices * 2);
@@ -738,8 +737,7 @@ _cogl_util_get_eye_planes_for_screen_poly (float *polygon,
* cogl_vector APIs just took pointers to floats.
*/
- count = n_vertices - 1;
- for (i = 0; i < count; i++)
+ for (i = 0; i < n_vertices; i++)
{
plane = &planes[i];
@@ -749,7 +747,7 @@ _cogl_util_get_eye_planes_for_screen_poly (float *polygon,
poly = &tmp_poly[n_vertices + i];
graphene_vec3_init (&b, poly->x, poly->y, poly->z);
- poly = &tmp_poly[n_vertices + i + 1];
+ poly = &tmp_poly[n_vertices + ((i + 1) % n_vertices)];
graphene_vec3_init (&c, poly->x, poly->y, poly->z);
graphene_vec3_subtract (&b, &plane->v0, &b);
@@ -757,22 +755,6 @@ _cogl_util_get_eye_planes_for_screen_poly (float *polygon,
graphene_vec3_cross (&b, &c, &plane->n);
graphene_vec3_normalize (&plane->n, &plane->n);
}
-
- plane = &planes[n_vertices - 1];
-
- poly = &tmp_poly[0];
- graphene_vec3_init (&plane->v0, poly->x, poly->y, poly->z);
-
- poly = &tmp_poly[2 * n_vertices - 1];
- graphene_vec3_init (&b, poly->x, poly->y, poly->z);
-
- poly = &tmp_poly[n_vertices];
- graphene_vec3_init (&c, poly->x, poly->y, poly->z);
-
- graphene_vec3_subtract (&b, &plane->v0, &b);
- graphene_vec3_subtract (&c, &plane->v0, &c);
- graphene_vec3_cross (&b, &c, &plane->n);
- graphene_vec3_normalize (&plane->n, &plane->n);
}
/* XXX: Instead of having a toplevel 2D clip region, it might be
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]