mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
clutter/actor: Cull out when picking
Testing points and rays against boxes is substantially cheaper - in fact, almost trivial - 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. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1520>
This commit is contained in:
parent
1fdde25b3e
commit
6c4b897d74
@ -635,6 +635,7 @@
|
|||||||
#include "clutter-paint-nodes.h"
|
#include "clutter-paint-nodes.h"
|
||||||
#include "clutter-paint-node-private.h"
|
#include "clutter-paint-node-private.h"
|
||||||
#include "clutter-paint-volume-private.h"
|
#include "clutter-paint-volume-private.h"
|
||||||
|
#include "clutter-pick-context-private.h"
|
||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
#include "clutter-property-transition.h"
|
#include "clutter-property-transition.h"
|
||||||
#include "clutter-scriptable.h"
|
#include "clutter-scriptable.h"
|
||||||
@ -3959,6 +3960,15 @@ clutter_actor_pick (ClutterActor *actor,
|
|||||||
/* mark that we are in the paint process */
|
/* mark that we are in the paint process */
|
||||||
CLUTTER_SET_PRIVATE_FLAGS (actor, CLUTTER_IN_PICK);
|
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)
|
if (priv->enable_model_view_transform)
|
||||||
{
|
{
|
||||||
graphene_matrix_t matrix;
|
graphene_matrix_t matrix;
|
||||||
@ -4007,6 +4017,7 @@ clutter_actor_pick (ClutterActor *actor,
|
|||||||
if (transform_pushed)
|
if (transform_pushed)
|
||||||
clutter_pick_context_pop_transform (pick_context);
|
clutter_pick_context_pop_transform (pick_context);
|
||||||
|
|
||||||
|
out:
|
||||||
/* paint sequence complete */
|
/* paint sequence complete */
|
||||||
CLUTTER_UNSET_PRIVATE_FLAGS (actor, CLUTTER_IN_PICK);
|
CLUTTER_UNSET_PRIVATE_FLAGS (actor, CLUTTER_IN_PICK);
|
||||||
}
|
}
|
||||||
|
@ -30,4 +30,8 @@ clutter_pick_context_new_for_view (ClutterStageView *view,
|
|||||||
ClutterPickStack *
|
ClutterPickStack *
|
||||||
clutter_pick_context_steal_stack (ClutterPickContext *pick_context);
|
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 */
|
#endif /* CLUTTER_PICK_CONTEXT_PRIVATE_H */
|
||||||
|
@ -189,3 +189,11 @@ clutter_pick_context_pop_transform (ClutterPickContext *pick_context)
|
|||||||
{
|
{
|
||||||
clutter_pick_stack_pop_transform (pick_context->pick_stack);
|
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);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user