Minor guide and rulers performance boost

Got rid of their _process methods, Guides have input instead, and the rulers get updated when the camera zoom or offset change.
This commit is contained in:
OverloadedOrama 2020-04-20 18:52:05 +03:00
parent 06d19c8e48
commit b21455cfd0
6 changed files with 34 additions and 30 deletions

View file

@ -9,22 +9,12 @@ var minor_subdivision := 4
var first : Vector2
var last : Vector2
onready var _prev_camera_offset: Vector2 = Global.camera.offset
onready var _prev_camera_zoom: Vector2 = Global.camera.zoom
func _ready() -> void:
Global.main_viewport.connect("item_rect_changed", self, "update")
# warning-ignore:unused_argument
func _process(delta : float) -> void:
if Global.camera.offset != _prev_camera_offset:
_prev_camera_offset = Global.camera.offset
update()
if Global.camera.zoom != _prev_camera_zoom:
_prev_camera_zoom = Global.camera.zoom
update()
#Code taken and modified from Godot's source code
# Code taken and modified from Godot's source code
func _draw() -> void:
var transform := Transform2D()
var ruler_transform := Transform2D()
@ -68,6 +58,7 @@ func _draw() -> void:
else:
draw_line(Vector2(RULER_WIDTH * 0.66, position.y), Vector2(RULER_WIDTH, position.y), Color.white)
func _on_VerticalRuler_pressed() -> void:
if !Global.show_guides:
return