[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / public-api / physics-actor.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-actor.h>
19
20 // Internal headers
21 #include <dali-physics/internal/physics-actor-impl.h>
22 #include <dali-physics/internal/physics-adaptor-impl.h>
23
24 namespace Dali::Toolkit::Physics
25 {
26 PhysicsActor::PhysicsActor()                            = default;
27 PhysicsActor::~PhysicsActor()                           = default;
28 PhysicsActor::PhysicsActor(const PhysicsActor& handle)  = default;
29 PhysicsActor::PhysicsActor(PhysicsActor&& rhs) noexcept = default;
30 PhysicsActor& PhysicsActor::operator=(const PhysicsActor& handle) = default;
31 PhysicsActor& PhysicsActor::operator=(PhysicsActor&& handle) noexcept = default;
32
33 PhysicsActor PhysicsActor::New(Dali::Actor actor, Dali::Any body, PhysicsAdaptor adaptor)
34 {
35   Dali::Toolkit::Physics::Internal::PhysicsActorPtr internal = Internal::PhysicsActor::New(actor, body, GetImplementation(adaptor));
36   return PhysicsActor(internal.Get());
37 }
38
39 PhysicsActor PhysicsActor::DownCast(BaseHandle handle)
40 {
41   return PhysicsActor(dynamic_cast<Dali::Toolkit::Physics::Internal::PhysicsActor*>(handle.GetObjectPtr()));
42 }
43
44 uint32_t PhysicsActor::GetId() const
45 {
46   return GetImplementation(*this).GetId();
47 }
48
49 Dali::Any PhysicsActor::GetBody() const
50 {
51   return GetImplementation(*this).GetBody();
52 }
53
54 void PhysicsActor::AsyncSetPhysicsPosition(Dali::Vector3 actorPosition)
55 {
56   GetImplementation(*this).AsyncSetPhysicsPosition(actorPosition);
57 }
58
59 void PhysicsActor::AsyncSetPhysicsRotation(Dali::Quaternion actorRotation)
60 {
61   GetImplementation(*this).AsyncSetPhysicsRotation(actorRotation);
62 }
63
64 Dali::Vector3 PhysicsActor::GetPhysicsPosition() const
65 {
66   return GetImplementation(*this).GetPhysicsPosition();
67 }
68
69 Dali::Quaternion PhysicsActor::GetPhysicsRotation() const
70 {
71   return GetImplementation(*this).GetPhysicsRotation();
72 }
73
74 Dali::Vector3 PhysicsActor::GetActorPosition() const
75 {
76   return GetImplementation(*this).GetActorPosition();
77 }
78
79 Dali::Quaternion PhysicsActor::GetActorRotation() const
80 {
81   return GetImplementation(*this).GetActorRotation();
82 }
83
84 PhysicsActor::PhysicsActor(Internal::PhysicsActor* impl)
85 : BaseHandle(impl)
86 {
87 }
88
89 } // namespace Dali::Toolkit::Physics