2 * Copyright (c) 2023 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.
18 #include <dali-physics/public-api/physics-adaptor.h>
21 #include <dali-physics/internal/physics-actor-impl.h>
22 #include <dali-physics/internal/physics-adaptor-impl.h>
23 #include <dali-physics/public-api/physics-actor.h>
25 namespace Dali::Toolkit::Physics
27 PhysicsAdaptor::PhysicsAdaptor() = default;
29 PhysicsAdaptor::~PhysicsAdaptor() = default;
31 PhysicsAdaptor::PhysicsAdaptor(const PhysicsAdaptor& handle) = default;
33 PhysicsAdaptor::PhysicsAdaptor(PhysicsAdaptor&& rhs) noexcept = default;
35 PhysicsAdaptor& PhysicsAdaptor::operator=(const PhysicsAdaptor& handle) = default;
37 PhysicsAdaptor& PhysicsAdaptor::operator=(PhysicsAdaptor&& handle) noexcept = default;
39 PhysicsAdaptor PhysicsAdaptor::New(const Dali::Matrix& transform, Uint16Pair size)
41 Internal::PhysicsAdaptorPtr internal = Internal::PhysicsAdaptor::New(transform, size);
42 return PhysicsAdaptor(internal.Get());
45 PhysicsAdaptor PhysicsAdaptor::DownCast(BaseHandle handle)
47 return PhysicsAdaptor(dynamic_cast<Dali::Toolkit::Physics::Internal::PhysicsAdaptor*>(handle.GetObjectPtr()));
50 void PhysicsAdaptor::SetTimestep(float timestep)
52 GetImplementation(*this).SetTimestep(timestep);
55 float PhysicsAdaptor::GetTimestep()
57 return GetImplementation(*this).GetTimestep();
60 PhysicsAdaptor::ScopedPhysicsAccessorPtr PhysicsAdaptor::GetPhysicsAccessor()
62 return GetImplementation(*this).GetPhysicsAccessor();
65 Dali::Layer PhysicsAdaptor::CreateDebugLayer(Dali::Window window)
67 return GetImplementation(*this).CreateDebugLayer(window);
70 Dali::Vector3 PhysicsAdaptor::TranslateToPhysicsSpace(Dali::Vector3 vector)
72 return GetImplementation(*this).TranslateToPhysicsSpace(vector);
75 Dali::Quaternion PhysicsAdaptor::TranslateToPhysicsSpace(Dali::Quaternion rotation)
77 return GetImplementation(*this).TranslateToPhysicsSpace(rotation);
80 Dali::Vector3 PhysicsAdaptor::TranslateFromPhysicsSpace(Dali::Vector3 vector)
82 return GetImplementation(*this).TranslateFromPhysicsSpace(vector);
85 Dali::Vector3 PhysicsAdaptor::ConvertVectorToPhysicsSpace(Dali::Vector3 vector)
87 return GetImplementation(*this).ConvertVectorToPhysicsSpace(vector);
90 Dali::Vector3 PhysicsAdaptor::ConvertVectorFromPhysicsSpace(Dali::Vector3 vector)
92 return GetImplementation(*this).ConvertVectorFromPhysicsSpace(vector);
95 void PhysicsAdaptor::SetTransformAndSize(const Dali::Matrix& transform, Uint16Pair size)
97 GetImplementation(*this).SetTransformAndSize(transform, size);
100 void PhysicsAdaptor::SetIntegrationState(Physics::PhysicsAdaptor::IntegrationState state)
102 GetImplementation(*this).SetIntegrationState(state);
105 Physics::PhysicsAdaptor::IntegrationState PhysicsAdaptor::GetIntegrationState()
107 return GetImplementation(*this).GetIntegrationState();
110 void PhysicsAdaptor::SetDebugState(Physics::PhysicsAdaptor::DebugState state)
112 GetImplementation(*this).SetDebugState(state);
115 Physics::PhysicsAdaptor::DebugState PhysicsAdaptor::GetDebugState()
117 return GetImplementation(*this).GetDebugState();
120 PhysicsActor PhysicsAdaptor::AddActorBody(Dali::Actor actor, Dali::Any body)
122 Internal::PhysicsActorPtr physicsActor = GetImplementation(*this).AddActorBody(actor, body);
123 return PhysicsActor(physicsActor.Get());
126 PhysicsActor PhysicsAdaptor::GetPhysicsActor(Dali::Any body)
128 Internal::PhysicsActorPtr physicsActor = GetImplementation(*this).GetPhysicsActor(body);
129 return PhysicsActor(physicsActor.Get());
132 Dali::Actor PhysicsAdaptor::GetRootActor()
134 return GetImplementation(*this).GetRootActor();
137 void PhysicsAdaptor::BuildPickingRay(Dali::Vector3 origin, Dali::Vector3 direction, Dali::Vector3& rayFromWorld, Dali::Vector3& rayToWorld)
139 GetImplementation(*this).BuildPickingRay(origin, direction, rayFromWorld, rayToWorld);
142 Dali::Vector3 PhysicsAdaptor::ProjectPoint(Dali::Vector3 origin, Dali::Vector3 direction, float distance)
144 return GetImplementation(*this).ProjectPoint(origin, direction, distance);
147 void PhysicsAdaptor::Queue(std::function<void(void)> function)
149 GetImplementation(*this).Queue(function);
152 void PhysicsAdaptor::CreateSyncPoint()
154 GetImplementation(*this).CreateSyncPoint();
157 PhysicsAdaptor::PhysicsAdaptor(Internal::PhysicsAdaptor* impl)
162 } // namespace Dali::Toolkit::Physics