[mutter/gbsneto/pick-culling: 5/5] clutter/actor: Cull out when picking
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/gbsneto/pick-culling: 5/5] clutter/actor: Cull out when picking
- Date: Fri, 23 Oct 2020 00:18:57 +0000 (UTC)
commit 5b9a3dcc0be95e89de08cc6517c5e7c1606a843a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Oct 22 21:12:10 2020 -0300
clutter/actor: Cull out when picking
Testing points and rays against boxes is substantially cheaper
compared to triangles. Check if the actor's paint volume doesn't
intersect with the current pick point / ray, and skip recursing
altogether in those cases.
clutter/clutter/clutter-actor.c | 11 +++++++++++
clutter/clutter/clutter-pick-context-private.h | 4 ++++
clutter/clutter/clutter-pick-context.c | 8 ++++++++
3 files changed, 23 insertions(+)
---
diff --git a/clutter/clutter/clutter-actor.c b/clutter/clutter/clutter-actor.c
index 1d3fddddc3..1a9a2143dc 100644
--- a/clutter/clutter/clutter-actor.c
+++ b/clutter/clutter/clutter-actor.c
@@ -647,6 +647,7 @@
#include "clutter-paint-nodes.h"
#include "clutter-paint-node-private.h"
#include "clutter-paint-volume-private.h"
+#include "clutter-pick-context-private.h"
#include "clutter-private.h"
#include "clutter-property-transition.h"
#include "clutter-scriptable.h"
@@ -3964,6 +3965,15 @@ clutter_actor_pick (ClutterActor *actor,
/* mark that we are in the paint process */
CLUTTER_SET_PRIVATE_FLAGS (actor, CLUTTER_IN_PICK);
+ if (priv->paint_volume_valid && priv->last_paint_volume_valid)
+ {
+ graphene_box_t box;
+
+ _clutter_paint_volume_to_box (&priv->last_paint_volume, &box);
+ if (!clutter_pick_context_intersects_box (pick_context, &box))
+ goto out;
+ }
+
if (priv->enable_model_view_transform)
{
graphene_matrix_t matrix;
@@ -4012,6 +4022,7 @@ clutter_actor_pick (ClutterActor *actor,
if (transform_pushed)
clutter_pick_context_pop_transform (pick_context);
+out:
/* paint sequence complete */
CLUTTER_UNSET_PRIVATE_FLAGS (actor, CLUTTER_IN_PICK);
}
diff --git a/clutter/clutter/clutter-pick-context-private.h b/clutter/clutter/clutter-pick-context-private.h
index cc8baf8814..f40de6f3df 100644
--- a/clutter/clutter/clutter-pick-context-private.h
+++ b/clutter/clutter/clutter-pick-context-private.h
@@ -30,4 +30,8 @@ clutter_pick_context_new_for_view (ClutterStageView *view,
ClutterPickStack *
clutter_pick_context_steal_stack (ClutterPickContext *pick_context);
+gboolean
+clutter_pick_context_intersects_box (ClutterPickContext *pick_context,
+ const graphene_box_t *box);
+
#endif /* CLUTTER_PICK_CONTEXT_PRIVATE_H */
diff --git a/clutter/clutter/clutter-pick-context.c b/clutter/clutter/clutter-pick-context.c
index fd3d9e76a1..c56248f847 100644
--- a/clutter/clutter/clutter-pick-context.c
+++ b/clutter/clutter/clutter-pick-context.c
@@ -165,3 +165,11 @@ clutter_pick_context_pop_transform (ClutterPickContext *pick_context)
{
clutter_pick_stack_pop_transform (pick_context->pick_stack);
}
+
+gboolean
+clutter_pick_context_intersects_box (ClutterPickContext *pick_context,
+ const graphene_box_t *box)
+{
+ return graphene_box_contains_point (box, &pick_context->point) ||
+ graphene_ray_intersects_box (&pick_context->ray, box);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]