refactor: store weak client in the nodes

This commit is contained in:
Nova
2022-05-30 19:00:19 -04:00
parent a2e61f9b78
commit 09588ab31d
5 changed files with 93 additions and 66 deletions

View File

@@ -3,7 +3,7 @@ use crate::nodes::spatial::Spatial;
use anyhow::Result;
use libstardustxr::scenegraph;
use libstardustxr::scenegraph::ScenegraphError;
use rccell::{RcCell, WeakCell};
use rccell::RcCell;
use std::collections::HashMap;
pub struct Scenegraph<'a> {
@@ -11,7 +11,7 @@ pub struct Scenegraph<'a> {
}
impl<'a> Scenegraph<'a> {
pub fn new(client: &mut Client<'a>) -> Self {
pub fn new(client: RcCell<Client<'a>>) -> Self {
// root: Spatial::new(Some(client), "/", Default::default()),
// hmd: Spatial::new(Some(client), "/hmd", Default::default()),
Scenegraph {
@@ -20,6 +20,14 @@ impl<'a> Scenegraph<'a> {
}
}
impl<'a> Default for Scenegraph<'a> {
fn default() -> Self {
Scenegraph {
spatial_nodes: HashMap::new(),
}
}
}
impl<'a> scenegraph::Scenegraph for Scenegraph<'a> {
fn send_signal(&self, path: &str, method: &str, data: &[u8]) -> Result<(), ScenegraphError> {
self.spatial_nodes