mirror of
https://github.com/brl/mutter.git
synced 2025-02-08 17:44:09 +00:00
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:
parent
175851eef7
commit
793ca68d8c
@ -3444,7 +3444,7 @@ cull_actor (ClutterActor *self,
|
|||||||
{
|
{
|
||||||
ClutterActorPrivate *priv = self->priv;
|
ClutterActorPrivate *priv = self->priv;
|
||||||
ClutterStage *stage;
|
ClutterStage *stage;
|
||||||
const ClutterPlane *stage_clip;
|
const graphene_plane_t *stage_clip;
|
||||||
|
|
||||||
if (!priv->last_paint_volume_valid)
|
if (!priv->last_paint_volume_valid)
|
||||||
{
|
{
|
||||||
|
@ -124,7 +124,7 @@ void _clutter_paint_volume_set_reference_actor (ClutterPaintVolu
|
|||||||
ClutterActor *actor);
|
ClutterActor *actor);
|
||||||
|
|
||||||
ClutterCullResult _clutter_paint_volume_cull (ClutterPaintVolume *pv,
|
ClutterCullResult _clutter_paint_volume_cull (ClutterPaintVolume *pv,
|
||||||
const ClutterPlane *planes);
|
const graphene_plane_t *planes);
|
||||||
|
|
||||||
void _clutter_paint_volume_get_stage_paint_box (ClutterPaintVolume *pv,
|
void _clutter_paint_volume_get_stage_paint_box (ClutterPaintVolume *pv,
|
||||||
ClutterStage *stage,
|
ClutterStage *stage,
|
||||||
|
@ -1072,7 +1072,7 @@ _clutter_paint_volume_set_reference_actor (ClutterPaintVolume *pv,
|
|||||||
|
|
||||||
ClutterCullResult
|
ClutterCullResult
|
||||||
_clutter_paint_volume_cull (ClutterPaintVolume *pv,
|
_clutter_paint_volume_cull (ClutterPaintVolume *pv,
|
||||||
const ClutterPlane *planes)
|
const graphene_plane_t *planes)
|
||||||
{
|
{
|
||||||
int vertex_count;
|
int vertex_count;
|
||||||
graphene_point3d_t *vertices = pv->vertices;
|
graphene_point3d_t *vertices = pv->vertices;
|
||||||
@ -1097,18 +1097,11 @@ _clutter_paint_volume_cull (ClutterPaintVolume *pv,
|
|||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
const ClutterPlane *plane = &planes[i];
|
const graphene_plane_t *plane = &planes[i];
|
||||||
int out = 0;
|
int out = 0;
|
||||||
for (j = 0; j < vertex_count; j++)
|
for (j = 0; j < vertex_count; j++)
|
||||||
{
|
{
|
||||||
graphene_vec3_t v;
|
if (graphene_plane_distance (plane, &vertices[j]) < 0)
|
||||||
|
|
||||||
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)
|
|
||||||
out++;
|
out++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ ClutterActor *_clutter_stage_do_pick (ClutterStage *stage,
|
|||||||
ClutterPaintVolume *_clutter_stage_paint_volume_stack_allocate (ClutterStage *stage);
|
ClutterPaintVolume *_clutter_stage_paint_volume_stack_allocate (ClutterStage *stage);
|
||||||
void _clutter_stage_paint_volume_stack_free_all (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 *_clutter_stage_queue_actor_redraw (ClutterStage *stage,
|
||||||
ClutterStageQueueRedrawEntry *entry,
|
ClutterStageQueueRedrawEntry *entry,
|
||||||
|
@ -115,7 +115,7 @@ struct _ClutterStagePrivate
|
|||||||
|
|
||||||
GArray *paint_volume_stack;
|
GArray *paint_volume_stack;
|
||||||
|
|
||||||
ClutterPlane current_clip_planes[4];
|
graphene_plane_t current_clip_planes[4];
|
||||||
|
|
||||||
GSList *pending_relayouts;
|
GSList *pending_relayouts;
|
||||||
GList *pending_queue_redraws;
|
GList *pending_queue_redraws;
|
||||||
@ -664,15 +664,12 @@ _cogl_util_get_eye_planes_for_screen_poly (float *polygon,
|
|||||||
float *viewport,
|
float *viewport,
|
||||||
const graphene_matrix_t *projection,
|
const graphene_matrix_t *projection,
|
||||||
const graphene_matrix_t *inverse_project,
|
const graphene_matrix_t *inverse_project,
|
||||||
ClutterPlane *planes)
|
graphene_plane_t *planes)
|
||||||
{
|
{
|
||||||
float Wc;
|
float Wc;
|
||||||
Vector4 *tmp_poly;
|
Vector4 *tmp_poly;
|
||||||
ClutterPlane *plane;
|
|
||||||
int i;
|
int i;
|
||||||
Vector4 *poly;
|
Vector4 *poly;
|
||||||
graphene_vec3_t b;
|
|
||||||
graphene_vec3_t c;
|
|
||||||
float zw, ww;
|
float zw, ww;
|
||||||
|
|
||||||
tmp_poly = g_alloca (sizeof (Vector4) * n_vertices * 2);
|
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++)
|
for (i = 0; i < n_vertices; i++)
|
||||||
{
|
{
|
||||||
plane = &planes[i];
|
graphene_point3d_t p[3];
|
||||||
|
|
||||||
poly = &tmp_poly[i];
|
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];
|
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)];
|
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_plane_init_from_points (&planes[i], &p[0], &p[1], &p[2]);
|
||||||
graphene_vec3_subtract (&c, &plane->v0, &c);
|
|
||||||
graphene_vec3_cross (&b, &c, &plane->n);
|
|
||||||
graphene_vec3_normalize (&plane->n, &plane->n);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3081,7 +3075,7 @@ _clutter_stage_paint_volume_stack_free_all (ClutterStage *stage)
|
|||||||
|
|
||||||
/* The is an out-of-band parameter available while painting that
|
/* The is an out-of-band parameter available while painting that
|
||||||
* can be used to cull actors. */
|
* can be used to cull actors. */
|
||||||
const ClutterPlane *
|
const graphene_plane_t *
|
||||||
_clutter_stage_get_clip (ClutterStage *stage)
|
_clutter_stage_get_clip (ClutterStage *stage)
|
||||||
{
|
{
|
||||||
return stage->priv->current_clip_planes;
|
return stage->priv->current_clip_planes;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user