[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / public-api / physics-adaptor.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 // Class Header
18 #include <dali-physics/public-api/physics-adaptor.h>
19
20 // Internal headers
21 #include <dali-physics/internal/physics-actor-impl.h>
22 #include <dali-physics/internal/physics-adaptor-impl.h>
23 #include <dali-physics/public-api/physics-actor.h>
24
25 namespace Dali::Toolkit::Physics
26 {
27 PhysicsAdaptor::PhysicsAdaptor() = default;
28
29 PhysicsAdaptor::~PhysicsAdaptor() = default;
30
31 PhysicsAdaptor::PhysicsAdaptor(const PhysicsAdaptor& handle) = default;
32
33 PhysicsAdaptor::PhysicsAdaptor(PhysicsAdaptor&& rhs) noexcept = default;
34
35 PhysicsAdaptor& PhysicsAdaptor::operator=(const PhysicsAdaptor& handle) = default;
36
37 PhysicsAdaptor& PhysicsAdaptor::operator=(PhysicsAdaptor&& handle) noexcept = default;
38
39 PhysicsAdaptor PhysicsAdaptor::New(const Dali::Matrix& transform, Uint16Pair size)
40 {
41   Internal::PhysicsAdaptorPtr internal = Internal::CreateNewPhysicsAdaptor(transform, size);
42   return PhysicsAdaptor(internal.Get());
43 }
44
45 PhysicsAdaptor PhysicsAdaptor::DownCast(BaseHandle handle)
46 {
47   return PhysicsAdaptor(dynamic_cast<Dali::Toolkit::Physics::Internal::PhysicsAdaptor*>(handle.GetObjectPtr()));
48 }
49
50 void PhysicsAdaptor::SetTimestep(float timestep)
51 {
52   GetImplementation(*this).SetTimestep(timestep);
53 }
54
55 float PhysicsAdaptor::GetTimestep() const
56 {
57   return GetImplementation(*this).GetTimestep();
58 }
59
60 PhysicsAdaptor::ScopedPhysicsAccessorPtr PhysicsAdaptor::GetPhysicsAccessor()
61 {
62   return GetImplementation(*this).GetPhysicsAccessor();
63 }
64
65 Dali::Layer PhysicsAdaptor::CreateDebugLayer(Dali::Window window)
66 {
67   return GetImplementation(*this).CreateDebugLayer(window);
68 }
69
70 Dali::Vector3 PhysicsAdaptor::TranslateToPhysicsSpace(Dali::Vector3 vector) const
71 {
72   return GetImplementation(*this).TranslateToPhysicsSpace(vector);
73 }
74
75 Dali::Quaternion PhysicsAdaptor::TranslateToPhysicsSpace(Dali::Quaternion rotation) const
76 {
77   return GetImplementation(*this).TranslateToPhysicsSpace(rotation);
78 }
79
80 Dali::Vector3 PhysicsAdaptor::TranslateFromPhysicsSpace(Dali::Vector3 vector) const
81 {
82   return GetImplementation(*this).TranslateFromPhysicsSpace(vector);
83 }
84
85 Dali::Vector3 PhysicsAdaptor::ConvertVectorToPhysicsSpace(Dali::Vector3 vector) const
86 {
87   return GetImplementation(*this).ConvertVectorToPhysicsSpace(vector);
88 }
89
90 Dali::Vector3 PhysicsAdaptor::ConvertVectorFromPhysicsSpace(Dali::Vector3 vector) const
91 {
92   return GetImplementation(*this).ConvertVectorFromPhysicsSpace(vector);
93 }
94
95 void PhysicsAdaptor::SetTransformAndSize(const Dali::Matrix& transform, Uint16Pair size)
96 {
97   GetImplementation(*this).SetTransformAndSize(transform, size);
98 }
99
100 void PhysicsAdaptor::SetIntegrationState(Physics::PhysicsAdaptor::IntegrationState state)
101 {
102   GetImplementation(*this).SetIntegrationState(state);
103 }
104
105 Physics::PhysicsAdaptor::IntegrationState PhysicsAdaptor::GetIntegrationState() const
106 {
107   return GetImplementation(*this).GetIntegrationState();
108 }
109
110 void PhysicsAdaptor::SetDebugState(Physics::PhysicsAdaptor::DebugState state)
111 {
112   GetImplementation(*this).SetDebugState(state);
113 }
114
115 Physics::PhysicsAdaptor::DebugState PhysicsAdaptor::GetDebugState() const
116 {
117   return GetImplementation(*this).GetDebugState();
118 }
119
120 PhysicsActor PhysicsAdaptor::AddActorBody(Dali::Actor actor, Dali::Any body)
121 {
122   Internal::PhysicsActorPtr physicsActor = GetImplementation(*this).AddActorBody(actor, body);
123   return PhysicsActor(physicsActor.Get());
124 }
125
126 void PhysicsAdaptor::RemoveActorBody(PhysicsActor physicsActor)
127 {
128   GetImplementation(*this).RemoveActorBody(GetImplementation(physicsActor));
129 }
130
131 PhysicsActor PhysicsAdaptor::GetPhysicsActor(Dali::Any body) const
132 {
133   Internal::PhysicsActorPtr physicsActor = GetImplementation(*this).GetPhysicsActor(body);
134   return PhysicsActor(physicsActor.Get());
135 }
136
137 Dali::Actor PhysicsAdaptor::GetRootActor() const
138 {
139   return GetImplementation(*this).GetRootActor();
140 }
141
142 void PhysicsAdaptor::BuildPickingRay(Dali::Vector3 origin, Dali::Vector3 direction, Dali::Vector3& rayFromWorld, Dali::Vector3& rayToWorld)
143 {
144   GetImplementation(*this).BuildPickingRay(origin, direction, rayFromWorld, rayToWorld);
145 }
146
147 Dali::Vector3 PhysicsAdaptor::ProjectPoint(Dali::Vector3 origin, Dali::Vector3 direction, float distance)
148 {
149   return GetImplementation(*this).ProjectPoint(origin, direction, distance);
150 }
151
152 void PhysicsAdaptor::Queue(std::function<void(void)> function)
153 {
154   GetImplementation(*this).Queue(function);
155 }
156
157 void PhysicsAdaptor::CreateSyncPoint()
158 {
159   GetImplementation(*this).CreateSyncPoint();
160 }
161
162 PhysicsAdaptor::PhysicsAdaptor(Internal::PhysicsAdaptor* impl)
163 : BaseHandle(impl)
164 {
165 }
166
167 } // namespace Dali::Toolkit::Physics