c286edbdc44dfabed0be161948f690fef761ecbd
[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 DynamicsJoint::DynamicsJoint(const DynamicsJoint& handle)
40 : BaseHandle(handle)
41 {
42 }
43
44 DynamicsJoint& DynamicsJoint::operator=(const DynamicsJoint& rhs)
45 {
46   BaseHandle::operator=(rhs);
47   return *this;
48 }
49
50 DynamicsJoint& DynamicsJoint::operator=(BaseHandle::NullType* rhs)
51 {
52   DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
53   Reset();
54   return *this;
55 }
56
57 void DynamicsJoint::SetLinearLimit( const int axisIndex, const float lowerLimit, const float upperLimit )
58 {
59 #ifdef DYNAMICS_SUPPORT
60   GetImplementation(*this).SetLinearLimit(axisIndex, lowerLimit, upperLimit);
61 #endif
62 }
63
64 void DynamicsJoint::SetAngularLimit( const int axisIndex, const Degree& lowerLimit, const Degree& upperLimit )
65 {
66 #ifdef DYNAMICS_SUPPORT
67   GetImplementation(*this).SetAngularLimit( axisIndex, Radian(lowerLimit), Radian(upperLimit) );
68 #endif
69 }
70
71 void DynamicsJoint::EnableSpring(const int axisIndex, const bool flag)
72 {
73 #ifdef DYNAMICS_SUPPORT
74   GetImplementation(*this).EnableSpring(axisIndex, flag);
75 #endif
76 }
77
78 void DynamicsJoint::SetSpringStiffness(const int axisIndex, const float stiffness)
79 {
80 #ifdef DYNAMICS_SUPPORT
81   GetImplementation(*this).SetSpringStiffness(axisIndex, stiffness);
82 #endif
83 }
84
85 void DynamicsJoint::SetSpringDamping(const int axisIndex, const float damping)
86 {
87 #ifdef DYNAMICS_SUPPORT
88   GetImplementation(*this).SetSpringDamping(axisIndex, damping);
89 #endif
90 }
91
92 void DynamicsJoint::SetSpringCenterPoint(const int axisIndex, const float ratio)
93 {
94 #ifdef DYNAMICS_SUPPORT
95   GetImplementation(*this).SetSpringCenterPoint(axisIndex, ratio);
96 #endif
97 }
98
99 void DynamicsJoint::EnableMotor(const int axisIndex, const bool flag)
100 {
101 #ifdef DYNAMICS_SUPPORT
102   GetImplementation(*this).EnableMotor(axisIndex, flag);
103 #endif
104 }
105
106 void DynamicsJoint::SetMotorVelocity(const int axisIndex, const float velocity)
107 {
108 #ifdef DYNAMICS_SUPPORT
109   GetImplementation(*this).SetMotorVelocity(axisIndex, velocity);
110 #endif
111 }
112
113 void DynamicsJoint::SetMotorForce(const int axisIndex, const float force)
114 {
115 #ifdef DYNAMICS_SUPPORT
116   GetImplementation(*this).SetMotorForce(axisIndex, force);
117 #endif
118 }
119
120 Actor DynamicsJoint::GetActor( const bool first ) const
121 {
122 #ifdef DYNAMICS_SUPPORT
123   Internal::ActorPtr internal( GetImplementation(*this).GetActor(first) );
124
125   return Actor(internal.Get());
126 #else
127   return Actor();
128 #endif
129 }
130
131 DynamicsJoint::DynamicsJoint(Internal::DynamicsJoint* internal)
132 #ifdef DYNAMICS_SUPPORT
133 : BaseHandle(internal)
134 #else
135 : BaseHandle(NULL)
136 #endif
137 {
138 }
139
140 } // namespace Dali