clutter/stage: Use graphene_plane_t for clipping planes

It allows us to remove quite a bunch of code, and not deal with part
of the mind-melting maths behind it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1489
This commit is contained in:
Georges Basile Stavracas Neto 2020-10-09 16:29:52 -03:00
parent 175851eef7
commit 793ca68d8c
5 changed files with 19 additions and 32 deletions

View File

@ -3444,7 +3444,7 @@ cull_actor (ClutterActor *self,
{
ClutterActorPrivate *priv = self->priv;
ClutterStage *stage;
const ClutterPlane *stage_clip;
const graphene_plane_t *stage_clip;
if (!priv->last_paint_volume_valid)
{

View File

@ -123,8 +123,8 @@ void _clutter_paint_volume_axis_align (ClutterPaintVolu
void _clutter_paint_volume_set_reference_actor (ClutterPaintVolume *pv,
ClutterActor *actor);
ClutterCullResult _clutter_paint_volume_cull (ClutterPaintVolume *pv,
const ClutterPlane *planes);
ClutterCullResult _clutter_paint_volume_cull (ClutterPaintVolume *pv,
const graphene_plane_t *planes);
void _clutter_paint_volume_get_stage_paint_box (ClutterPaintVolume *pv,
ClutterStage *stage,

View File

@ -1071,8 +1071,8 @@ _clutter_paint_volume_set_reference_actor (ClutterPaintVolume *pv,
}
ClutterCullResult
_clutter_paint_volume_cull (ClutterPaintVolume *pv,
const ClutterPlane *planes)
_clutter_paint_volume_cull (ClutterPaintVolume *pv,
const graphene_plane_t *planes)
{
int vertex_count;
graphene_point3d_t *vertices = pv->vertices;
@ -1097,18 +1097,11 @@ _clutter_paint_volume_cull (ClutterPaintVolume *pv,
for (i = 0; i < 4; i++)
{
const ClutterPlane *plane = &planes[i];
const graphene_plane_t *plane = &planes[i];
int out = 0;
for (j = 0; j < vertex_count; j++)
{
graphene_vec3_t v;
graphene_vec3_init (&v,
vertices[j].x - graphene_vec3_get_x (&plane->v0),
vertices[j].y - graphene_vec3_get_y (&plane->v0),
vertices[j].z - graphene_vec3_get_z (&plane->v0));
if (graphene_vec3_dot (&plane->n, &v) < 0)
if (graphene_plane_distance (plane, &vertices[j]) < 0)
out++;
}

View File

@ -98,7 +98,7 @@ ClutterActor *_clutter_stage_do_pick (ClutterStage *stage,
ClutterPaintVolume *_clutter_stage_paint_volume_stack_allocate (ClutterStage *stage);
void _clutter_stage_paint_volume_stack_free_all (ClutterStage *stage);
const ClutterPlane *_clutter_stage_get_clip (ClutterStage *stage);
const graphene_plane_t *_clutter_stage_get_clip (ClutterStage *stage);
ClutterStageQueueRedrawEntry *_clutter_stage_queue_actor_redraw (ClutterStage *stage,
ClutterStageQueueRedrawEntry *entry,

View File

@ -115,7 +115,7 @@ struct _ClutterStagePrivate
GArray *paint_volume_stack;
ClutterPlane current_clip_planes[4];
graphene_plane_t current_clip_planes[4];
GSList *pending_relayouts;
GList *pending_queue_redraws;
@ -659,20 +659,17 @@ typedef struct _Vector4
} Vector4;
static void
_cogl_util_get_eye_planes_for_screen_poly (float *polygon,
int n_vertices,
float *viewport,
_cogl_util_get_eye_planes_for_screen_poly (float *polygon,
int n_vertices,
float *viewport,
const graphene_matrix_t *projection,
const graphene_matrix_t *inverse_project,
ClutterPlane *planes)
graphene_plane_t *planes)
{
float Wc;
Vector4 *tmp_poly;
ClutterPlane *plane;
int i;
Vector4 *poly;
graphene_vec3_t b;
graphene_vec3_t c;
float zw, ww;
tmp_poly = g_alloca (sizeof (Vector4) * n_vertices * 2);
@ -739,21 +736,18 @@ _cogl_util_get_eye_planes_for_screen_poly (float *polygon,
for (i = 0; i < n_vertices; i++)
{
plane = &planes[i];
graphene_point3d_t p[3];
poly = &tmp_poly[i];
graphene_vec3_init (&plane->v0, poly->x, poly->y, poly->z);
graphene_point3d_init (&p[0], poly->x, poly->y, poly->z);
poly = &tmp_poly[n_vertices + i];
graphene_vec3_init (&b, poly->x, poly->y, poly->z);
graphene_point3d_init (&p[1], poly->x, poly->y, poly->z);
poly = &tmp_poly[n_vertices + ((i + 1) % n_vertices)];
graphene_vec3_init (&c, poly->x, poly->y, poly->z);
graphene_point3d_init (&p[2], 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);
graphene_plane_init_from_points (&planes[i], &p[0], &p[1], &p[2]);
}
}
@ -3081,7 +3075,7 @@ _clutter_stage_paint_volume_stack_free_all (ClutterStage *stage)
/* The is an out-of-band parameter available while painting that
* can be used to cull actors. */
const ClutterPlane *
const graphene_plane_t *
_clutter_stage_get_clip (ClutterStage *stage)
{
return stage->priv->current_clip_planes;