fix performance

This commit is contained in:
Nitwel 2024-01-30 17:47:38 +01:00
parent c011901853
commit 01397190ee
8 changed files with 31 additions and 16 deletions

View File

@ -9,7 +9,9 @@ func _ready():
ray.set_collision_mask_value(5, true)
get_parent().add_child.call_deferred(ray)
func _process(_delta):
EventSystem.on_slow_tick.connect(_slow_tick)
func _slow_tick(_delta):
ray.target_position = get_parent().to_local(player_camera.global_position)
get_parent().visible = ray.is_colliding() == false

View File

@ -6,6 +6,7 @@ const RoomType = preload("./room/room.gd")
@onready var levels = $Levels
@onready var collision_shape = $Levels/CollisionShape3D
@onready var align_reference = $AlignReference
@onready var animate_timer = $AnimateTimer
var fixing_reference: bool = false
var editing_room: RoomType = null
@ -22,9 +23,11 @@ func _ready():
)
func _physics_process(delta):
levels.scale.x = lerp(levels.scale.x, target_size, 10.0 * delta)
levels.scale.y = lerp(levels.scale.y, target_size, 10.0 * delta)
levels.scale.z = lerp(levels.scale.z, target_size, 10.0 * delta)
if animate_timer.is_stopped() == false:
levels.scale.x = lerp(levels.scale.x, target_size, 10.0 * delta)
levels.scale.y = lerp(levels.scale.y, target_size, 10.0 * delta)
levels.scale.z = lerp(levels.scale.z, target_size, 10.0 * delta)
func update_house():
for old_room in get_rooms(0):
@ -210,6 +213,7 @@ func update_mini_view():
levels.position = Vector3(0, 0, 0)
target_size = 0.1 if mini_view else 1.0
animate_timer.start()
for room in get_rooms(0):
room.state_machine.change_to("Mini" if mini_view else "View")

View File

@ -25,3 +25,6 @@ lock_rotation = true
[node name="AlignReference" parent="." instance=ExtResource("3_e1tcn")]
visible = false
disabled = true
[node name="AnimateTimer" type="Timer" parent="."]
one_shot = true

View File

@ -1,8 +1,7 @@
[gd_scene load_steps=10 format=3 uid="uid://bswgmclohuqui"]
[gd_scene load_steps=9 format=3 uid="uid://bswgmclohuqui"]
[ext_resource type="Script" path="res://content/system/house/room/room.gd" id="1_fccq0"]
[ext_resource type="Script" path="res://content/functions/clickable.gd" id="1_ugebq"]
[ext_resource type="Material" uid="uid://bbx6fv7jq50tr" path="res://content/system/house/room/walls.tres" id="3_al1ev"]
[ext_resource type="Script" path="res://lib/utils/state_machine/state_machine.gd" id="4_nbbo6"]
[ext_resource type="Script" path="res://content/system/house/room/states/mini.gd" id="6_g4qca"]
[ext_resource type="Script" path="res://content/system/house/room/states/view.gd" id="6_g066t"]
@ -27,10 +26,8 @@ shape = SubResource("WorldBoundaryShape3D_08sv0")
script = ExtResource("1_ugebq")
[node name="WallMesh" type="MeshInstance3D" parent="."]
material_override = ExtResource("3_al1ev")
[node name="CeilingMesh" type="MeshInstance3D" parent="."]
material_override = ExtResource("3_al1ev")
[node name="WallCollisions" type="Node3D" parent="."]

View File

@ -6,7 +6,7 @@ const walls_material = preload("../walls.tres")
func _on_enter():
room.wall_mesh.visible = true
room.ceiling_mesh.visible = true
room.ceiling_mesh.visible = false
room.wall_mesh.material_override = walls_mini_material
room.room_ceiling.get_node("CollisionShape3D").disabled = true
room.room_floor.get_node("CollisionShape3D").disabled = true

View File

@ -9,8 +9,8 @@ func _on_enter():
if room_store == null || room_store.corners.size() < 3:
return
room.wall_mesh.visible = true
room.ceiling_mesh.visible = true
room.wall_mesh.visible = false
room.ceiling_mesh.visible = false
room.wall_mesh.mesh = Room.generate_wall_mesh(room_store)
@ -37,13 +37,8 @@ func _on_enter():
static_body.collision_mask = 0
static_body.add_child(collision)
room.wall_collisions.add_child(static_body)
room.wall_mesh.visible = true
func _on_leave():
room.wall_mesh.visible = false
room.ceiling_mesh.visible = false
room.room_ceiling.get_node("CollisionShape3D").disabled = true
room.room_floor.get_node("CollisionShape3D").disabled = true

View File

@ -2,6 +2,7 @@ extends Node
const FN_PREFIX = "_on_"
const SIGNAL_PREFIX = "on_"
const SLOW_TICK = 0.1
# Interaction Events
signal on_click(event: EventPointer)
@ -30,6 +31,15 @@ signal on_touch_leave(event: EventTouch)
signal on_notify(event: EventNotify)
signal on_slow_tick(delta: float)
var _slow_tick: float = 0.0
func _physics_process(delta):
_slow_tick += delta
if _slow_tick >= SLOW_TICK:
on_slow_tick.emit(_slow_tick)
_slow_tick -= SLOW_TICK
var _active_node: Node = null
func emit(type: String, event: Event):

View File

@ -53,6 +53,10 @@ theme/custom_font="res://assets/fonts/ui_font_500.tres"
3d_physics/layer_4="physics"
3d_physics/layer_5="room"
[physics]
common/physics_ticks_per_second=30
[rendering]
renderer/rendering_method="mobile"