Skip to content
Snippets Groups Projects
Commit eb29c6e3 authored by Florent Berthaut's avatar Florent Berthaut
Browse files

Fixed passthrough toggling

parent 51d73838
No related branches found
No related tags found
No related merge requests found
...@@ -77,22 +77,7 @@ func _ready(): ...@@ -77,22 +77,7 @@ func _ready():
_xr_interface.connect("session_visible",_on_xr_session) _xr_interface.connect("session_visible",_on_xr_session)
_is_2D = false _is_2D = false
print("IVMI : Initialised OpenXR Interface") print("IVMI : Initialised OpenXR Interface")
if _open_xr_passthrough : set_passthrough(_open_xr_passthrough)
get_viewport().transparent_bg=true
var pt : bool = true
if _xr_interface.is_passthrough_supported():
if !_xr_interface.start_passthrough():
pt=false
else:
var modes = _xr_interface.get_supported_environment_blend_modes()
if _xr_interface.XR_ENV_BLEND_MODE_ALPHA_BLEND in modes:
_xr_interface.set_environment_blend_mode(_xr_interface.XR_ENV_BLEND_MODE_ALPHA_BLEND)
else:
pt=false
if pt :
print("IVMI : Activated OpenXR Passthrough")
else:
print("Error : Could not activate OpenXR Passthrough")
else: else:
print("Error : Could not initialize OpenXR interface") print("Error : Could not initialize OpenXR interface")
...@@ -134,36 +119,6 @@ func _ready(): ...@@ -134,36 +119,6 @@ func _ready():
# Start network # Start network
_start_network() _start_network()
func _start_network() -> void :
_is_connected=false
if _network_mode!=NetMode.None :
if _network_protocol==NetProto.Enet :
match _network_mode :
NetMode.Server :
# init server
var peer = ENetMultiplayerPeer.new()
peer.create_server(_server_port)
multiplayer.multiplayer_peer = peer
_on_network_ready()
print("IVMI : Starting Server")
NetMode.Client :
if _server_ip!="" :
_on_found_server(_server_ip, _server_port)
#start discov
_network_discov = IvmiDiscov.new()
if _network_mode==NetMode.Server :
_network_discov.set_server(_server_port)
add_child(_network_discov)
_network_discov.connect("found_server",Callable(self,"_on_found_server"))
_network_discov.connect("timeout",Callable(self,"_on_timeout"))
_network_discov.start()
# TODO trying to fix resume error on quest, not working yet ...
func _on_xr_session() :
get_viewport().use_xr = true
_start_network()
func _process(delta) : func _process(delta) :
if is_inside_tree() : if is_inside_tree() :
...@@ -208,8 +163,71 @@ func _process(delta) : ...@@ -208,8 +163,71 @@ func _process(delta) :
# --------XR-----------------
func set_passthrough(activate : bool) -> void :
if _xr_interface :
get_viewport().transparent_bg=true
var pt : bool = true
if _xr_interface.is_passthrough_supported():
if activate :
if !_xr_interface.start_passthrough():
pt=false
else :
_xr_interface.stop_passthrough()
else:
if activate :
var modes = _xr_interface.get_supported_environment_blend_modes()
if _xr_interface.XR_ENV_BLEND_MODE_ALPHA_BLEND in modes:
_xr_interface.set_environment_blend_mode(_xr_interface.XR_ENV_BLEND_MODE_ALPHA_BLEND)
else:
pt=false
else :
_xr_interface.set_environment_blend_mode(_xr_interface.XR_ENV_BLEND_MODE_OPAQUE)
if activate :
if pt :
print("IVMI : Activated OpenXR Passthrough")
else:
print("Error : Could not activate OpenXR Passthrough")
else :
print("IVMI : Deactivated OpenXR Passthrough")
func _on_xr_session() :
get_viewport().use_xr = true
_start_network()
# --------Network----------------- # --------Network-----------------
func _start_network() -> void :
_is_connected=false
if _network_mode!=NetMode.None :
if _network_protocol==NetProto.Enet :
match _network_mode :
NetMode.Server :
# init server
var peer = ENetMultiplayerPeer.new()
peer.create_server(_server_port)
multiplayer.multiplayer_peer = peer
_on_network_ready()
print("IVMI : Starting Server")
NetMode.Client :
if _server_ip!="" :
_on_found_server(_server_ip, _server_port)
#start discov
_network_discov = IvmiDiscov.new()
if _network_mode==NetMode.Server :
_network_discov.set_server(_server_port)
add_child(_network_discov)
_network_discov.connect("found_server",Callable(self,"_on_found_server"))
_network_discov.connect("timeout",Callable(self,"_on_timeout"))
_network_discov.start()
func _on_found_server(server_ip, port) : func _on_found_server(server_ip, port) :
match _network_protocol : match _network_protocol :
NetProto.Enet : NetProto.Enet :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment