Lot of tweaks of the physics engine for much smoother sim

This commit is contained in:
Lucas 2025-03-25 09:52:48 +01:00
parent c63ead5e9d
commit 228f6bff9c
No known key found for this signature in database
9 changed files with 81 additions and 51 deletions

View file

@ -3,6 +3,7 @@ class_name BuyancyProbe
## How much force is applied upward
@export var float_strength: float = 10.0
@export var max_float_force:float = 500.0
var currentdepth:float
@export_category("Debug")
@ -34,10 +35,11 @@ func _ready() -> void:
func _physics_process(_delta: float) -> void:
var depth = get_wave_height(global_position,Oceantime) - global_position.y
print(depth)
if depth > 0.0:
var float_force = get_parent().mass
get_parent().apply_force(Vector3.UP * gravity * depth * float_force ,global_position-get_parent().global_position)
#print(depth)
if depth > 0.0 && get_parent() != null:
var parentRigid = get_parent()
var float_force = parentRigid.mass * float_strength
parentRigid.apply_force(Vector3.UP * clamp(gravity * depth * float_force,-max_float_force,max_float_force) ,global_position-parentRigid.global_position)
func _process(_delta: float) -> void:
if OceanNode != null:

View file

@ -52,7 +52,7 @@ shader_parameter/roughness = 0.02
shader_parameter/texture_normal = SubResource("NoiseTexture2D_d50os")
shader_parameter/texture_normal2 = SubResource("NoiseTexture2D_ca8p6")
shader_parameter/wave = SubResource("NoiseTexture2D_cuet1")
shader_parameter/wave_time = 21.1359
shader_parameter/wave_time = 25.0167
shader_parameter/wave_direction = Vector2(2, 0)
shader_parameter/wave_2_direction = Vector2(0, 0.9)
shader_parameter/time_scale = 0.02

View file

@ -1,6 +1,6 @@
[gd_resource type="PlaneMesh" load_steps=2 format=3 uid="uid://c82xwqk7ljku0"]
[ext_resource type="Material" uid="uid://cf3lxmfb2d7c8" path="res://Ocean/OceanShaderl.tres" id="1_vta1j"]
[ext_resource type="Material" uid="uid://cf3lxmfb2d7c8" path="res://Ocean/OceanShader_Calm.tres" id="1_vta1j"]
[resource]
resource_name = "OceanTile_Main"

View file

@ -1,6 +1,6 @@
[gd_resource type="PlaneMesh" load_steps=2 format=3 uid="uid://wes0mbjy8mno"]
[ext_resource type="Material" uid="uid://cf3lxmfb2d7c8" path="res://Ocean/OceanShaderl.tres" id="1_0jqxu"]
[ext_resource type="Material" uid="uid://cf3lxmfb2d7c8" path="res://Ocean/OceanShader_Calm.tres" id="1_0jqxu"]
[resource]
resource_name = "OceanTile_Main"

View file

@ -1,6 +1,6 @@
[gd_resource type="PlaneMesh" load_steps=2 format=3 uid="uid://coql6l6v4cybp"]
[ext_resource type="Material" uid="uid://cf3lxmfb2d7c8" path="res://Ocean/OceanShaderl.tres" id="1_4jiw1"]
[ext_resource type="Material" uid="uid://cf3lxmfb2d7c8" path="res://Ocean/OceanShader_Calm.tres" id="1_4jiw1"]
[resource]
resource_name = "OceanTile_Main"

11
Ocean/WeatherManager.gd Normal file
View file

@ -0,0 +1,11 @@
extends Node
class_name WeatherManager
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass

View file

@ -0,0 +1 @@
uid://3ympc26kcuul

View file

