update grab visualisation properly if overlay was already touched when setting changed

This commit is contained in:
Crispy 2021-06-06 22:46:52 +02:00
parent 0ad307d194
commit eda8c8c06c
3 changed files with 18 additions and 4 deletions

View file

@ -7,9 +7,9 @@ signal trigger_off# trigger released
var touch_state := false
var trigger_state := false
var grab_mode := false
var grab_mode := false setget set_grab_mode
# controller that currently the trigger down
# controller that currently has the trigger down
var active_controller := ""
# reference to the area node thats used for touch
var _overlay_area = preload("res://addons/openvr_overlay/interaction/OverlayArea.tscn").instance()
@ -35,6 +35,8 @@ func _ready() -> void:
get_parent().connect("offset_changed", self, "_update_offset")
get_parent().connect("target_changed", self, "_update_target")
OverlayManager.connect("grab_mode_changed", self, "update_selection")
_update_width()
_update_offset()
_update_target()
@ -57,7 +59,7 @@ func _on_OverlayArea_entered(body: Node) -> void:
return
touch_state = true
active_controller = body.get_parent().name
get_parent().get_node("OverlayViewport/Selected").visible = Settings.s.grab_mode or grab_mode
update_selection()
emit_signal("touch_on")
@ -67,10 +69,20 @@ func _on_OverlayArea_exited(body: Node) -> void:
# TODO revert to other controller if both were touching (edge case)
active_controller = ""
touch_state = false
get_parent().get_node("OverlayViewport/Selected").visible = false
update_selection()
emit_signal("touch_off")
func update_selection():
var sel = touch_state and (Settings.s.grab_mode or grab_mode)
get_parent().get_node("OverlayViewport/Selected").visible = sel
func set_grab_mode(state: bool) -> void:
grab_mode = state
update_selection()
func _update_width():
var ratio = OverlayInit.ovr_interface.get_render_targetsize()
var extents = get_parent().width_meters * 0.5

View file

@ -2,6 +2,7 @@ extends Node
signal added_overlay
signal removed_overlay
signal grab_mode_changed
var loaded := false

View file

@ -22,6 +22,7 @@ func _remove_overlay_from_list(name):
func _on_GrabMode_toggled(state: bool) -> void:
Settings.s.grab_mode = state
OverlayManager.emit_signal("grab_mode_changed")
func _on_ShowOverlays_toggled(state: bool) -> void: