mirror of
https://github.com/CrispyPin/ovr-utils.git
synced 2024-11-10 02:40:25 +01:00
update grab visualisation properly if overlay was already touched when setting changed
This commit is contained in:
parent
0ad307d194
commit
eda8c8c06c
3 changed files with 18 additions and 4 deletions
|
@ -7,9 +7,9 @@ signal trigger_off# trigger released
|
||||||
|
|
||||||
var touch_state := false
|
var touch_state := false
|
||||||
var trigger_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 := ""
|
var active_controller := ""
|
||||||
# reference to the area node thats used for touch
|
# reference to the area node thats used for touch
|
||||||
var _overlay_area = preload("res://addons/openvr_overlay/interaction/OverlayArea.tscn").instance()
|
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("offset_changed", self, "_update_offset")
|
||||||
get_parent().connect("target_changed", self, "_update_target")
|
get_parent().connect("target_changed", self, "_update_target")
|
||||||
|
|
||||||
|
OverlayManager.connect("grab_mode_changed", self, "update_selection")
|
||||||
|
|
||||||
_update_width()
|
_update_width()
|
||||||
_update_offset()
|
_update_offset()
|
||||||
_update_target()
|
_update_target()
|
||||||
|
@ -57,7 +59,7 @@ func _on_OverlayArea_entered(body: Node) -> void:
|
||||||
return
|
return
|
||||||
touch_state = true
|
touch_state = true
|
||||||
active_controller = body.get_parent().name
|
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")
|
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)
|
# TODO revert to other controller if both were touching (edge case)
|
||||||
active_controller = ""
|
active_controller = ""
|
||||||
touch_state = false
|
touch_state = false
|
||||||
get_parent().get_node("OverlayViewport/Selected").visible = false
|
update_selection()
|
||||||
emit_signal("touch_off")
|
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():
|
func _update_width():
|
||||||
var ratio = OverlayInit.ovr_interface.get_render_targetsize()
|
var ratio = OverlayInit.ovr_interface.get_render_targetsize()
|
||||||
var extents = get_parent().width_meters * 0.5
|
var extents = get_parent().width_meters * 0.5
|
||||||
|
|
|
@ -2,6 +2,7 @@ extends Node
|
||||||
|
|
||||||
signal added_overlay
|
signal added_overlay
|
||||||
signal removed_overlay
|
signal removed_overlay
|
||||||
|
signal grab_mode_changed
|
||||||
|
|
||||||
var loaded := false
|
var loaded := false
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ func _remove_overlay_from_list(name):
|
||||||
|
|
||||||
func _on_GrabMode_toggled(state: bool) -> void:
|
func _on_GrabMode_toggled(state: bool) -> void:
|
||||||
Settings.s.grab_mode = state
|
Settings.s.grab_mode = state
|
||||||
|
OverlayManager.emit_signal("grab_mode_changed")
|
||||||
|
|
||||||
|
|
||||||
func _on_ShowOverlays_toggled(state: bool) -> void:
|
func _on_ShowOverlays_toggled(state: bool) -> void:
|
||||||
|
|
Loading…
Reference in a new issue