General proofreading (#1262)

* General proofreading for grammar and spelling
* General formatting
* Addition of appropriate literals where appropriate, i.e. `&"foo"` for `StringName` cases and `^"foo/bar"` for `NodePath` cases
This commit is contained in:
A Thousand Ships
2025-10-11 10:39:59 +02:00
committed by GitHub
parent a01005f397
commit 0343cedd48
180 changed files with 721 additions and 692 deletions

View File

@@ -7,10 +7,10 @@ func _ready():
xr_interface = XRServer.find_interface("Native mobile")
if xr_interface and xr_interface.initialize():
# Disable lens distortion.
# xr_interface.k1 = 0.0
# xr_interface.k2 = 0.0
#xr_interface.k1 = 0.0
#xr_interface.k2 = 0.0
# setup viewport
# Set up viewport.
var vp = get_viewport()
vp.use_xr = true
vp.vrs_mode = Viewport.VRS_XR
@@ -21,13 +21,13 @@ func _ready():
func _process(delta):
var dir : Vector2 = Vector2()
if Input.is_action_pressed("ui_left"):
if Input.is_action_pressed(&"ui_left"):
dir.x = -1.0
elif Input.is_action_pressed("ui_right"):
elif Input.is_action_pressed(&"ui_right"):
dir.x = 1.0
if Input.is_action_pressed("ui_up"):
if Input.is_action_pressed(&"ui_up"):
dir.y = -1.0
elif Input.is_action_pressed("ui_down"):
elif Input.is_action_pressed(&"ui_down"):
dir.y = 1.0
$XROrigin3D.global_position += $XROrigin3D.global_transform.basis.x * dir.x * delta

View File

@@ -21,8 +21,8 @@ The misunderstandings this causes in handling player movement is described in de
This demo implements the character body centric solution to the player movement problem.
Virtual movement by the player (e.g. movement through controller input) in this demo is handled similarly to a non-XR Godot game.
Physical movement by the player will result in the character body attempting to move to the players new location.
If successful the XROrigin node is moved in the opposite direction of the players movement.
Physical movement by the player will result in the character body attempting to move to the player's new location.
If successful the XROrigin node is moved in the opposite direction of the player's movement.
If unsuccessful the character body stays behind, the further the player moves the more we black out the screen.
## Action map

View File

@@ -15,7 +15,7 @@ func _update_fade() -> void:
$MeshInstance3D.visible = false
else:
if material:
material.set_shader_parameter("albedo", Color(0.0, 0.0, 0.0, fade))
material.set_shader_parameter(&"albedo", Color(0.0, 0.0, 0.0, fade))
$MeshInstance3D.visible = true

View File

@@ -32,12 +32,12 @@ func recenter() -> void:
XRServer.center_on_hmd(XRServer.RESET_BUT_KEEP_TILT, true)
# XRCamera3D node won't be updated yet, so go straight to the source!
var head_tracker: XRPositionalTracker = XRServer.get_tracker("head")
var head_tracker: XRPositionalTracker = XRServer.get_tracker(&"head")
if not head_tracker:
push_error("Couldn't locate head tracker!")
return
var pose: XRPose = head_tracker.get_pose("default")
var pose: XRPose = head_tracker.get_pose(&"default")
var head_transform: Transform3D = pose.get_adjusted_transform()
# Get neck transform in XROrigin3D space
@@ -53,17 +53,19 @@ func recenter() -> void:
# Finally reset character orientation
transform.basis = Basis()
# Returns our move input by querying the move action on each controller.
func _get_movement_input() -> Vector2:
var movement := Vector2()
# If move is not bound to one of our controllers,
# that controller will return `Vector2.ZERO`.
movement += $XROrigin3D/LeftHand.get_vector2("move")
movement += $XROrigin3D/RightHand.get_vector2("move")
movement += $XROrigin3D/LeftHand.get_vector2(&"move")
movement += $XROrigin3D/RightHand.get_vector2(&"move")
return movement
# `_process_on_physical_movement()` handles the physical movement of the player
# adjusting our character body position to "catch up to" the player.
# If the character body encounters an obstruction our view will black out
@@ -113,6 +115,7 @@ func _process_on_physical_movement(delta: float) -> bool:
black_out.fade = 0.0
return false
# `_process_movement_on_input()` handles movement through controller input.
# We first handle rotating the player and then apply movement.
# We also apply the effects of gravity at this point.
@@ -144,6 +147,7 @@ func _process_movement_on_input(is_colliding: bool, delta: float) -> void:
move_and_slide()
# `_physics_process()` handles our player movement.
func _physics_process(delta: float) -> void:
var is_colliding := _process_on_physical_movement(delta)

View File

@@ -19,7 +19,7 @@ The subsequent quality loss often renders text unreadable or at the least ugly l
It turns out however that when 2D interfaces are presented on a virtual screen in front of the user,
often as a rectangle or slightly curved screen,
that rendering this content ontop of the lens distorted 3D rendering,
that rendering this content on top of the lens distorted 3D rendering,
and simply curving this 2D plane,
results in a high quality render.

View File

@@ -13,10 +13,10 @@ func _ready():
# Callback for our tween to set the energy level on our active pointer.
func _update_energy(new_value : float):
var pointer = active_hand.get_node("Pointer")
var pointer = active_hand.get_node(^"Pointer")
var material : ShaderMaterial = pointer.material_override
if material:
material.set_shader_parameter("energy", new_value)
material.set_shader_parameter(&"energy", new_value)
# Start our tween to show a pulse on our click.

View File

@@ -1,6 +1,6 @@
# XR Hand Tracking Demo
This is a demo showing OpenXRs hand tracking and controller tracking logic.
This is a demo showing OpenXR's hand tracking and controller tracking logic.
Language: GDScript
@@ -16,9 +16,9 @@ Renderer: Compatibility
## How does it work?
Being able to see the players hands, and having those hands interact with elements in the environment are paramount to a good XR experience.
Being able to see the player's hands, and having those hands interact with elements in the environment are paramount to a good XR experience.
In this demo we look at the off the shelf logic for displaying a hand model that is automated based on either controller input or through optical tracking of the players hands.
In this demo we look at the off the shelf logic for displaying a hand model that is automated based on either controller input or through optical tracking of the player's hands.
We also implement logic that allows interaction based on input from the action map that allows the user to pick up the blocks in this demo.
The problem this poses to us is that there have been two schools of thought around what hand tracking actually means,
@@ -45,7 +45,7 @@ and treats them as two versions of the same.
Especially with controllers like the Valve Index, or with various data gloves that are treated as controllers,
there is no discernible difference here.
The hand tracking API is mostly used for visualising the players hand with bone positions either being inferred
The hand tracking API is mostly used for visualising the player's hand with bone positions either being inferred
from controller input or matching the optical tracking.
For advanced gesture recognition you would still use this data however it is now accessible regardless of
the physical means in which this data is obtained.
@@ -56,10 +56,10 @@ gestures such as pinching and pointing resulting in inputs that can be bound in
OpenXR is moving towards this approach and this demo has been build in accordance with this however not all runtimes have been updated yet.
SteamVR has followed this approach for a long time and works out of the box, however SteamVR treats everything as controllers resulting in some short comings when a Quest is used over Meta Link or Steam Link and optical hand tracking is used.
SteamVR has followed this approach for a long time and works out of the box, however SteamVR treats everything as controllers resulting in some shortcomings when a Quest is used over Meta Link or Steam Link and optical hand tracking is used.
Metas native Quest runtime on all versions of Quest now support OpenXRs "data source extension" which Godot enables when hand tracking is enabled.
However Meta does not yet support OpenXRs "hand interaction profile extension" which is required.
Metas native Quest runtime on all versions of Quest now support OpenXR's "data source extension" which Godot enables when hand tracking is enabled.
However Meta does not yet support OpenXR's "hand interaction profile extension" which is required.
Meta link is still trailing behind and does not support this brave new world **yet**.
@@ -78,12 +78,12 @@ This demo project shows what that future looks like.
## Hand tracking API
As mentioned, the hand tracking API is at the center of visualising the users hand.
As mentioned, the hand tracking API is at the center of visualising the user's hand.
In Godot 4.3 we overhauled the system so the XR Interface needs to convert hand tracking data to the Godot humanoid skeleton hand bone layout.
This also means that this logic works both in WebXR, OpenXR and any other XR Interface that adds support for this feature.
Hand tracking now also makes use of the new Skeleton Modifier logic in Godot 4.3 however
the skeleton is posed in the hands local space, while positioning is provided through a XRNode3D node.
the skeleton is posed in the hands local space, while positioning is provided through an XRNode3D node.
This split is applied because:
@@ -125,7 +125,7 @@ differs between XR runtimes and can cause misalignment of the hand mesh.
## Action map
As mentioned, we're using the action map here for input however when optical hand tracking is used
we rely on OpenXRs hand interaction profile extension.
we rely on OpenXR's hand interaction profile extension.
Without support for this extension this demo will not fully function.
This can be solved by checking that no interaction profile has been bound to our XRController3D node,

View File

@@ -13,16 +13,16 @@ func _process(delta):
else:
text += "Right hand\n"
var controller_tracker : XRPositionalTracker = XRServer.get_tracker("left_hand" if hand == 0 else "right_hand")
var controller_tracker : XRPositionalTracker = XRServer.get_tracker(&"left_hand" if hand == 0 else &"right_hand")
if controller_tracker:
var profile = controller_tracker.profile.replace("/interaction_profiles/", "").replace("/", " ")
text += "\nProfile: " + profile + "\n"
var pose : XRPose = controller_tracker.get_pose("palm_pose")
var pose : XRPose = controller_tracker.get_pose(&"palm_pose")
if pose and pose.tracking_confidence != XRPose.XR_TRACKING_CONFIDENCE_NONE:
text +=" - Using palm pose\n"
else:
pose = controller_tracker.get_pose("grip")
pose = controller_tracker.get_pose(&"grip")
if pose:
text +=" - Using grip pose\n"
@@ -40,7 +40,7 @@ func _process(delta):
else:
text += "\nNo controller tracker found!\n"
var hand_tracker : XRHandTracker = XRServer.get_tracker("/user/hand_tracker/left" if hand == 0 else "/user/hand_tracker/right")
var hand_tracker : XRHandTracker = XRServer.get_tracker(&"/user/hand_tracker/left" if hand == 0 else &"/user/hand_tracker/right")
if hand_tracker:
text += "\nHand tracker found\n"

View File

@@ -68,7 +68,7 @@ func pick_up(pick_up_by) -> void:
# Add code here to determine snap position and orientation.
# Now tween
tween.tween_property(self, "transform", snap_to, 0.1)
tween.tween_property(self, ^"transform", snap_to, 0.1)
# Let this object go.

View File

@@ -2,7 +2,7 @@
class_name PickupHandler3D
extends Area3D
# This area3D class detects all physics bodys based on
# This area3D class detects all physics bodies based on
# PickupAbleBody3D within range and handles the logic
# for selecting the closest one and allowing pickup
# of that object.

View File

@@ -69,11 +69,11 @@ func _process_modification() -> void:
var r : Transform3D
t = t * r.rotated(Vector3(1.0, 0.0, 0.0), deg_to_rad(20.0) * trigger)
elif bone_name == "LeftMiddleDistal" or bone_name == "LeftMiddleIntermediate" or bone_name == "LeftMiddleProximal" \
or bone_name == "RightMiddleDistal" or bone_name == "RightMiddleIntermediate" or bone_name == "RightMiddleProximal" \
or bone_name == "LeftRingDistal" or bone_name == "LeftRingIntermediate" or bone_name == "LeftRingProximal" \
or bone_name == "RightRingDistal" or bone_name == "RightRingIntermediate" or bone_name == "RightRingProximal" \
or bone_name == "LeftLittleDistal" or bone_name == "LeftLittleIntermediate" or bone_name == "LeftLittleProximal" \
or bone_name == "RightLittleDistal" or bone_name == "RightLittleIntermediate" or bone_name == "RightLittleProximal":
or bone_name == "RightMiddleDistal" or bone_name == "RightMiddleIntermediate" or bone_name == "RightMiddleProximal" \
or bone_name == "LeftRingDistal" or bone_name == "LeftRingIntermediate" or bone_name == "LeftRingProximal" \
or bone_name == "RightRingDistal" or bone_name == "RightRingIntermediate" or bone_name == "RightRingProximal" \
or bone_name == "LeftLittleDistal" or bone_name == "LeftLittleIntermediate" or bone_name == "LeftLittleProximal" \
or bone_name == "RightLittleDistal" or bone_name == "RightLittleIntermediate" or bone_name == "RightLittleProximal":
var r : Transform3D
t = t * r.rotated(Vector3(1.0, 0.0, 0.0), deg_to_rad(90.0) * grip)

View File

@@ -1,6 +1,6 @@
# XR Origin Centric Movement demo
This is a demo for an OpenXR project where player movement is handled with a XRorigin3D as a base node.
This is a demo for an OpenXR project where player movement is handled with an XRorigin3D as a base node.
This is based on the [Origin centric solution as explained in the room scale manual page](https://docs.godotengine.org/en/stable/tutorials/xr/xr_room_scale.html#origin-centric-solution).
Language: GDScript

View File

@@ -14,7 +14,7 @@ func _update_fade() -> void:
$MeshInstance3D.visible = false
else:
if material:
material.set_shader_parameter("albedo", Color(0.0, 0.0, 0.0, fade))
material.set_shader_parameter(&"albedo", Color(0.0, 0.0, 0.0, fade))
$MeshInstance3D.visible = true

View File

@@ -42,17 +42,19 @@ func recenter() -> void:
# Recenter character body.
character_body.transform = Transform3D()
# `_get_movement_input()` returns our move input by querying the move action on each controller.
func _get_movement_input() -> Vector2:
var movement : Vector2 = Vector2()
# If move is not bound to one of our controllers,
# that controller will return `Vector2.ZERO`.
movement += $LeftHand.get_vector2("move")
movement += $RightHand.get_vector2("move")
movement += $LeftHand.get_vector2(&"move")
movement += $RightHand.get_vector2(&"move")
return movement
# `_process_on_physical_movement` handles the physical movement of the player
# adjusting our character body position to "catch up to" the player.
# If the character body encounters an obstruction our view will black out