diff options
Diffstat (limited to 'modules')
10 files changed, 97 insertions, 16 deletions
diff --git a/modules/gdscript/gdscript_byte_codegen.cpp b/modules/gdscript/gdscript_byte_codegen.cpp index 27766115d5..36b157521d 100644 --- a/modules/gdscript/gdscript_byte_codegen.cpp +++ b/modules/gdscript/gdscript_byte_codegen.cpp @@ -429,7 +429,7 @@ void GDScriptByteCodeGenerator::set_initial_line(int p_line) { (m_var.type.has_type && m_var.type.kind == GDScriptDataType::BUILTIN) #define IS_BUILTIN_TYPE(m_var, m_type) \ - (m_var.type.has_type && m_var.type.kind == GDScriptDataType::BUILTIN && m_var.type.builtin_type == m_type) + (m_var.type.has_type && m_var.type.kind == GDScriptDataType::BUILTIN && m_var.type.builtin_type == m_type && m_type != Variant::NIL) void GDScriptByteCodeGenerator::write_type_adjust(const Address &p_target, Variant::Type p_new_type) { switch (p_new_type) { diff --git a/modules/gdscript/tests/scripts/runtime/features/match_test_null.gd b/modules/gdscript/tests/scripts/runtime/features/match_test_null.gd new file mode 100644 index 0000000000..9bb57b68ee --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/match_test_null.gd @@ -0,0 +1,6 @@ +func test(): + match null: + null: + print('null matched') + _: + pass diff --git a/modules/gdscript/tests/scripts/runtime/features/match_test_null.out b/modules/gdscript/tests/scripts/runtime/features/match_test_null.out new file mode 100644 index 0000000000..7640cf42ab --- /dev/null +++ b/modules/gdscript/tests/scripts/runtime/features/match_test_null.out @@ -0,0 +1,2 @@ +GDTEST_OK +null matched diff --git a/modules/multiplayer/editor/multiplayer_editor_plugin.cpp b/modules/multiplayer/editor/multiplayer_editor_plugin.cpp index af2db543c0..e8dfc3379c 100644 --- a/modules/multiplayer/editor/multiplayer_editor_plugin.cpp +++ b/modules/multiplayer/editor/multiplayer_editor_plugin.cpp @@ -36,6 +36,7 @@ #include "editor/editor_interface.h" #include "editor/editor_node.h" +#include "editor/gui/editor_bottom_panel.h" void MultiplayerEditorDebugger::_bind_methods() { ADD_SIGNAL(MethodInfo("open_request", PropertyInfo(Variant::STRING, "path"))); @@ -112,7 +113,7 @@ void MultiplayerEditorDebugger::setup_session(int p_session_id) { MultiplayerEditorPlugin::MultiplayerEditorPlugin() { repl_editor = memnew(ReplicationEditor); - button = EditorNode::get_singleton()->add_bottom_panel_item(TTR("Replication"), repl_editor); + button = EditorNode::get_bottom_panel()->add_item(TTR("Replication"), repl_editor); button->hide(); repl_editor->get_pin()->connect("pressed", callable_mp(this, &MultiplayerEditorPlugin::_pinned)); debugger.instantiate(); @@ -139,7 +140,7 @@ void MultiplayerEditorPlugin::_node_removed(Node *p_node) { if (p_node && p_node == repl_editor->get_current()) { repl_editor->edit(nullptr); if (repl_editor->is_visible_in_tree()) { - EditorNode::get_singleton()->hide_bottom_panel(); + EditorNode::get_bottom_panel()->hide_bottom_panel(); } button->hide(); repl_editor->get_pin()->set_pressed(false); @@ -149,7 +150,7 @@ void MultiplayerEditorPlugin::_node_removed(Node *p_node) { void MultiplayerEditorPlugin::_pinned() { if (!repl_editor->get_pin()->is_pressed()) { if (repl_editor->is_visible_in_tree()) { - EditorNode::get_singleton()->hide_bottom_panel(); + EditorNode::get_bottom_panel()->hide_bottom_panel(); } button->hide(); } @@ -166,10 +167,10 @@ bool MultiplayerEditorPlugin::handles(Object *p_object) const { void MultiplayerEditorPlugin::make_visible(bool p_visible) { if (p_visible) { button->show(); - EditorNode::get_singleton()->make_bottom_panel_item_visible(repl_editor); + EditorNode::get_bottom_panel()->make_item_visible(repl_editor); } else if (!repl_editor->get_pin()->is_pressed()) { if (repl_editor->is_visible_in_tree()) { - EditorNode::get_singleton()->hide_bottom_panel(); + EditorNode::get_bottom_panel()->hide_bottom_panel(); } button->hide(); } diff --git a/modules/openxr/doc_classes/OpenXRHand.xml b/modules/openxr/doc_classes/OpenXRHand.xml index 1c4da83138..23d932ddd7 100644 --- a/modules/openxr/doc_classes/OpenXRHand.xml +++ b/modules/openxr/doc_classes/OpenXRHand.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="OpenXRHand" inherits="Node3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> +<class name="OpenXRHand" inherits="Node3D" deprecated="Use [XRHandModifier3D] instead." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> <brief_description> Node supporting hand and finger tracking in OpenXR. </brief_description> diff --git a/modules/openxr/doc_classes/OpenXRInterface.xml b/modules/openxr/doc_classes/OpenXRInterface.xml index caaaeb90ff..5d38788dcd 100644 --- a/modules/openxr/doc_classes/OpenXRInterface.xml +++ b/modules/openxr/doc_classes/OpenXRInterface.xml @@ -23,7 +23,7 @@ Returns display refresh rates supported by the current HMD. Only returned if this feature is supported by the OpenXR runtime and after the interface has been initialized. </description> </method> - <method name="get_hand_joint_angular_velocity" qualifiers="const"> + <method name="get_hand_joint_angular_velocity" qualifiers="const" deprecated="Use [method XRHandTracker.get_hand_joint_angular_velocity] obtained from [method XRServer.get_hand_tracker] instead."> <return type="Vector3" /> <param index="0" name="hand" type="int" enum="OpenXRInterface.Hand" /> <param index="1" name="joint" type="int" enum="OpenXRInterface.HandJoints" /> @@ -31,7 +31,7 @@ If handtracking is enabled, returns the angular velocity of a joint ([param joint]) of a hand ([param hand]) as provided by OpenXR. This is relative to [XROrigin3D]! </description> </method> - <method name="get_hand_joint_flags" qualifiers="const"> + <method name="get_hand_joint_flags" qualifiers="const" deprecated="Use [method XRHandTracker.get_hand_joint_flags] obtained from [method XRServer.get_hand_tracker] instead."> <return type="int" enum="OpenXRInterface.HandJointFlags" is_bitfield="true" /> <param index="0" name="hand" type="int" enum="OpenXRInterface.Hand" /> <param index="1" name="joint" type="int" enum="OpenXRInterface.HandJoints" /> @@ -39,7 +39,7 @@ If handtracking is enabled, returns flags that inform us of the validity of the tracking data. </description> </method> - <method name="get_hand_joint_linear_velocity" qualifiers="const"> + <method name="get_hand_joint_linear_velocity" qualifiers="const" deprecated="Use [method XRHandTracker.get_hand_joint_linear_velocity] obtained from [method XRServer.get_hand_tracker] instead."> <return type="Vector3" /> <param index="0" name="hand" type="int" enum="OpenXRInterface.Hand" /> <param index="1" name="joint" type="int" enum="OpenXRInterface.HandJoints" /> @@ -47,7 +47,7 @@ If handtracking is enabled, returns the linear velocity of a joint ([param joint]) of a hand ([param hand]) as provided by OpenXR. This is relative to [XROrigin3D] without worldscale applied! </description> </method> - <method name="get_hand_joint_position" qualifiers="const"> + <method name="get_hand_joint_position" qualifiers="const" deprecated="Use [method XRHandTracker.get_hand_joint_transform] obtained from [method XRServer.get_hand_tracker] instead."> <return type="Vector3" /> <param index="0" name="hand" type="int" enum="OpenXRInterface.Hand" /> <param index="1" name="joint" type="int" enum="OpenXRInterface.HandJoints" /> @@ -55,7 +55,7 @@ If handtracking is enabled, returns the position of a joint ([param joint]) of a hand ([param hand]) as provided by OpenXR. This is relative to [XROrigin3D] without worldscale applied! </description> </method> - <method name="get_hand_joint_radius" qualifiers="const"> + <method name="get_hand_joint_radius" qualifiers="const" deprecated="Use [method XRHandTracker.get_hand_joint_radius] obtained from [method XRServer.get_hand_tracker] instead."> <return type="float" /> <param index="0" name="hand" type="int" enum="OpenXRInterface.Hand" /> <param index="1" name="joint" type="int" enum="OpenXRInterface.HandJoints" /> @@ -63,7 +63,7 @@ If handtracking is enabled, returns the radius of a joint ([param joint]) of a hand ([param hand]) as provided by OpenXR. This is without worldscale applied! </description> </method> - <method name="get_hand_joint_rotation" qualifiers="const"> + <method name="get_hand_joint_rotation" qualifiers="const" deprecated="Use [method XRHandTracker.get_hand_joint_transform] obtained from [method XRServer.get_hand_tracker] instead."> <return type="Quaternion" /> <param index="0" name="hand" type="int" enum="OpenXRInterface.Hand" /> <param index="1" name="joint" type="int" enum="OpenXRInterface.HandJoints" /> @@ -71,7 +71,7 @@ If handtracking is enabled, returns the rotation of a joint ([param joint]) of a hand ([param hand]) as provided by OpenXR. </description> </method> - <method name="get_hand_tracking_source" qualifiers="const"> + <method name="get_hand_tracking_source" qualifiers="const" deprecated="Use [member XRHandTracker.hand_tracking_source] obtained from [method XRServer.get_hand_tracker] instead."> <return type="int" enum="OpenXRInterface.HandTrackedSource" /> <param index="0" name="hand" type="int" enum="OpenXRInterface.Hand" /> <description> diff --git a/modules/openxr/editor/openxr_action_map_editor.cpp b/modules/openxr/editor/openxr_action_map_editor.cpp index 15468a1c67..5dd737756a 100644 --- a/modules/openxr/editor/openxr_action_map_editor.cpp +++ b/modules/openxr/editor/openxr_action_map_editor.cpp @@ -33,6 +33,7 @@ #include "core/config/project_settings.h" #include "editor/editor_node.h" #include "editor/editor_settings.h" +#include "editor/gui/editor_bottom_panel.h" #include "editor/gui/editor_file_dialog.h" #include "editor/themes/editor_scale.h" @@ -356,7 +357,7 @@ void OpenXRActionMapEditor::_do_remove_interaction_profile_editor(OpenXRInteract } void OpenXRActionMapEditor::open_action_map(String p_path) { - EditorNode::get_singleton()->make_bottom_panel_item_visible(this); + EditorNode::get_bottom_panel()->make_item_visible(this); // out with the old... _clear_action_map(); diff --git a/modules/openxr/editor/openxr_editor_plugin.cpp b/modules/openxr/editor/openxr_editor_plugin.cpp index 559890ecb3..f545e31073 100644 --- a/modules/openxr/editor/openxr_editor_plugin.cpp +++ b/modules/openxr/editor/openxr_editor_plugin.cpp @@ -33,6 +33,7 @@ #include "../action_map/openxr_action_map.h" #include "editor/editor_node.h" +#include "editor/gui/editor_bottom_panel.h" void OpenXREditorPlugin::edit(Object *p_node) { if (Object::cast_to<OpenXRActionMap>(p_node)) { @@ -52,7 +53,7 @@ void OpenXREditorPlugin::make_visible(bool p_visible) { OpenXREditorPlugin::OpenXREditorPlugin() { action_map_editor = memnew(OpenXRActionMapEditor); - EditorNode::get_singleton()->add_bottom_panel_item(TTR("OpenXR Action Map"), action_map_editor); + EditorNode::get_bottom_panel()->add_item(TTR("OpenXR Action Map"), action_map_editor); #ifndef ANDROID_ENABLED select_runtime = memnew(OpenXRSelectRuntime); diff --git a/modules/openxr/extensions/openxr_hand_tracking_extension.cpp b/modules/openxr/extensions/openxr_hand_tracking_extension.cpp index 884fb41a3c..b3c20ef8b9 100644 --- a/modules/openxr/extensions/openxr_hand_tracking_extension.cpp +++ b/modules/openxr/extensions/openxr_hand_tracking_extension.cpp @@ -193,11 +193,18 @@ void OpenXRHandTrackingExtension::on_process() { hand_trackers[i].locations.jointCount = XR_HAND_JOINT_COUNT_EXT; hand_trackers[i].locations.jointLocations = hand_trackers[i].joint_locations; + Ref<XRHandTracker> godot_tracker; + godot_tracker.instantiate(); + godot_tracker->set_hand(i == 0 ? XRHandTracker::HAND_LEFT : XRHandTracker::HAND_RIGHT); + XRServer::get_singleton()->add_hand_tracker(i == 0 ? "/user/left" : "/user/right", godot_tracker); + hand_trackers[i].godot_tracker = godot_tracker; + hand_trackers[i].is_initialized = true; } } if (hand_trackers[i].is_initialized) { + Ref<XRHandTracker> godot_tracker = hand_trackers[i].godot_tracker; void *next_pointer = nullptr; XrHandJointsMotionRangeInfoEXT motion_range_info = { XR_TYPE_HAND_JOINTS_MOTION_RANGE_INFO_EXT, next_pointer, hand_trackers[i].motion_range }; @@ -216,6 +223,7 @@ void OpenXRHandTrackingExtension::on_process() { if (XR_FAILED(result)) { // not successful? then we do nothing. print_line("OpenXR: Failed to get tracking for hand", i, "[", OpenXRAPI::get_singleton()->get_error_string(result), "]"); + godot_tracker->set_has_tracking_data(false); continue; } @@ -225,6 +233,64 @@ void OpenXRHandTrackingExtension::on_process() { !hand_trackers[i].locations.isActive || isnan(palm.position.x) || palm.position.x < -1000000.00 || palm.position.x > 1000000.00) { hand_trackers[i].locations.isActive = false; // workaround, make sure its inactive } + + if (hand_trackers[i].locations.isActive) { + godot_tracker->set_has_tracking_data(true); + + // SKELETON_RIG_HUMANOID bone adjustment. This rotation performs: + // OpenXR Z+ -> Godot Humanoid Y- (Back along the bone) + // OpenXR Y+ -> Godot Humanoid Z- (Out the back of the hand) + const Quaternion bone_adjustment(0.0, -Math_SQRT12, Math_SQRT12, 0.0); + + for (int joint = 0; joint < XR_HAND_JOINT_COUNT_EXT; joint++) { + const XrHandJointLocationEXT &location = hand_trackers[i].joint_locations[joint]; + const XrHandJointVelocityEXT &velocity = hand_trackers[i].joint_velocities[joint]; + const XrHandTrackingDataSourceStateEXT &data_source = hand_trackers[i].data_source; + const XrPosef &pose = location.pose; + + Transform3D transform; + BitField<XRHandTracker::HandJointFlags> flags; + + if (location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) { + if (pose.orientation.x != 0 || pose.orientation.y != 0 || pose.orientation.z != 0 || pose.orientation.w != 0) { + flags.set_flag(XRHandTracker::HAND_JOINT_FLAG_ORIENTATION_VALID); + transform.basis = Basis(Quaternion(pose.orientation.x, pose.orientation.y, pose.orientation.z, pose.orientation.w) * bone_adjustment); + } + } + if (location.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) { + flags.set_flag(XRHandTracker::HAND_JOINT_FLAG_POSITION_VALID); + transform.origin = Vector3(pose.position.x, pose.position.y, pose.position.z); + } + if (location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT) { + flags.set_flag(XRHandTracker::HAND_JOINT_FLAG_ORIENTATION_TRACKED); + } + if (location.locationFlags & XR_SPACE_LOCATION_POSITION_TRACKED_BIT) { + flags.set_flag(XRHandTracker::HAND_JOINT_FLAG_POSITION_TRACKED); + } + if (location.locationFlags & XR_SPACE_VELOCITY_LINEAR_VALID_BIT) { + flags.set_flag(XRHandTracker::HAND_JOINT_FLAG_LINEAR_VELOCITY_VALID); + godot_tracker->set_hand_joint_linear_velocity((XRHandTracker::HandJoint)joint, Vector3(velocity.linearVelocity.x, velocity.linearVelocity.y, velocity.linearVelocity.z)); + } + if (location.locationFlags & XR_SPACE_VELOCITY_ANGULAR_VALID_BIT) { + flags.set_flag(XRHandTracker::HAND_JOINT_FLAG_ANGULAR_VELOCITY_VALID); + godot_tracker->set_hand_joint_angular_velocity((XRHandTracker::HandJoint)joint, Vector3(velocity.angularVelocity.x, velocity.angularVelocity.y, velocity.angularVelocity.z)); + } + + godot_tracker->set_hand_joint_flags((XRHandTracker::HandJoint)joint, flags); + godot_tracker->set_hand_joint_transform((XRHandTracker::HandJoint)joint, transform); + godot_tracker->set_hand_joint_radius((XRHandTracker::HandJoint)joint, location.radius); + + XRHandTracker::HandTrackingSource source = XRHandTracker::HAND_TRACKING_SOURCE_UNKNOWN; + if (data_source.dataSource == XR_HAND_TRACKING_DATA_SOURCE_UNOBSTRUCTED_EXT) { + source = XRHandTracker::HAND_TRACKING_SOURCE_UNOBSTRUCTED; + } else if (data_source.dataSource == XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT) { + source = XRHandTracker::HAND_TRACKING_SOURCE_CONTROLLER; + } + godot_tracker->set_hand_tracking_source(source); + } + } else { + godot_tracker->set_has_tracking_data(false); + } } } } @@ -244,6 +310,8 @@ void OpenXRHandTrackingExtension::cleanup_hand_tracking() { hand_trackers[i].is_initialized = false; hand_trackers[i].hand_tracker = XR_NULL_HANDLE; + + XRServer::get_singleton()->remove_hand_tracker(i == 0 ? "/user/left" : "/user/right"); } } } diff --git a/modules/openxr/extensions/openxr_hand_tracking_extension.h b/modules/openxr/extensions/openxr_hand_tracking_extension.h index 967538b377..f709bc05c2 100644 --- a/modules/openxr/extensions/openxr_hand_tracking_extension.h +++ b/modules/openxr/extensions/openxr_hand_tracking_extension.h @@ -34,6 +34,7 @@ #include "../util.h" #include "core/math/quaternion.h" #include "openxr_extension_wrapper.h" +#include "servers/xr/xr_hand_tracker.h" class OpenXRHandTrackingExtension : public OpenXRExtensionWrapper { public: @@ -52,6 +53,7 @@ public: struct HandTracker { bool is_initialized = false; + Ref<XRHandTracker> godot_tracker; XrHandJointsMotionRangeEXT motion_range = XR_HAND_JOINTS_MOTION_RANGE_UNOBSTRUCTED_EXT; HandTrackedSource source = OPENXR_SOURCE_UNKNOWN; |
