-#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) 2020 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/devel-api/common/stage.h>
#include <dali/integration-api/scene.h>
-
+#include <dali/public-api/actors/actor.h>
namespace Dali
{
-
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.
};
/**
*/
struct Results
{
- Actor actor; ///< The hit actor.
- Vector2 actorCoordinates; ///< The actor coordinates.
+ Actor actor; ///< The hit actor.
+ Vector2 actorCoordinates; ///< The actor coordinates.
};
/**
*
* @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
* @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