1
0
Fork 0

clutter/pick-context: Store point and ray on construction

It'll be used to do a quick box test to cull out while picking.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1520>
This commit is contained in:
Georges Basile Stavracas Neto 2020-10-22 21:10:33 -03:00 committed by Marge Bot
parent 1b29d265a8
commit c3534d3390
3 changed files with 17 additions and 7 deletions

View file

@ -21,8 +21,11 @@
#include "clutter-pick-context.h"
#include "clutter-pick-stack-private.h"
ClutterPickContext * clutter_pick_context_new_for_view (ClutterStageView *view,
ClutterPickMode mode);
ClutterPickContext *
clutter_pick_context_new_for_view (ClutterStageView *view,
ClutterPickMode mode,
const graphene_point3d_t *point,
const graphene_ray_t *ray);
ClutterPickStack *
clutter_pick_context_steal_stack (ClutterPickContext *pick_context);

View file

@ -26,6 +26,9 @@ struct _ClutterPickContext
ClutterPickMode mode;
ClutterPickStack *pick_stack;
graphene_ray_t ray;
graphene_point3d_t point;
};
G_DEFINE_BOXED_TYPE (ClutterPickContext, clutter_pick_context,
@ -33,8 +36,10 @@ G_DEFINE_BOXED_TYPE (ClutterPickContext, clutter_pick_context,
clutter_pick_context_unref)
ClutterPickContext *
clutter_pick_context_new_for_view (ClutterStageView *view,
ClutterPickMode mode)
clutter_pick_context_new_for_view (ClutterStageView *view,
ClutterPickMode mode,
const graphene_point3d_t *point,
const graphene_ray_t *ray)
{
ClutterPickContext *pick_context;
CoglContext *context;
@ -42,6 +47,8 @@ clutter_pick_context_new_for_view (ClutterStageView *view,
pick_context = g_new0 (ClutterPickContext, 1);
g_ref_count_init (&pick_context->ref_count);
pick_context->mode = mode;
graphene_ray_init_from_ray (&pick_context->ray, ray);
graphene_point3d_init_from_point (&pick_context->point, point);
context = clutter_backend_get_cogl_context (clutter_get_default_backend ());
pick_context->pick_stack = clutter_pick_stack_new (context);

View file

@ -1088,14 +1088,14 @@ _clutter_stage_do_pick_on_view (ClutterStage *stage,
COGL_TRACE_BEGIN_SCOPED (ClutterStagePickView, "Pick (view)");
pick_context = clutter_pick_context_new_for_view (view, mode);
setup_ray_for_coordinates (stage, x, y, &p, &ray);
pick_context = clutter_pick_context_new_for_view (view, mode, &p, &ray);
clutter_actor_pick (CLUTTER_ACTOR (stage), pick_context);
pick_stack = clutter_pick_context_steal_stack (pick_context);
clutter_pick_context_destroy (pick_context);
setup_ray_for_coordinates (stage, x, y, &p, &ray);
actor = clutter_pick_stack_search_actor (pick_stack, &p, &ray);
return actor ? actor : CLUTTER_ACTOR (stage);
}