2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <dali-scene3d/public-api/algorithm/path-finder.h>
21 #include <dali-scene3d/internal/algorithm/path-finder-djikstra.h>
22 #include <dali-scene3d/internal/algorithm/path-finder-spfa-double-way.h>
23 #include <dali-scene3d/internal/algorithm/path-finder-spfa.h>
25 namespace Dali::Scene3D::Algorithm
27 std::unique_ptr<PathFinder> PathFinder::New(NavigationMesh& navigationMesh, PathFinderAlgorithm algorithm)
29 PathFinderBase* impl = nullptr;
33 case PathFinderAlgorithm::DJIKSTRA_SHORTEST_PATH:
35 impl = new Dali::Scene3D::Internal::Algorithm::PathFinderAlgorithmDjikstra(navigationMesh);
38 case PathFinderAlgorithm::SPFA:
40 impl = new Dali::Scene3D::Internal::Algorithm::PathFinderAlgorithmSPFA(navigationMesh);
43 case PathFinderAlgorithm::SPFA_DOUBLE_WAY:
45 impl = new Dali::Scene3D::Internal::Algorithm::PathFinderAlgorithmSPFADoubleWay(navigationMesh);
55 auto retval = std::unique_ptr<PathFinderBase>();
57 return std::unique_ptr<Algorithm::PathFinder>(new Algorithm::PathFinder(std::move(retval)));
60 WayPointList PathFinder::FindPath(const Dali::Vector3& positionFrom, const Dali::Vector3& positionTo)
62 return mImpl->FindPath(positionFrom, positionTo);
65 WayPointList PathFinder::FindPath(uint32_t polyIndexFrom, uint32_t polyIndexTo)
67 return mImpl->FindPath(polyIndexFrom, polyIndexTo);
70 PathFinder::PathFinder(std::unique_ptr<PathFinderBase>&& baseImpl)
72 mImpl = std::move(baseImpl);
75 } // namespace Dali::Scene3D::Algorithm