Skip to content

Commit

Permalink
refactor: remove lod scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
florianvazelle committed Dec 30, 2023
1 parent 4e77e48 commit 947df83
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 174 deletions.
32 changes: 3 additions & 29 deletions scenes/marble.tscn
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
[gd_scene load_steps=12 format=3 uid="uid://4g5aorgnd1hu"]
[gd_scene load_steps=9 format=3 uid="uid://4g5aorgnd1hu"]

[ext_resource type="Script" path="res://scripts/marble.gd" id="1"]
[ext_resource type="Material" uid="uid://5gxm1ehx7waa" path="res://resources/materials/xray_marble.tres" id="2"]
[ext_resource type="Script" path="res://scripts/lod/lod_spatial.gd" id="2_5e2c6"]
[ext_resource type="Script" path="res://scripts/roll_sound.gd" id="4"]
[ext_resource type="AudioStream" uid="uid://3hc6gfblh3gf" path="res://assets/sounds/sfx/roll.wav" id="4_d1o80"]
[ext_resource type="AudioStream" uid="uid://b7ga03rbxi6qs" path="res://assets/sounds/sfx/hit.wav" id="6_iicuw"]
[ext_resource type="AudioStream" uid="uid://c44julexev4dj" path="res://assets/sounds/explosion/bomb.ogg" id="7_1gve1"]

[sub_resource type="SphereMesh" id="1"]
radius = 0.3
height = 0.6

[sub_resource type="SphereMesh" id="5"]
radius = 0.3
height = 0.6
radial_segments = 32
rings = 16

[sub_resource type="SphereMesh" id="4"]
radius = 0.3
height = 0.6
Expand All @@ -33,24 +22,9 @@ max_contacts_reported = 10000
contact_monitor = true
script = ExtResource("1")

[node name="LODSpatial" type="Node3D" parent="."]
script = ExtResource("2_5e2c6")

[node name="Ball-0" type="MeshInstance3D" parent="LODSpatial"]
mesh = SubResource("1")
skeleton = NodePath("../..")
surface_material_override/0 = ExtResource("2")

[node name="Ball-1" type="MeshInstance3D" parent="LODSpatial"]
visible = false
mesh = SubResource("5")
skeleton = NodePath("../..")
surface_material_override/0 = ExtResource("2")

[node name="Ball-2" type="MeshInstance3D" parent="LODSpatial"]
visible = false
[node name="Ball" type="MeshInstance3D" parent="."]
unique_name_in_owner = true
mesh = SubResource("4")
skeleton = NodePath("../..")
surface_material_override/0 = ExtResource("2")

[node name="CollisionShape" type="CollisionShape3D" parent="."]
Expand Down
51 changes: 0 additions & 51 deletions scripts/lod/lod_particles.gd

This file was deleted.

85 changes: 0 additions & 85 deletions scripts/lod/lod_spatial.gd

This file was deleted.

18 changes: 9 additions & 9 deletions scripts/marble.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var _checkpoint_count := 0
@onready var _name := get_node(^"%Name") as Label3D
@onready var _bomb_sound = get_node(^"%BombSound")
@onready var _score = get_node(^"%Score")
@onready var _ball_mesh := get_node(^"%Ball")


func _ready() -> void:
Expand All @@ -23,16 +24,15 @@ func _ready() -> void:

# Set material color
var color = Color(randf(), randf(), randf())
for i in range(3):
var x_ray_material: StandardMaterial3D = (
get_node("LODSpatial/Ball-%d" % i).get_active_material(0)
)
x_ray_material.set_albedo(color)
var toon_material: StandardMaterial3D = x_ray_material.get_next_pass()
toon_material.set_albedo(color)
var x_ray_material: StandardMaterial3D = (
_ball_mesh.get_active_material(0)
)
x_ray_material.set_albedo(color)
var toon_material: StandardMaterial3D = x_ray_material.get_next_pass()
toon_material.set_albedo(color)
# toon_material.set_shader_parameter(&"albedo", color)
x_ray_material.set_next_pass(toon_material)
get_node("LODSpatial/Ball-%d" % i).set_surface_override_material(0, x_ray_material)
x_ray_material.set_next_pass(toon_material)
_ball_mesh.set_surface_override_material(0, x_ray_material)

# Set collision mask
var collision_enabled = SettingsManager.get_value(&"marbles", &"collision_enabled") as bool
Expand Down

0 comments on commit 947df83

Please sign in to comment.