Browse Source

OpenXR: Re-enable Linux support (#975)

Signed-off-by: Reece Hagan <[email protected]>
Reece Hagan 6 ngày trước cách đây
mục cha
commit
81a40a88d9

+ 1 - 0
Gems/OpenXRVk/Code/CMakeLists.txt

@@ -48,6 +48,7 @@ ly_add_target(
         ${pal_include_dir}/platform_private_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
     PLATFORM_INCLUDE_FILES
         ${pal_source_dir}/platform_private_static_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
+        ${pal_include_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake
     INCLUDE_DIRECTORIES
         PRIVATE
             Source

+ 3 - 0
Gems/OpenXRVk/Code/Include/OpenXRVk/OpenXRVkUtils.h

@@ -11,6 +11,7 @@
 #include <AzCore/Math/Transform.h>
 #include <OpenXRVk_Platform.h>
 #include <XR/XRBase.h>
+#include "OpenXRVkActionsInterface.h"
 
 
 // Macro to generate stringify functions for OpenXR enumerations based data provided in openxr_reflection.h
@@ -73,4 +74,6 @@ namespace OpenXRVk
     AZ::Vector3 AzPositionFromXrPose(const XrPosef& pose, bool convertCoordinates = true);
     AZ::Transform AzTransformFromXrPose(const XrPosef& pose, bool convertCoordinates = true);
     XrPosef XrPoseFromAzTransform(const AZ::Transform& tm, bool convertCoordinates = true);
+
+    float ReadActionHandleFloat(IOpenXRActions* iface, IOpenXRActions::ActionHandle actionHandle, float deadZone = 0.05f);
 }

+ 8 - 0
Gems/OpenXRVk/Code/Include/OpenXRVk/Platform/Android/platform_android.cmake

@@ -0,0 +1,8 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+

+ 15 - 0
Gems/OpenXRVk/Code/Include/OpenXRVk/Platform/Linux/platform_linux.cmake

@@ -0,0 +1,15 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+if (${PAL_TRAIT_LINUX_WINDOW_MANAGER} STREQUAL "xcb")
+    set(LY_COMPILE_DEFINITIONS PUBLIC PAL_TRAIT_LINUX_WINDOW_MANAGER_XCB)
+elseif(PAL_TRAIT_LINUX_WINDOW_MANAGER STREQUAL "wayland")
+    set(LY_COMPILE_DEFINITIONS PUBLIC PAL_TRAIT_LINUX_WINDOW_MANAGER_WAYLAND)
+else()
+    message(FATAL_ERROR, "Linux Window Manager ${PAL_TRAIT_LINUX_WINDOW_MANAGER} is not recognized")
+endif()

+ 8 - 0
Gems/OpenXRVk/Code/Include/OpenXRVk/Platform/Mac/platform_mac.cmake

@@ -0,0 +1,8 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+

+ 8 - 0
Gems/OpenXRVk/Code/Include/OpenXRVk/Platform/Windows/platform_windows.cmake

@@ -0,0 +1,8 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+

+ 8 - 0
Gems/OpenXRVk/Code/Include/OpenXRVk/Platform/iOS/platform_ios.cmake

@@ -0,0 +1,8 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+#
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+

+ 2 - 1
Gems/OpenXRVk/Code/Source/Devices/Common/XRControllerAnimationsComponent.cpp

@@ -18,6 +18,8 @@
 
 #include <Integration/AnimGraphComponentBus.h>
 
+#include "OpenXRVk/OpenXRVkUtils.h"
+
 namespace OpenXRVk
 {
     void XRControllerAnimationsComponent::Reflect(AZ::ReflectContext* context)
@@ -86,7 +88,6 @@ namespace OpenXRVk
     }
 
     extern AZ::Transform ReadActionHandlePose(IOpenXRActions* iface, IOpenXRActions::ActionHandle actionHandle);
-    extern float ReadActionHandleFloat(IOpenXRActions* iface, IOpenXRActions::ActionHandle actionHandle, float deadZone);
 
     void XRControllerAnimationsComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint timePoint)
     {

+ 16 - 0
Gems/OpenXRVk/Code/Source/OpenXRVkUtils.cpp

@@ -152,4 +152,20 @@ namespace OpenXRVk
         return AZStd::string(pathAsChars);
     }
 
+
+    float ReadActionHandleFloat(IOpenXRActions* iface, IOpenXRActions::ActionHandle actionHandle, float deadZone)
+    {
+        auto outcome = iface->GetActionStateFloat(actionHandle);
+        if (!outcome.IsSuccess())
+        {
+            // Most likely the controller went to sleep.
+            return 0.0f;
+        }
+        float value = outcome.GetValue();
+        if (fabsf(value) < deadZone)
+        {
+            return 0.0f;
+        }
+        return value;
+    }
 }

