[mutter/gbsneto/pick-culling: 60/63] clutter/pick-context: Store point and ray on construction




commit b0fd1fb37ed51d9639169d2ecab46a6729e28cb7
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Oct 22 21:10:33 2020 -0300

    clutter/pick-context: Store point and ray on construction
    
    It'll be used to do a quick box test to cull out while picking.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1520

 clutter/clutter/clutter-pick-context-private.h |  7 +++++--
 clutter/clutter/clutter-pick-context.c         | 11 +++++++++--
 clutter/clutter/clutter-stage.c                |  6 +++---
 3 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/clutter/clutter/clutter-pick-context-private.h b/clutter/clutter/clutter-pick-context-private.h
index cfbfce6eb4..cc8baf8814 100644
--- a/clutter/clutter/clutter-pick-context-private.h
+++ b/clutter/clutter/clutter-pick-context-private.h
@@ -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);
diff --git a/clutter/clutter/clutter-pick-context.c b/clutter/clutter/clutter-pick-context.c
index 4e6fb7a882..b9758366d4 100644
--- a/clutter/clutter/clutter-pick-context.c
+++ b/clutter/clutter/clutter-pick-context.c
@@ -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);
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 01f63cbfcb..de4a3c18e6 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -1156,14 +1156,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);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]