Add BuildPickingRay to devel api
[platform/core/uifw/dali-core.git] / dali / devel-api / events / hit-test-algorithm.h
index f3b5774..cc7aad9 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef  __DALI_HIT_TEST_ALGORITHM_H__
-#define  __DALI_HIT_TEST_ALGORITHM_H__
+#ifndef __DALI_HIT_TEST_ALGORITHM_H__
+#define __DALI_HIT_TEST_ALGORITHM_H__
 
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  */
 
-#include <dali/public-api/actors/actor.h>
-#include <dali/public-api/common/stage.h>
+#include <dali/devel-api/common/stage.h>
 #include <dali/integration-api/scene.h>
-
+#include <dali/public-api/actors/actor.h>
 
 namespace Dali
 {
-
 class RenderTask;
 
 /**
@@ -102,14 +100,13 @@ class RenderTask;
  */
 namespace HitTestAlgorithm
 {
-
 /**
  * @brief How the actor tree should be traversed.
  */
 enum TraverseType
 {
-  CHECK_ACTOR,            ///< Hit test the given actor.
-  DESCEND_ACTOR_TREE      ///< Check whether the actor tree should be descended to hit-test its children.
+  CHECK_ACTOR,       ///< Hit test the given actor.
+  DESCEND_ACTOR_TREE ///< Check whether the actor tree should be descended to hit-test its children.
 };
 
 /**
@@ -117,8 +114,8 @@ enum TraverseType
  */
 struct Results
 {
-  Actor      actor;            ///< The hit actor.
-  Vector2    actorCoordinates; ///< The actor coordinates.
+  Actor   actor;            ///< The hit actor.
+  Vector2 actorCoordinates; ///< The actor coordinates.
 };
 
 /**
@@ -126,7 +123,7 @@ struct Results
  *
  * @return true, if the actor is hittable, false otherwise.
  */
-typedef bool (*HitTestFunction)(Actor actor, TraverseType type);
+using HitTestFunction = bool (*)(Actor, TraverseType);
 
 /**
  * @brief Given screen coordinates, this method returns the hit actor & the local coordinates relative to
@@ -144,7 +141,18 @@ typedef bool (*HitTestFunction)(Actor actor, TraverseType type);
  * @param[in] func The function to use in the hit-test algorithm.
  * @return true if something was hit
  */
-DALI_CORE_API bool HitTest( Stage stage, const Vector2& screenCoordinates, Results& results, HitTestFunction func );
+DALI_CORE_API bool HitTest(Stage stage, const Vector2& screenCoordinates, Results& results, HitTestFunction func);
+
+/**
+ * @brief Given screen coordinates, this method returns the camera origin in world coordinates and the direction of the picking ray in world-space.
+ *
+ * @param[in] renderTask The render task owning a camera.
+ * @param[in] screenCoordinates The screen coordinates.
+ * @param[out] origin The camera origin in world coordinates
+ * @param[out] direction The direction of the picking ray in world-space
+ * @return true if the screen coordinates are inside the render task's viewport
+ */
+DALI_CORE_API bool BuildPickingRay(RenderTask renderTask, const Vector2& screenCoordinates, Vector3& origin, Vector3& direction);
 
 } // namespace HitTestAlgorithm