From 9d0e1ce021ccacd6a4c2ca5c0c84484d1c37ceb7 Mon Sep 17 00:00:00 2001 From: Nova Date: Thu, 15 May 2025 21:21:14 -0700 Subject: [PATCH] fix: root sending frame events to dead clients --- src/nodes/root.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/nodes/root.rs b/src/nodes/root.rs index 0f9417b..aae066c 100644 --- a/src/nodes/root.rs +++ b/src/nodes/root.rs @@ -1,10 +1,9 @@ use super::spatial::Spatial; use super::{Aspect, AspectIdentifier, Node}; use crate::bail; -use crate::core::client::Client; +use crate::core::client::{CLIENTS, Client}; use crate::core::client_state::ClientStateParsed; use crate::core::error::Result; -use crate::core::registry::Registry; use crate::nodes::spatial::SPATIAL_REF_ASPECT_ALIAS_INFO; use crate::session::connection_env; use glam::Mat4; @@ -13,8 +12,6 @@ use std::sync::Arc; use std::time::Instant; use tracing::info; -static ROOT_REGISTRY: Registry = Registry::new(); - stardust_xr_server_codegen::codegen_root_protocol!(); pub struct Root { @@ -30,12 +27,14 @@ impl Root { node: node.clone(), connect_instant: Instant::now(), }); - ROOT_REGISTRY.add_raw(&root_aspect); Ok(root_aspect) } pub fn send_frame_events(delta: f64) { - for root in ROOT_REGISTRY.get_valid_contents() { + for client in CLIENTS.get_vec() { + let Some(root) = client.root.get() else { + continue; + }; let _ = root_client::frame( &root.node, &FrameInfo { @@ -104,8 +103,3 @@ impl RootAspect for Root { Ok(()) } } -impl Drop for Root { - fn drop(&mut self) { - ROOT_REGISTRY.remove(self); - } -}