License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-core.git] / dali / public-api / dynamics / dynamics-joint.cpp
1 /*
2  * Copyright (c) 2014 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/public-api/dynamics/dynamics-joint.h>
20
21 // INTERNAL HEADERS
22 #include <dali/internal/event/actors/actor-impl.h>
23
24 #ifdef DYNAMICS_SUPPORT
25 #include <dali/internal/event/dynamics/dynamics-joint-impl.h>
26 #endif
27
28 namespace Dali
29 {
30
31 DynamicsJoint::DynamicsJoint()
32 {
33 }
34
35 DynamicsJoint::~DynamicsJoint()
36 {
37 }
38
39 void DynamicsJoint::SetLinearLimit( const int axisIndex, const float lowerLimit, const float upperLimit )
40 {
41 #ifdef DYNAMICS_SUPPORT
42   GetImplementation(*this).SetLinearLimit(axisIndex, lowerLimit, upperLimit);
43 #endif
44 }
45
46 void DynamicsJoint::SetAngularLimit( const int axisIndex, const Degree& lowerLimit, const Degree& upperLimit )
47 {
48 #ifdef DYNAMICS_SUPPORT
49   GetImplementation(*this).SetAngularLimit( axisIndex, Radian(lowerLimit), Radian(upperLimit) );
50 #endif
51 }
52
53 void DynamicsJoint::EnableSpring(const int axisIndex, const bool flag)
54 {
55 #ifdef DYNAMICS_SUPPORT
56   GetImplementation(*this).EnableSpring(axisIndex, flag);
57 #endif
58 }
59
60 void DynamicsJoint::SetSpringStiffness(const int axisIndex, const float stiffness)
61 {
62 #ifdef DYNAMICS_SUPPORT
63   GetImplementation(*this).SetSpringStiffness(axisIndex, stiffness);
64 #endif
65 }
66
67 void DynamicsJoint::SetSpringDamping(const int axisIndex, const float damping)
68 {
69 #ifdef DYNAMICS_SUPPORT
70   GetImplementation(*this).SetSpringDamping(axisIndex, damping);
71 #endif
72 }
73
74 void DynamicsJoint::SetSpringCenterPoint(const int axisIndex, const float ratio)
75 {
76 #ifdef DYNAMICS_SUPPORT
77   GetImplementation(*this).SetSpringCenterPoint(axisIndex, ratio);
78 #endif
79 }
80
81 void DynamicsJoint::EnableMotor(const int axisIndex, const bool flag)
82 {
83 #ifdef DYNAMICS_SUPPORT
84   GetImplementation(*this).EnableMotor(axisIndex, flag);
85 #endif
86 }
87
88 void DynamicsJoint::SetMotorVelocity(const int axisIndex, const float velocity)
89 {
90 #ifdef DYNAMICS_SUPPORT
91   GetImplementation(*this).SetMotorVelocity(axisIndex, velocity);
92 #endif
93 }
94
95 void DynamicsJoint::SetMotorForce(const int axisIndex, const float force)
96 {
97 #ifdef DYNAMICS_SUPPORT
98   GetImplementation(*this).SetMotorForce(axisIndex, force);
99 #endif
100 }
101
102 Actor DynamicsJoint::GetActor( const bool first ) const
103 {
104 #ifdef DYNAMICS_SUPPORT
105   Internal::ActorPtr internal( GetImplementation(*this).GetActor(first) );
106
107   return Actor(internal.Get());
108 #else
109   return Actor();
110 #endif
111 }
112
113 DynamicsJoint::DynamicsJoint(Internal::DynamicsJoint* internal)
114 #ifdef DYNAMICS_SUPPORT
115 : BaseHandle(internal)
116 #else
117 : BaseHandle(NULL)
118 #endif
119 {
120 }
121
122 } // namespace Dali