Skip to content

Commit

Permalink
Renamed files and classes to match new godot-xr-tools standard.
Browse files Browse the repository at this point in the history
Minor gdlint cleanups.
  • Loading branch information
Malcolmnixon committed Sep 25, 2022
1 parent 2885db6 commit b539680
Show file tree
Hide file tree
Showing 148 changed files with 1,045 additions and 1,044 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class_name XRToolsHand, "res://addons/godot-xr-tools/editor/icons/XRToolsHand.svg"
class_name XRToolsHand, "res://addons/godot-xr-tools/editor/icons/hand.svg"
extends Spatial


Expand Down Expand Up @@ -28,7 +28,7 @@ onready var _transform := transform


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
func _process(_delta: float) -> void:
# Scale the hand mesh with the world scale. This is required for OpenXR plugin
# 1.3.0 and later where the plugin no-longer scales the controllers with
# world_scale
Expand All @@ -42,14 +42,14 @@ func _process(delta: float) -> void:
if controller:
var grip = controller.get_joystick_axis(JOY_VR_ANALOG_GRIP)
var trigger = controller.get_joystick_axis(JOY_VR_ANALOG_TRIGGER)

# Uncomment for workaround for bug in OpenXR plugin 1.1.1 and earlier giving values from -1.0 to 1.0
# note that when controller are not being tracking yet this will result in a value of 0.5
# grip = (grip + 1.0) * 0.5
# trigger = (trigger + 1.0) * 0.5

$AnimationTree.set("parameters/Grip/blend_amount", grip)
$AnimationTree.set("parameters/Trigger/blend_amount", trigger)

# var grip_state = controller.is_button_pressed(JOY_VR_GRIP)
# print("Pressed: " + str(grip_state))
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ nodes/Grip/position = Vector2( 780, 180 )
nodes/Trigger/node = SubResource( 2 )
nodes/Trigger/position = Vector2( 560, 80 )
nodes/output/position = Vector2( 1020, 80 )
node_connections = [ "output", 0, "Grip", "Trigger", 0, "Default", "Trigger", 1, "Fist", "Grip", 0, "Trigger", "Grip", 1, "Fist2" ]
node_connections = [ "output", 0, "Grip", "Grip", 0, "Trigger", "Grip", 1, "Fist2", "Trigger", 0, "Default", "Trigger", 1, "Fist" ]
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extends BoneAttachment
## the hand skeleton, and uses this position to move a CapsuleShape bone
## KinematicBody.
##
## The bone Kinematic is set as top-level and manually driven with the
## The bone Kinematic is set as top-level and manually driven with the
## bones positon and rotation. This is to prevent hand-scaling from scaling
## the Kinematic collision shape, as colliders cannot tolerate being scaled.
##
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

importer="scene"
type="PackedScene"
path="res://.import/RightHand.glb-b0ade3e24442d11ee987628909f601b4.scn"
path="res://.import/left_hand.glb-54ab35158cb64aaf29610f7be672554e.scn"

[deps]

source_file="res://addons/godot-xr-tools/assets/RightHand.glb"
dest_files=[ "res://.import/RightHand.glb-b0ade3e24442d11ee987628909f601b4.scn" ]
source_file="res://addons/godot-xr-tools/assets/left_hand.glb"
dest_files=[ "res://.import/left_hand.glb-54ab35158cb64aaf29610f7be672554e.scn" ]

[params]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://addons/godot-xr-tools/assets/LeftHand.glb" type="PackedScene" id=1]
[ext_resource path="res://addons/godot-xr-tools/assets/Hand.gd" type="Script" id=2]
[ext_resource path="res://addons/godot-xr-tools/assets/HandBlendTree.tres" type="AnimationNodeBlendTree" id=3]
[ext_resource path="res://addons/godot-xr-tools/assets/left_hand.glb" type="PackedScene" id=1]
[ext_resource path="res://addons/godot-xr-tools/assets/hand.gd" type="Script" id=2]
[ext_resource path="res://addons/godot-xr-tools/assets/hand_blend_tree.tres" type="AnimationNodeBlendTree" id=3]

