2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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
8 // http://floralicense.org/license/
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.
18 #include <dali/internal/event/dynamics/dynamics-slider-joint-impl.h>
23 #include <dali/integration-api/debug.h>
24 #include <dali/internal/event/common/stage-impl.h>
25 #include <dali/internal/update/dynamics/scene-graph-dynamics-slider-joint.h>
26 #include <dali/internal/event/dynamics/dynamics-body-impl.h>
27 #include <dali/internal/event/dynamics/dynamics-world-impl.h>
35 DynamicsSliderJoint::DynamicsSliderJoint(DynamicsWorldPtr world,
36 DynamicsBodyPtr bodyA, DynamicsBodyPtr bodyB,
37 const Vector3& pointA, const Vector3& pointB, const Vector3& axis,
38 const float translationLowerLimit, const float translationUpperLimit,
39 const Radian& rotationLowerLimit, const Radian& rotationUpperLimit )
40 : DynamicsJoint(Dali::DynamicsJoint::SLIDER),
41 mTranslationLowerLimit(1.0f),
42 mTranslationUpperLimit(-1.0f),
43 mRotationLowerLimit(0.0f),
44 mRotationUpperLimit(0.0f)
46 DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s - (\"%s\", \"%s\")\n",
47 __PRETTY_FUNCTION__, bodyA->GetName().c_str(), (bodyB) ? bodyB->GetName().c_str() : "FIXED" );
49 SceneGraph::DynamicsSliderJoint* joint( new SceneGraph::DynamicsSliderJoint( *(world->GetSceneObject()) ) );
50 mDynamicsJoint = joint;
52 SceneGraph::DynamicsBody* bA(bodyA->GetSceneObject());
53 SceneGraph::DynamicsBody* bB(!bodyB ? NULL : bodyB->GetSceneObject() );
55 Stage::GetCurrent().QueueMessage( InitializeDynamicsSliderJointMessage(*joint, *bA, bB, pointA, pointB, axis) );
57 SetTranslationLowerLimit(translationLowerLimit);
58 SetTranslationUpperLimit(translationUpperLimit);
59 SetRotationLowerLimit(rotationLowerLimit);
60 SetRotationUpperLimit(rotationUpperLimit);
63 DynamicsSliderJoint::~DynamicsSliderJoint()
65 DALI_LOG_INFO(Debug::Filter::gDynamics, Debug::Verbose, "%s\n", __PRETTY_FUNCTION__);
68 float DynamicsSliderJoint::GetTranslationLowerLimit() const
70 return mTranslationLowerLimit;
73 void DynamicsSliderJoint::SetTranslationLowerLimit( const float limit )
75 if( mTranslationLowerLimit != limit )
77 mTranslationLowerLimit = limit;
79 Stage::GetCurrent().QueueMessage( SetTranslationLowerLimitMessage( *(GetSceneObject()), limit ) );
83 float DynamicsSliderJoint::GetTranslationUpperLimit() const
85 return mTranslationUpperLimit;
88 void DynamicsSliderJoint::SetTranslationUpperLimit( const float limit )
90 if( mTranslationUpperLimit != limit )
92 mTranslationUpperLimit = limit;
94 Stage::GetCurrent().QueueMessage( SetTranslationUpperLimitMessage( *(GetSceneObject()), limit ) );
98 Radian DynamicsSliderJoint::GetRotationLowerLimit() const
100 return mRotationLowerLimit;
103 void DynamicsSliderJoint::SetRotationLowerLimit( const Radian& limit )
105 if( mRotationLowerLimit != limit )
107 mRotationLowerLimit = limit;
109 Stage::GetCurrent().QueueMessage( SetRotationLowerLimitMessage( *(GetSceneObject()), limit ) );
113 Radian DynamicsSliderJoint::GetRotationUpperLimit() const
115 return mRotationUpperLimit;
118 void DynamicsSliderJoint::SetRotationUpperLimit( const Radian& limit )
120 if( mRotationUpperLimit != limit )
122 mRotationUpperLimit = limit;
124 Stage::GetCurrent().QueueMessage( SetRotationUpperLimitMessage( *(GetSceneObject()), limit ) );
128 SceneGraph::DynamicsSliderJoint* DynamicsSliderJoint::GetSceneObject() const
130 return static_cast<SceneGraph::DynamicsSliderJoint*>(DynamicsJoint::GetSceneObject());
134 } // namespace Internal