4 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 #include <dali-toolkit/public-api/dali-toolkit-common.h>
19 #include <dali/public-api/math/vector3.h>
20 #include <dali/public-api/object/any.h>
22 namespace Dali::Toolkit::Physics::Internal
27 namespace Dali::Toolkit::Physics::Integration
29 /** Proxy to the physics world impl.
31 * Does NOT own physics world.
32 * Copyable. Doesn't track lock.
34 class DALI_TOOLKIT_API PhysicsWorld
39 * @param[in] impl The physics world implementation class.
41 PhysicsWorld(Dali::Toolkit::Physics::Internal::PhysicsWorld* impl);
45 * Does not destroy the physic world.
52 PhysicsWorld(const PhysicsWorld& rhs) = default;
57 PhysicsWorld& operator=(const PhysicsWorld& rhs) = default;
60 * Lock the physics world. The caller MUST unlock it afterwards, otherwise
61 * the physics integration step will block, and DALi update thread will be locked.
66 * Unlock the physics world.
71 * Get a handle to the native physics world / space
73 * This API should be wrapped with Lock/Unlock in any interop implementation
74 * @return a pointer to the native world.
76 Dali::Any GetNative();
79 * Hit test the physics world.
81 * This API should be wrapped with Lock/Unlock in any interop implementation
82 * @param[in] rayFromWorld The origin in physics world space
83 * @param[in] rayToWorld A point along the direction on the far side of the physics world
84 * @param[in] nativeFilter a native body / shape filter
85 * @param[out] localPivot The hit point local to the body
86 * @param[out] distanceFromCamera The distance of the pick point from the camera
87 * @return Either a pointer to the native body, or an empty value.
89 Dali::Any HitTest(Dali::Vector3 rayFromWorld, Dali::Vector3 rayToWorld, Dali::Any nativeFilter, Dali::Vector3& localPivot, float& distanceFromCamera);
92 * Get the implementation pointer.
94 * @return the implementation pointer.
96 Dali::Toolkit::Physics::Internal::PhysicsWorld* GetImpl();
99 Dali::Toolkit::Physics::Internal::PhysicsWorld* impl;
102 } // namespace Dali::Toolkit::Physics::Integration