From 1898b28fda606c0bd7ab4c5ecb3e47a4cf37dd25 Mon Sep 17 00:00:00 2001 From: Malcolm Nixon Date: Fri, 3 Mar 2023 21:37:51 -0500 Subject: [PATCH] Added tool script annotation so is_class works. Merge grab-point-hand gdlint cleanup from 4.0. Fix PascalCase file name. --- VERSIONS.md | 1 + .../functions/function_pose_detector.gd | 1 + .../godot-xr-tools/functions/movement_wind.gd | 6 ---- .../godot-xr-tools/hands/hand_physics_bone.gd | 1 + .../interactable_handle_driven.gd | 1 + .../interactables/interactable_hinge.gd | 1 + .../interactables/interactable_joystick.gd | 1 + .../interactables/interactable_slider.gd | 1 + .../objects/grab_points/grab_point_hand.gd | 28 +++++++++++-------- .../godot-xr-tools/objects/hand_pose_area.gd | 1 + .../objects/interactable_area.gd | 1 + .../objects/keyboard/virtual_keyboard_2d.gd | 1 + addons/godot-xr-tools/objects/wind_area.gd | 1 + ...{BeltSnapZone.tscn => belt_snap_zone.tscn} | 0 scenes/pickable_demo/pickable_demo.tscn | 2 +- 15 files changed, 29 insertions(+), 18 deletions(-) rename scenes/pickable_demo/objects/{BeltSnapZone.tscn => belt_snap_zone.tscn} (100%) diff --git a/VERSIONS.md b/VERSIONS.md index cc084b1b..a95a3257 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -1,6 +1,7 @@ # 3.4.0 (Development) - Fixed footstep resource leak and added jump sounds and footstep signal - Added grab-point switching to pickable objects +- Added return-to-snap-zone feature # 3.3.0 - Added reset-scene and scene-control functions to scene-base diff --git a/addons/godot-xr-tools/functions/function_pose_detector.gd b/addons/godot-xr-tools/functions/function_pose_detector.gd index f185c260..eaf1cd50 100644 --- a/addons/godot-xr-tools/functions/function_pose_detector.gd +++ b/addons/godot-xr-tools/functions/function_pose_detector.gd @@ -1,3 +1,4 @@ +tool class_name XRToolsFunctionPoseDetector, "res://addons/godot-xr-tools/editor/icons/hand.svg" extends Spatial diff --git a/addons/godot-xr-tools/functions/movement_wind.gd b/addons/godot-xr-tools/functions/movement_wind.gd index 97865343..d41c36e5 100644 --- a/addons/godot-xr-tools/functions/movement_wind.gd +++ b/addons/godot-xr-tools/functions/movement_wind.gd @@ -130,9 +130,3 @@ func physics_movement(delta: float, player_body: XRToolsPlayerBody, _disabled: b var drag_factor := _active_wind_area.drag * drag_multiplier * delta drag_factor = clamp(drag_factor, 0.0, 1.0) player_body.velocity = lerp(player_body.velocity, wind_velocity, drag_factor) - - -# This method verifies the movement provider has a valid configuration. -func _get_configuration_warning(): - # Call base class - return ._get_configuration_warning() diff --git a/addons/godot-xr-tools/hands/hand_physics_bone.gd b/addons/godot-xr-tools/hands/hand_physics_bone.gd index ed50bdae..cf0110f3 100644 --- a/addons/godot-xr-tools/hands/hand_physics_bone.gd +++ b/addons/godot-xr-tools/hands/hand_physics_bone.gd @@ -1,3 +1,4 @@ +tool class_name XRToolsHandPhysicsBone extends BoneAttachment diff --git a/addons/godot-xr-tools/interactables/interactable_handle_driven.gd b/addons/godot-xr-tools/interactables/interactable_handle_driven.gd index 45b0bce4..d1c0c820 100644 --- a/addons/godot-xr-tools/interactables/interactable_handle_driven.gd +++ b/addons/godot-xr-tools/interactables/interactable_handle_driven.gd @@ -1,3 +1,4 @@ +tool class_name XRToolsInteractableHandleDriven extends Spatial diff --git a/addons/godot-xr-tools/interactables/interactable_hinge.gd b/addons/godot-xr-tools/interactables/interactable_hinge.gd index bb596d76..c19b16a3 100644 --- a/addons/godot-xr-tools/interactables/interactable_hinge.gd +++ b/addons/godot-xr-tools/interactables/interactable_hinge.gd @@ -1,3 +1,4 @@ +tool class_name XRToolsInteractableHinge extends XRToolsInteractableHandleDriven diff --git a/addons/godot-xr-tools/interactables/interactable_joystick.gd b/addons/godot-xr-tools/interactables/interactable_joystick.gd index cef348a8..92b91399 100644 --- a/addons/godot-xr-tools/interactables/interactable_joystick.gd +++ b/addons/godot-xr-tools/interactables/interactable_joystick.gd @@ -1,3 +1,4 @@ +tool class_name XRToolsInteractableJoystick extends XRToolsInteractableHandleDriven diff --git a/addons/godot-xr-tools/interactables/interactable_slider.gd b/addons/godot-xr-tools/interactables/interactable_slider.gd index 0357ca14..229119d8 100644 --- a/addons/godot-xr-tools/interactables/interactable_slider.gd +++ b/addons/godot-xr-tools/interactables/interactable_slider.gd @@ -1,3 +1,4 @@ +tool class_name XRToolsInteractableSlider extends XRToolsInteractableHandleDriven diff --git a/addons/godot-xr-tools/objects/grab_points/grab_point_hand.gd b/addons/godot-xr-tools/objects/grab_points/grab_point_hand.gd index 21f1802e..a833f674 100644 --- a/addons/godot-xr-tools/objects/grab_points/grab_point_hand.gd +++ b/addons/godot-xr-tools/objects/grab_points/grab_point_hand.gd @@ -58,17 +58,8 @@ func can_grab(_grabber : Node) -> bool: if not enabled: return false - # Ensure the pickup is valid - if not is_instance_valid(_grabber): - return false - - # Ensure the pickup is a function pickup for a controller - var pickup := _grabber as XRToolsFunctionPickup - if not pickup: - return false - - # Get the parent controller - var controller := pickup.get_controller() + # Get the grabber controller + var controller := _get_grabber_controller(_grabber) if not controller: return false @@ -130,3 +121,18 @@ func _update_editor_preview() -> void: # Add the editor-preview hand as a child add_child(_editor_preview_hand) + + +# Get the controller associated with a grabber +static func _get_grabber_controller(_grabber : Node) -> ARVRController: + # Ensure the grabber is valid + if not is_instance_valid(_grabber): + return null + + # Ensure the pickup is a function pickup for a controller + var pickup := _grabber as XRToolsFunctionPickup + if not pickup: + return null + + # Get the controller associated with the pickup + return pickup.get_controller() diff --git a/addons/godot-xr-tools/objects/hand_pose_area.gd b/addons/godot-xr-tools/objects/hand_pose_area.gd index a9db5394..1f69f040 100644 --- a/addons/godot-xr-tools/objects/hand_pose_area.gd +++ b/addons/godot-xr-tools/objects/hand_pose_area.gd @@ -1,3 +1,4 @@ +tool class_name XRToolsHandPoseArea, "res://addons/godot-xr-tools/editor/icons/hand.svg" extends Area diff --git a/addons/godot-xr-tools/objects/interactable_area.gd b/addons/godot-xr-tools/objects/interactable_area.gd index 8044be21..879acbc9 100644 --- a/addons/godot-xr-tools/objects/interactable_area.gd +++ b/addons/godot-xr-tools/objects/interactable_area.gd @@ -1,3 +1,4 @@ +tool class_name XRToolsInteractableArea extends Area diff --git a/addons/godot-xr-tools/objects/keyboard/virtual_keyboard_2d.gd b/addons/godot-xr-tools/objects/keyboard/virtual_keyboard_2d.gd index ae2515b2..ceca39cc 100644 --- a/addons/godot-xr-tools/objects/keyboard/virtual_keyboard_2d.gd +++ b/addons/godot-xr-tools/objects/keyboard/virtual_keyboard_2d.gd @@ -1,3 +1,4 @@ +tool class_name XRToolsVirtualKeyboard2D extends CanvasLayer diff --git a/addons/godot-xr-tools/objects/wind_area.gd b/addons/godot-xr-tools/objects/wind_area.gd index c3716621..9671fd69 100644 --- a/addons/godot-xr-tools/objects/wind_area.gd +++ b/addons/godot-xr-tools/objects/wind_area.gd @@ -1,3 +1,4 @@ +tool class_name XRToolsWindArea extends Area diff --git a/scenes/pickable_demo/objects/BeltSnapZone.tscn b/scenes/pickable_demo/objects/belt_snap_zone.tscn similarity index 100% rename from scenes/pickable_demo/objects/BeltSnapZone.tscn rename to scenes/pickable_demo/objects/belt_snap_zone.tscn diff --git a/scenes/pickable_demo/pickable_demo.tscn b/scenes/pickable_demo/pickable_demo.tscn index 6304da9b..b395eaa6 100644 --- a/scenes/pickable_demo/pickable_demo.tscn +++ b/scenes/pickable_demo/pickable_demo.tscn @@ -22,7 +22,7 @@ [ext_resource path="res://scenes/pickable_demo/objects/saucer.tscn" type="PackedScene" id=20] [ext_resource path="res://scenes/pickable_demo/objects/teacup_stand.tscn" type="PackedScene" id=21] [ext_resource path="res://scenes/pickable_demo/objects/instructions.tscn" type="PackedScene" id=22] -[ext_resource path="res://scenes/pickable_demo/objects/BeltSnapZone.tscn" type="PackedScene" id=23] +[ext_resource path="res://scenes/pickable_demo/objects/belt_snap_zone.tscn" type="PackedScene" id=23] [ext_resource path="res://scenes/pickable_demo/objects/knife.tscn" type="PackedScene" id=24] [ext_resource path="res://addons/godot-xr-tools/objects/return_to_snap_zone.gd" type="Script" id=25]