@ -1,10 +1,11 @@
[gd_scene load_steps=13 format=3 uid="uid://bhwuawppmqk4"]
[gd_scene load_steps=14 format=3 uid="uid://bhwuawppmqk4"]
[ext_resource type="Script" uid="uid://cdnrxp6nu1wor" path="res://Ocean/ocean.gd" id="1_xncsh"]
[ext_resource type="PlaneMesh" uid="uid://wes0mbjy8mno" path="res://Ocean/OceanTile_PlaneMesh_Main.tres" id="2_7sjql"]
[ext_resource type="PlaneMesh" uid="uid://coql6l6v4cybp" path="res://Ocean/OceanTile_PlaneMesh_Near.tres" id="2_ydaaq"]
[ext_resource type="PlaneMesh" uid="uid://c82xwqk7ljku0" path="res://Ocean/OceanTile_PlaneMesh_Far.tres" id="3_spien"]
[ext_resource type="Script" uid="uid://cnfkxclrq0i0s" path="res://Boats/buyancy_probe.gd" id="5_spien"]
[ext_resource type="Script" uid="uid://3ympc26kcuul" path="res://Ocean/WeatherManager.gd" id="6_kisq7"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_xncsh"]
sky_top_color = Color(0.191699, 0.357914, 1, 1)
@ -310,28 +311,28 @@ shape = SubResource("BoxShape3D_kisq7")
[node name="BuyancyProbe" type="Marker3D" parent="Boat"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, -0.5, 2)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe2" type="Marker3D" parent="Boat"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, -0.5, -2)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe3" type="Marker3D" parent="Boat"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, -0.5, 2)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe4" type="Marker3D" parent="Boat"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, -0.5, -2)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
@ -349,28 +350,28 @@ shape = SubResource("BoxShape3D_kisq7")
[node name="BuyancyProbe" type="Marker3D" parent="Boat2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, -0.5, 2)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe2" type="Marker3D" parent="Boat2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, -0.5, -2)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe3" type="Marker3D" parent="Boat2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, -0.5, 2)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe4" type="Marker3D" parent="Boat2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, -0.5, -2)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
@ -387,28 +388,28 @@ shape = SubResource("BoxShape3D_0g14k")
[node name="BuyancyProbe" type="Marker3D" parent="Boat3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe2" type="Marker3D" parent="Boat3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe3" type="Marker3D" parent="Boat3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe4" type="Marker3D" parent="Boat3"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
@ -425,34 +426,34 @@ shape = SubResource("BoxShape3D_0g14k")
[node name="BuyancyProbe" type="Marker3D" parent="Boat4"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe2" type="Marker3D" parent="Boat4"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe3" type="Marker3D" parent="Boat4"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe4" type="Marker3D" parent="Boat4"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="Boat5" type="RigidBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.0411781, -0.999152, 0, 0.999152, 0.0411781, 4.62591, 0.543982, 2.98498)
mass = 2.0
mass = 5.0
[node name="MeshInstance3D" type="MeshInstance3D" parent="Boat5"]
mesh = SubResource("BoxMesh_kisq7")
@ -463,34 +464,34 @@ shape = SubResource("BoxShape3D_0g14k")
[node name="BuyancyProbe" type="Marker3D" parent="Boat5"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe2" type="Marker3D" parent="Boat5"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe3" type="Marker3D" parent="Boat5"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe4" type="Marker3D" parent="Boat5"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="Boat6" type="RigidBody3D" parent="."]
transform = Transform3D(0.676837, -0.735508, -0.0303125, 0, 0.0411781, -0.999152, 0.736133, 0.676263, 0.0278709, 7.3866, 0.543982, 3.8094)
mass = 2.0
mass = 5.0
[node name="MeshInstance3D" type="MeshInstance3D" parent="Boat6"]
mesh = SubResource("BoxMesh_kisq7")
@ -501,28 +502,28 @@ shape = SubResource("BoxShape3D_0g14k")
[node name="BuyancyProbe" type="Marker3D" parent="Boat6"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe2" type="Marker3D" parent="Boat6"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe3" type="Marker3D" parent="Boat6"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe4" type="Marker3D" parent="Boat6"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
@ -539,28 +540,28 @@ shape = SubResource("BoxShape3D_0g14k")
[node name="BuyancyProbe" type="Marker3D" parent="Boat7"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe2" type="Marker3D" parent="Boat7"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe3" type="Marker3D" parent="Boat7"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe4" type="Marker3D" parent="Boat7"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
@ -577,28 +578,28 @@ shape = SubResource("BoxShape3D_0g14k")
[node name="BuyancyProbe" type="Marker3D" parent="Boat8"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe2" type="Marker3D" parent="Boat8"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe3" type="Marker3D" parent="Boat8"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe4" type="Marker3D" parent="Boat8"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
@ -615,28 +616,28 @@ shape = SubResource("BoxShape3D_0g14k")
[node name="BuyancyProbe" type="Marker3D" parent="Boat9"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe2" type="Marker3D" parent="Boat9"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe3" type="Marker3D" parent="Boat9"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe4" type="Marker3D" parent="Boat9"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
@ -653,31 +654,34 @@ shape = SubResource("BoxShape3D_0g14k")
[node name="BuyancyProbe" type="Marker3D" parent="Boat10"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe2" type="Marker3D" parent="Boat10"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, -0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe3" type="Marker3D" parent="Boat10"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="BuyancyProbe4" type="Marker3D" parent="Boat10"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4, 0.5, 0)
script = ExtResource("5_spien")
float_strength = 5.0
float_strength = 2.0
show_probe = true
metadata/_custom_type_script = "uid://cnfkxclrq0i0s"
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(0.817859, -0.4492, 0.35962, 0, 0.62497, 0.780649, -0.575419, -0.63846, 0.511137, 8.74584, 11.0902, 11.4458)
current = true
[node name="Node" type="Node" parent="."]
script = ExtResource("6_kisq7")

View file

@ -11,6 +11,8 @@ config_version=5
[application]
config/name="ChatBoat"
config/version="0.1"
config/tags=PackedStringArray("games")
run/main_scene="uid://bhwuawppmqk4"
config/features=PackedStringArray("4.4", "Forward Plus")
config/icon="res://icon.svg"
@ -28,6 +30,16 @@ window/vsync/vsync_mode=0
Ocean="Oceans"
[physics]
3d/run_on_separate_thread=true
3d/physics_engine="Jolt Physics"
jolt_physics_3d/simulation/bounce_velocity_threshold=2.0
3d/default_linear_damp=0.5
3d/default_angular_damp=1.5
3d/sleep_threshold_angular=0.174533
common/physics_interpolation=true
[rendering]
global_illumination/gi/use_half_resolution=true