[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / internal / event / collider-mesh-processor.cpp
1 /*
2  * Copyright (c) 2023 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
18 // CLASS HEADER
19 #include <dali-scene3d/internal/event/collider-mesh-processor.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/devel-api/common/singleton-service.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-scene3d/internal/event/collider-mesh-processor-impl.h>
26
27 namespace Dali::Scene3D
28 {
29 ColliderMeshProcessor ColliderMeshProcessor::Get()
30 {
31   ColliderMeshProcessor processor;
32
33   // Check whether the processor has already created
34   SingletonService singletonService(SingletonService::Get());
35   if(singletonService)
36   {
37     Dali::BaseHandle handle = singletonService.GetSingleton(typeid(ColliderMeshProcessor));
38     if(handle)
39     {
40       // If so, downcast the handle of singleton to focus manager
41       processor = ColliderMeshProcessor(dynamic_cast<Internal::ColliderMeshProcessor*>(handle.GetObjectPtr()));
42     }
43
44     if(!processor)
45     {
46       // If not, create the focus manager and register it as a singleton
47       processor = ColliderMeshProcessor(new Internal::ColliderMeshProcessor());
48       singletonService.Register(typeid(processor), processor);
49     }
50   }
51
52   return processor;
53 }
54
55 void ColliderMeshProcessor::ColliderMeshChanged(Scene3D::Model model)
56 {
57   GetImpl(*this).ColliderMeshChanged(model);
58 }
59
60 ColliderMeshProcessor::ColliderMeshProcessor(Internal::ColliderMeshProcessor* impl)
61 : BaseHandle(impl)
62 {
63 }
64
65 } // namespace Dali::Scene3D