[node name="LeftHand" type="Spatial"]
script = ExtResource( 2 )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://addons/godot-xr-tools/assets/LeftHand.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/godot-xr-tools/assets/HandPhysicsBone.gd" type="Script" id=2]
[ext_resource path="res://addons/godot-xr-tools/assets/PhysicsHand.gd" type="Script" id=3]
[ext_resource path="res://addons/godot-xr-tools/assets/left_hand.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/godot-xr-tools/assets/hand_physics_bone.gd" type="Script" id=2]
[ext_resource path="res://addons/godot-xr-tools/assets/physics_hand.gd" type="Script" id=3]

[node name="LeftPhysicsHand" instance=ExtResource( 1 )]
script = ExtResource( 3 )
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tool
class_name PlayerBody, "res://addons/godot-xr-tools/editor/icons/XRToolsBody.svg"
class_name XRToolsPlayerBody, "res://addons/godot-xr-tools/editor/icons/body.svg"
extends Node

##
Expand Down Expand Up @@ -32,7 +32,7 @@ signal player_bounced(collider, magnitude)
const HORIZONTAL := Vector3(1.0, 0.0, 1.0)


## PlayerBody enabled flag
## Player body enabled flag
export var enabled := true setget set_enabled

## Player radius
Expand Down Expand Up @@ -66,25 +66,25 @@ export (int, LAYERS_3D_PHYSICS) var collision_layer = 1 << 19 setget set_collisi
export (int, LAYERS_3D_PHYSICS) var collision_mask = 1023 setget set_collision_mask


## Player Velocity - modifiable by MovementProvider nodes
## Player Velocity - modifiable by movement providers
var velocity := Vector3.ZERO

## Player On Ground flag - used by MovementProvider nodes
## Player On Ground flag - used by movement providers
var on_ground := true

## Ground 'up' vector - used by MovementProvider nodes
## Ground 'up' vector - used by movement providers
var ground_vector := Vector3.UP

## Ground slope angle - used by MovementProvider nodes
## Ground slope angle - used by movement providers
var ground_angle := 0.0

## Ground node the player is touching
var ground_node: Spatial = null

## Ground physics override (if present)
var ground_physics: GroundPhysicsSettings = null
var ground_physics: XRToolsGroundPhysicsSettings = null

## Ground control velocity - modified by MovementProvider nodes
## Ground control velocity - modified by movement providers
var ground_control_velocity := Vector2.ZERO

## Player height offset (for height calibration)
Expand Down Expand Up @@ -258,12 +258,12 @@ func request_jump(var skip_jump_velocity := false):
return

# Skip if jump disabled on this ground
var jump_velocity := GroundPhysicsSettings.get_jump_velocity(ground_physics, default_physics)
var jump_velocity := XRToolsGroundPhysicsSettings.get_jump_velocity(ground_physics, default_physics)
if jump_velocity == 0.0:
return

# Skip if the ground is too steep to jump
var max_slope := GroundPhysicsSettings.get_jump_max_slope(ground_physics, default_physics)
var max_slope := XRToolsGroundPhysicsSettings.get_jump_max_slope(ground_physics, default_physics)
if ground_angle > max_slope:
return

Expand Down Expand Up @@ -345,8 +345,8 @@ func _update_ground_information(delta: float):
ground_node = ground_collision.collider

# Select the ground physics
var physics_node := ground_node.get_node_or_null("GroundPhysics") as GroundPhysics
ground_physics = GroundPhysics.get_physics(physics_node, default_physics)
var physics_node := ground_node.get_node_or_null("GroundPhysics") as XRToolsGroundPhysics
ground_physics = XRToolsGroundPhysics.get_physics(physics_node, default_physics)

# Detect if we're sliding on a wall
# TODO: consider reworking this magic angle
Expand All @@ -358,7 +358,7 @@ func _update_ground_information(delta: float):
var pos_old := _previous_ground_global
var pos_new := ground_node.to_global(_previous_ground_local)
ground_velocity = (pos_new - pos_old) / delta

# Update ground velocity information
_previous_ground_node = ground_node
_previous_ground_global = ground_collision.position
Expand All @@ -369,7 +369,7 @@ func _update_ground_information(delta: float):
func _apply_velocity_and_control(delta: float):
# Calculate local velocity
var local_velocity := velocity - ground_velocity

