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

@@ -74,7 +74,7 @@ func _process(delta: float) -> void:
fps_label.text = "%d FPS (%.2f mspf)" % [Engine.get_frames_per_second(), 1000.0 / Engine.get_frames_per_second()]
# Color FPS counter depending on framerate.
# The Gradient resource is stored as metadata within the FPSLabel node (accessible in the inspector).
fps_label.modulate = fps_label.get_meta("gradient").sample(remap(Engine.get_frames_per_second(), 0, 180, 0.0, 1.0))
fps_label.modulate = fps_label.get_meta(&"gradient").sample(remap(Engine.get_frames_per_second(), 0, 180, 0.0, 1.0))
@@ -144,9 +144,9 @@ func _on_fsr_sharpness_item_selected(index: int) -> void:
func _on_viewport_size_changed() -> void:
$ViewportResolution.text = "Viewport resolution: %d×%d" % [
get_viewport().size.x * get_viewport().scaling_3d_scale,
get_viewport().size.y * get_viewport().scaling_3d_scale,
]
get_viewport().size.x * get_viewport().scaling_3d_scale,
get_viewport().size.y * get_viewport().scaling_3d_scale,
]
func _on_v_sync_item_selected(index: int) -> void:

View File

@@ -36,7 +36,7 @@ func _unhandled_input(event: InputEvent) -> void:
if not result.is_empty():
var decal := preload("res://decal.tscn").instantiate()
add_child(decal)
decal.get_node("Decal").modulate = Color(1.0,0.0,0)
decal.get_node(^"Decal").modulate = Color(1.0,0.0,0)
decal.position = result["position"]
decal.transform.basis = camera.global_transform.basis

View File

@@ -1,7 +1,7 @@
# Global Illumination
This demo showcases Godot's global illumination systems:
LightmapGI, VoxelGI, SDFGI, ReflectionProbe and screen-space effects like SSAO and SSIL.
LightmapGI, VoxelGI, SDFGI, ReflectionProbe, and screen-space effects like SSAO and SSIL.
Use the mouse to look around, <kbd>W</kbd>/<kbd>A</kbd>/<kbd>S</kbd>/<kbd>D</kbd>
or arrow keys to move.
@@ -17,7 +17,7 @@ Check out this demo on the asset library: https://godotengine.org/asset-library/
A sphere and box are parented to the camera to showcase dynamic object lighting.
A ReflectionProbe is parented to the sphere to showcase real-time reflections.
When the ReflectionProbe is hidden, it is disabled. In this case,
VoxelGI, SDFGI or environment lighting will be used to provide fallback reflections.
VoxelGI, SDFGI, or environment lighting will be used to provide fallback reflections.
A Decal node is parented to the moving sphere and cube to provide simple shadows for them.
This is especially effective when using the LightmapGI (All) global illumination mode,

View File

@@ -19,7 +19,7 @@ func _input(event: InputEvent) -> void:
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
transform.basis = Basis.from_euler(rot)
if event.is_action_pressed("toggle_mouse_capture"):
if event.is_action_pressed(&"toggle_mouse_capture"):
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
@@ -31,7 +31,7 @@ func _process(delta: float) -> void:
Input.get_axis(&"move_left", &"move_right"),
0,
Input.get_axis(&"move_forward", &"move_back")
)
)
# Normalize motion to prevent diagonal movement from being
# `sqrt(2)` times faster than straight movement.

View File

