2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/devel-api/dynamics/dynamics-world.h>
22 #include <dali/devel-api/dynamics/dynamics-shape.h>
23 #include <dali/internal/event/actors/actor-impl.h>
25 #ifdef DALI_DYNAMICS_SUPPORT
26 #include <dali/internal/event/dynamics/dynamics-body-impl.h>
27 #include <dali/internal/event/dynamics/dynamics-joint-impl.h>
28 #include <dali/internal/event/dynamics/dynamics-world-impl.h>
29 #include <dali/internal/event/dynamics/dynamics-world-config-impl.h>
35 #ifndef DALI_DYNAMICS_SUPPORT
36 DynamicsWorld::CollisionSignalType STUB_COLLISION_SIGNAL;
39 DynamicsWorld::DynamicsWorld()
43 DynamicsWorld::~DynamicsWorld()
47 DynamicsWorld::DynamicsWorld(const DynamicsWorld& handle)
52 DynamicsWorld& DynamicsWorld::operator=(const DynamicsWorld& rhs)
54 BaseHandle::operator=(rhs);
58 DynamicsWorld DynamicsWorld::GetInstance( DynamicsWorldConfig configuration )
60 #ifdef DALI_DYNAMICS_SUPPORT
61 Internal::DynamicsWorldConfigPtr configImpl( &( GetImplementation( configuration ) ) );
63 return DynamicsWorld( Internal::DynamicsWorld::GetInstance( configImpl ).Get() );
65 return DynamicsWorld();
69 DynamicsWorld DynamicsWorld::Get()
71 #ifdef DALI_DYNAMICS_SUPPORT
72 Internal::DynamicsWorld* dynamicsWorld = Internal::DynamicsWorld::Get().Get();
73 DALI_ASSERT_ALWAYS( dynamicsWorld && "DynamicsWorld doesn't exist" );
74 return DynamicsWorld( dynamicsWorld );
76 return DynamicsWorld();
80 void DynamicsWorld::DestroyInstance()
82 #ifdef DALI_DYNAMICS_SUPPORT
83 Internal::DynamicsWorld::DestroyInstance();
87 void DynamicsWorld::SetGravity(const Vector3& gravity )
89 #ifdef DALI_DYNAMICS_SUPPORT
90 GetImplementation(*this).SetGravity(gravity);
94 const Vector3& DynamicsWorld::GetGravity() const
96 #ifdef DALI_DYNAMICS_SUPPORT
97 return GetImplementation(*this).GetGravity();
103 int DynamicsWorld::GetDebugDrawMode() const
105 #ifdef DALI_DYNAMICS_SUPPORT
106 return GetImplementation(*this).GetDebugDrawMode();
112 void DynamicsWorld::SetDebugDrawMode(int mode)
114 #ifdef DALI_DYNAMICS_SUPPORT
115 GetImplementation(*this).SetDebugDrawMode( mode );
119 void DynamicsWorld::SetRootActor(Actor actor)
121 #ifdef DALI_DYNAMICS_SUPPORT
122 GetImplementation(*this).SetRootActor( &GetImplementation(actor) );
126 Actor DynamicsWorld::GetRootActor() const
128 #ifdef DALI_DYNAMICS_SUPPORT
129 Internal::ActorPtr actor( GetImplementation(*this).GetRootActor() );
131 DALI_ASSERT_DEBUG(actor || "Root Actor has not been set");
133 return Actor(actor.Get());
139 DynamicsWorld::CollisionSignalType& DynamicsWorld::CollisionSignal()
141 #ifdef DALI_DYNAMICS_SUPPORT
142 return GetImplementation(*this).CollisionSignal();
144 return STUB_COLLISION_SIGNAL;
148 DynamicsWorld::DynamicsWorld( Internal::DynamicsWorld* internal )
149 #ifdef DALI_DYNAMICS_SUPPORT
150 : BaseHandle(internal)