# Split the velocity into horizontal and vertical components
var horizontal_velocity := local_velocity * HORIZONTAL
var vertical_velocity := local_velocity * Vector3.UP
Expand All @@ -385,12 +385,12 @@ func _apply_velocity_and_control(delta: float):
control_velocity = (dir_forward * -ground_control_velocity.y + dir_right * ground_control_velocity.x) * ARVRServer.world_scale

# Apply control velocity to horizontal velocity based on traction
var current_traction := GroundPhysicsSettings.get_move_traction(ground_physics, default_physics)
var current_traction := XRToolsGroundPhysicsSettings.get_move_traction(ground_physics, default_physics)
var traction_factor: float = clamp(current_traction * delta, 0.0, 1.0)
horizontal_velocity = lerp(horizontal_velocity, control_velocity, traction_factor)

# Prevent the player from moving up steep slopes
var current_max_slope := GroundPhysicsSettings.get_move_max_slope(ground_physics, default_physics)
var current_max_slope := XRToolsGroundPhysicsSettings.get_move_max_slope(ground_physics, default_physics)
if ground_angle > current_max_slope:
# Get a vector in the down-hill direction
var down_direction := (ground_vector * HORIZONTAL).normalized()
Expand All @@ -399,7 +399,7 @@ func _apply_velocity_and_control(delta: float):
horizontal_velocity -= down_direction * vdot
else:
# User is not trying to move, so apply the ground drag
var current_drag := GroundPhysicsSettings.get_move_drag(ground_physics, default_physics)
var current_drag := XRToolsGroundPhysicsSettings.get_move_drag(ground_physics, default_physics)
var drag_factor: float = clamp(current_drag * delta, 0, 1)
horizontal_velocity = lerp(horizontal_velocity, control_velocity, drag_factor)

Expand All @@ -414,12 +414,12 @@ func _apply_velocity_and_control(delta: float):
# Detect bounciness
var collision := kinematic_node.get_slide_collision(0)
var collision_node := collision.collider
var collision_physics_node := collision_node.get_node_or_null("GroundPhysics") as GroundPhysics
var collision_physics = GroundPhysics.get_physics(collision_physics_node, default_physics)
var bounce_threshold := GroundPhysicsSettings.get_bounce_threshold(collision_physics, default_physics)
var bounciness := GroundPhysicsSettings.get_bounciness(collision_physics, default_physics)
var collision_physics_node := collision_node.get_node_or_null("GroundPhysics") as XRToolsGroundPhysics
var collision_physics = XRToolsGroundPhysics.get_physics(collision_physics_node, default_physics)
var bounce_threshold := XRToolsGroundPhysicsSettings.get_bounce_threshold(collision_physics, default_physics)
var bounciness := XRToolsGroundPhysicsSettings.get_bounciness(collision_physics, default_physics)
var magnitude := -collision.normal.dot(local_velocity)

# Detect if bounce should be performed
if bounciness > 0.0 and magnitude >= bounce_threshold:
local_velocity += 2 * collision.normal * magnitude * bounciness
Expand All @@ -432,16 +432,16 @@ func _apply_velocity_and_control(delta: float):

# Get a guaranteed-valid physics
func _guaranteed_physics():
# Ensure we have a guaranteed-valid GroundPhysicsSettings value
var valid_physics := physics as GroundPhysicsSettings
# Ensure we have a guaranteed-valid XRToolsGroundPhysicsSettings value
var valid_physics := physics as XRToolsGroundPhysicsSettings
if !valid_physics:
valid_physics = GroundPhysicsSettings.new()
valid_physics = XRToolsGroundPhysicsSettings.new()
valid_physics.resource_name = "default"

# Return the guaranteed-valid physics
return valid_physics

# This method verifies the PlayerBody has a valid configuration. Specifically it
# This method verifies the player body has a valid configuration. Specifically it
# checks the following:
# - ARVROrigin can be identified
# - ARVRCamera can be identified
Expand Down Expand Up @@ -476,19 +476,19 @@ func _get_configuration_warning():
return "Eyes too far forwards. Move eyes back or decrease camera near clipping plane"

# If specified, verify the ground physics is a valid type
if physics and !physics is GroundPhysicsSettings:
return "Physics resource must be a GroundPhysicsSetting"
if physics and !physics is XRToolsGroundPhysicsSettings:
return "Physics resource must be a GroundPhysicsSettings"

