diff --git a/src/core/client.rs b/src/core/client.rs index 8ca2eea..4a0416d 100644 --- a/src/core/client.rs +++ b/src/core/client.rs @@ -23,9 +23,9 @@ impl<'a> Client<'a> { self.messenger.dispatch(&self.scenegraph) } - pub fn get_messenger(&self) -> &Messenger<'a> { - &self.messenger - } + // pub fn get_messenger(&self) -> &Messenger<'a> { + // &self.messenger + // } pub fn get_scenegraph(&self) -> &Scenegraph<'a> { &self.scenegraph } diff --git a/src/nodes/core.rs b/src/nodes/core.rs index 3f74940..dd3abfc 100644 --- a/src/nodes/core.rs +++ b/src/nodes/core.rs @@ -10,7 +10,7 @@ pub type Method = fn(&Node, Rc, &[u8]) -> Result>; pub struct Node<'a> { client: Weak>, path: String, - trailing_slash_pos: usize, + // trailing_slash_pos: usize, local_signals: HashMap, local_methods: HashMap, destroyable: bool, @@ -22,9 +22,9 @@ impl<'a> Node<'a> { pub fn get_client(&self) -> Option>> { self.client.clone().upgrade() } - pub fn get_name(&self) -> &str { - &self.path[self.trailing_slash_pos + 1..] - } + // pub fn get_name(&self) -> &str { + // &self.path[self.trailing_slash_pos + 1..] + // } pub fn get_path(&self) -> &str { self.path.as_str() } @@ -39,7 +39,7 @@ impl<'a> Node<'a> { let mut node = Node { client, path, - trailing_slash_pos: parent.len(), + // trailing_slash_pos: parent.len(), local_signals: HashMap::new(), local_methods: HashMap::new(), destroyable, @@ -92,23 +92,23 @@ impl<'a> Node<'a> { .ok_or_else(|| anyhow!("Method {} not found", method))?; method(self, calling_client, data) } - pub fn send_remote_signal(&self, method: &str, data: &[u8]) -> Result<()> { - self.get_client() - .ok_or_else(|| anyhow!("Node has no client, can't send remote signal!"))? - .get_messenger() - .send_remote_signal(self.path.as_str(), method, data) - .map_err(|_| anyhow!("Unable to write in messenger")) - } - pub fn execute_remote_method( - &self, - method: &str, - data: &[u8], - callback: Box, - ) -> Result<()> { - self.get_client() - .ok_or_else(|| anyhow!("Node has no client, can't send remote signal!"))? - .get_messenger() - .execute_remote_method(self.path.as_str(), method, data, callback) - .map_err(|_| anyhow!("Unable to write in messenger")) - } + // pub fn send_remote_signal(&self, method: &str, data: &[u8]) -> Result<()> { + // self.get_client() + // .ok_or_else(|| anyhow!("Node has no client, can't send remote signal!"))? + // .get_messenger() + // .send_remote_signal(self.path.as_str(), method, data) + // .map_err(|_| anyhow!("Unable to write in messenger")) + // } + // pub fn execute_remote_method( + // &self, + // method: &str, + // data: &[u8], + // callback: Box, + // ) -> Result<()> { + // self.get_client() + // .ok_or_else(|| anyhow!("Node has no client, can't send remote signal!"))? + // .get_messenger() + // .execute_remote_method(self.path.as_str(), method, data, callback) + // .map_err(|_| anyhow!("Unable to write in messenger")) + // } } diff --git a/src/nodes/spatial.rs b/src/nodes/spatial.rs index e492c30..0a8f00e 100644 --- a/src/nodes/spatial.rs +++ b/src/nodes/spatial.rs @@ -5,12 +5,12 @@ use glam::{Mat4, Quat, Vec3}; use libstardustxr::flex::flexbuffer_from_vector_arguments; use libstardustxr::push_to_vec; use libstardustxr::{flex_to_quat, flex_to_vec3}; -use rccell::{RcCell, WeakCell}; +use rccell::RcCell; use std::cell::{Cell, RefCell}; use std::rc::Rc; pub struct Spatial<'a> { - node: WeakCell>, + // node: WeakCell>, parent: RefCell>>>, transform: Cell, } @@ -25,7 +25,7 @@ impl<'a> Spatial<'a> { bail!("Node already has a Spatial aspect!"); } let spatial = Spatial { - node: node.downgrade(), + // node: node.downgrade(), parent: RefCell::new(parent), transform: Cell::new(transform), }; @@ -69,9 +69,15 @@ impl<'a> Spatial<'a> { let (mut reference_space_scl, mut reference_space_rot, mut reference_space_pos) = local_transform_in_reference_space.to_scale_rotation_translation(); - pos.map(|pos| reference_space_pos = pos); - rot.map(|rot| reference_space_rot = rot); - scl.map(|scl| reference_space_scl = scl); + if let Some(pos) = pos { + reference_space_pos = pos + } + if let Some(rot) = rot { + reference_space_rot = rot + } + if let Some(scl) = scl { + reference_space_scl = scl + } local_transform_in_reference_space = Mat4::from_scale_rotation_translation( reference_space_scl, @@ -122,7 +128,9 @@ impl<'a> Spatial<'a> { .as_ref() .ok_or_else(|| anyhow!("Node somehow is not spatial"))?; let reference_space_path = flex_vec.idx(0).as_str(); - let reference_space_transform = if reference_space_path != "" { + let reference_space_transform = if reference_space_path.is_empty() { + None + } else { Some( calling_client .get_scenegraph() @@ -134,8 +142,6 @@ impl<'a> Spatial<'a> { .ok_or_else(|| anyhow!("Node is not a Spatial!"))? .clone(), ) - } else { - None }; spatial.set_local_transform_components( reference_space_transform.as_deref(),