Compare commits
3 Commits
Nervyalloy
...
0.46.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd1c6ed0cf | ||
|
|
13c6dbfd4d | ||
|
|
4fb7c3df84 |
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -2620,7 +2620,7 @@ checksum = "2f2b15926089e5526bb2dd738a2eb0e59034356e06eb71e1cd912358c0e62c4d"
|
||||
[[package]]
|
||||
name = "stardust-xr"
|
||||
version = "0.45.0"
|
||||
source = "git+https://github.com/StardustXR/core.git?branch=dev#d2964d8db079afaadb7faa4987e34814e62d6279"
|
||||
source = "git+https://github.com/StardustXR/core.git?branch=dev#bce6ec660f026c577156b3cff41f9312c1caa1d3"
|
||||
dependencies = [
|
||||
"cluFlock",
|
||||
"color-eyre",
|
||||
@@ -2641,7 +2641,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "stardust-xr-schemas"
|
||||
version = "1.5.3"
|
||||
source = "git+https://github.com/StardustXR/core.git?branch=dev#d2964d8db079afaadb7faa4987e34814e62d6279"
|
||||
source = "git+https://github.com/StardustXR/core.git?branch=dev#bce6ec660f026c577156b3cff41f9312c1caa1d3"
|
||||
dependencies = [
|
||||
"flatbuffers",
|
||||
"flexbuffers",
|
||||
@@ -3359,7 +3359,7 @@ version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -4,7 +4,11 @@ use super::{
|
||||
input_method_client,
|
||||
};
|
||||
use crate::{
|
||||
core::{client::Client, error::Result, registry::Registry},
|
||||
core::{
|
||||
client::Client,
|
||||
error::{Result, ServerError},
|
||||
registry::Registry,
|
||||
},
|
||||
nodes::{
|
||||
Node,
|
||||
alias::{Alias, AliasList},
|
||||
@@ -12,6 +16,7 @@ use crate::{
|
||||
spatial::Spatial,
|
||||
},
|
||||
};
|
||||
use color_eyre::eyre::eyre;
|
||||
use parking_lot::Mutex;
|
||||
use stardust_xr::values::Datamap;
|
||||
use std::sync::{Arc, Weak};
|
||||
@@ -242,7 +247,16 @@ impl InputMethodRefAspect for InputMethodRef {
|
||||
let input_handler = handler.get_aspect::<InputHandler>()?;
|
||||
|
||||
input_method.capture_attempts.add_raw(&input_handler);
|
||||
Ok(())
|
||||
|
||||
let Some(handler_alias) = input_method
|
||||
.handler_aliases
|
||||
.get_from_aspect(&*input_handler)
|
||||
else {
|
||||
return Err(ServerError::Report(eyre!(
|
||||
"Internal: Couldn't get handler alias somehow?"
|
||||
)));
|
||||
};
|
||||
input_method_client::request_capture_handler(&node, handler_alias.get_id())
|
||||
}
|
||||
|
||||
#[doc = "If captured by this handler, release it (e.g. the object is let go of after grabbing)."]
|
||||
@@ -251,6 +265,15 @@ impl InputMethodRefAspect for InputMethodRef {
|
||||
let input_handler = handler.get_aspect::<InputHandler>()?;
|
||||
|
||||
input_method.capture_attempts.remove(&input_handler);
|
||||
Ok(())
|
||||
|
||||
let Some(handler_alias) = input_method
|
||||
.handler_aliases
|
||||
.get_from_aspect(&*input_handler)
|
||||
else {
|
||||
return Err(ServerError::Report(eyre!(
|
||||
"Internal: Couldn't get handler alias somehow?"
|
||||
)));
|
||||
};
|
||||
input_method_client::release_handler(&node, handler_alias.get_id())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ impl Root {
|
||||
|
||||
pub fn set_transform(&self, transform: Mat4) {
|
||||
let spatial = self.node.get_aspect::<Spatial>().unwrap();
|
||||
spatial.set_spatial_parent(None).unwrap();
|
||||
// spatial.set_spatial_parent(None).unwrap();
|
||||
spatial.set_local_transform(transform);
|
||||
}
|
||||
pub async fn save_state(&self) -> Result<ClientState> {
|
||||
|
||||
@@ -192,45 +192,29 @@ impl Spatial {
|
||||
fn get_parent(&self) -> Option<Arc<Spatial>> {
|
||||
self.parent.lock().clone()
|
||||
}
|
||||
fn set_parent(self: &Arc<Self>, new_parent: Option<&Arc<Spatial>>) {
|
||||
fn set_parent(self: &Arc<Self>, new_parent: &Arc<Spatial>) {
|
||||
if let Some(parent) = self.get_parent() {
|
||||
parent.children.remove(self);
|
||||
}
|
||||
if let Some(new_parent) = &new_parent {
|
||||
new_parent.children.add_raw(self);
|
||||
}
|
||||
new_parent.children.add_raw(self);
|
||||
|
||||
*self.parent.lock() = new_parent.cloned();
|
||||
*self.parent.lock() = Some(new_parent.clone());
|
||||
}
|
||||
|
||||
pub fn set_spatial_parent(self: &Arc<Self>, parent: Option<&Arc<Spatial>>) -> Result<()> {
|
||||
let is_ancestor = parent
|
||||
.as_ref()
|
||||
.map(|parent| self.is_ancestor_of((*parent).clone()))
|
||||
.unwrap_or(false);
|
||||
if is_ancestor {
|
||||
pub fn set_spatial_parent(self: &Arc<Self>, parent: &Arc<Spatial>) -> Result<()> {
|
||||
if self.is_ancestor_of(parent.clone()) {
|
||||
bail!("Setting spatial parent would cause a loop");
|
||||
}
|
||||
self.set_parent(parent);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
pub fn set_spatial_parent_in_place(
|
||||
self: &Arc<Self>,
|
||||
parent: Option<&Arc<Spatial>>,
|
||||
) -> Result<()> {
|
||||
let is_ancestor = parent
|
||||
.as_ref()
|
||||
.map(|parent| self.is_ancestor_of((*parent).clone()))
|
||||
.unwrap_or(false);
|
||||
if is_ancestor {
|
||||
pub fn set_spatial_parent_in_place(self: &Arc<Self>, parent: &Arc<Spatial>) -> Result<()> {
|
||||
if self.is_ancestor_of(parent.clone()) {
|
||||
bail!("Setting spatial parent would cause a loop");
|
||||
}
|
||||
|
||||
self.set_local_transform(Spatial::space_to_space_matrix(
|
||||
Some(self),
|
||||
parent.map(AsRef::as_ref),
|
||||
));
|
||||
self.set_local_transform(Spatial::space_to_space_matrix(Some(self), Some(parent)));
|
||||
self.set_parent(parent);
|
||||
|
||||
Ok(())
|
||||
@@ -282,7 +266,7 @@ impl SpatialAspect for Spatial {
|
||||
let this_spatial = node.get_aspect::<Spatial>()?;
|
||||
let parent = parent.get_aspect::<Spatial>()?;
|
||||
|
||||
this_spatial.set_spatial_parent(Some(&parent))?;
|
||||
this_spatial.set_spatial_parent(&parent)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -294,7 +278,7 @@ impl SpatialAspect for Spatial {
|
||||
let this_spatial = node.get_aspect::<Spatial>()?;
|
||||
let parent = parent.get_aspect::<Spatial>()?;
|
||||
|
||||
this_spatial.set_spatial_parent_in_place(Some(&parent))?;
|
||||
this_spatial.set_spatial_parent_in_place(&parent)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,10 @@ pub fn release(spatial: &Spatial) {
|
||||
};
|
||||
let spatial = spatial_node.get_aspect::<Spatial>().unwrap();
|
||||
|
||||
let _ = spatial.set_spatial_parent_in_place(spatial.old_parent.lock().take().as_ref());
|
||||
let Some(old_parent) = spatial.old_parent.lock().take() else {
|
||||
return;
|
||||
};
|
||||
let _ = spatial.set_spatial_parent_in_place(&old_parent);
|
||||
let mut spatial_zone = spatial.zone.lock();
|
||||
|
||||
if let Some(spatial_zone) = spatial_zone.upgrade() {
|
||||
|
||||
Reference in New Issue
Block a user