DALi Version 2.0.1
[platform/core/uifw/dali-core.git] / dali / internal / event / events / ray-test.h
1 #ifndef DALI_INTERNAL_RAY_TEST_H
2 #define DALI_INTERNAL_RAY_TEST_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // CLASS HEADER
22 #include <dali/internal/event/actors/actor-impl.h>
23
24 namespace Dali
25 {
26
27 class Vector2;
28 class Vector4;
29
30 namespace Internal
31 {
32
33 class Actor;
34 class EventThreadServices;
35
36 /**
37  * Contains methods to perform ray tests on given actors.
38  *
39  * Stores a reference to the EventThreadServices so limit the number of times this is created
40  * to avoid repeated calls to EventThreadServices::Get().
41  */
42 class RayTest
43 {
44 public:
45
46   /// Constructor
47   RayTest();
48
49   /// Default Destructor
50   ~RayTest() = default;
51
52   /**
53    * Performs a ray-sphere test with the given pick-ray and the given actor's bounding sphere.
54    *
55    * @param[in] actor The actor to perform the ray-sphere test on
56    * @param[in] rayOrigin The ray origin in the world's reference system
57    * @param[in] rayDir The ray director vector in the world's reference system
58    * @return True if the ray intersects the actor's bounding sphere
59    *
60    * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
61    */
62   bool SphereTest(const Internal::Actor& actor, const Vector4& rayOrigin, const Vector4& rayDir) const;
63
64   /**
65    * Performs a ray-actor test with the given pick-ray and the given actor's geometry.
66    *
67    * @param[in] actor The actor to perform the ray-sphere test on
68    * @param[in] rayOrigin The ray origin in the world's reference system.
69    * @param[in] rayDir The ray director vector in the world's reference system.
70    * @param[out] hitPointLocal The hit point in the Actor's local reference system.
71    * @param[out] distance The distance from the hit point to the camera.
72    * @return True if the ray intersects the actor's geometry.
73    *
74    * @note The actor coordinates are relative to the top-left (0.0, 0.0, 0.5)
75    */
76   bool ActorTest(const Internal::Actor& actor, const Vector4& rayOrigin, const Vector4& rayDir, Vector2& hitPointLocal, float& distance) const;
77
78 private:
79   const EventThreadServices& mEventThreadServices;
80 };
81
82 } // namespace Internal
83
84 } // namespace Dali
85
86 #endif // DALI_INTERNAL_RAY_TEST_H