mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
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:
parent
1b29d265a8
commit
c3534d3390
@ -21,8 +21,11 @@
|
|||||||
#include "clutter-pick-context.h"
|
#include "clutter-pick-context.h"
|
||||||
#include "clutter-pick-stack-private.h"
|
#include "clutter-pick-stack-private.h"
|
||||||
|
|
||||||
ClutterPickContext * clutter_pick_context_new_for_view (ClutterStageView *view,
|
ClutterPickContext *
|
||||||
ClutterPickMode mode);
|
clutter_pick_context_new_for_view (ClutterStageView *view,
|
||||||
|
ClutterPickMode mode,
|
||||||
|
const graphene_point3d_t *point,
|
||||||
|
const graphene_ray_t *ray);
|
||||||
|
|
||||||
ClutterPickStack *
|
ClutterPickStack *
|
||||||
clutter_pick_context_steal_stack (ClutterPickContext *pick_context);
|
clutter_pick_context_steal_stack (ClutterPickContext *pick_context);
|
||||||
|
@ -26,6 +26,9 @@ struct _ClutterPickContext
|
|||||||
|
|
||||||
ClutterPickMode mode;
|
ClutterPickMode mode;
|
||||||
ClutterPickStack *pick_stack;
|
ClutterPickStack *pick_stack;
|
||||||
|
|
||||||
|
graphene_ray_t ray;
|
||||||
|
graphene_point3d_t point;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE (ClutterPickContext, clutter_pick_context,
|
G_DEFINE_BOXED_TYPE (ClutterPickContext, clutter_pick_context,
|
||||||
@ -34,7 +37,9 @@ G_DEFINE_BOXED_TYPE (ClutterPickContext, clutter_pick_context,
|
|||||||
|
|
||||||
ClutterPickContext *
|
ClutterPickContext *
|
||||||
clutter_pick_context_new_for_view (ClutterStageView *view,
|
clutter_pick_context_new_for_view (ClutterStageView *view,
|
||||||
ClutterPickMode mode)
|
ClutterPickMode mode,
|
||||||
|
const graphene_point3d_t *point,
|
||||||
|
const graphene_ray_t *ray)
|
||||||
{
|
{
|
||||||
ClutterPickContext *pick_context;
|
ClutterPickContext *pick_context;
|
||||||
CoglContext *context;
|
CoglContext *context;
|
||||||
@ -42,6 +47,8 @@ clutter_pick_context_new_for_view (ClutterStageView *view,
|
|||||||
pick_context = g_new0 (ClutterPickContext, 1);
|
pick_context = g_new0 (ClutterPickContext, 1);
|
||||||
g_ref_count_init (&pick_context->ref_count);
|
g_ref_count_init (&pick_context->ref_count);
|
||||||
pick_context->mode = mode;
|
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 ());
|
context = clutter_backend_get_cogl_context (clutter_get_default_backend ());
|
||||||
pick_context->pick_stack = clutter_pick_stack_new (context);
|
pick_context->pick_stack = clutter_pick_stack_new (context);
|
||||||
|
@ -1088,14 +1088,14 @@ _clutter_stage_do_pick_on_view (ClutterStage *stage,
|
|||||||
|
|
||||||
COGL_TRACE_BEGIN_SCOPED (ClutterStagePickView, "Pick (view)");
|
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);
|
clutter_actor_pick (CLUTTER_ACTOR (stage), pick_context);
|
||||||
pick_stack = clutter_pick_context_steal_stack (pick_context);
|
pick_stack = clutter_pick_context_steal_stack (pick_context);
|
||||||
clutter_pick_context_destroy (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);
|
actor = clutter_pick_stack_search_actor (pick_stack, &p, &ray);
|
||||||
return actor ? actor : CLUTTER_ACTOR (stage);
|
return actor ? actor : CLUTTER_ACTOR (stage);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user