style: apply gdformat formatting across the entire project

Auto-format all GDScript files using gdformat from gdtoolkit.
This is a baseline formatting pass to ensure consistent style:

- Normalizes indentation and spacing
- Wraps long lines to 100 characters
- Removes trailing whitespace
- Standardizes blank lines between functions

68 files reformatted, 8 files left unchanged (3rd-party addon files
with parse errors excluded).
This commit is contained in:
2026-07-05 23:06:23 +02:00
parent 28a2e42c41
commit 4463e524aa
69 changed files with 2253 additions and 1647 deletions
+17 -11
View File
@@ -1,6 +1,6 @@
# Copyright © 2023-2026 Cory Petkovsek, Roope Palmroos, and Contributors.
# Import From SimpleGrassTextured
#
#
# This script demonstrates how to import transforms from SimpleGrassTextured. To use it:
#
# 1. Setup the mesh asset you wish to use in the asset dock.
@@ -9,14 +9,14 @@
# 1. At the very top, assign your SimpleGrassTextured node.
# 1. Input the desired mesh asset ID.
# 1. Click import. The output window and console will report when finished.
# 1. Clear the script from your Terrain3D node, and save your scene.
# 1. Clear the script from your Terrain3D node, and save your scene.
#
# The instance transforms are now stored in your region files.
#
# Use clear_instances to erase all instances that match the assign_mesh_id.
#
# The add_transforms function (called by add_multimesh) applies the height_offset specified in the
# Terrain3DMeshAsset.
# The add_transforms function (called by add_multimesh) applies the height_offset specified in the
# Terrain3DMeshAsset.
# Once the transforms are imported, you can reassign any mesh you like into this mesh slot.
@tool
@@ -24,8 +24,10 @@ extends Terrain3D
@export var simple_grass_textured: MultiMeshInstance3D
@export var assign_mesh_id: int
@export var import: bool = false : set = import_sgt
@export var clear_instances: bool = false : set = clear_multimeshes
@export var import: bool = false:
set = import_sgt
@export var clear_instances: bool = false:
set = clear_multimeshes
func clear_multimeshes(value: bool) -> void:
@@ -34,9 +36,13 @@ func clear_multimeshes(value: bool) -> void:
func import_sgt(value: bool) -> void:
var sgt_mm: MultiMesh = simple_grass_textured.multimesh
var global_xform: Transform3D = simple_grass_textured.global_transform
print("Starting to import %d instances from SimpleGrassTextured using mesh id %d" % [ sgt_mm.instance_count, assign_mesh_id])
var global_xform: Transform3D = simple_grass_textured.global_transform
print(
(
"Starting to import %d instances from SimpleGrassTextured using mesh id %d"
% [sgt_mm.instance_count, assign_mesh_id]
)
)
var time: int = Time.get_ticks_msec()
get_instancer().add_multimesh(assign_mesh_id, sgt_mm, simple_grass_textured.global_transform)
print("Import complete in %.2f seconds" % [ float(Time.get_ticks_msec() - time)/1000. ])
get_instancer().add_multimesh(assign_mesh_id, sgt_mm, simple_grass_textured.global_transform)
print("Import complete in %.2f seconds" % [float(Time.get_ticks_msec() - time) / 1000.])
+96 -96
View File
@@ -1,6 +1,6 @@
# Copyright © 2023-2026 Cory Petkovsek, Roope Palmroos, and Contributors.
# This script is an addon for HungryProton's Scatter https://github.com/HungryProton/scatter
# It provides a `Project on Terrain3D` modifier, which allows Scatter
# It provides a `Project on Terrain3D` modifier, which allows Scatter
# to detect the terrain height from Terrain3D without using collision.
#
# Copy this file into /addons/proton_scatter/src/modifiers
@@ -26,112 +26,112 @@
#
#
#func _init() -> void:
#display_name = "Project On Terrain3D"
#category = "Edit"
#can_restrict_height = false
#global_reference_frame_available = true
#local_reference_frame_available = true
#individual_instances_reference_frame_available = true
#use_global_space_by_default()
#display_name = "Project On Terrain3D"
#category = "Edit"
#can_restrict_height = false
#global_reference_frame_available = true
#local_reference_frame_available = true
#individual_instances_reference_frame_available = true
#use_global_space_by_default()
#
#documentation.add_paragraph(
#"This is a modified version of `Project on Colliders` that queries Terrain3D
#for heights without using collision. It constrains placement by slope or texture.
#documentation.add_paragraph(
#"This is a modified version of `Project on Colliders` that queries Terrain3D
#for heights without using collision. It constrains placement by slope or texture.
#
#This modifier must have terrain_node set to a Terrain3D node.")
#This modifier must have terrain_node set to a Terrain3D node.")
#
#var p := documentation.add_parameter("Terrain Node")
#p.set_type("NodePath")
#p.set_description("Set your Terrain3D node.")
#
#p = documentation.add_parameter("Align with collision normal")
#p.set_type("bool")
#p.set_description(
#"Rotate the transform to align it with the collision normal in case
#the ray cast hit a collider.")
#
#p = documentation.add_parameter("Enable Texture Filtering")
#p.set_type("bool")
#p.set_description(
#"If enabled, objects will only be placed based on the ground texture specified.")
#
#p = documentation.add_parameter("Target Texture ID")
#p.set_type("int")
#p.set_description(
#"The ID of the texture to place objects on (0-31). Objects will only be placed on this texture.")
#
#p = documentation.add_parameter("Not Target Texture")
#p.set_type("bool")
#p.set_description(
#"If true, objects will be placed on all textures EXCEPT the target texture.")
#
#p = documentation.add_parameter("Texture Threshold")
#p.set_type("float")
#p.set_description("The blend value required for placement on the texture.")
#var p := documentation.add_parameter("Terrain Node")
#p.set_type("NodePath")
#p.set_description("Set your Terrain3D node.")
#
#p = documentation.add_parameter("Align with collision normal")
#p.set_type("bool")
#p.set_description(
#"Rotate the transform to align it with the collision normal in case
#the ray cast hit a collider.")
#
#p = documentation.add_parameter("Enable Texture Filtering")
#p.set_type("bool")
#p.set_description(
#"If enabled, objects will only be placed based on the ground texture specified.")
#
#p = documentation.add_parameter("Target Texture ID")
#p.set_type("int")
#p.set_description(
#"The ID of the texture to place objects on (0-31). Objects will only be placed on this texture.")
#
#p = documentation.add_parameter("Not Target Texture")
#p.set_type("bool")
#p.set_description(
#"If true, objects will be placed on all textures EXCEPT the target texture.")
#
#p = documentation.add_parameter("Texture Threshold")
#p.set_type("float")
#p.set_description("The blend value required for placement on the texture.")
#
#
#func _process_transforms(transforms, domain, _seed) -> void:
#if transforms.is_empty():
#return
#if transforms.is_empty():
#return
#
#if terrain_node:
#_terrain = domain.get_root().get_node_or_null(terrain_node)
#if terrain_node:
#_terrain = domain.get_root().get_node_or_null(terrain_node)
#
#if not _terrain:
#warning += """No Terrain3D node found"""
#return
#if not _terrain:
#warning += """No Terrain3D node found"""
#return
#
#if not _terrain.data:
#warning += """Terrain3DData is not initialized"""
#return
#if not _terrain.data:
#warning += """Terrain3DData is not initialized"""
#return
#
## Review transforms
#var gt: Transform3D = domain.get_global_transform()
#var gt_inverse := gt.affine_inverse()
#var new_transforms_array: Array[Transform3D] = []
#var remapped_max_slope: float = remap(max_slope, 0.0, 90.0, 0.0, 1.0)
#for i in transforms.list.size():
#var t: Transform3D = transforms.list[i]
#
#var location: Vector3 = (gt * t).origin
#var height: float = _terrain.data.get_height(location)
#if is_nan(height):
#continue
#
#var normal: Vector3 = _terrain.data.get_normal(location)
#if not abs(Vector3.UP.dot(normal)) >= (1.0 - remapped_max_slope):
#continue
#
#if enable_texture_filtering:
#var texture_info: Vector3 = _terrain.data.get_texture_id(location)
#var base_id: int = int(texture_info.x)
#var overlay_id: int = int(texture_info.y)
#var blend_value: float = texture_info.z
## Skip if overlay or blend != target texture, unless inverted
#if ((overlay_id != target_texture_id or blend_value < texture_threshold) and \
#(base_id != target_texture_id or blend_value >= texture_threshold)) != not_target_texture:
#continue
## Review transforms
#var gt: Transform3D = domain.get_global_transform()
#var gt_inverse := gt.affine_inverse()
#var new_transforms_array: Array[Transform3D] = []
#var remapped_max_slope: float = remap(max_slope, 0.0, 90.0, 0.0, 1.0)
#for i in transforms.list.size():
#var t: Transform3D = transforms.list[i]
#
#if align_with_collision_normal and not is_nan(normal.x):
#t.basis.y = normal
#t.basis.x = -t.basis.z.cross(normal)
#t.basis = t.basis.orthonormalized()
#var location: Vector3 = (gt * t).origin
#var height: float = _terrain.data.get_height(location)
#if is_nan(height):
#continue
#
#t.origin.y = height - gt.origin.y
#new_transforms_array.push_back(t)
#var normal: Vector3 = _terrain.data.get_normal(location)
#if not abs(Vector3.UP.dot(normal)) >= (1.0 - remapped_max_slope):
#continue
#
#transforms.list.clear()
#transforms.list.append_array(new_transforms_array)
#if enable_texture_filtering:
#var texture_info: Vector3 = _terrain.data.get_texture_id(location)
#var base_id: int = int(texture_info.x)
#var overlay_id: int = int(texture_info.y)
#var blend_value: float = texture_info.z
## Skip if overlay or blend != target texture, unless inverted
#if ((overlay_id != target_texture_id or blend_value < texture_threshold) and \
#(base_id != target_texture_id or blend_value >= texture_threshold)) != not_target_texture:
#continue
#
#if transforms.is_empty():
#warning += """All transforms have been removed. Possible reasons include: \n"""
#if enable_texture_filtering:
#warning += """+ No matching texture found at any position.
#+ Texture threshold may be too high.
#"""
#warning += """+ No collider is close enough to the shapes.
#+ Ray length is too short.
#+ Ray direction is incorrect.
#+ Collision mask is not set properly.
#+ Max slope is too low.
#"""
#if align_with_collision_normal and not is_nan(normal.x):
#t.basis.y = normal
#t.basis.x = -t.basis.z.cross(normal)
#t.basis = t.basis.orthonormalized()
#
#t.origin.y = height - gt.origin.y
#new_transforms_array.push_back(t)
#
#transforms.list.clear()
#transforms.list.append_array(new_transforms_array)
#
#if transforms.is_empty():
#warning += """All transforms have been removed. Possible reasons include: \n"""
#if enable_texture_filtering:
#warning += """+ No matching texture found at any position.
#+ Texture threshold may be too high.
#"""
#warning += """+ No collider is close enough to the shapes.
#+ Ray length is too short.
#+ Ray direction is incorrect.
#+ Collision mask is not set properly.
#+ Max slope is too low.
#"""
@@ -7,7 +7,6 @@
@tool
extends Node3D
#region settings
## Auto set if attached as a child of a Terrain3D node
@export var terrain: Terrain3D:
@@ -15,7 +14,6 @@ extends Node3D
terrain = value
_create_grid()
## Distance between instances
@export_range(0.125, 2.0, 0.015625) var instance_spacing: float = 0.5:
set(value):
@@ -24,7 +22,6 @@ extends Node3D
amount = rows * rows
_set_offsets()
## Width of an individual cell of the grid
@export_range(8.0, 256.0, 1.0) var cell_width: float = 32.0:
set(value):
@@ -44,8 +41,7 @@ extends Node3D
p.custom_aabb = aabb
_set_offsets()
## Grid width. Must be odd.
## Grid width. Must be odd.
## Higher values cull slightly better, draw further out.
@export_range(1, 15, 2) var grid_width: int = 9:
set(value):
@@ -54,7 +50,6 @@ extends Node3D
min_draw_distance = 1.0
_create_grid()
@export_storage var rows: int = 1
@export_storage var amount: int = 1:
@@ -65,7 +60,6 @@ extends Node3D
for p in particle_nodes:
p.amount = amount
@export_range(1, 256, 1) var process_fixed_fps: int = 30:
set(value):
process_fixed_fps = maxi(value, 1)
@@ -73,7 +67,6 @@ extends Node3D
p.fixed_fps = process_fixed_fps
p.preprocess = 1.0 / float(process_fixed_fps)
## Access to process material parameters
@export var process_material: ShaderMaterial
@@ -81,23 +74,21 @@ extends Node3D
@export var mesh: Mesh
@export var shadow_mode: GeometryInstance3D.ShadowCastingSetting = (
GeometryInstance3D.ShadowCastingSetting.SHADOW_CASTING_SETTING_ON):
GeometryInstance3D.ShadowCastingSetting.SHADOW_CASTING_SETTING_ON
):
set(value):
shadow_mode = value
for p in particle_nodes:
p.cast_shadow = value
## Override material for the particle mesh
@export_custom(
PROPERTY_HINT_RESOURCE_TYPE,
"BaseMaterial3D,ShaderMaterial") var mesh_material_override: Material:
@export_custom(PROPERTY_HINT_RESOURCE_TYPE, "BaseMaterial3D,ShaderMaterial")
var mesh_material_override: Material:
set(value):
mesh_material_override = value
for p in particle_nodes:
p.material_override = mesh_material_override
@export_group("Info")
## The minimum distance that particles will be drawn upto
## If using fade out effects like pixel alpha this is the limit to use.
@@ -105,7 +96,6 @@ extends Node3D
set(value):
min_draw_distance = float(cell_width * grid_width) * 0.5
## Displays current total particle count based on Cell Width and Instance Spacing
@export var particle_count: int = 1:
set(value):
@@ -113,7 +103,6 @@ extends Node3D
#endregion
var offsets: Array[Vector3]
var last_pos: Vector3 = Vector3.ZERO
var particle_nodes: Array[GPUParticles3D]
@@ -139,7 +128,9 @@ func _physics_process(delta: float) -> void:
if last_pos.distance_squared_to(camera.global_position) > 1.0:
var pos: Vector3 = camera.global_position.snapped(Vector3.ONE)
_position_grid(pos)
RenderingServer.material_set_param(process_material.get_rid(), "camera_position", pos )
RenderingServer.material_set_param(
process_material.get_rid(), "camera_position", pos
)
last_pos = camera.global_position
_update_process_parameters()
else:
@@ -180,7 +171,7 @@ func _create_grid() -> void:
if mesh_material_override:
particle_node.material_override = mesh_material_override
particle_node.use_fixed_seed = true
if (x > -half_grid and z > -half_grid): # Use the same seed across all nodes
if x > -half_grid and z > -half_grid: # Use the same seed across all nodes
particle_node.seed = particle_nodes[0].seed
self.add_child(particle_node)
particle_node.emitting = true
@@ -194,9 +185,7 @@ func _set_offsets() -> void:
for x in range(-half_grid, half_grid + 1):
for z in range(-half_grid, half_grid + 1):
var offset := Vector3(
float(x * rows) * instance_spacing,
0.0,
float(z * rows) * instance_spacing
float(x * rows) * instance_spacing, 0.0, float(z * rows) * instance_spacing
)
offsets.append(offset)
@@ -214,24 +203,42 @@ func _position_grid(pos: Vector3) -> void:
var snap = Vector3(pos.x, 0, pos.z).snapped(Vector3.ONE) + offsets[i]
node.global_position = (snap / instance_spacing).round() * instance_spacing
node.reset_physics_interpolation()
node.restart(true) # keep the same seed.
node.restart(true) # keep the same seed.
func _update_process_parameters() -> void:
if process_material:
var process_rid: RID = process_material.get_rid()
if terrain and process_rid.is_valid():
RenderingServer.material_set_param(process_rid, "_background_mode", terrain.material.world_background)
RenderingServer.material_set_param(process_rid, "_vertex_spacing", terrain.vertex_spacing)
RenderingServer.material_set_param(process_rid, "_vertex_density", 1.0 / terrain.vertex_spacing)
RenderingServer.material_set_param(
process_rid, "_background_mode", terrain.material.world_background
)
RenderingServer.material_set_param(
process_rid, "_vertex_spacing", terrain.vertex_spacing
)
RenderingServer.material_set_param(
process_rid, "_vertex_density", 1.0 / terrain.vertex_spacing
)
RenderingServer.material_set_param(process_rid, "_region_size", terrain.region_size)
RenderingServer.material_set_param(process_rid, "_region_texel_size", 1.0 / terrain.region_size)
RenderingServer.material_set_param(
process_rid, "_region_texel_size", 1.0 / terrain.region_size
)
RenderingServer.material_set_param(process_rid, "_region_map_size", 32)
RenderingServer.material_set_param(process_rid, "_region_map", terrain.data.get_region_map())
RenderingServer.material_set_param(process_rid, "_region_locations", terrain.data.get_region_locations())
RenderingServer.material_set_param(process_rid, "_height_maps", terrain.data.get_height_maps_rid())
RenderingServer.material_set_param(process_rid, "_control_maps", terrain.data.get_control_maps_rid())
RenderingServer.material_set_param(process_rid, "_color_maps", terrain.data.get_color_maps_rid())
RenderingServer.material_set_param(
process_rid, "_region_map", terrain.data.get_region_map()
)
RenderingServer.material_set_param(
process_rid, "_region_locations", terrain.data.get_region_locations()
)
RenderingServer.material_set_param(
process_rid, "_height_maps", terrain.data.get_height_maps_rid()
)
RenderingServer.material_set_param(
process_rid, "_control_maps", terrain.data.get_control_maps_rid()
)
RenderingServer.material_set_param(
process_rid, "_color_maps", terrain.data.get_color_maps_rid()
)
RenderingServer.material_set_param(process_rid, "instance_spacing", instance_spacing)
RenderingServer.material_set_param(process_rid, "instance_rows", rows)
RenderingServer.material_set_param(process_rid, "max_dist", min_draw_distance)