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::CreateNewPhysicsAdaptor(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() const
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) const
72 return GetImplementation(*this).TranslateToPhysicsSpace(vector);
75 Dali::Quaternion PhysicsAdaptor::TranslateToPhysicsSpace(Dali::Quaternion rotation) const
77 return GetImplementation(*this).TranslateToPhysicsSpace(rotation);
80 Dali::Vector3 PhysicsAdaptor::TranslateFromPhysicsSpace(Dali::Vector3 vector) const
82 return GetImplementation(*this).TranslateFromPhysicsSpace(vector);
85 Dali::Vector3 PhysicsAdaptor::ConvertVectorToPhysicsSpace(Dali::Vector3 vector) const
87 return GetImplementation(*this).ConvertVectorToPhysicsSpace(vector);
90 Dali::Vector3 PhysicsAdaptor::ConvertVectorFromPhysicsSpace(Dali::Vector3 vector) const
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() const
107 return GetImplementation(*this).GetIntegrationState();
110 void PhysicsAdaptor::SetDebugState(Physics::PhysicsAdaptor::DebugState state)
112 GetImplementation(*this).SetDebugState(state);
115 Physics::PhysicsAdaptor::DebugState PhysicsAdaptor::GetDebugState() const
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 void PhysicsAdaptor::RemoveActorBody(PhysicsActor physicsActor)
128 GetImplementation(*this).RemoveActorBody(GetImplementation(physicsActor));
131 PhysicsActor PhysicsAdaptor::GetPhysicsActor(Dali::Any body) const
133 Internal::PhysicsActorPtr physicsActor = GetImplementation(*this).GetPhysicsActor(body);
134 return PhysicsActor(physicsActor.Get());
137 Dali::Actor PhysicsAdaptor::GetRootActor() const
139 return GetImplementation(*this).GetRootActor();
142 void PhysicsAdaptor::BuildPickingRay(Dali::Vector3 origin, Dali::Vector3 direction, Dali::Vector3& rayFromWorld, Dali::Vector3& rayToWorld)
144 GetImplementation(*this).BuildPickingRay(origin, direction, rayFromWorld, rayToWorld);
147 Dali::Vector3 PhysicsAdaptor::ProjectPoint(Dali::Vector3 origin, Dali::Vector3 direction, float distance)
149 return GetImplementation(*this).ProjectPoint(origin, direction, distance);
152 void PhysicsAdaptor::Queue(std::function<void(void)> function)
154 GetImplementation(*this).Queue(function);
157 void PhysicsAdaptor::CreateSyncPoint()
159 GetImplementation(*this).CreateSyncPoint();
162 PhysicsAdaptor::PhysicsAdaptor(Internal::PhysicsAdaptor* impl)
167 } // namespace Dali::Toolkit::Physics