+ 1 - 1
Gems/OpenXRVk/Code/Source/Platform/Linux/PAL_linux.cmake

@@ -6,4 +6,4 @@
 #
 #
 
-set(PAL_TRAIT_OPENXRVK_SUPPORTED FALSE)
+set(PAL_TRAIT_OPENXRVK_SUPPORTED TRUE)

+ 6 - 4
Gems/OpenXRVk/Code/Source/Platform/Linux/platform_private_linux_files.cmake

@@ -12,9 +12,11 @@ set(FILES
     ../Common/Default/InputDeviceXRController_Default.cpp
     ../Common/Default/OculusTouch_Default.cpp
     ../Common/Default/OculusTouch_Default.h
-    ../Common/Default/XRControllerComponent.cpp
-    ../Common/Default/XRControllerComponent.h
-    ../Common/Default/XRControllerAnimationsComponent.cpp
-    ../Common/Default/XRControllerAnimationsComponent.h
     ../Common/Unimplemented/OpenXRVkCommon_Unimplemented.cpp
+    ../../Devices/Common/XRControllerComponent.cpp
+    ../../Devices/Common/XRControllerComponent.h
+    ../../Devices/Common/XRControllerAnimationsComponent.cpp
+    ../../Devices/Common/XRControllerAnimationsComponent.h
+    ../../Devices/Common/XRControllersConfig.cpp
+    ../../Devices/Common/XRControllersConfig.h
 )

+ 2 - 17
Gems/OpenXRVk/Code/Source/XRCameraMovementComponent.cpp

@@ -22,6 +22,8 @@
 #include <Atom/RPI.Public/ViewportContext.h>
 #include <Atom/RPI.Public/ViewportContextBus.h>
 
+#include "OpenXRVk/OpenXRVkUtils.h"
+
 
 namespace OpenXRVk
 {
@@ -117,23 +119,6 @@ namespace OpenXRVk
         AZ::TransformBus::Event(GetEntityId(), &AZ::TransformBus::Events::SetWorldTM, cameraTransform);
     }
 
-
-    static float ReadActionHandleFloat(IOpenXRActions* iface, IOpenXRActions::ActionHandle actionHandle, float deadZone = 0.05f)
-    {
-        auto outcome = iface->GetActionStateFloat(actionHandle);
-        if (!outcome.IsSuccess())
-        {
-            // Most likely the controller went to sleep.
-            return 0.0f;
-        }
-        float value = outcome.GetValue();
-        if (fabsf(value) < deadZone)
-        {
-            return 0.0f;
-        }
-        return value;
-    }
-
     void XRCameraMovementComponent::ProcessOpenXRActions()
     {
         auto actionsIFace = OpenXRActionsInterface::Get();

+ 2 - 16
Gems/OpenXRVk/Code/Source/XRRayInteractorComponent.cpp

@@ -39,6 +39,8 @@
 #include <AzFramework/Physics/RigidBodyBus.h>
 #include <AzFramework/Physics/SimulatedBodies/RigidBody.h>
 
+#include "OpenXRVk/OpenXRVkUtils.h"
+
 namespace OpenXRVk
 {
     const AZStd::string baseColorPropertyName = "baseColor.color";
@@ -278,22 +280,6 @@ namespace OpenXRVk
         }
     }
 
-    static float ReadActionHandleFloat(IOpenXRActions* iface, IOpenXRActions::ActionHandle actionHandle, float deadZone = 0.05f)
-    {
-        auto outcome = iface->GetActionStateFloat(actionHandle);
-        if (!outcome.IsSuccess())
-        {
-            // Most likely the controller went to sleep.
-            return 0.0f;
-        }
-        float value = outcome.GetValue();
-        if (fabsf(value) < deadZone)
-        {
-            return 0.0f;
-        }
-        return value;
-    }
-
     void XRRayInteractorComponent::ProcessOpenXRActions()
     {
         m_currentSqueezeValue = 0;

+ 1 - 0
Gems/XR/Code/Include/XR/XRPassRegisterSystemComponent.h

@@ -9,6 +9,7 @@
 #pragma once
 
 #include <AzCore/Component/Component.h>
+#include <Atom/RPI.Public/Pass/PassSystemInterface.h>
 
 namespace XR
 {

+ 1 - 1
Gems/XR/Code/Source/Platform/Linux/PAL_linux.cmake

@@ -6,4 +6,4 @@
 #
 #
 
-set(PAL_TRAIT_XR_SUPPORTED FALSE)
+set(PAL_TRAIT_XR_SUPPORTED TRUE)