Suddenly remembered high school physics lol

This commit is contained in:
Rob Kelly 2024-12-11 20:27:26 -07:00
parent e9abc96002
commit ba7d0024f6
4 changed files with 87 additions and 71 deletions

View File

@ -45,6 +45,21 @@ streams_count = 2
stream_0/stream = ExtResource("11_i5g55")
stream_1/stream = ExtResource("12_0losp")
[sub_resource type="Animation" id="Animation_ll5da"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AudioStreamPlayer3D:playing")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
[sub_resource type="Animation" id="Animation_dlkgq"]
resource_name = "death"
length = 8.0
@ -140,21 +155,6 @@ tracks/5/keys = {
"values": [true]
}
[sub_resource type="Animation" id="Animation_ll5da"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AudioStreamPlayer3D:playing")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_kc803"]
_data = {
"RESET": SubResource("Animation_ll5da"),
@ -574,8 +574,8 @@ unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 0.707107, -0.707107, 0, 0.707107, 0.707107, 0, -0.02, 0)
visible = false
initial_speed = 50.0
time_step = 0.01
max_steps = 800
time_step = 0.1
max_steps = 100
[node name="ProjectedTarget" parent="ArrowPivot/ShotProjection" instance=ExtResource("6_mynqj")]

View File

@ -8,7 +8,7 @@ uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_n
void fragment() {
vec4 source = texture(screen_texture, SCREEN_UV);
COLOR.rgb = mix(vec3(dot(source.rgb, vec3(0.299, 0.587, 0.114))), source.rgb, saturation);
COLOR.a = source.a;
}

View File

@ -36,10 +36,19 @@ const PUTT_ATTRITION := 0.8325 # green?
## If disabled, global gravity will be used instead.
@export var check_gravity := true
## Improves performance by caching gravity at each point along the projection.
## This can cause problems if there is a moving gravity field.
@export var cache_gravity := true
var _tick_counter := 0
var _debug_points: Array[Vector3] = []
var _gravity_cache: Array[Vector3] = []
var _cached_pos: Vector3
var _cached_vel: Vector3
@onready var polygon: CSGPolygon3D = %Polygon
@onready var path: Path3D = %Path
@ -73,6 +82,11 @@ func _process(_delta: float) -> void:
var pos := global_position
var vel := -global_basis.z * initial_speed
if not cache_gravity or pos != _cached_pos or vel != _cached_vel:
_gravity_cache = []
_cached_pos = pos
_cached_vel = vel
var final_normal: Vector3
for t in range(0, max_steps):
@ -82,11 +96,13 @@ func _process(_delta: float) -> void:
# Get local gravity if enabled
var local_gravity := gravity * gravity_vec
if check_gravity and Game.settings.projection_gravity:
local_gravity = _get_gravity(pos)
if t >= len(_gravity_cache):
_gravity_cache.append(_get_gravity(pos))
local_gravity = _gravity_cache[t]
# Integrate projectile path
var next_pos := pos + vel * time_step + 0.5 * local_gravity * time_step * time_step
vel += local_gravity * time_step
var next_pos := pos + vel * time_step
# Collision
if check_collision and Game.settings.projection_collisions:

View File

@ -35,6 +35,57 @@ point_count = 2
curve_x = SubResource("Curve_ndj60")
curve_y = SubResource("Curve_nld14")
[sub_resource type="Animation" id="Animation_4aged"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AlertContainer/GradientBG:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("AlertContainer/Text/Subheading: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(".:modulate")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Desaturator:material:shader_parameter/saturation")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [1.0]
}
[sub_resource type="Animation" id="Animation_l6yhv"]
resource_name = "display"
length = 8.0
@ -116,57 +167,6 @@ tracks/5/keys = {
"values": [1.0, 0.0, 0.0, 1.0]
}
[sub_resource type="Animation" id="Animation_4aged"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("AlertContainer/GradientBG:modulate")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("AlertContainer/Text/Subheading: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(".:modulate")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Desaturator:material:shader_parameter/saturation")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [1.0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_em7mg"]
_data = {
"RESET": SubResource("Animation_4aged"),