Compare commits

...

7 Commits

40 changed files with 997 additions and 175 deletions

View File

@ -36,7 +36,7 @@ loop-variable-name: _?[a-z][a-z0-9]*(_[a-z0-9]+)*
max-file-lines: 1000
max-line-length: 100
max-public-methods: 40
max-returns: 6
max-returns: 99
mixed-tabs-and-spaces: null
no-elif-return: null
no-else-return: null

View File

@ -3,25 +3,27 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://tancoet1lih5"
path="res://.godot/imported/basic_icon.png-bc904292cc126e1d3e1fd0eb1ba5acc2.ctex"
path.s3tc="res://.godot/imported/basic_icon.png-bc904292cc126e1d3e1fd0eb1ba5acc2.s3tc.ctex"
path.etc2="res://.godot/imported/basic_icon.png-bc904292cc126e1d3e1fd0eb1ba5acc2.etc2.ctex"
metadata={
"vram_texture": false
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://assets/ui/ball_icons/basic_icon.png"
dest_files=["res://.godot/imported/basic_icon.png-bc904292cc126e1d3e1fd0eb1ba5acc2.ctex"]
dest_files=["res://.godot/imported/basic_icon.png-bc904292cc126e1d3e1fd0eb1ba5acc2.s3tc.ctex", "res://.godot/imported/basic_icon.png-bc904292cc126e1d3e1fd0eb1ba5acc2.etc2.ctex"]
[params]
compress/mode=0
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
@ -31,4 +33,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
detect_3d/compress_to=0

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=64 format=3 uid="uid://bm2o3mex10v11"]
[gd_scene load_steps=65 format=3 uid="uid://bm2o3mex10v11"]
[ext_resource type="Terrain3DAssets" uid="uid://cwl34gstabgrx" path="res://levels/debug_level/terrain_assets.res" id="1_5smdk"]
[ext_resource type="Material" uid="uid://drxnue0xsen13" path="res://assets/materials/tropical_water.tres" id="4_bwkbv"]
@ -24,6 +24,7 @@
[ext_resource type="Texture2D" uid="uid://bq8dxuxfw1rwu" path="res://assets/textures/wood/lacquered_planks.png" id="17_xciuf"]
[ext_resource type="Texture2D" path="res://assets/textures/grass_green/grass_green_albedo.dds" id="18_scall"]
[ext_resource type="PackedScene" uid="uid://cblsayfgirexr" path="res://src/characters/umineko/umineko.tscn" id="21_ch6qk"]
[ext_resource type="Script" path="res://src/world/terrain_marker.gd" id="23_7p8cl"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_rpgb7"]
noise_type = 0
@ -67,12 +68,12 @@ auto_shader = true
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_h8tes"]
panorama = ExtResource("6_ectru")
[sub_resource type="Sky" id="Sky_3yoab"]
[sub_resource type="Sky" id="Sky_x5sbg"]
sky_material = SubResource("PanoramaSkyMaterial_h8tes")
[sub_resource type="Environment" id="Environment_k6wwx"]
background_mode = 2
sky = SubResource("Sky_3yoab")
sky = SubResource("Sky_x5sbg")
ambient_light_source = 2
ambient_light_color = Color(0.78, 0.78, 0.78, 1)
ssao_enabled = true
@ -573,6 +574,10 @@ mesh = SubResource("BoxMesh_jpetf")
[node name="StaticBody3D" type="StaticBody3D" parent="GravityCube/MeshInstance3D"]
[node name="TerrainMarker" type="Node" parent="GravityCube/MeshInstance3D/StaticBody3D"]
script = ExtResource("23_7p8cl")
type = 9
[node name="CollisionShape3D" type="CollisionShape3D" parent="GravityCube/MeshInstance3D/StaticBody3D"]
shape = SubResource("BoxShape3D_74f5g")
@ -639,6 +644,10 @@ mesh = SubResource("SphereMesh_ooxtq")
[node name="StaticBody3D" type="StaticBody3D" parent="GravityOrb/MeshInstance3D"]
[node name="TerrainMarker" type="Node" parent="GravityOrb/MeshInstance3D/StaticBody3D"]
script = ExtResource("23_7p8cl")
type = 5
[node name="CollisionShape3D" type="CollisionShape3D" parent="GravityOrb/MeshInstance3D/StaticBody3D"]
shape = SubResource("SphereShape3D_ne5nm")
@ -658,6 +667,10 @@ transform = Transform3D(2.33934e-08, 0.535178, -0.844739, 1, -4.37114e-08, 0, -3
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="GravityBowl"]
use_collision = true
[node name="TerrainMarker" type="Node" parent="GravityBowl/CSGCombiner3D"]
script = ExtResource("23_7p8cl")
type = 7
[node name="OuterCylinder" type="CSGCylinder3D" parent="GravityBowl/CSGCombiner3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 16, 0)
radius = 32.0
@ -689,6 +702,10 @@ transform = Transform3D(0.688355, -0.285755, 0.666717, 0, 0.919135, 0.393942, -0
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="GravityHalo"]
use_collision = true
[node name="TerrainMarker" type="Node" parent="GravityHalo/CSGCombiner3D"]
script = ExtResource("23_7p8cl")
type = 7
[node name="OuterShell" type="CSGTorus3D" parent="GravityHalo/CSGCombiner3D"]
inner_radius = 32.0
outer_radius = 108.0

BIN
levels/terrain_test/terrain_3d_data/terrain3d-01-01.res (Stored with Git LFS) Normal file

Binary file not shown.

BIN
levels/terrain_test/terrain_3d_data/terrain3d-01-02.res (Stored with Git LFS) Normal file

Binary file not shown.

BIN
levels/terrain_test/terrain_3d_data/terrain3d-01_00.res (Stored with Git LFS) Normal file

Binary file not shown.

BIN
levels/terrain_test/terrain_3d_data/terrain3d-01_01.res (Stored with Git LFS) Normal file

Binary file not shown.

BIN
levels/terrain_test/terrain_3d_data/terrain3d-02-01.res (Stored with Git LFS) Normal file

Binary file not shown.

BIN
levels/terrain_test/terrain_3d_data/terrain3d-02_00.res (Stored with Git LFS) Normal file

Binary file not shown.

BIN
levels/terrain_test/terrain_3d_data/terrain3d_00-01.res (Stored with Git LFS) Normal file

Binary file not shown.

BIN
levels/terrain_test/terrain_3d_data/terrain3d_00-02.res (Stored with Git LFS) Normal file

Binary file not shown.

BIN
levels/terrain_test/terrain_3d_data/terrain3d_00_00.res (Stored with Git LFS) Normal file

Binary file not shown.

BIN
levels/terrain_test/terrain_3d_data/terrain3d_00_01.res (Stored with Git LFS) Normal file

Binary file not shown.

BIN
levels/terrain_test/terrain_3d_data/terrain3d_01-01.res (Stored with Git LFS) Normal file

Binary file not shown.

BIN
levels/terrain_test/terrain_3d_data/terrain3d_01_00.res (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,22 @@
extends Node3D
const BALL_SPAWN_GROUP := "BallSpawn"
@export var ball_scene: PackedScene
func spawn_balls() -> void:
for spawn: Node3D in get_tree().get_nodes_in_group(BALL_SPAWN_GROUP):
var ball: GameBall = ball_scene.instantiate()
var callback := func() -> void:
if ball.sleeping:
ball.queue_free()
ball.sleeping_state_changed.connect(callback)
spawn.add_sibling(ball)
ball.global_transform = spawn.global_transform
ball.freeze = false
func _process(_delta: float) -> void:
if Input.is_action_just_pressed("debug_1"):
spawn_balls()

View File

@ -0,0 +1,519 @@
[gd_scene load_steps=37 format=3 uid="uid://cvs546kk7t7aw"]
[ext_resource type="Texture2D" uid="uid://c47ern0l2d50r" path="res://assets/vista_2.png" id="1_d1wmn"]
[ext_resource type="Script" path="res://levels/terrain_test/terrain_test.gd" id="1_drk48"]
[ext_resource type="Terrain3DAssets" uid="uid://cwl34gstabgrx" path="res://levels/debug_level/terrain_assets.res" id="2_25igk"]
[ext_resource type="PackedScene" uid="uid://b7pgvftmj7nbe" path="res://src/equipment/balls/debug_ball/debug_ball.tscn" id="2_77pf6"]
[ext_resource type="Texture2D" path="res://assets/textures/grass_rough/grass_rough_albedo.dds" id="4_rm170"]
[ext_resource type="FontFile" uid="uid://cbaqlaqdobnux" path="res://assets/fonts/Orbitron/Orbitron-VariableFont_wght.ttf" id="5_h18yf"]
[ext_resource type="Script" path="res://src/world/terrain_marker.gd" id="6_4bo0x"]
[ext_resource type="Texture2D" path="res://assets/textures/grass_fairway/grass_fairway_albedo.dds" id="6_wdukl"]
[ext_resource type="Texture2D" path="res://assets/textures/grass_green/grass_green_albedo.dds" id="8_gxslv"]
[ext_resource type="Texture2D" path="res://assets/textures/sand_trap/sand_trap_albedo.dds" id="9_ris7y"]
[ext_resource type="Texture2D" uid="uid://cqlp0tjmadi75" path="res://assets/textures/highway/highway_road.png" id="10_4nt4g"]
[ext_resource type="Texture2D" path="res://assets/textures/mountain_rock/mountain_rock_albedo.dds" id="11_2lq7o"]
[ext_resource type="Texture2D" uid="uid://bq8dxuxfw1rwu" path="res://assets/textures/wood/lacquered_planks.png" id="12_e07mg"]
[ext_resource type="Texture2D" uid="uid://b8vgf8wy7h4nx" path="res://assets/textures/guard_rail/guard_rail.png" id="13_ll3kp"]
[ext_resource type="Material" uid="uid://c5hidbq5gbmr" path="res://assets/materials/crystal.tres" id="14_o81al"]
[sub_resource type="PanoramaSkyMaterial" id="PanoramaSkyMaterial_kd0nc"]
panorama = ExtResource("1_d1wmn")
[sub_resource type="Sky" id="Sky_3yoab"]
sky_material = SubResource("PanoramaSkyMaterial_kd0nc")
[sub_resource type="Environment" id="Environment_qax3v"]
background_mode = 2
sky = SubResource("Sky_3yoab")
ambient_light_source = 2
ambient_light_color = Color(0.78, 0.78, 0.78, 1)
ssao_enabled = true
ssao_intensity = 1.7
glow_enabled = true
glow_bloom = 0.05
volumetric_fog_enabled = true
volumetric_fog_density = 0.001
volumetric_fog_emission = Color(0.6, 1, 1, 1)
volumetric_fog_length = 1024.0
volumetric_fog_sky_affect = 0.0
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_ph8qj"]
dof_blur_far_distance = 200.0
dof_blur_far_transition = 800.0
dof_blur_near_enabled = true
dof_blur_near_distance = 1.0
dof_blur_near_transition = 0.5
[sub_resource type="FastNoiseLite" id="FastNoiseLite_rpgb7"]
noise_type = 0
frequency = 1.0
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_sb318"]
width = 256
height = 256
seamless = true
noise = SubResource("FastNoiseLite_rpgb7")
[sub_resource type="Terrain3DMaterial" id="Terrain3DMaterial_4xim8"]
_shader_parameters = {
"auto_base_texture": 4,
"auto_height_reduction": 0.1,
"auto_overlay_texture": 0,
"auto_slope": 0.41,
"blend_sharpness": 1.0,
"height_blending": true,
"macro_variation1": Color(0.964742, 0.964742, 0.964742, 1),
"macro_variation2": Color(1, 1, 1, 1),
"noise1_angle": 0.0,
"noise1_offset": Vector2(0.5, 0.5),
"noise1_scale": 0.062,
"noise2_scale": 0.076,
"noise3_scale": 0.021,
"noise_texture": SubResource("NoiseTexture2D_sb318"),
"vertex_normals_distance": 128.0,
"world_noise_height": 74.0,
"world_noise_lod_distance": 7500.0,
"world_noise_max_octaves": 8,
"world_noise_min_octaves": 2,
"world_noise_offset": Vector3(0, -8, 0),
"world_noise_region_blend": 0.55,
"world_noise_scale": 5.0
}
world_background = 2
texture_filtering = 1
auto_shader = true
[sub_resource type="BoxMesh" id="BoxMesh_7awoq"]
size = Vector3(10, 1, 60)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ceq7g"]
albedo_texture = ExtResource("4_rm170")
[sub_resource type="PrismMesh" id="PrismMesh_kdeya"]
left_to_right = 1.0
size = Vector3(100, 50, 10)
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_ufirn"]
data = PackedVector3Array(-5, 0.5, 30, 5, 0.5, 30, -5, -0.5, 30, 5, 0.5, 30, 5, -0.5, 30, -5, -0.5, 30, 5, 0.5, -30, -5, 0.5, -30, 5, -0.5, -30, -5, 0.5, -30, -5, -0.5, -30, 5, -0.5, -30, 5, 0.5, 30, 5, 0.5, -30, 5, -0.5, 30, 5, 0.5, -30, 5, -0.5, -30, 5, -0.5, 30, -5, 0.5, -30, -5, 0.5, 30, -5, -0.5, -30, -5, 0.5, 30, -5, -0.5, 30, -5, -0.5, -30, 5, 0.5, 30, -5, 0.5, 30, 5, 0.5, -30, -5, 0.5, 30, -5, 0.5, -30, 5, 0.5, -30, -5, -0.5, 30, 5, -0.5, 30, -5, -0.5, -30, 5, -0.5, 30, 5, -0.5, -30, -5, -0.5, -30)
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_gq475"]
data = PackedVector3Array(50, 25, 5, 50, -25, 5, -50, -25, 5, 50, 25, -5, -50, -25, -5, 50, -25, -5, 50, 25, 5, 50, 25, -5, 50, -25, 5, 50, 25, -5, 50, -25, -5, 50, -25, 5, 50, 25, -5, 50, 25, 5, -50, -25, -5, 50, 25, 5, -50, -25, 5, -50, -25, -5, -50, -25, 5, 50, -25, 5, -50, -25, -5, 50, -25, 5, 50, -25, -5, -50, -25, -5)
[sub_resource type="BoxMesh" id="BoxMesh_oukkf"]
size = Vector3(10, 1, 60)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_c7541"]
albedo_texture = ExtResource("6_wdukl")
[sub_resource type="PrismMesh" id="PrismMesh_c7rfr"]
left_to_right = 1.0
size = Vector3(100, 50, 10)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_18mqp"]
albedo_texture = ExtResource("8_gxslv")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_2lnp3"]
albedo_texture = ExtResource("9_ris7y")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nflf8"]
albedo_texture = ExtResource("10_4nt4g")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_3qcr7"]
albedo_texture = ExtResource("11_2lq7o")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5nlxd"]
albedo_texture = ExtResource("12_e07mg")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_fhrit"]
albedo_texture = ExtResource("13_ll3kp")
[node name="TerrainTestMap" type="Node3D"]
script = ExtResource("1_drk48")
ball_scene = ExtResource("2_77pf6")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_qax3v")
camera_attributes = SubResource("CameraAttributesPractical_ph8qj")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.782608, -0.611691, 0.11558, 0, 0.185667, 0.982613, -0.622515, -0.769001, 0.145304, 0, 0, 0)
shadow_enabled = true
shadow_blur = 4.0
directional_shadow_split_1 = 0.017
directional_shadow_split_2 = 0.042
directional_shadow_split_3 = 0.247
directional_shadow_fade_start = 0.98
directional_shadow_max_distance = 750.0
directional_shadow_pancake_size = 5.0
[node name="Terrain3D" type="Terrain3D" parent="."]
data_directory = "res://levels/terrain_test/terrain_3d_data"
material = SubResource("Terrain3DMaterial_4xim8")
assets = ExtResource("2_25igk")
mesh_size = 64
top_level = true
metadata/_edit_lock_ = true
[node name="PlayerSpawn" type="Marker3D" parent="." groups=["PlayerSpawn"]]
[node name="TestRamps" type="Node3D" parent="."]
[node name="Rough" type="Node3D" parent="TestRamps"]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0)
[node name="RampGeometry" type="Node3D" parent="TestRamps/Rough"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
[node name="MeshInstance3D" type="MeshInstance3D" parent="TestRamps/Rough/RampGeometry"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
mesh = SubResource("BoxMesh_7awoq")
surface_material_override/0 = SubResource("StandardMaterial3D_ceq7g")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="TestRamps/Rough/RampGeometry"]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 25, 109)
mesh = SubResource("PrismMesh_kdeya")
surface_material_override/0 = SubResource("StandardMaterial3D_ceq7g")
[node name="Label3D" type="Label3D" parent="TestRamps/Rough/RampGeometry"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 8, 0)
text = "Rough"
font = ExtResource("5_h18yf")
font_size = 300
outline_size = 48
[node name="StaticBody3D" type="StaticBody3D" parent="TestRamps/Rough/RampGeometry"]
[node name="TerrainMarker" type="Node" parent="TestRamps/Rough/RampGeometry/StaticBody3D"]
script = ExtResource("6_4bo0x")
type = 1
[node name="CollisionShape3D" type="CollisionShape3D" parent="TestRamps/Rough/RampGeometry/StaticBody3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
shape = SubResource("ConcavePolygonShape3D_ufirn")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="TestRamps/Rough/RampGeometry/StaticBody3D"]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 25, 109)
shape = SubResource("ConcavePolygonShape3D_gq475")
[node name="BallSpawn" type="Marker3D" parent="TestRamps/Rough/RampGeometry" groups=["BallSpawn"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 158)
[node name="Fairway" type="Node3D" parent="TestRamps"]
transform = Transform3D(0.34202, 0, 0.939693, 0, 1, 0, -0.939693, 0, 0.34202, 0, 0, 0)
[node name="RampGeometry" type="Node3D" parent="TestRamps/Fairway"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
[node name="MeshInstance3D" type="MeshInstance3D" parent="TestRamps/Fairway/RampGeometry"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
mesh = SubResource("BoxMesh_oukkf")
surface_material_override/0 = SubResource("StandardMaterial3D_c7541")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="TestRamps/Fairway/RampGeometry"]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 25, 109)
mesh = SubResource("PrismMesh_c7rfr")
surface_material_override/0 = SubResource("StandardMaterial3D_c7541")
[node name="Label3D" type="Label3D" parent="TestRamps/Fairway/RampGeometry"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 8, 0)
text = "Fairway"
font = ExtResource("5_h18yf")
font_size = 300
outline_size = 48
[node name="StaticBody3D2" type="StaticBody3D" parent="TestRamps/Fairway/RampGeometry"]
[node name="TerrainMarker" type="Node" parent="TestRamps/Fairway/RampGeometry/StaticBody3D2"]
script = ExtResource("6_4bo0x")
type = 2
[node name="CollisionShape3D" type="CollisionShape3D" parent="TestRamps/Fairway/RampGeometry/StaticBody3D2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
shape = SubResource("ConcavePolygonShape3D_ufirn")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="TestRamps/Fairway/RampGeometry/StaticBody3D2"]
transform = Transform3D(-2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 0, 25, 109)
shape = SubResource("ConcavePolygonShape3D_gq475")
[node name="BallSpawn" type="Marker3D" parent="TestRamps/Fairway/RampGeometry" groups=["BallSpawn"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 158)
[node name="Green" type="Node3D" parent="TestRamps"]
transform = Transform3D(0.642788, 0, 0.766044, 0, 1, 0, -0.766044, 0, 0.642788, 0, 0, 0)
[node name="RampGeometry" type="Node3D" parent="TestRamps/Green"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
[node name="MeshInstance3D" type="MeshInstance3D" parent="TestRamps/Green/RampGeometry"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
mesh = SubResource("BoxMesh_oukkf")
surface_material_override/0 = SubResource("StandardMaterial3D_18mqp")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="TestRamps/Green/RampGeometry"]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 25, 109)
mesh = SubResource("PrismMesh_c7rfr")
surface_material_override/0 = SubResource("StandardMaterial3D_18mqp")
[node name="Label3D" type="Label3D" parent="TestRamps/Green/RampGeometry"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 8, 0)
text = "Green"
font = ExtResource("5_h18yf")
font_size = 300
outline_size = 48
[node name="StaticBody3D2" type="StaticBody3D" parent="TestRamps/Green/RampGeometry"]
[node name="TerrainMarker" type="Node" parent="TestRamps/Green/RampGeometry/StaticBody3D2"]
script = ExtResource("6_4bo0x")
type = 3
[node name="CollisionShape3D" type="CollisionShape3D" parent="TestRamps/Green/RampGeometry/StaticBody3D2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
shape = SubResource("ConcavePolygonShape3D_ufirn")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="TestRamps/Green/RampGeometry/StaticBody3D2"]
transform = Transform3D(-2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 0, 25, 109)
shape = SubResource("ConcavePolygonShape3D_gq475")
[node name="BallSpawn" type="Marker3D" parent="TestRamps/Green/RampGeometry" groups=["BallSpawn"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 158)
[node name="Sand" type="Node3D" parent="TestRamps"]
transform = Transform3D(0.866025, 0, 0.5, 0, 1, 0, -0.5, 0, 0.866025, 0, 0, 0)
[node name="RampGeometry" type="Node3D" parent="TestRamps/Sand"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
[node name="MeshInstance3D" type="MeshInstance3D" parent="TestRamps/Sand/RampGeometry"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
mesh = SubResource("BoxMesh_oukkf")
surface_material_override/0 = SubResource("StandardMaterial3D_2lnp3")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="TestRamps/Sand/RampGeometry"]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 25, 109)
mesh = SubResource("PrismMesh_c7rfr")
surface_material_override/0 = SubResource("StandardMaterial3D_2lnp3")
[node name="Label3D" type="Label3D" parent="TestRamps/Sand/RampGeometry"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 8, 0)
text = "Sand"
font = ExtResource("5_h18yf")
font_size = 300
outline_size = 48
[node name="StaticBody3D2" type="StaticBody3D" parent="TestRamps/Sand/RampGeometry"]
[node name="TerrainMarker" type="Node" parent="TestRamps/Sand/RampGeometry/StaticBody3D2"]
script = ExtResource("6_4bo0x")
type = 4
[node name="CollisionShape3D" type="CollisionShape3D" parent="TestRamps/Sand/RampGeometry/StaticBody3D2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
shape = SubResource("ConcavePolygonShape3D_ufirn")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="TestRamps/Sand/RampGeometry/StaticBody3D2"]
transform = Transform3D(-2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 0, 25, 109)
shape = SubResource("ConcavePolygonShape3D_gq475")
[node name="BallSpawn" type="Marker3D" parent="TestRamps/Sand/RampGeometry" groups=["BallSpawn"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 158)
[node name="Concrete" type="Node3D" parent="TestRamps"]
transform = Transform3D(0.984808, 0, 0.173648, 0, 1, 0, -0.173648, 0, 0.984808, 0, 0, 0)
[node name="RampGeometry" type="Node3D" parent="TestRamps/Concrete"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
[node name="MeshInstance3D" type="MeshInstance3D" parent="TestRamps/Concrete/RampGeometry"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
mesh = SubResource("BoxMesh_oukkf")
surface_material_override/0 = SubResource("StandardMaterial3D_nflf8")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="TestRamps/Concrete/RampGeometry"]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 25, 109)
mesh = SubResource("PrismMesh_c7rfr")
surface_material_override/0 = SubResource("StandardMaterial3D_nflf8")
[node name="Label3D" type="Label3D" parent="TestRamps/Concrete/RampGeometry"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 8, 0)
text = "Concrete"
font = ExtResource("5_h18yf")
font_size = 300
outline_size = 48
[node name="StaticBody3D2" type="StaticBody3D" parent="TestRamps/Concrete/RampGeometry"]
[node name="TerrainMarker" type="Node" parent="TestRamps/Concrete/RampGeometry/StaticBody3D2"]
script = ExtResource("6_4bo0x")
type = 5
[node name="CollisionShape3D" type="CollisionShape3D" parent="TestRamps/Concrete/RampGeometry/StaticBody3D2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
shape = SubResource("ConcavePolygonShape3D_ufirn")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="TestRamps/Concrete/RampGeometry/StaticBody3D2"]
transform = Transform3D(-2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 0, 25, 109)
shape = SubResource("ConcavePolygonShape3D_gq475")
[node name="BallSpawn" type="Marker3D" parent="TestRamps/Concrete/RampGeometry" groups=["BallSpawn"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 158)
[node name="Rock" type="Node3D" parent="TestRamps"]
transform = Transform3D(0.984808, 0, -0.173648, 0, 1, 0, 0.173648, 0, 0.984808, 0, 0, 0)
[node name="RampGeometry" type="Node3D" parent="TestRamps/Rock"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
[node name="MeshInstance3D" type="MeshInstance3D" parent="TestRamps/Rock/RampGeometry"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
mesh = SubResource("BoxMesh_oukkf")
surface_material_override/0 = SubResource("StandardMaterial3D_3qcr7")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="TestRamps/Rock/RampGeometry"]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 25, 109)
mesh = SubResource("PrismMesh_c7rfr")
surface_material_override/0 = SubResource("StandardMaterial3D_3qcr7")
[node name="Label3D" type="Label3D" parent="TestRamps/Rock/RampGeometry"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 8, 0)
text = "Rock"
font = ExtResource("5_h18yf")
font_size = 300
outline_size = 48
[node name="StaticBody3D2" type="StaticBody3D" parent="TestRamps/Rock/RampGeometry"]
[node name="TerrainMarker" type="Node" parent="TestRamps/Rock/RampGeometry/StaticBody3D2"]
script = ExtResource("6_4bo0x")
type = 6
[node name="CollisionShape3D" type="CollisionShape3D" parent="TestRamps/Rock/RampGeometry/StaticBody3D2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
shape = SubResource("ConcavePolygonShape3D_ufirn")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="TestRamps/Rock/RampGeometry/StaticBody3D2"]
transform = Transform3D(-2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 0, 25, 109)
shape = SubResource("ConcavePolygonShape3D_gq475")
[node name="BallSpawn" type="Marker3D" parent="TestRamps/Rock/RampGeometry" groups=["BallSpawn"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 158)
[node name="Wood" type="Node3D" parent="TestRamps"]
transform = Transform3D(0.866025, 0, -0.5, 0, 1, 0, 0.5, 0, 0.866025, 0, 0, 0)
[node name="RampGeometry" type="Node3D" parent="TestRamps/Wood"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
[node name="MeshInstance3D" type="MeshInstance3D" parent="TestRamps/Wood/RampGeometry"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
mesh = SubResource("BoxMesh_oukkf")
surface_material_override/0 = SubResource("StandardMaterial3D_5nlxd")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="TestRamps/Wood/RampGeometry"]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 25, 109)
mesh = SubResource("PrismMesh_c7rfr")
surface_material_override/0 = SubResource("StandardMaterial3D_5nlxd")
[node name="Label3D" type="Label3D" parent="TestRamps/Wood/RampGeometry"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 8, 0)
text = "Wood"
font = ExtResource("5_h18yf")
font_size = 300
outline_size = 48
[node name="StaticBody3D2" type="StaticBody3D" parent="TestRamps/Wood/RampGeometry"]
[node name="TerrainMarker" type="Node" parent="TestRamps/Wood/RampGeometry/StaticBody3D2"]
script = ExtResource("6_4bo0x")
type = 7
[node name="CollisionShape3D" type="CollisionShape3D" parent="TestRamps/Wood/RampGeometry/StaticBody3D2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
shape = SubResource("ConcavePolygonShape3D_ufirn")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="TestRamps/Wood/RampGeometry/StaticBody3D2"]
transform = Transform3D(-2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 0, 25, 109)
shape = SubResource("ConcavePolygonShape3D_gq475")
[node name="BallSpawn" type="Marker3D" parent="TestRamps/Wood/RampGeometry" groups=["BallSpawn"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 158)
[node name="Metal" type="Node3D" parent="TestRamps"]
transform = Transform3D(0.642788, 0, -0.766044, 0, 1, 0, 0.766044, 0, 0.642788, 0, 0, 0)
[node name="RampGeometry" type="Node3D" parent="TestRamps/Metal"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
[node name="MeshInstance3D" type="MeshInstance3D" parent="TestRamps/Metal/RampGeometry"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
mesh = SubResource("BoxMesh_oukkf")
surface_material_override/0 = SubResource("StandardMaterial3D_fhrit")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="TestRamps/Metal/RampGeometry"]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 25, 109)
mesh = SubResource("PrismMesh_c7rfr")
surface_material_override/0 = SubResource("StandardMaterial3D_fhrit")
[node name="Label3D" type="Label3D" parent="TestRamps/Metal/RampGeometry"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 8, 0)
text = "Metal"
font = ExtResource("5_h18yf")
font_size = 300
outline_size = 48
[node name="StaticBody3D2" type="StaticBody3D" parent="TestRamps/Metal/RampGeometry"]
[node name="TerrainMarker" type="Node" parent="TestRamps/Metal/RampGeometry/StaticBody3D2"]
script = ExtResource("6_4bo0x")
type = 8
[node name="CollisionShape3D" type="CollisionShape3D" parent="TestRamps/Metal/RampGeometry/StaticBody3D2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
shape = SubResource("ConcavePolygonShape3D_ufirn")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="TestRamps/Metal/RampGeometry/StaticBody3D2"]
transform = Transform3D(-2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 0, 25, 109)
shape = SubResource("ConcavePolygonShape3D_gq475")
[node name="BallSpawn" type="Marker3D" parent="TestRamps/Metal/RampGeometry" groups=["BallSpawn"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 158)
[node name="Glass" type="Node3D" parent="TestRamps"]
transform = Transform3D(0.34202, 0, -0.939692, 0, 1, 0, 0.939692, 0, 0.34202, 0, 0, 0)
[node name="RampGeometry" type="Node3D" parent="TestRamps/Glass"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
[node name="MeshInstance3D" type="MeshInstance3D" parent="TestRamps/Glass/RampGeometry"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
mesh = SubResource("BoxMesh_oukkf")
surface_material_override/0 = ExtResource("14_o81al")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="TestRamps/Glass/RampGeometry"]
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, 25, 109)
mesh = SubResource("PrismMesh_c7rfr")
surface_material_override/0 = ExtResource("14_o81al")
[node name="Label3D" type="Label3D" parent="TestRamps/Glass/RampGeometry"]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 8, 0)
text = "Glass"
font = ExtResource("5_h18yf")
font_size = 300
outline_size = 48
[node name="StaticBody3D2" type="StaticBody3D" parent="TestRamps/Glass/RampGeometry"]
[node name="TerrainMarker" type="Node" parent="TestRamps/Glass/RampGeometry/StaticBody3D2"]
script = ExtResource("6_4bo0x")
type = 9
[node name="CollisionShape3D" type="CollisionShape3D" parent="TestRamps/Glass/RampGeometry/StaticBody3D2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30)
shape = SubResource("ConcavePolygonShape3D_ufirn")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="TestRamps/Glass/RampGeometry/StaticBody3D2"]
transform = Transform3D(-2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 0, 25, 109)
shape = SubResource("ConcavePolygonShape3D_gq475")
[node name="BallSpawn" type="Marker3D" parent="TestRamps/Glass/RampGeometry" groups=["BallSpawn"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 158)

View File

@ -248,14 +248,6 @@ locale/translations=PackedStringArray("res://assets/text/text.en.translation")
3d_physics/layer_1="Collision Geometry"
3d_physics/layer_2="Water"
3d_physics/layer_25="Green Material"
3d_physics/layer_26="Fairway Material"
3d_physics/layer_27="Glass Material"
3d_physics/layer_28="Metal Material"
3d_physics/layer_29="Rock Material"
3d_physics/layer_30="Wood Material"
3d_physics/layer_31="Sand Material"
3d_physics/layer_32="Grass Material"
[physics]
@ -263,6 +255,7 @@ locale/translations=PackedStringArray("res://assets/text/text.en.translation")
3d/sleep_threshold_angular=2.0
jolt_3d/sleep/velocity_threshold=0.1
jolt_3d/sleep/time_threshold=1.0
jolt_3d/limits/max_angular_velocity=270000.0
jolt_3d/limits/max_temporary_memory=64
[rendering]

View File

@ -0,0 +1,18 @@
extends GameBall
const INFO_FMT := "speed: {0} m/s\nang.spd: {1}\nsurface: {2}\ntime: {3} s"
@onready var debug_info: Label3D = %DebugInfo
func _physics_process(delta: float) -> void:
super._physics_process(delta)
debug_info.text = INFO_FMT.format(
[
linear_velocity.length(),
angular_velocity.length(),
Terrain.Type.keys()[_surface_terrain],
_shot_time_s
]
)

View File

@ -0,0 +1,44 @@
[gd_scene load_steps=7 format=3 uid="uid://b7pgvftmj7nbe"]
[ext_resource type="PackedScene" uid="uid://dfttci386ohip" path="res://src/equipment/balls/physics_ball/physics_ball.tscn" id="1_gcsxs"]
[ext_resource type="Script" path="res://src/equipment/balls/debug_ball/debug_ball.gd" id="2_edye5"]
[ext_resource type="Texture2D" uid="uid://tancoet1lih5" path="res://assets/ui/ball_icons/basic_icon.png" id="2_h3ccx"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_8pnwh"]
transparency = 1
no_depth_test = true
shading_mode = 0
albedo_texture = ExtResource("2_h3ccx")
texture_filter = 2
billboard_mode = 1
fixed_size = true
[sub_resource type="QuadMesh" id="QuadMesh_lf5f4"]
material = SubResource("StandardMaterial3D_8pnwh")
size = Vector2(0.05, 0.05)
[sub_resource type="SystemFont" id="SystemFont_td87w"]
font_names = PackedStringArray("Monospace")
subpixel_positioning = 0
[node name="DebugBall" instance=ExtResource("1_gcsxs")]
script = ExtResource("2_edye5")
[node name="MeshInstance3D" type="MeshInstance3D" parent="BallMesh" index="0"]
mesh = SubResource("QuadMesh_lf5f4")
[node name="DebugInfo" type="Label3D" parent="BallMesh" index="1"]
unique_name_in_owner = true
pixel_size = 0.0005
offset = Vector2(0, -64)
billboard = 1
no_depth_test = true
fixed_size = true
texture_filter = 2
text = "DEBUG INFO
DEBUG INFO
DEBUG INFO"
font = SubResource("SystemFont_td87w")
outline_size = 10
horizontal_alignment = 0
vertical_alignment = 0

View File

@ -14,16 +14,28 @@ enum Type {
POWER,
}
const TERRAIN_DAMPING_EPSILON := 1e-6
const MAGNUS_EPSILON := 1e-3
const MAGNUS_SQ_EPSILON := 1e-3
## If enabled, ball ability cooldown is only reset at end of shot.
@export var once_per_shot_ability := false
## Angular damping while in air
@export var air_damping := 0.0
## Angular damping while in collision with rough terrain
@export var rough_damping := 8.0
## Material physics configuration for this ball.
@export var terrain_physics: TerrainPhysics
## Coefficient of the roll damping quadratic curve.
## This applies progressively greater damping after the ball rolls for a period of time.
@export var roll_damping_coefficient := 0.4
## Time in seconds after the ball begins rolling after which roll damping will start to apply.
## This applies progressively greater damping after the ball rolls for a period of time.
@export var roll_damping_delay := 12.0
## Coefficient of the roll cull linear curve.
## The ball be frozen if it rolls with speed under this curve.
@export var roll_cull_coefficient := 0.2
## Time in seconds after the ball begins rolling after which roll culling will start to apply.
@export var roll_cull_delay := 16.0
#@export var fluid_density := 1.225
#@export var lift_coefficient := 0.05
@ -58,6 +70,9 @@ var _position_on_last_wake: Vector3
var _awake := false
var _ability_triggered := false
var _zones: Array[BallZone] = []
var _shot_time_s := 0.0
var _surface_time_s := 0.0
var _surface_terrain: Terrain.Type
@onready var ability_cooldown: Timer = %AbilityCooldown
@onready var manual_sleep_timer: Timer = %ManualSleepTimer
@ -102,12 +117,6 @@ func get_damage() -> float:
return base_damage + linear_velocity.length_squared() * damage_force_scale
func _total_terrain_angular_damping() -> float:
return _zones.reduce(
func(a: float, b: BallZone) -> float: return a + b.terrain_angular_damping, 0.0
)
func _magnus_force() -> Vector3:
return magnus_coefficient * radius * angular_velocity.cross(linear_velocity)
@ -120,33 +129,52 @@ func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
_ability_triggered = false
_position_on_last_wake = global_position
_last_contact_normal = Vector3.UP
_shot_time_s = 0.0
_surface_time_s = 0.0
# TODO something's fucky here... I think this gets called once after the ball sleeps
var damping := air_damping
if state.get_contact_count():
constant_force = Vector3.ZERO
# Ball is in contact with a surface
# We want the contact normal which minimizes the angle to the up vector
var min_dot := -1.0
var primary_body: Node
for i: int in range(state.get_contact_count()):
var norm := state.get_contact_local_normal(i)
var dot := norm.dot(Vector3.UP)
if dot > min_dot:
min_dot = dot
_last_contact_normal = norm
primary_body = state.get_contact_collider_object(i)
damping = _total_terrain_angular_damping()
if damping <= TERRAIN_DAMPING_EPSILON:
damping = rough_damping
angular_damp = damping
_surface_terrain = Terrain.from_collision(global_position, primary_body)
else:
# Ball is in the air
_surface_terrain = Terrain.Type.NONE
_surface_time_s = 0.0
var params := terrain_physics.get_params(_surface_terrain)
angular_damp = params.angular_damp
linear_damp = params.linear_damp
# Progressively increase linear damping after a delay.
linear_damp += roll_damping_coefficient * pow(maxf(_surface_time_s - roll_damping_delay, 0), 2)
var cull_speed := roll_cull_coefficient * maxf(_surface_time_s - roll_cull_delay, 0)
if linear_velocity.length_squared() < pow(cull_speed, 2):
_manual_sleep()
func _physics_process(_delta: float) -> void:
func _physics_process(delta: float) -> void:
# Simulate magnus effect
var magnus := _magnus_force()
if magnus.length_squared() > MAGNUS_EPSILON:
if magnus.length_squared() > MAGNUS_SQ_EPSILON:
apply_central_force(magnus)
# Keep shot time
_shot_time_s += delta
_surface_time_s += delta
func enter_zone(zone: BallZone) -> void:
_zones.push_back(zone)
@ -176,21 +204,20 @@ func _on_sleeping_state_changed() -> void:
_awake = false
func _manual_sleep() -> void:
freeze = true
linear_velocity = Vector3.ZERO
angular_velocity = Vector3.ZERO
manual_sleep_timer.start()
func _on_collision(body: Node) -> void:
if is_sticky():
# Freeze physics as soon as we hit something
freeze = true
manual_sleep_timer.start()
_manual_sleep()
var terrain: Terrain.Type
if body is Terrain3D:
terrain = Terrain.at_position(global_position, body as Terrain3D)
elif body is CSGShape3D:
terrain = Terrain.from_physical_layer((body as CSGShape3D).collision_layer)
elif body is CollisionObject3D:
terrain = Terrain.from_physical_layer((body as CollisionObject3D).collision_layer)
else:
print_debug("COLLIDER: ", body)
var terrain := Terrain.from_collision(global_position, body)
print_debug("Collision terrain: ", Terrain.Type.keys()[terrain])
if terrain:
sfx.play_sfx(terrain)

View File

@ -1,4 +1,4 @@
[gd_resource type="PhysicsMaterial" format=3 uid="uid://3bih72l068ic"]
[resource]
bounce = 0.5
bounce = 0.4

View File

@ -1,8 +1,10 @@
[gd_scene load_steps=25 format=3 uid="uid://dfttci386ohip"]
[gd_scene load_steps=38 format=3 uid="uid://dfttci386ohip"]
[ext_resource type="Script" path="res://src/equipment/balls/physics_ball/game_ball.gd" id="1_iwh2u"]
[ext_resource type="PhysicsMaterial" uid="uid://3bih72l068ic" path="res://src/equipment/balls/physics_ball/normal_physics.tres" id="1_l23pw"]
[ext_resource type="Script" path="res://src/equipment/balls/physics_ball/terrain_physics/terrain_physics.gd" id="3_52hui"]
[ext_resource type="Material" uid="uid://dpsmjlhjpc7vs" path="res://assets/materials/basic_ball_material.tres" id="3_rc7m1"]
[ext_resource type="Script" path="res://src/equipment/balls/physics_ball/terrain_physics/terrain_parameters.gd" id="4_onl6o"]
[ext_resource type="Script" path="res://src/equipment/balls/physics_ball/ball_sfx.gd" id="5_bhshl"]
[ext_resource type="AudioStream" uid="uid://cayyndwmxua5x" path="res://assets/sound/sfx/ball/grass2.wav" id="7_l22cv"]
[ext_resource type="AudioStream" uid="uid://orisjdcj3mes" path="res://assets/sound/sfx/ball/concrete3.wav" id="7_t2ak2"]
@ -15,6 +17,69 @@
[ext_resource type="Texture2D" uid="uid://c47bkx508biqr" path="res://assets/sprites/particles/plasma.png" id="12_guipt"]
[ext_resource type="PackedScene" uid="uid://cm4bb3lg4mfd2" path="res://src/world/effects/splash/splash_effect.tscn" id="12_qlrvx"]
[sub_resource type="Resource" id="Resource_casfi"]
script = ExtResource("4_onl6o")
linear_damp = 0.0
angular_damp = 1.4
[sub_resource type="Resource" id="Resource_3k63c"]
script = ExtResource("4_onl6o")
linear_damp = 0.0
angular_damp = 0.0
[sub_resource type="Resource" id="Resource_xf73q"]
script = ExtResource("4_onl6o")
linear_damp = 0.0
angular_damp = 2.0
[sub_resource type="Resource" id="Resource_nhn3l"]
script = ExtResource("4_onl6o")
linear_damp = 0.0
angular_damp = 0.6
[sub_resource type="Resource" id="Resource_m3wjo"]
script = ExtResource("4_onl6o")
linear_damp = 0.0
angular_damp = 1.0
[sub_resource type="Resource" id="Resource_h4rld"]
script = ExtResource("4_onl6o")
linear_damp = 0.0
angular_damp = 0.9
[sub_resource type="Resource" id="Resource_j6lib"]
script = ExtResource("4_onl6o")
linear_damp = 0.0
angular_damp = 2.5
[sub_resource type="Resource" id="Resource_7f7ql"]
script = ExtResource("4_onl6o")
linear_damp = 0.0
angular_damp = 4.0
[sub_resource type="Resource" id="Resource_pusmf"]
script = ExtResource("4_onl6o")
linear_damp = 0.0
angular_damp = 8.0
[sub_resource type="Resource" id="Resource_edkxb"]
script = ExtResource("4_onl6o")
linear_damp = 0.0
angular_damp = 0.9
[sub_resource type="Resource" id="Resource_3ngau"]
script = ExtResource("3_52hui")
default = SubResource("Resource_3k63c")
rough = SubResource("Resource_7f7ql")
fairway = SubResource("Resource_xf73q")
green = SubResource("Resource_m3wjo")
sand = SubResource("Resource_pusmf")
concrete = SubResource("Resource_casfi")
rock = SubResource("Resource_j6lib")
wood = SubResource("Resource_edkxb")
metal = SubResource("Resource_h4rld")
glass = SubResource("Resource_nhn3l")
[sub_resource type="SphereMesh" id="SphereMesh_y0d13"]
material = ExtResource("3_rc7m1")
radius = 0.05
@ -132,14 +197,15 @@ size = Vector2(0.2, 0.2)
[node name="PhysicsBall" type="RigidBody3D"]
mass = 0.05
physics_material_override = ExtResource("1_l23pw")
sleeping = true
freeze = true
continuous_cd = true
contact_monitor = true
max_contacts_reported = 3
linear_damp_mode = 1
angular_damp_mode = 1
angular_damp = 8.0
script = ExtResource("1_iwh2u")
terrain_physics = SubResource("Resource_3ngau")
[node name="BallMesh" type="MeshInstance3D" parent="."]
mesh = SubResource("SphereMesh_y0d13")

View File

@ -0,0 +1,5 @@
class_name TerrainParameters extends Resource
## Physical parameters for an individual terrain type.
@export var linear_damp := 0.0
@export var angular_damp := 0.0

View File

@ -0,0 +1,40 @@
class_name TerrainPhysics extends Resource
## Container for ball behavior parameters when in contact with different terrain types
@export var default: TerrainParameters
@export var rough: TerrainParameters
@export var fairway: TerrainParameters
@export var green: TerrainParameters
@export var sand: TerrainParameters
@export var concrete: TerrainParameters
@export var rock: TerrainParameters
@export var wood: TerrainParameters
@export var metal: TerrainParameters
@export var glass: TerrainParameters
func get_params(type: Terrain.Type) -> TerrainParameters:
# NOTE: sure would be nice to just store this in a dict,
# but that makes editing physics through the editor unweildy.
match type:
Terrain.Type.ROUGH:
return rough
Terrain.Type.FAIRWAY:
return fairway
Terrain.Type.GREEN:
return green
Terrain.Type.SAND:
return sand
Terrain.Type.CONCRETE:
return concrete
Terrain.Type.ROCK:
return rock
Terrain.Type.WOOD:
return wood
Terrain.Type.METAL:
return metal
Terrain.Type.GLASS:
return glass
_:
return default

View File

@ -1,7 +1,7 @@
class_name Game extends Node
## Wrapper for the game application
@export var start_scene: String = "res://src/ui/menus/title_screen/title_screen.tscn"
@export_file("*.tscn") var start_scene: String = "res://src/ui/menus/title_screen/title_screen.tscn"
var _loading_resources := {}

View File

@ -119,6 +119,7 @@ _data = {
[node name="Game" type="Node" groups=["GameGroup"]]
process_mode = 3
script = ExtResource("1_4qa87")
start_scene = "res://src/world/world.tscn"
[node name="RootControl" type="Control" parent="."]
unique_name_in_owner = true

View File

@ -426,6 +426,7 @@ stream_0/stream = ExtResource("15_fn6g1")
[node name="ShotSetup" type="Node3D"]
script = ExtResource("1_r6ei4")
perfect_aim = true
[node name="BallPoint" type="Node3D" parent="."]
unique_name_in_owner = true

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://dagh38vap4t1d"]
[gd_scene load_steps=4 format=3 uid="uid://dagh38vap4t1d"]
[ext_resource type="PackedScene" uid="uid://mhycq1tk1bpm" path="res://assets/models/scenery/city/concrete_building_1/concrete_building_1.gltf" id="1_id6ph"]
[ext_resource type="Script" path="res://src/world/terrain_marker.gd" id="2_5x2lp"]
[sub_resource type="BoxShape3D" id="BoxShape3D_5g4vq"]
size = Vector3(16, 24, 16)
@ -9,6 +10,10 @@ size = Vector3(16, 24, 16)
[node name="StaticBody3D" type="StaticBody3D" parent="." index="1"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" index="0"]
[node name="TerrainMarker" type="Node" parent="StaticBody3D" index="0"]
script = ExtResource("2_5x2lp")
type = 5
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" index="1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 12, 0)
shape = SubResource("BoxShape3D_5g4vq")

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=5 format=3 uid="uid://cjubxs7peir5k"]
[gd_scene load_steps=6 format=3 uid="uid://cjubxs7peir5k"]
[ext_resource type="PackedScene" uid="uid://hwc1px831dgm" path="res://assets/models/scenery/city/kana_signboard/kana_signboard.gltf" id="1_o4tvg"]
[ext_resource type="Texture2D" uid="uid://d0lsrrx0r5wnu" path="res://assets/models/scenery/city/kana_signboard/kana_signboard.png" id="2_85s5u"]
[ext_resource type="Script" path="res://src/world/terrain_marker.gd" id="3_dllon"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_dwyvb"]
albedo_texture = ExtResource("2_85s5u")
@ -18,13 +19,17 @@ surface_material_override/0 = SubResource("StandardMaterial3D_dwyvb")
[node name="StaticBody3D" type="StaticBody3D" parent="." index="3"]
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" index="0"]
[node name="TerrainMarker" type="Node" parent="StaticBody3D" index="0"]
script = ExtResource("3_dllon")
type = 8
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" index="1"]
shape = SubResource("BoxShape3D_kp4b0")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D" index="1"]
[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D" index="2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 1.2)
shape = SubResource("BoxShape3D_kp4b0")
[node name="CollisionShape3D3" type="CollisionShape3D" parent="StaticBody3D" index="2"]
[node name="CollisionShape3D3" type="CollisionShape3D" parent="StaticBody3D" index="3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.5, 1.2)
shape = SubResource("BoxShape3D_kp4b0")

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=5 format=3 uid="uid://nqar1qcun8ax"]
[gd_scene load_steps=6 format=3 uid="uid://nqar1qcun8ax"]
[ext_resource type="Script" path="res://src/props/scenery/highway/guard_rail/guard_rail.gd" id="1_imntf"]
[ext_resource type="Material" uid="uid://cift6p0wn1oce" path="res://assets/materials/guard_rail.tres" id="2_1s4wy"]
[ext_resource type="PlaneMesh" uid="uid://bdcmgvgpj1e0w" path="res://src/props/scenery/highway/guard_rail/guard_rail_post_mesh.tres" id="3_hha2c"]
[ext_resource type="Script" path="res://src/world/terrain_marker.gd" id="3_nfjvf"]
[sub_resource type="MultiMesh" id="MultiMesh_1o4mq"]
[sub_resource type="MultiMesh" id="MultiMesh_1dcl6"]
transform_format = 1
mesh = ExtResource("3_hha2c")
@ -26,6 +27,10 @@ path_u_distance = 1.0
path_joined = false
material = ExtResource("2_1s4wy")
[node name="TerrainMarker" type="Node" parent="UpperRail"]
script = ExtResource("3_nfjvf")
type = 8
[node name="LowerRail" type="CSGPolygon3D" parent="."]
use_collision = true
polygon = PackedVector2Array(0, 0.4, -0.01, 0.5, 0, 0.6, 0.01, 0.5)
@ -41,7 +46,11 @@ path_u_distance = 1.0
path_joined = false
material = ExtResource("2_1s4wy")
[node name="TerrainMarker" type="Node" parent="LowerRail"]
script = ExtResource("3_nfjvf")
type = 8
[node name="PostMultiMesh" type="MultiMeshInstance3D" parent="."]
multimesh = SubResource("MultiMesh_1o4mq")
multimesh = SubResource("MultiMesh_1dcl6")
[connection signal="curve_changed" from="." to="." method="_on_curve_changed"]

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://d0tcr6uijpym5"]
[gd_scene load_steps=4 format=3 uid="uid://d0tcr6uijpym5"]
[ext_resource type="Texture2D" uid="uid://dloe67udf7fpd" path="res://assets/textures/highway/highway_road_grass.png" id="1_f3xui"]
[ext_resource type="Script" path="res://src/world/terrain_marker.gd" id="2_4f0hb"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nkovu"]
transparency = 1
@ -25,3 +26,7 @@ path_continuous_u = true
path_u_distance = 1.0
path_joined = false
material = SubResource("StandardMaterial3D_nkovu")
[node name="TerrainMarker" type="Node" parent="CSGPolygon3D"]
script = ExtResource("2_4f0hb")
type = 5

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=8 format=3 uid="uid://di7aql54lksn7"]
[gd_scene load_steps=9 format=3 uid="uid://di7aql54lksn7"]
[ext_resource type="PackedScene" uid="uid://bgdgd3lky5w60" path="res://assets/models/scenery/trees/palm_tree/palm_tree.gltf" id="1_o3thn"]
[ext_resource type="Script" path="res://src/world/terrain_marker.gd" id="2_1lamy"]
[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_bp5t6"]
data = PackedVector3Array(-0.6467, 5.2727, -3.6037, -0.7678, 3.663, -4.1571, 0.0705, 4.1529, -5.0529, 0.1793, 5.4514, -3.9613, 1.1035, 5.3325, -3.712, 0.2063, 5.6673, -3.3214, 0.2063, 5.6673, -3.3214, 1.1035, 5.3325, -3.712, 0.2526, 6.0382, -2.2225, -0.102, 1.5632, -4.5545, 0.9292, 3.4191, -4.4363, 0.0705, 4.1529, -5.0529, 0.0705, 4.1529, -5.0529, -0.7379, 3.4651, -4.2526, -0.102, 1.5632, -4.5545, 0.0705, 4.1529, -5.0529, 0.992, 3.6309, -4.3423, 1.1035, 5.3325, -3.712, 0.0705, 4.1529, -5.0529, 1.1035, 5.3325, -3.712, 0.1793, 5.4514, -3.9613, 0.0705, 4.1529, -5.0529, 0.1793, 5.4514, -3.9613, -0.6467, 5.2727, -3.6037, 0.2063, 5.6673, -3.3214, 0.2526, 6.0382, -2.2225, -0.4953, 5.4015, -3.3712, 0.2063, 5.6673, -3.3214, -0.6467, 5.2727, -3.6037, 0.1793, 5.4514, -3.9613)
@ -44,26 +45,35 @@ bones/10/rotation = Quaternion(0.183326, -0.237737, -0.342496, 0.890264)
bones/10/scale = Vector3(1, 1, 1)
bones/11/rotation = Quaternion(-0.13894, 0.0183908, 0.000355869, 0.99013)
[node name="StaticBody3D" type="StaticBody3D" parent="." index="2"]
collision_layer = 2147483649
[node name="LeafBody" type="StaticBody3D" parent="." index="2"]
[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D" index="0"]
[node name="TerrainMarker" type="Node" parent="LeafBody" index="0"]
script = ExtResource("2_1lamy")
type = 1
[node name="CollisionShape3D2" type="CollisionShape3D" parent="LeafBody" index="1"]
shape = SubResource("ConcavePolygonShape3D_bp5t6")
[node name="CollisionShape3D3" type="CollisionShape3D" parent="StaticBody3D" index="1"]
[node name="CollisionShape3D3" type="CollisionShape3D" parent="LeafBody" index="2"]
shape = SubResource("ConcavePolygonShape3D_j5qxc")
[node name="CollisionShape3D4" type="CollisionShape3D" parent="StaticBody3D" index="2"]
[node name="CollisionShape3D4" type="CollisionShape3D" parent="LeafBody" index="3"]
shape = SubResource("ConcavePolygonShape3D_eopyd")
[node name="CollisionShape3D5" type="CollisionShape3D" parent="StaticBody3D" index="3"]
[node name="CollisionShape3D5" type="CollisionShape3D" parent="LeafBody" index="4"]
shape = SubResource("ConcavePolygonShape3D_npgp7")
[node name="CollisionShape3D6" type="CollisionShape3D" parent="StaticBody3D" index="4"]
[node name="CollisionShape3D6" type="CollisionShape3D" parent="LeafBody" index="5"]
shape = SubResource("ConcavePolygonShape3D_xl1fh")
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" index="5"]
[node name="TrunkBody" type="StaticBody3D" parent="." index="3"]
[node name="TerrainMarker" type="Node" parent="TrunkBody" index="0"]
script = ExtResource("2_1lamy")
type = 7
[node name="CollisionShape3D" type="CollisionShape3D" parent="TrunkBody" index="1"]
shape = SubResource("ConcavePolygonShape3D_lol7j")
[node name="AnimationPlayer" parent="." index="3"]
[node name="AnimationPlayer" parent="." index="4"]
autoplay = "sway_circle"

View File

@ -64,25 +64,25 @@ void fragment() {
vec2 centered_uv = (UV - 0.5) * size;
float radius = length(centered_uv);
float angle = atan(centered_uv.y, centered_uv.x) + PI; // Add PI to fix left side cutoff
vec2 ray1 = vec2(angle * ray1_density + TIME * speed + seed + sin(angle * 3.0), radius * 2.0);
vec2 ray2 = vec2(angle * ray2_density + TIME * speed * 1.5 + seed + cos(angle * 2.0), radius * 2.0);
float cut = 1.0 - smoothstep(cutoff, cutoff + 0.2, radius);
ray1 *= cut;
ray2 *= cut;
float rays = hdr ?
float rays = hdr ?
noise(ray1) + (noise(ray2) * ray2_intensity) :
clamp(noise(ray1) + (noise(ray2) * ray2_intensity), 0., 1.);
rays *= smoothstep(spread, spread * 0.3, radius);
float core = smoothstep(0.2, 0.0, radius) * core_intensity;
rays += core;
vec4 gradient_color = texture(gradient, vec2(rays, 0.5));
vec3 shine = vec3(rays) * gradient_color.rgb;
float blur_amount = radius * 0.1;
vec2 blur_uv = SCREEN_UV + centered_uv * blur_amount;
vec4 blurred = texture(SCREEN_TEXTURE, blur_uv);

View File

@ -63,7 +63,8 @@ var _cached_vel: Vector3
func set_ball(ball: GameBall) -> void:
global_position = ball.global_position
linear_damp = ball.linear_damp
linear_damp = ball.terrain_physics.default.linear_damp
print("using linear damp: ", linear_damp)
func _process(_delta: float) -> void:

View File

@ -110,6 +110,57 @@ particles_anim_loop = false
material = SubResource("StandardMaterial3D_l1irr")
size = Vector2(0.1, 0.1)
[sub_resource type="Animation" id="Animation_mg6va"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Decal:size")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(2, 4, 2)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Decal:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("SprayParticles:emitting")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("BubbleParticles:emitting")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
[sub_resource type="Animation" id="Animation_ifddj"]
resource_name = "effect"
length = 2.0
@ -176,57 +227,6 @@ tracks/4/keys = {
}]
}
[sub_resource type="Animation" id="Animation_mg6va"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Decal:size")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(2, 4, 2)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Decal:modulate")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("SprayParticles:emitting")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("BubbleParticles:emitting")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_87fye"]
_data = {
"RESET": SubResource("Animation_mg6va"),

View File

@ -16,17 +16,7 @@ enum Type {
GLASS,
}
## We use the upper bits of collision layers to encode material data
const PHYSICAL_LAYERS := {
1 << 31: Type.ROUGH,
1 << 30: Type.SAND,
1 << 29: Type.WOOD,
1 << 28: Type.ROCK,
1 << 27: Type.METAL,
1 << 26: Type.GLASS,
1 << 25: Type.FAIRWAY,
1 << 24: Type.GREEN,
}
const DEFAULT_MATERIAL := Type.CONCRETE
## Get the `Terrain.Type` value which corresponds to the given Terrain3D texture ID.
@ -46,18 +36,18 @@ static func from_texture_id(tex_id: int) -> Type:
4:
return Type.ROCK
_:
return Type.NONE
return DEFAULT_MATERIAL
## Get the `Terrain.Type` value encoded in the given collision layer setting.
## Get the `Terrain.Type` value associated with a collision body.
##
## We use the upper bits in the collision layer to encode material data.
## Check the collision layer descriptions for more information.
static func from_physical_layer(collision_layer: int) -> Type:
for bit: int in PHYSICAL_LAYERS:
if collision_layer & bit:
return PHYSICAL_LAYERS[bit]
return Type.CONCRETE
## This returns the type stored in the first `TerrainMarker` direct child of the body.
## Use this method to set the terrain type of arbitrary bodies!
static func from_body(body: Node) -> Type:
for n: Node in body.get_children():
if n is TerrainMarker:
return (n as TerrainMarker).type
return DEFAULT_MATERIAL
## Get the `Terrain.Type` value at the given position in a Terrain3D node.
@ -69,3 +59,13 @@ static func at_position(global_position: Vector3, terrain3d: Terrain3D) -> Type:
else:
id = int(blend.x)
return from_texture_id(id)
## Get the Terrain.Type value at the given position for the given body.
##
## Position is only used when colliding with a Terrain3D node.
## Other bodies will have one material type for the entire body node.
static func from_collision(global_position: Vector3, body: Node) -> Type:
if body is Terrain3D:
return Terrain.at_position(global_position, body as Terrain3D)
return Terrain.from_body(body)

View File

@ -0,0 +1,4 @@
class_name TerrainMarker extends Node
## Marks the terrain type of a parent collision body.
@export var type: Terrain.Type

View File

@ -1,32 +1,20 @@
[gd_scene load_steps=24 format=3 uid="uid://cwnwcd8kushl3"]
[gd_scene load_steps=22 format=3 uid="uid://cwnwcd8kushl3"]
[ext_resource type="Script" path="res://src/world/world.gd" id="1_ybjyx"]
[ext_resource type="Script" path="res://src/player/world_player.gd" id="2_e743i"]
[ext_resource type="Script" path="res://src/ui/world_ui.gd" id="2_imewa"]
[ext_resource type="PackedScene" uid="uid://ciqd8r8yt00y0" path="res://levels/mall/mall.tscn" id="2_u4xvm"]
[ext_resource type="PackedScene" uid="uid://bm2o3mex10v11" path="res://levels/debug_level/debug_level.tscn" id="2_l08a0"]
[ext_resource type="Resource" uid="uid://crock3revdn73" path="res://src/player/debug_player.tres" id="3_pyw81"]
[ext_resource type="Resource" uid="uid://c1pnqsddvey3m" path="res://src/equipment/clubs/drivers/debug_driver.tres" id="5_28hal"]
[ext_resource type="Script" path="res://src/world/play_manager/round_robin_manager.gd" id="5_h6mje"]
[ext_resource type="Script" path="res://src/world/play_manager/practice_manager.gd" id="5_yk526"]
[ext_resource type="PackedScene" uid="uid://byvjsvavbg5xe" path="res://src/ui/menus/pause_menu/pause_menu.tscn" id="7_0gd42"]
[ext_resource type="PackedScene" uid="uid://biokiug3e0ipk" path="res://src/ui/shot_hud/death_alert.tscn" id="8_fuyxc"]
[ext_resource type="PackedScene" uid="uid://dwyy7tt3nose1" path="res://src/ui/shot_hud/winner_alert.tscn" id="9_lln1k"]
[ext_resource type="FontFile" uid="uid://dwy8k2w7vt64x" path="res://assets/fonts/classic-better-vcr/classic-better-vcr.otf" id="11_uv5b5"]
[ext_resource type="Shader" path="res://src/shaders/vcr_distortion.gdshader" id="11_xag32"]
[sub_resource type="Resource" id="Resource_mbhdy"]
script = ExtResource("2_e743i")
life = 3.0
name = "DeadGfolfer"
color = Color(1, 0.439216, 0.439216, 1)
driver = ExtResource("5_28hal")
_balls = {
1: -1,
2: -1
}
[sub_resource type="Resource" id="Resource_rdjhi"]
script = ExtResource("5_h6mje")
players = Array[ExtResource("2_e743i")]([ExtResource("3_pyw81"), SubResource("Resource_mbhdy")])
[sub_resource type="Resource" id="Resource_hpydy"]
script = ExtResource("5_yk526")
players = Array[ExtResource("2_e743i")]([ExtResource("3_pyw81")])
[sub_resource type="Animation" id="Animation_6350f"]
length = 0.001
@ -167,8 +155,8 @@ _data = {
[node name="World" type="Node" groups=["WorldGroup"]]
script = ExtResource("1_ybjyx")
initial_level = ExtResource("2_u4xvm")
manager = SubResource("Resource_rdjhi")
initial_level = ExtResource("2_l08a0")
manager = SubResource("Resource_hpydy")
[node name="Level" type="Node3D" parent="."]
unique_name_in_owner = true