1 #ifndef __DALI_INTERNAL_HIT_TEST_ALGORITHM_H__
2 #define __DALI_INTERNAL_HIT_TEST_ALGORITHM_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/events/hit-test-algorithm.h>
23 #include <dali/public-api/render-tasks/render-task.h>
32 * This namespace is provided for application developers to do hit test for the actors.
34 namespace HitTestAlgorithm
39 Dali::RenderTask renderTask; ///< The render-task displaying the actor.
40 Dali::Actor actor; ///< The hit actor.
41 Vector2 actorCoordinates; ///< The actor coordinates.
42 Vector4 rayOrigin; ///< The point of origin of the ray.
43 Vector4 rayDirection; ///< The direction vector of the ray.
47 * @copydoc Dali::HitTestAlgorithm::HitTest(Stage stage, const Vector2& screenCoordinates, Results& results, HitTestFunction func )
49 void HitTest( Stage& stage, const Vector2& screenCoordinates, Dali::HitTestAlgorithm::Results& results, Dali::HitTestAlgorithm::HitTestFunction func );
52 * Given screen coordinates, this method returns the hit actor & the local coordinates relative to the actor etc.
53 * @param[in] stage The stage.
54 * @param[in] screenCoordinates The screen coordinates.
55 * @param[out] results The results of the hit-test.
57 * <h3>Hit Test Algorithm:</h3>
59 * - The system overlay RenderTaskList is hit-tested first.
60 * - If no hit then the regular RenderTaskList is used to hit test the on stage actors.
61 * - The bulk of the hit test algorithm is described in Dali::Actor.
62 * - In each RenderTask's its viewing parameters (the view and projection matrices, and the viewport)
63 * are used to build a picking ray into the scene which is used for our ray tests when hit testing
64 * an actor within each layer.
65 * - If an actor is deemed to be hittable, then a quicker ray sphere test on the actor is performed
66 * first to determine if the ray is in the actor's proximity.
67 * - If this is also successful, then a more accurate ray test is performed to see if we have a hit.
69 * - NOTE: Currently, we prefer a child hit over a parent (regardless of the distance from the
70 * camera) unless the parent is a RenderableActor but this is subject to change.
72 void HitTest( Stage& stage, const Vector2& screenCoordinates, Results& results );
75 * Hit test specific to a given RenderTask
76 * @param[in] stage The stage.
77 * @param[in] renderTask The render task for hit test
78 * @param[in] screenCoordinates The screen coordinates.
79 * @param[out] results The results of the hit-test.
80 * @param[in] func The function to use in the hit-test algorithm.
82 void HitTest( Stage& stage, RenderTask& renderTask, const Vector2& screenCoordinates,
83 Dali::HitTestAlgorithm::Results& results, Dali::HitTestAlgorithm::HitTestFunction func );
85 } // namespace HitTestAlgorithm
87 } // namespace Internal
91 #endif // __DALI_INTERNAL_HIT_TEST_ALGORITHM_H__