# Passed basic validation
return ""

## Find the Player Body from a player node and an optional path
static func get_player_body(node: Node, path: NodePath = NodePath("")) -> PlayerBody:
var player_body: PlayerBody
static func get_player_body(node: Node, path: NodePath = NodePath("")) -> XRToolsPlayerBody:
var player_body: XRToolsPlayerBody

# Try using the node path first
if path:
player_body = node.get_node(path) as PlayerBody
player_body = node.get_node(path) as XRToolsPlayerBody
if player_body:
return player_body

Expand All @@ -498,13 +498,13 @@ static func get_player_body(node: Node, path: NodePath = NodePath("")) -> Player
return null

# Attempt to get by the default name
player_body = arvr_origin.get_node_or_null("PlayerBody") as PlayerBody
player_body = arvr_origin.get_node_or_null("PlayerBody") as XRToolsPlayerBody
if player_body:
return player_body

# Search all children of the origin for the player body
for child in arvr_origin.get_children():
player_body = child as PlayerBody
player_body = child as XRToolsPlayerBody
if player_body:
return player_body

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=2]

[ext_resource path="res://addons/godot-xr-tools/assets/PlayerBody.gd" type="Script" id=1]
[ext_resource path="res://addons/godot-xr-tools/assets/player_body.gd" type="Script" id=1]

[sub_resource type="CapsuleShape" id=1]
radius = 0.4
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

importer="scene"
type="PackedScene"
path="res://.import/LeftHand.glb-7a289350d7a0389e0068af98c6813b91.scn"
path="res://.import/right_hand.glb-8f20889edf64365280173e0ad873b53e.scn"

[deps]

source_file="res://addons/godot-xr-tools/assets/LeftHand.glb"
dest_files=[ "res://.import/LeftHand.glb-7a289350d7a0389e0068af98c6813b91.scn" ]
source_file="res://addons/godot-xr-tools/assets/right_hand.glb"
dest_files=[ "res://.import/right_hand.glb-8f20889edf64365280173e0ad873b53e.scn" ]

[params]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://addons/godot-xr-tools/assets/HandBlendTree.tres" type="AnimationNodeBlendTree" id=1]
[ext_resource path="res://addons/godot-xr-tools/assets/Hand.gd" type="Script" id=2]
[ext_resource path="res://addons/godot-xr-tools/assets/LeftHand.glb" type="PackedScene" id=3]
[ext_resource path="res://addons/godot-xr-tools/assets/hand_blend_tree.tres" type="AnimationNodeBlendTree" id=1]
[ext_resource path="res://addons/godot-xr-tools/assets/hand.gd" type="Script" id=2]
[ext_resource path="res://addons/godot-xr-tools/assets/left_hand.glb" type="PackedScene" id=3]

[node name="RightHand" type="Spatial"]
script = ExtResource( 2 )
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://addons/godot-xr-tools/assets/RightHand.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/godot-xr-tools/assets/HandPhysicsBone.gd" type="Script" id=2]
[ext_resource path="res://addons/godot-xr-tools/assets/PhysicsHand.gd" type="Script" id=3]
[ext_resource path="res://addons/godot-xr-tools/assets/right_hand.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/godot-xr-tools/assets/hand_physics_bone.gd" type="Script" id=2]
[ext_resource path="res://addons/godot-xr-tools/assets/physics_hand.gd" type="Script" id=3]

[node name="RightPhysicsHand" instance=ExtResource( 1 )]
script = ExtResource( 3 )
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

importer="texture"
type="StreamTexture"
path="res://.import/XRToolsHand.svg-61051cd7afee04c5c901b73a96c00708.stex"
path="res://.import/body.svg-324e141d452c32f3136ca97c338025b4.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://addons/godot-xr-tools/editor/icons/XRToolsHand.svg"
dest_files=[ "res://.import/XRToolsHand.svg-61051cd7afee04c5c901b73a96c00708.stex" ]
source_file="res://addons/godot-xr-tools/editor/icons/body.svg"
dest_files=[ "res://.import/body.svg-324e141d452c32f3136ca97c338025b4.stex" ]

[params]

Expand Down
Loading

0 comments on commit b539680

Please sign in to comment.