@@ -74,7 +74,7 @@ func _ready() -> void:
# Remove unsupported VoxelGI/SDFGI references from the label.
reflection_probe_mode_texts[0] = "Disabled - Using environment reflections (Fast)"
set_gi_mode(GIMode.NONE)
# Darken lights's energy to compensate for sRGB blending (without affecting sky rendering).
# Darken lights' energy to compensate for sRGB blending (without affecting sky rendering).
# This only applies to lights with shadows enabled.
$GrateOmniLight.light_energy = 0.25
$GarageOmniLight.light_energy = 0.5
@@ -94,7 +94,7 @@ Escape or F10: Toggle mouse capture"""
func _input(event: InputEvent) -> void:
if event.is_action_pressed("cycle_gi_mode"):
if event.is_action_pressed(&"cycle_gi_mode"):
if is_compatibility:
# Only LightmapGI is supported in Compatibility.
# Note that the actual GI mode is the opposite of what's being set here, due to a bug
@@ -103,10 +103,10 @@ func _input(event: InputEvent) -> void:
else:
set_gi_mode(wrapi(gi_mode + 1, 0, GIMode.MAX))
if event.is_action_pressed("cycle_reflection_probe_mode"):
if event.is_action_pressed(&"cycle_reflection_probe_mode"):
set_reflection_probe_mode(wrapi(reflection_probe_mode + 1, 0, ReflectionProbeMode.MAX))
if event.is_action_pressed("cycle_ssil_mode"):
if event.is_action_pressed(&"cycle_ssil_mode"):
set_ssil_mode(wrapi(ssil_mode + 1, 0, SSILMode.MAX))

View File

@@ -35,7 +35,7 @@ func _ready() -> void:
mark_as_unsupported(%SSReflectionsOptionButton)
mark_as_unsupported(%SSILOptionButton)
mark_as_unsupported(%VolumetricFogOptionButton)
# Darken lights's energy to compensate for sRGB blending (without affecting sky rendering).
# Darken lights' energy to compensate for sRGB blending (without affecting sky rendering).
$Node3D/OmniLight3D.light_energy = 0.5
$Node3D/SpotLight3D.light_energy = 0.5
$Node3D/DirectionalLight3D.sky_mode = DirectionalLight3D.SKY_MODE_SKY_ONLY
@@ -59,7 +59,7 @@ func _process(delta: float) -> void:
fps_label.text = "%d FPS (%.2f mspf)" % [Engine.get_frames_per_second(), 1000.0 / Engine.get_frames_per_second()]
# Color FPS counter depending on framerate.
# The Gradient resource is stored as metadata within the FPSLabel node (accessible in the inspector).
fps_label.modulate = fps_label.get_meta("gradient").sample(remap(Engine.get_frames_per_second(), 0, 180, 0.0, 1.0))
fps_label.modulate = fps_label.get_meta(&"gradient").sample(remap(Engine.get_frames_per_second(), 0, 180, 0.0, 1.0))
func update_resolution_label() -> void:
@@ -174,7 +174,7 @@ func _on_fxaa_option_button_item_selected(index: int) -> void:
func _on_fullscreen_option_button_item_selected(index: int) -> void:
# To change between window, fullscreen and other window modes,
# To change between window, fullscreen, and other window modes,
# set the root mode to one of the options of Window.MODE_*.
# Other modes are maximized and minimized.
if index == 0: # Disabled (default)

View File

@@ -23,7 +23,7 @@ const CHAIN_MAX_ITER = 10
var temp = get_node(skeleton_path)
if temp != null:
# If it has the method "get_bone_global_pose" it is likely a Skeleton3D
if temp.has_method("get_bone_global_pose"):
if temp.has_method(&"get_bone_global_pose"):
skeleton = temp
bone_IDs = {}
@@ -109,7 +109,7 @@ func _ready():
if target == null:
# NOTE: You MUST have a node called Target as a child of this node!
# So we create one if one doesn't already exist.
if not has_node("Target"):
if not has_node(^"Target"):
target = Node3D.new()
add_child(target)
@@ -127,7 +127,7 @@ func _ready():
_make_editor_sphere_at_node(target, Color.MAGENTA)
if middle_joint_target == null:
if not has_node("MiddleJoint"):
if not has_node(^"MiddleJoint"):
middle_joint_target = Node3D.new()
add_child(middle_joint_target)
@@ -243,7 +243,7 @@ func solve_chain():
else:
dir = -target.global_transform.basis.z.normalized()
# Get the target position (accounting for the final bone and it's length)
# Get the target position (accounting for the final bone and its length)
var target_pos = target.global_transform.origin + (dir * bones_in_chain_lengths[bone_nodes.size()-1])
# If we are using middle joint target (and have more than 2 bones), move our middle joint towards it!

View File

@@ -6,7 +6,7 @@ extends Node3D
# Assign skeleton_path to whatever value is passed.
skeleton_path = value
# Because get_node doesn't work in the first call, we just want to assign instead.
# This is to get around a issue with NodePaths exposed to the editor.
# This is to get around an issue with NodePaths exposed to the editor.
if first_call:
return
_setup_skeleton_path()
@@ -158,9 +158,9 @@ func update_skeleton():
var additional_bone_id = skeleton_to_use.find_bone(additional_bone_name)
var additional_bone_pos = skeleton_to_use.get_bone_global_pose(additional_bone_id)
rest.origin = (
additional_bone_pos.origin
- additional_bone_pos.basis.z.normalized() * additional_bone_length
)
additional_bone_pos.origin
- additional_bone_pos.basis.z.normalized() * additional_bone_length
)
# Finally, apply the new rotation to the bone in the skeleton.
skeleton_to_use.set_bone_global_pose_override(bone, rest, interpolation, true)

View File

@@ -96,10 +96,10 @@ func process_input(delta):
if anim_done:
if current_anim != "Aiming":
anim_player.play("Aiming")
anim_player.play(&"Aiming")
current_anim = "Aiming"
else:
anim_player.play("Idle")
anim_player.play(&"Idle")
current_anim = "Idle"
anim_done = false

View File

@@ -8,8 +8,8 @@ extends Camera3D
func _process(_delta):
var mouse_to_world = (
project_local_ray_normal(get_viewport().get_mouse_position()) * MOVEMENT_SPEED
)
project_local_ray_normal(get_viewport().get_mouse_position()) * MOVEMENT_SPEED
)
if flip_axis:
mouse_to_world = -mouse_to_world

View File

@@ -54,7 +54,7 @@ func set_health(p_health: int) -> void:
$HealthBarBackground.outline_modulate = Color(0.15, 0.2, 0.15)
$HealthBarBackground.modulate = Color(0.15, 0.2, 0.15)
# Construct an health bar with `|` symbols brought very close to each other using
# Construct a health bar with `|` symbols brought very close to each other using
# a custom FontVariation on the HealthBarForeground and HealthBarBackground nodes.
var bar_text := ""
var bar_text_bg := ""

View File

@@ -74,7 +74,7 @@ func _on_enable_sun_toggled(button_pressed: bool) -> void:
func _on_animate_lights_toggled(button_pressed: bool) -> void:
for animatable_node in get_tree().get_nodes_in_group("animatable"):
for animatable_node in get_tree().get_nodes_in_group(&"animatable"):
animatable_node.set_process(button_pressed)

View File

@@ -40,5 +40,5 @@ func set_target_position(target_position: Vector3) -> void:
start_position,
target_position,
optimize
)
)
_nav_path_line.draw_path(path)

View File

@@ -19,7 +19,7 @@ func _unhandled_input(event: InputEvent) -> void:
get_world_3d().navigation_map,
camera_ray_start,
camera_ray_end
)
)
_robot.set_target_position(closest_point_on_navmesh)
elif event is InputEventMouseMotion:

View File

@@ -40,12 +40,12 @@ static func create_region_chunks(chunks_root_node: Node, p_source_geometry: Navi
# Rasterize bounding box into chunk grid to know range of required chunks.
var start_chunk: Vector3 = floor(
input_geometry_bounds.position / p_chunk_size
)
input_geometry_bounds.position / p_chunk_size
)
var end_chunk: Vector3 = floor(
(input_geometry_bounds.position + input_geometry_bounds.size)
/ p_chunk_size
)
(input_geometry_bounds.position + input_geometry_bounds.size)
/ p_chunk_size
)
# NavigationMesh.border_size is limited to the xz-axis.
# So we can only bake one chunk for the y-axis and also
@@ -61,9 +61,9 @@ static func create_region_chunks(chunks_root_node: Node, p_source_geometry: Navi
var chunk_id: Vector3i = Vector3i(chunk_x, chunk_y, chunk_z)
var chunk_bounding_box: AABB = AABB(
Vector3(chunk_x, bounds_min_height, chunk_z) * p_chunk_size,
Vector3(p_chunk_size, bounds_max_height, p_chunk_size),
)
Vector3(chunk_x, bounds_min_height, chunk_z) * p_chunk_size,
Vector3(p_chunk_size, bounds_max_height, p_chunk_size),
)
# We grow the chunk bounding box to include geometry
# from all the neighbor chunks so edges can align.
# The border size is the same value as our grow amount so
@@ -109,10 +109,10 @@ func _process(_delta: float) -> void:
var camera_ray_start: Vector3 = camera.project_ray_origin(mouse_cursor_position)
var camera_ray_end: Vector3 = camera_ray_start + camera.project_ray_normal(mouse_cursor_position) * camera_ray_length
var closest_point_on_navmesh: Vector3 = NavigationServer3D.map_get_closest_point_to_segment(
map,
camera_ray_start,
camera_ray_end
)
map,
camera_ray_start,
camera_ray_end
)
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
path_start_position = closest_point_on_navmesh

View File

@@ -26,7 +26,7 @@ will vary depending on your CPU and GPU model.
> **Warning**
>
> If you are using a engine build that is not fully optimized, you may notice
> If you are using an engine build that is not fully optimized, you may notice
> that enabling occlusion culling decreases performance. This is because
> occlusion culling is a demanding process on the CPU, which needs all the
> build-time optimization it can get.

View File

@@ -19,7 +19,7 @@ func _input(event: InputEvent) -> void:
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
transform.basis = Basis.from_euler(rot)
if event.is_action_pressed("toggle_mouse_capture"):
if event.is_action_pressed(&"toggle_mouse_capture"):
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
@@ -31,7 +31,7 @@ func _process(delta: float) -> void:
Input.get_axis(&"move_left", &"move_right"),
0,
Input.get_axis(&"move_forward", &"move_back")
)
)
# Normalize motion to prevent diagonal movement from being
# `sqrt(2)` times faster than straight movement.

View File

@@ -3,16 +3,16 @@ extends Node3D
var open := false
func _input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_doors"):
if event.is_action_pressed(&"toggle_doors"):
if open:
# Close the door.
# The occluder will be re-enabled when the animation ends
# using `_on_animation_player_animation_finished()`.
$AnimationPlayer.play_backwards("open")
$AnimationPlayer.play_backwards(&"open")
open = false
else:
# Open the door.
$AnimationPlayer.play("open")
$AnimationPlayer.play(&"open")
open = true
# Disable the occluder as soon as the door starts opening.
# The occluder is not part of the pivot to prevent it from having its

View File

@@ -1,16 +1,16 @@
extends Node3D
func _input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_occlusion_culling"):
if event.is_action_pressed(&"toggle_occlusion_culling"):
get_viewport().use_occlusion_culling = not get_viewport().use_occlusion_culling
update_labels()
if event.is_action_pressed("toggle_mesh_lod"):
if event.is_action_pressed(&"toggle_mesh_lod"):
get_viewport().mesh_lod_threshold = 1.0 if is_zero_approx(get_viewport().mesh_lod_threshold) else 0.0
update_labels()
if event.is_action_pressed("cycle_draw_mode"):
if event.is_action_pressed(&"cycle_draw_mode"):
get_viewport().debug_draw = wrapi(get_viewport().debug_draw + 1, 0, 5) as Viewport.DebugDraw
update_labels()
if event.is_action_pressed("toggle_vsync"):
if event.is_action_pressed(&"toggle_vsync"):
if DisplayServer.window_get_vsync_mode() == DisplayServer.VSYNC_DISABLED:
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)
else:

View File

@@ -1,7 +1,7 @@
# 3D Particles
This project showcases various 3D particle features supported by Godot, for both GPU-based and CPU-based particles.
This includes particle collision, attractors, trails and subemitters.
This includes particle collision, attractors, trails, and subemitters.
Language: GDScript

View File

@@ -17,11 +17,11 @@ func get_color_from_temperature(p_temperature: float) -> Color:
var u := (
(0.860117757 + 1.54118254e-4 * p_temperature + 1.28641212e-7 * t2) /
(1.0 + 8.42420235e-4 * p_temperature + 7.08145163e-7 * t2)
)
)
var v := (
(0.317398726 + 4.22806245e-5 * p_temperature + 4.20481691e-8 * t2) /
(1.0 - 2.89741816e-5 * p_temperature + 1.61456053e-7 * t2)
)
)
# Convert to xyY space.
var d := 1.0 / (2.0 * u - 8.0 * v + 4.0)
@@ -37,7 +37,7 @@ func get_color_from_temperature(p_temperature: float) -> Color:
3.2404542 * xyz.x - 1.5371385 * xyz.y - 0.4985314 * xyz.z,
-0.9692660 * xyz.x + 1.8760108 * xyz.y + 0.0415560 * xyz.z,
0.0556434 * xyz.x - 0.2040259 * xyz.y + 1.0572252 * xyz.z
)
)
linear /= maxf(1e-5, linear[linear.max_axis_index()])
# Normalize, clamp, and convert to sRGB.
return Color(linear.x, linear.y, linear.z).clamp().linear_to_srgb()
@@ -67,7 +67,7 @@ func _on_lightbulb1_intensity_value_changed(value: float) -> void:
func _on_lightbulb1_temperature_value_changed(value: float) -> void:
lightbulb_1.light_temperature = value
$Light/Lightbulb1Temperature/Value.text = "%d K" % value
$Light/Lightbulb1Temperature/Value.add_theme_color_override("font_color", get_color_from_temperature(value))
$Light/Lightbulb1Temperature/Value.add_theme_color_override(&"font_color", get_color_from_temperature(value))
func _on_lightbulb2_intensity_value_changed(value: float) -> void:
@@ -78,7 +78,7 @@ func _on_lightbulb2_intensity_value_changed(value: float) -> void:
func _on_lightbulb2_temperature_value_changed(value: float) -> void:
lightbulb_2.light_temperature = value
$Light/Lightbulb2Temperature/Value.text = "%d K" % value
$Light/Lightbulb2Temperature/Value.add_theme_color_override("font_color", get_color_from_temperature(value))
$Light/Lightbulb2Temperature/Value.add_theme_color_override(&"font_color", get_color_from_temperature(value))
func _on_focus_distance_value_changed(value: float) -> void:

View File

@@ -114,7 +114,7 @@ func cycle_camera_type() -> void:
$Rig/Camera_TPS.make_current()
CameraType.CAM_TPS:
_cam_type = CameraType.CAM_FIXED
get_node("../Camera_Fixed").make_current()
get_node(^"../Camera_Fixed").make_current()
# Hide body in FPS view (but keep shadow casting to improve spatial awareness).
if _cam_type == CameraType.CAM_FPS:

View File

@@ -160,7 +160,7 @@ func start_test() -> void:
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_PHYSICS
else:
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_IDLE
animation_player.play("Move")
animation_player.play(&"Move")
$LabelBodyType.text = "Body Type: " + _body_type[_current_body_index] + " \nCollision Shape: " + _current_shape

View File

@@ -152,7 +152,7 @@ func _remove_objects() -> void:
Log.print_log("* Removing objects...")
var timer := Time.get_ticks_usec()
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
# Remove objects in reversed order to avoid the overhead of changing child index in parent.
var object_count := _objects.size()
for object_index in object_count:
root_node.remove_child(_objects[object_count - object_index - 1])

View File

@@ -190,7 +190,7 @@ func _despawn_objects() -> void:
for spawn in spawns:
var spawn_parent := get_node(spawn)
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
# Remove objects in reversed order to avoid the overhead of changing child index in parent.
var object_count := spawn_parent.get_child_count()
for object_index in object_count:
var node := spawn_parent.get_child(object_count - object_index - 1)

View File

@@ -52,19 +52,19 @@ func _physics_process(delta: float) -> void:
target + Basis(Vector3.UP, deg_to_rad(autoturn_ray_aperture)) * (difference),
0xffffffff,
collision_exception
))
))
var col := ds.intersect_ray(PhysicsRayQueryParameters3D.create(
target,
target + difference,
0xffffffff,
collision_exception
))
))
var col_right := ds.intersect_ray(PhysicsRayQueryParameters3D.create(
target,
target + Basis(Vector3.UP, deg_to_rad(-autoturn_ray_aperture)) * (difference),
0xffffffff,
collision_exception
))
))
if not col.is_empty():
# If main ray was occluded, get camera closer, this is the worst case scenario.

View File

@@ -36,7 +36,7 @@ var coins := 0
func _physics_process(delta: float) -> void:
if Input.is_action_pressed("reset_position") or global_position.y < -12:
if Input.is_action_pressed(&"reset_position") or global_position.y < -12:
# Player hit the reset button or fell off the map.
position = initial_position
velocity = Vector3.ZERO
@@ -48,10 +48,10 @@ func _physics_process(delta: float) -> void:
# Update coin count and its "parallax" copies.
# This gives text a pseudo-3D appearance while still using Label3D instead of the more limited TextMesh.
%CoinCount.text = str(coins)
%CoinCount.get_node("Parallax").text = str(coins)
%CoinCount.get_node("Parallax2").text = str(coins)
%CoinCount.get_node("Parallax3").text = str(coins)
%CoinCount.get_node("Parallax4").text = str(coins)
%CoinCount.get_node(^"Parallax").text = str(coins)
%CoinCount.get_node(^"Parallax2").text = str(coins)
%CoinCount.get_node(^"Parallax3").text = str(coins)
%CoinCount.get_node(^"Parallax4").text = str(coins)
velocity += gravity * delta
@@ -79,12 +79,12 @@ func _physics_process(delta: float) -> void:
if movement_direction.length() > 0.1 and not sharp_turn:
if horizontal_speed > 0.001:
horizontal_direction = adjust_facing(
horizontal_direction,
movement_direction,
delta,
1.0 / horizontal_speed * TURN_SPEED,
Vector3.UP
)
horizontal_direction,
movement_direction,
delta,
1.0 / horizontal_speed * TURN_SPEED,
Vector3.UP
)
else:
horizontal_direction = movement_direction
@@ -103,17 +103,17 @@ func _physics_process(delta: float) -> void:
if horizontal_speed > 0:
facing_mesh = adjust_facing(
facing_mesh,
movement_direction,
delta,
1.0 / horizontal_speed * TURN_SPEED,
Vector3.UP
)
facing_mesh,
movement_direction,
delta,
1.0 / horizontal_speed * TURN_SPEED,
Vector3.UP
)
var m3 := Basis(
-facing_mesh,
Vector3.UP,
-facing_mesh.cross(Vector3.UP).normalized()
).scaled(CHAR_SCALE)
-facing_mesh,
Vector3.UP,
-facing_mesh.cross(Vector3.UP).normalized()
).scaled(CHAR_SCALE)
$Player/Skeleton.set_transform(Transform3D(m3, mesh_xform.origin))
@@ -135,7 +135,7 @@ func _physics_process(delta: float) -> void:
horizontal_speed = 0
horizontal_velocity = horizontal_direction * horizontal_speed
if Input.is_action_just_released("jump") and velocity.y > 0.0:
if Input.is_action_just_released(&"jump") and velocity.y > 0.0:
# Reduce jump height if releasing the jump key before reaching the apex.
vertical_velocity *= 0.7
@@ -160,8 +160,8 @@ func _physics_process(delta: float) -> void:
bullet.set_transform($Player/Skeleton/Bullet.get_global_transform().orthonormalized())
get_parent().add_child(bullet)
bullet.set_linear_velocity(
$Player/Skeleton/Bullet.get_global_transform().basis[2].normalized() * BULLET_SPEED
)
$Player/Skeleton/Bullet.get_global_transform().basis[2].normalized() * BULLET_SPEED
)
bullet.add_collision_exception_with(self)
$SoundShoot.play()

View File

@@ -14,7 +14,7 @@ resource dropdown.
> **Warning**
>
> Sky shaders are rendered every frame if they use the `TIME` variable or are
> otherwise updated every frame (e.g. if an uniform is updated in `_process()`
> otherwise updated every frame (e.g. if a uniform is updated in `_process()`
> or with an AnimationPlayer). This has a significant performance impact for
> complex sky shaders. The performance impact can be reduced by adjusting the
> radiance map properties in Environment, but it will remain significant.

View File

@@ -13,21 +13,21 @@ func _ready() -> void:
func _process(delta: float) -> void:
# Make the slider follow the day/night cycle.
$Panel/MarginContainer/VBoxContainer/TimeOfDay/HSlider.value = $AnimationPlayer.current_animation_position
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter("cloud_time_offset", $AnimationPlayer.current_animation_position)
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter(&"cloud_time_offset", $AnimationPlayer.current_animation_position)
$YawCamera/Camera3D.fov = lerpf($YawCamera/Camera3D.fov, desired_fov, 1.0 - exp(-delta * 10.0))
func _input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_gui"):
if event.is_action_pressed(&"toggle_gui"):
$Panel.visible = not $Panel.visible
$Help.visible = not $Help.visible
if event.is_action_pressed("toggle_spheres"):
if event.is_action_pressed(&"toggle_spheres"):
$Spheres.visible = not $Spheres.visible
if event.is_action_pressed("toggle_mouse_capture"):
if event.is_action_pressed(&"toggle_mouse_capture"):
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
else:
@@ -40,9 +40,9 @@ func _input(event: InputEvent) -> void:
$YawCamera.rotation.y -= relative_motion.x * MOUSE_SENSITIVITY
# Mouse wheel currently doesn't work in input actions. Hardcode mouse wheel as a workaround.
if event.is_action_pressed("increase_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_DOWN):
if event.is_action_pressed(&"increase_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_DOWN):
desired_fov = clampf(desired_fov + 5.0, 20.0, 120.0)
if event.is_action_pressed("decrease_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_UP):
if event.is_action_pressed(&"decrease_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_UP):
desired_fov = clampf(desired_fov - 5.0, 20.0, 120.0)
@@ -81,12 +81,12 @@ func update_speed_label() -> void:
func _on_cloud_coverage_value_changed(value: float) -> void:
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter("cloud_coverage", value)
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter(&"cloud_coverage", value)
$Panel/MarginContainer/VBoxContainer/Clouds/CoverageValue.text = "%d%%" % (value * 100)
func _on_cloud_density_value_changed(value: float) -> void:
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter("cloud_density", value)
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter(&"cloud_density", value)
$Panel/MarginContainer/VBoxContainer/Clouds/DensityValue.text = "%d%%" % (value * 100)

View File

@@ -9,8 +9,8 @@ var velocity: Vector3 = Vector3.ZERO
func _process(delta: float) -> void:
var input_vector: Vector2 = Vector2.ZERO
input_vector.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
input_vector.y = Input.get_action_strength("move_back") - Input.get_action_strength("move_forward")
input_vector.x = Input.get_action_strength(&"move_right") - Input.get_action_strength(&"move_left")
input_vector.y = Input.get_action_strength(&"move_back") - Input.get_action_strength(&"move_forward")
if input_vector.length() > 0:
input_vector = input_vector.normalized()
@@ -20,8 +20,8 @@ func _process(delta: float) -> void:
# Play corresponding animation.
if abs(input_vector.x) > abs(input_vector.y):
sprite.play("walk_right" if input_vector.x > 0 else "walk_left")
sprite.play(&"walk_right" if input_vector.x > 0 else &"walk_left")
else:
sprite.play("walk_down" if input_vector.y > 0 else "walk_up")
sprite.play(&"walk_down" if input_vector.y > 0 else &"walk_up")
else:
sprite.stop()

View File

@@ -20,7 +20,7 @@ func _ready():
func _unhandled_input(event):
if event.is_action_pressed("ui_accept") and $UserInterface/Retry.visible:
if event.is_action_pressed(&"ui_accept") and $UserInterface/Retry.visible:
get_tree().reload_current_scene()
@@ -29,7 +29,7 @@ func _on_mob_timer_timeout():
var mob = mob_scene.instantiate()
# Choose a random location on the SpawnPath.
var mob_spawn_location = get_node("SpawnPath/SpawnLocation")
var mob_spawn_location = get_node(^"SpawnPath/SpawnLocation")
mob_spawn_location.progress_ratio = randf()
# Communicate the spawn location and the player's location to the mob.

View File

@@ -14,13 +14,13 @@ signal hit
func _physics_process(delta):
var direction = Vector3.ZERO
if Input.is_action_pressed("move_right"):
if Input.is_action_pressed(&"move_right"):
direction.x += 1
if Input.is_action_pressed("move_left"):
if Input.is_action_pressed(&"move_left"):
direction.x -= 1
if Input.is_action_pressed("move_back"):
if Input.is_action_pressed(&"move_back"):
direction.z += 1
if Input.is_action_pressed("move_forward"):
if Input.is_action_pressed(&"move_forward"):
direction.z -= 1
if direction != Vector3.ZERO:
@@ -36,7 +36,7 @@ func _physics_process(delta):
velocity.z = direction.z * speed
# Jumping.
if is_on_floor() and Input.is_action_just_pressed("jump"):
if is_on_floor() and Input.is_action_just_pressed(&"jump"):
velocity.y += jump_impulse
# We apply gravity every frame so the character always collides with the ground when moving.
@@ -52,7 +52,7 @@ func _physics_process(delta):
# If there are no "slides" this frame, the loop below won't run.
for index in range(get_slide_collision_count()):
var collision = get_slide_collision(index)
if collision.get_collider().is_in_group("mob"):
if collision.get_collider().is_in_group(&"mob"):
var mob = collision.get_collider()
if Vector3.UP.dot(collision.get_normal()) > 0.1:
mob.squash()

View File

@@ -7,15 +7,15 @@ class_name GradientBars extends Node3D
func set_num_steps(steps: int) -> void:
var shader_mat: ShaderMaterial = hdr_bar.material_override as ShaderMaterial
if shader_mat:
shader_mat.set_shader_parameter("steps", min(1, steps))
shader_mat.set_shader_parameter(&"steps", min(1, steps))
func set_color(color: Color) -> void:
var shader_mat: ShaderMaterial = sdr_bar.material_override as ShaderMaterial
if shader_mat:
shader_mat.set_shader_parameter("my_color", color)
shader_mat.set_shader_parameter(&"my_color", color)
shader_mat = hdr_bar.material_override as ShaderMaterial
if shader_mat:
shader_mat.set_shader_parameter("my_color", color)
shader_mat.set_shader_parameter(&"my_color", color)
label.text = "#" + color.to_html(false)

View File

@@ -22,10 +22,10 @@ func _on_steps_value_changed(value):
for bar_path in bars:
var bar = get_node(bar_path)
var shader_mat = bar.hdr_bar.material_override as ShaderMaterial
shader_mat.set_shader_parameter("steps", value)
shader_mat.set_shader_parameter(&"steps", value)
if hues:
var shader_mat = hues.material_override as ShaderMaterial
shader_mat.set_shader_parameter("steps", value)
shader_mat.set_shader_parameter(&"steps", value)
func _on_color_picker_button_color_changed(color):
@@ -37,10 +37,10 @@ func _on_exponential_toggled(button_pressed):
for bar_path in bars:
var bar = get_node(bar_path)
var shader_mat = bar.hdr_bar.material_override as ShaderMaterial
shader_mat.set_shader_parameter("exponential_view", button_pressed)
shader_mat.set_shader_parameter(&"exponential_view", button_pressed)
shader_mat = bar.sdr_bar.material_override as ShaderMaterial
shader_mat.set_shader_parameter("exponential_view", button_pressed)
shader_mat.set_shader_parameter(&"exponential_view", button_pressed)
if hues:
var shader_mat = hues.material_override as ShaderMaterial
shader_mat.set_shader_parameter("exponential_view", button_pressed)
shader_mat.set_shader_parameter(&"exponential_view", button_pressed)

View File

@@ -13,7 +13,7 @@ func create_neutral_lut(name: String, size: int, vertical: bool):
(size * size) if vertical else size,
false,
Image.FORMAT_RGB8
)
)
for z in size:
var x_offset := int(z * size) if not vertical else 0
@@ -26,7 +26,7 @@ func create_neutral_lut(name: String, size: int, vertical: bool):
roundi(((x + 0.2) / float(size - 1)) * 255),
roundi(((y + 0.2) / float(size - 1)) * 255),
roundi(((z + 0.2) / float(size - 1)) * 255)
))
))
image.save_png("user://" + name + ".png")

View File

@@ -31,7 +31,7 @@ func _process(_delta: float) -> void:
text = "Speed: " + ("%.0f" % speed) + " mph"
# Change speedometer color depending on speed in m/s (regardless of unit).
add_theme_color_override("font_color", gradient.sample(remap(car_body.linear_velocity.length(), 0.0, 30.0, 0.0, 1.0)))
add_theme_color_override(&"font_color", gradient.sample(remap(car_body.linear_velocity.length(), 0.0, 30.0, 0.0, 1.0)))
func _on_spedometer_pressed() -> void:

View File

@@ -20,7 +20,7 @@ func _input(input_event: InputEvent) -> void:
rot.x = clampf(rot.x - input_event.relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
transform.basis = Basis.from_euler(rot)
if input_event.is_action_pressed("toggle_mouse_capture"):
if input_event.is_action_pressed(&"toggle_mouse_capture"):
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
@@ -32,7 +32,7 @@ func _process(delta: float) -> void:
Input.get_axis(&"move_left", &"move_right"),
0,
Input.get_axis(&"move_forward", &"move_back")
)
)
# Normalize motion to prevent diagonal movement from being
# `sqrt(2)` times faster than straight movement.

View File

@@ -18,10 +18,10 @@ func _ready() -> void:
func _process(delta: float) -> void:
var motion := Vector3(
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
Input.get_action_strength(&"move_right") - Input.get_action_strength(&"move_left"),
0,
Input.get_action_strength("move_back") - Input.get_action_strength("move_forward")
)
Input.get_action_strength(&"move_back") - Input.get_action_strength(&"move_forward")
)
# Normalize motion to prevent diagonal movement from being
# `sqrt(2)` times faster than straight movement.
@@ -41,33 +41,33 @@ func _input(event: InputEvent) -> void:
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
transform.basis = Basis.from_euler(rot)
if event.is_action_pressed("toggle_mouse_capture"):
if event.is_action_pressed(&"toggle_mouse_capture"):
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
if event.is_action_pressed("toggle_temporal_reprojection"):
if event.is_action_pressed(&"toggle_temporal_reprojection"):
get_world_3d().environment.volumetric_fog_temporal_reprojection_enabled = not get_world_3d().environment.volumetric_fog_temporal_reprojection_enabled
update_label()
elif event.is_action_pressed("increase_temporal_reprojection"):
elif event.is_action_pressed(&"increase_temporal_reprojection"):
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount = clamp(get_world_3d().environment.volumetric_fog_temporal_reprojection_amount + 0.01, 0.5, 0.99)
update_label()
elif event.is_action_pressed("decrease_temporal_reprojection"):
elif event.is_action_pressed(&"decrease_temporal_reprojection"):
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount = clamp(get_world_3d().environment.volumetric_fog_temporal_reprojection_amount - 0.01, 0.5, 0.99)
update_label()
elif event.is_action_pressed("increase_fog_density"):
elif event.is_action_pressed(&"increase_fog_density"):
get_world_3d().environment.volumetric_fog_density = clamp(get_world_3d().environment.volumetric_fog_density + 0.01, 0.0, 1.0)
update_label()
elif event.is_action_pressed("decrease_fog_density"):
elif event.is_action_pressed(&"decrease_fog_density"):
get_world_3d().environment.volumetric_fog_density = clamp(get_world_3d().environment.volumetric_fog_density - 0.01, 0.0, 1.0)
update_label()
elif event.is_action_pressed("increase_volumetric_fog_quality"):
elif event.is_action_pressed(&"increase_volumetric_fog_quality"):
volumetric_fog_volume_size = clamp(volumetric_fog_volume_size + 16, 16, 384)
volumetric_fog_volume_depth = clamp(volumetric_fog_volume_depth + 16, 16, 384)
RenderingServer.environment_set_volumetric_fog_volume_size(volumetric_fog_volume_size, volumetric_fog_volume_depth)
update_label()
elif event.is_action_pressed("decrease_volumetric_fog_quality"):
elif event.is_action_pressed(&"decrease_volumetric_fog_quality"):
volumetric_fog_volume_size = clamp(volumetric_fog_volume_size - 16, 16, 384)
volumetric_fog_volume_depth = clamp(volumetric_fog_volume_depth - 16, 16, 384)
RenderingServer.environment_set_volumetric_fog_volume_size(volumetric_fog_volume_size, volumetric_fog_volume_depth)
@@ -77,16 +77,16 @@ func _input(event: InputEvent) -> void:
func update_label() -> void:
if get_world_3d().environment.volumetric_fog_temporal_reprojection_enabled:
label.text = "Fog density: %.2f\nTemporal reprojection: Enabled\nTemporal reprojection strength: %.2f\nVolumetric fog quality: %d×%d×%d" % [
get_world_3d().environment.volumetric_fog_density,
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount,
volumetric_fog_volume_size,
volumetric_fog_volume_size,
volumetric_fog_volume_depth,
]
get_world_3d().environment.volumetric_fog_density,
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount,
volumetric_fog_volume_size,
volumetric_fog_volume_size,
volumetric_fog_volume_depth,
]
else:
label.text = "Fog density: %.2f\nTemporal reprojection: Disabled\nVolumetric fog quality: %d×%d×%d" % [
get_world_3d().environment.volumetric_fog_density,
volumetric_fog_volume_size,
volumetric_fog_volume_size,
volumetric_fog_volume_depth,
]
get_world_3d().environment.volumetric_fog_density,
volumetric_fog_volume_size,
volumetric_fog_volume_size,
volumetric_fog_volume_depth,
]

View File

@@ -62,7 +62,7 @@ func _process(_delta: float) -> void:
aim_preview.global_position = Vector3(ray_current_block_position) + Vector3(0.5, 0.5, 0.5)
var breaking := Input.is_action_just_pressed(&"break")
var placing := Input.is_action_just_pressed(&"place")
# Either both buttons were pressed or neither are, so stop.
# Either both buttons were pressed or neither is, so stop.
if breaking == placing:
return
@@ -87,7 +87,7 @@ func _physics_process(delta: float) -> void:
head.transform.origin.y = lerpf(head.transform.origin.y, EYE_HEIGHT_CROUCH if crouching else EYE_HEIGHT_STAND, 1.0 - exp(-delta * 16.0))
# Keyboard movement.
var movement_vec2: Vector2 = Input.get_vector("move_left", "move_right", "move_forward", "move_back")
var movement_vec2: Vector2 = Input.get_vector(&"move_left", &"move_right", &"move_forward", &"move_back")
var movement: Vector3 = transform.basis * (Vector3(movement_vec2.x, 0, movement_vec2.y))
if is_on_floor():

View File

@@ -226,26 +226,26 @@ static func calculate_block_uvs(block_id: int) -> Array[Vector2]:
var col := block_id % TEXTURE_SHEET_WIDTH
return [
# Godot 4 has a weird bug where there are seams at the edge
# of the textures. Adding a margin of 0.01 "fixes" it.
TEXTURE_TILE_SIZE * Vector2(col + 0.01, row + 0.01),
TEXTURE_TILE_SIZE * Vector2(col + 0.01, row + 0.99),
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.01),
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.99),
]
# Godot 4 has a weird bug where there are seams at the edge
# of the textures. Adding a margin of 0.01 "fixes" it.
TEXTURE_TILE_SIZE * Vector2(col + 0.01, row + 0.01),
TEXTURE_TILE_SIZE * Vector2(col + 0.01, row + 0.99),
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.01),
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.99),
]
static func calculate_block_verts(block_position: Vector3) -> Array[Vector3]:
return [
Vector3(block_position.x, block_position.y, block_position.z),
Vector3(block_position.x, block_position.y, block_position.z + 1),
Vector3(block_position.x, block_position.y + 1, block_position.z),
Vector3(block_position.x, block_position.y + 1, block_position.z + 1),
Vector3(block_position.x + 1, block_position.y, block_position.z),
Vector3(block_position.x + 1, block_position.y, block_position.z + 1),
Vector3(block_position.x + 1, block_position.y + 1, block_position.z),
Vector3(block_position.x + 1, block_position.y + 1, block_position.z + 1),
]
Vector3(block_position.x, block_position.y, block_position.z),
Vector3(block_position.x, block_position.y, block_position.z + 1),
Vector3(block_position.x, block_position.y + 1, block_position.z),
Vector3(block_position.x, block_position.y + 1, block_position.z + 1),
Vector3(block_position.x + 1, block_position.y, block_position.z),
Vector3(block_position.x + 1, block_position.y, block_position.z + 1),
Vector3(block_position.x + 1, block_position.y + 1, block_position.z),
Vector3(block_position.x + 1, block_position.y + 1, block_position.z + 1),
]
static func is_block_transparent(block_id: int) -> int:

View File

@@ -31,7 +31,7 @@ func _process(delta: float) -> void:
Input.get_axis(&"move_left", &"move_right"),
0,
Input.get_axis(&"move_forward", &"move_back")
)
)
# Normalize motion to prevent diagonal movement from being
# `sqrt(2)` times faster than straight movement.

View File

@@ -47,7 +47,7 @@ func _process(_delta: float) -> void:
var viewport_base_size: Vector2i = (
get_viewport().content_scale_size if get_viewport().content_scale_size > Vector2i(0, 0)
else get_viewport().size
)
)
if not sticky:
# For non-sticky waypoints, we don't need to clamp and calculate
@@ -80,7 +80,7 @@ func _process(_delta: float) -> void:
position = Vector2(
clamp(unprojected_position.x, MARGIN, viewport_base_size.x - MARGIN),
clamp(unprojected_position.y, MARGIN, viewport_base_size.y - MARGIN)
)
)
label.visible = true
rotation = 0