[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / algorithm / navigation-mesh.cpp
1 /*
2  * Copyright (c) 2024 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 // CLASS HEADER
18 #include <dali-scene3d/public-api/algorithm/navigation-mesh.h>
19
20 // INTERNAL HEADERS
21 #include <dali-scene3d/internal/algorithm/navigation-mesh-impl.h>
22
23 using Dali::Vector3;
24
25 namespace Dali::Scene3D::Algorithm
26 {
27 NavigationMesh::NavigationMesh(NavigationMeshImpl* impl)
28 {
29   mImpl.reset(impl);
30 }
31
32 NavigationMesh::~NavigationMesh() = default;
33
34 [[nodiscard]] uint32_t NavigationMesh::GetFaceCount() const
35 {
36   return mImpl->GetFaceCount();
37 }
38
39 [[nodiscard]] uint32_t NavigationMesh::GetEdgeCount() const
40 {
41   return mImpl->GetEdgeCount();
42 }
43
44 [[nodiscard]] uint32_t NavigationMesh::GetVertexCount() const
45 {
46   return mImpl->GetVertexCount();
47 }
48
49 bool NavigationMesh::FindFloor(const Dali::Vector3& position, Dali::Vector3& outPosition, FaceIndex& outFaceIndex)
50 {
51   return mImpl->FindFloor(position, outPosition, outFaceIndex);
52 }
53
54 bool NavigationMesh::FindFloorForFace(const Dali::Vector3& position, FaceIndex faceIndex, bool dontCheckNeighbours, Dali::Vector3& outPosition)
55 {
56   return mImpl->FindFloorForFace(position, faceIndex, dontCheckNeighbours, outPosition);
57 }
58
59 [[nodiscard]] const NavigationMesh::Face* NavigationMesh::GetFace(FaceIndex index) const
60 {
61   return mImpl->GetFace(index);
62 }
63
64 [[nodiscard]] const NavigationMesh::Edge* NavigationMesh::GetEdge(EdgeIndex index) const
65 {
66   return mImpl->GetEdge(index);
67 }
68
69 [[nodiscard]] const NavigationMesh::Vertex* NavigationMesh::GetVertex(VertexIndex index) const
70 {
71   return mImpl->GetVertex(index);
72 }
73
74 void NavigationMesh::SetSceneTransform(const Dali::Matrix& transform)
75 {
76   mImpl->SetTransform(transform);
77 }
78
79 Dali::Vector3 NavigationMesh::PointSceneToLocal(const Dali::Vector3& point) const
80 {
81   return mImpl->PointSceneToLocal(point);
82 }
83
84 Dali::Vector3 NavigationMesh::PointLocalToScene(const Dali::Vector3& point) const
85 {
86   return mImpl->PointLocalToScene(point);
87 }
88
89 Dali::Vector3 NavigationMesh::GetGravityVector() const
90 {
91   return mImpl->GetGravityVector();
92 }
93
94 FaceIndex NavigationMesh::RayFaceIntersect(const Vector3& origin, const Vector3& direction) const
95 {
96   Internal::Algorithm::NavigationRay ray;
97   ray.origin    = origin;
98   ray.direction = direction;
99
100   auto result = mImpl->RayCastIntersect(ray);
101   if(result.result)
102   {
103     return result.faceIndex;
104   }
105   return NULL_FACE;
106 }
107
108 } // namespace Dali::Scene3D::Algorithm