feat(fields): use new field ref and field types
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -2015,7 +2015,7 @@ checksum = "2f2b15926089e5526bb2dd738a2eb0e59034356e06eb71e1cd912358c0e62c4d"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "stardust-xr"
|
name = "stardust-xr"
|
||||||
version = "0.45.0"
|
version = "0.45.0"
|
||||||
source = "git+https://github.com/StardustXR/core.git?branch=dev#a21dc0e610f6e7c905d42f80009700ff4474e583"
|
source = "git+https://github.com/StardustXR/core.git?branch=dev#4f2a7f87a864d07db4a2a783d52c30a4926e8925"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cluFlock",
|
"cluFlock",
|
||||||
"color-rs",
|
"color-rs",
|
||||||
@@ -2035,7 +2035,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "stardust-xr-schemas"
|
name = "stardust-xr-schemas"
|
||||||
version = "1.5.3"
|
version = "1.5.3"
|
||||||
source = "git+https://github.com/StardustXR/core.git?branch=dev#a21dc0e610f6e7c905d42f80009700ff4474e583"
|
source = "git+https://github.com/StardustXR/core.git?branch=dev#4f2a7f87a864d07db4a2a783d52c30a4926e8925"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"flatbuffers",
|
"flatbuffers",
|
||||||
"flexbuffers",
|
"flexbuffers",
|
||||||
|
|||||||
@@ -382,6 +382,11 @@ fn generate_handler(member: &Member) -> TokenStream {
|
|||||||
quote!(let (#argument_names): (#argument_types) = stardust_xr::schemas::flex::deserialize(_message.as_ref())?;)
|
quote!(let (#argument_names): (#argument_types) = stardust_xr::schemas::flex::deserialize(_message.as_ref())?;)
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
let serialize = generate_argument_serialize(
|
||||||
|
"result",
|
||||||
|
&member.return_type.clone().unwrap_or(ArgumentType::Empty),
|
||||||
|
false,
|
||||||
|
);
|
||||||
let argument_uses = member
|
let argument_uses = member
|
||||||
.arguments
|
.arguments
|
||||||
.iter()
|
.iter()
|
||||||
@@ -399,7 +404,8 @@ fn generate_handler(member: &Member) -> TokenStream {
|
|||||||
node.add_local_method(#opcode, |_node, _calling_client, _message, _method_response| {
|
node.add_local_method(#opcode, |_node, _calling_client, _message, _method_response| {
|
||||||
_method_response.wrap_async(async move {
|
_method_response.wrap_async(async move {
|
||||||
#deserialize
|
#deserialize
|
||||||
Ok((Self::#member_name_ident(_node, _calling_client.clone(), #argument_uses).await?, Vec::new()))
|
let result = Self::#member_name_ident(_node, _calling_client.clone(), #argument_uses).await?;
|
||||||
|
Ok((#serialize, Vec::new()))
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ impl PulseSender {
|
|||||||
.get_aspect::<PulseReceiver>()
|
.get_aspect::<PulseReceiver>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.field
|
.field
|
||||||
.spatial_ref()
|
.spatial
|
||||||
.node()
|
.node()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
&tx_client,
|
&tx_client,
|
||||||
|
|||||||
@@ -1,14 +1,4 @@
|
|||||||
pub mod r#box;
|
use super::alias::{Alias, AliasInfo};
|
||||||
mod cylinder;
|
|
||||||
mod sphere;
|
|
||||||
mod torus;
|
|
||||||
|
|
||||||
use self::cylinder::CylinderField;
|
|
||||||
use self::r#box::BoxField;
|
|
||||||
use self::sphere::SphereField;
|
|
||||||
use self::torus::TorusField;
|
|
||||||
|
|
||||||
use super::alias::AliasInfo;
|
|
||||||
use super::spatial::{
|
use super::spatial::{
|
||||||
Spatial, SPATIAL_REF_GET_LOCAL_BOUNDING_BOX_SERVER_OPCODE,
|
Spatial, SPATIAL_REF_GET_LOCAL_BOUNDING_BOX_SERVER_OPCODE,
|
||||||
SPATIAL_REF_GET_RELATIVE_BOUNDING_BOX_SERVER_OPCODE, SPATIAL_REF_GET_TRANSFORM_SERVER_OPCODE,
|
SPATIAL_REF_GET_RELATIVE_BOUNDING_BOX_SERVER_OPCODE, SPATIAL_REF_GET_TRANSFORM_SERVER_OPCODE,
|
||||||
@@ -19,11 +9,12 @@ use crate::create_interface;
|
|||||||
use crate::nodes::spatial::Transform;
|
use crate::nodes::spatial::Transform;
|
||||||
use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO;
|
use crate::nodes::spatial::SPATIAL_ASPECT_ALIAS_INFO;
|
||||||
use crate::nodes::spatial::SPATIAL_REF_ASPECT_ALIAS_INFO;
|
use crate::nodes::spatial::SPATIAL_REF_ASPECT_ALIAS_INFO;
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::{OptionExt, Result};
|
||||||
use glam::{vec2, vec3a, Mat4, Vec3, Vec3A};
|
use glam::{vec2, vec3, vec3a, Vec3, Vec3A, Vec3Swizzles};
|
||||||
use mint::Vector3;
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use std::ops::Deref;
|
use parking_lot::Mutex;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
|
use stardust_xr::values::Vector3;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
// TODO: get SDFs working properly with non-uniform scale and so on, output distance relative to the spatial it's compared against
|
// TODO: get SDFs working properly with non-uniform scale and so on, output distance relative to the spatial it's compared against
|
||||||
@@ -33,16 +24,20 @@ pub static FIELD_ALIAS_INFO: Lazy<AliasInfo> = Lazy::new(|| AliasInfo {
|
|||||||
SPATIAL_REF_GET_TRANSFORM_SERVER_OPCODE,
|
SPATIAL_REF_GET_TRANSFORM_SERVER_OPCODE,
|
||||||
SPATIAL_REF_GET_LOCAL_BOUNDING_BOX_SERVER_OPCODE,
|
SPATIAL_REF_GET_LOCAL_BOUNDING_BOX_SERVER_OPCODE,
|
||||||
SPATIAL_REF_GET_RELATIVE_BOUNDING_BOX_SERVER_OPCODE,
|
SPATIAL_REF_GET_RELATIVE_BOUNDING_BOX_SERVER_OPCODE,
|
||||||
FIELD_DISTANCE_SERVER_OPCODE,
|
FIELD_REF_DISTANCE_SERVER_OPCODE,
|
||||||
FIELD_NORMAL_SERVER_OPCODE,
|
FIELD_REF_NORMAL_SERVER_OPCODE,
|
||||||
FIELD_CLOSEST_POINT_SERVER_OPCODE,
|
FIELD_REF_CLOSEST_POINT_SERVER_OPCODE,
|
||||||
FIELD_RAY_MARCH_SERVER_OPCODE,
|
FIELD_REF_RAY_MARCH_SERVER_OPCODE,
|
||||||
],
|
],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
stardust_xr_server_codegen::codegen_field_protocol!();
|
stardust_xr_server_codegen::codegen_field_protocol!();
|
||||||
|
|
||||||
|
lazy_static::lazy_static! {
|
||||||
|
pub static ref EXPORTED_FIELDS: Mutex<FxHashMap<u64, Arc<Node>>> = Mutex::new(FxHashMap::default());
|
||||||
|
}
|
||||||
|
|
||||||
pub trait FieldTrait: Send + Sync + 'static {
|
pub trait FieldTrait: Send + Sync + 'static {
|
||||||
fn spatial_ref(&self) -> &Spatial;
|
fn spatial_ref(&self) -> &Spatial;
|
||||||
|
|
||||||
@@ -122,60 +117,6 @@ pub trait FieldTrait: Send + Sync + 'static {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<Fi: FieldTrait + 'static> FieldAspect for Fi {
|
|
||||||
async fn distance(
|
|
||||||
node: Arc<Node>,
|
|
||||||
_calling_client: Arc<Client>,
|
|
||||||
space: Arc<Node>,
|
|
||||||
point: mint::Vector3<f32>,
|
|
||||||
) -> Result<f32> {
|
|
||||||
let reference_space = space.get_aspect::<Spatial>()?;
|
|
||||||
let this_field = node.get_aspect::<Field>()?;
|
|
||||||
Ok((*this_field).distance(reference_space.as_ref(), point.into()))
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn normal(
|
|
||||||
node: Arc<Node>,
|
|
||||||
_calling_client: Arc<Client>,
|
|
||||||
space: Arc<Node>,
|
|
||||||
point: mint::Vector3<f32>,
|
|
||||||
) -> Result<Vector3<f32>> {
|
|
||||||
let reference_space = space.get_aspect::<Spatial>()?;
|
|
||||||
let this_field = node.get_aspect::<Field>()?;
|
|
||||||
Ok(this_field
|
|
||||||
.normal(reference_space.as_ref(), point.into(), 0.001)
|
|
||||||
.into())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn closest_point(
|
|
||||||
node: Arc<Node>,
|
|
||||||
_calling_client: Arc<Client>,
|
|
||||||
space: Arc<Node>,
|
|
||||||
point: mint::Vector3<f32>,
|
|
||||||
) -> Result<Vector3<f32>> {
|
|
||||||
let reference_space = space.get_aspect::<Spatial>()?;
|
|
||||||
let this_field = node.get_aspect::<Field>()?;
|
|
||||||
Ok(this_field
|
|
||||||
.closest_point(reference_space.as_ref(), point.into(), 0.001)
|
|
||||||
.into())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn ray_march(
|
|
||||||
node: Arc<Node>,
|
|
||||||
_calling_client: Arc<Client>,
|
|
||||||
space: Arc<Node>,
|
|
||||||
ray_origin: mint::Vector3<f32>,
|
|
||||||
ray_direction: mint::Vector3<f32>,
|
|
||||||
) -> Result<RayMarchResult> {
|
|
||||||
let reference_space = space.get_aspect::<Spatial>()?;
|
|
||||||
let this_field = node.get_aspect::<Field>()?;
|
|
||||||
Ok(this_field.ray_march(Ray {
|
|
||||||
origin: ray_origin.into(),
|
|
||||||
direction: ray_direction.into(),
|
|
||||||
space: reference_space.clone(),
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Ray {
|
pub struct Ray {
|
||||||
pub origin: Vec3,
|
pub origin: Vec3,
|
||||||
@@ -192,23 +133,113 @@ const MAX_RAY_MARCH: f32 = f32::MAX;
|
|||||||
// const MIN_RAY_LENGTH: f32 = 0_f32;
|
// const MIN_RAY_LENGTH: f32 = 0_f32;
|
||||||
const MAX_RAY_LENGTH: f32 = 1000_f32;
|
const MAX_RAY_LENGTH: f32 = 1000_f32;
|
||||||
|
|
||||||
pub enum Field {
|
pub struct Field {
|
||||||
Box(BoxField),
|
pub spatial: Arc<Spatial>,
|
||||||
Cylinder(CylinderField),
|
pub shape: Mutex<Shape>,
|
||||||
Sphere(SphereField),
|
}
|
||||||
Torus(TorusField),
|
impl Field {
|
||||||
|
pub fn add_to(node: &Arc<Node>, shape: Shape) -> Result<()> {
|
||||||
|
let spatial = node.get_aspect::<Spatial>()?;
|
||||||
|
let field = Field {
|
||||||
|
spatial,
|
||||||
|
shape: Mutex::new(shape),
|
||||||
|
};
|
||||||
|
node.add_aspect(field);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
impl Aspect for Field {
|
impl Aspect for Field {
|
||||||
const NAME: &'static str = "Field";
|
const NAME: &'static str = "Field";
|
||||||
}
|
}
|
||||||
impl Deref for Field {
|
impl FieldRefAspect for Field {
|
||||||
type Target = dyn FieldTrait;
|
async fn distance(
|
||||||
fn deref(&self) -> &Self::Target {
|
node: Arc<Node>,
|
||||||
match self {
|
_calling_client: Arc<Client>,
|
||||||
Field::Box(field) => field,
|
space: Arc<Node>,
|
||||||
Field::Cylinder(field) => field,
|
point: Vector3<f32>,
|
||||||
Field::Sphere(field) => field,
|
) -> Result<f32> {
|
||||||
Field::Torus(field) => field,
|
let reference_space = space.get_aspect::<Spatial>()?;
|
||||||
|
let field = node.get_aspect::<Field>()?;
|
||||||
|
Ok(field.distance(&reference_space, point.into()).into())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn normal(
|
||||||
|
node: Arc<Node>,
|
||||||
|
_calling_client: Arc<Client>,
|
||||||
|
space: Arc<Node>,
|
||||||
|
point: Vector3<f32>,
|
||||||
|
) -> Result<Vector3<f32>> {
|
||||||
|
let reference_space = space.get_aspect::<Spatial>()?;
|
||||||
|
let field = node.get_aspect::<Field>()?;
|
||||||
|
Ok(field.normal(&reference_space, point.into(), 0.0001).into())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn closest_point(
|
||||||
|
node: Arc<Node>,
|
||||||
|
_calling_client: Arc<Client>,
|
||||||
|
space: Arc<Node>,
|
||||||
|
point: Vector3<f32>,
|
||||||
|
) -> Result<Vector3<f32>> {
|
||||||
|
let reference_space = space.get_aspect::<Spatial>()?;
|
||||||
|
let field = node.get_aspect::<Field>()?;
|
||||||
|
Ok(field
|
||||||
|
.closest_point(&reference_space, point.into(), 0.0001)
|
||||||
|
.into())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn ray_march(
|
||||||
|
node: Arc<Node>,
|
||||||
|
_calling_client: Arc<Client>,
|
||||||
|
space: Arc<Node>,
|
||||||
|
ray_origin: Vector3<f32>,
|
||||||
|
ray_direction: Vector3<f32>,
|
||||||
|
) -> Result<RayMarchResult> {
|
||||||
|
let space = space.get_aspect::<Spatial>()?;
|
||||||
|
let field = node.get_aspect::<Field>()?;
|
||||||
|
Ok(field.ray_march(Ray {
|
||||||
|
origin: ray_origin.into(),
|
||||||
|
direction: ray_direction.into(),
|
||||||
|
space,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl FieldAspect for Field {
|
||||||
|
fn set_shape(node: Arc<Node>, _calling_client: Arc<Client>, shape: Shape) -> Result<()> {
|
||||||
|
let field = node.get_aspect::<Field>()?;
|
||||||
|
*field.shape.lock() = shape;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn export_field(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<u64> {
|
||||||
|
let id = rand::random();
|
||||||
|
EXPORTED_FIELDS.lock().insert(id, node);
|
||||||
|
Ok(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl FieldTrait for Field {
|
||||||
|
fn spatial_ref(&self) -> &Spatial {
|
||||||
|
&self.spatial
|
||||||
|
}
|
||||||
|
fn local_distance(&self, p: Vec3A) -> f32 {
|
||||||
|
match self.shape.lock().clone() {
|
||||||
|
Shape::Box(size) => {
|
||||||
|
let q = vec3(
|
||||||
|
p.x.abs() - (size.x * 0.5_f32),
|
||||||
|
p.y.abs() - (size.y * 0.5_f32),
|
||||||
|
p.z.abs() - (size.z * 0.5_f32),
|
||||||
|
);
|
||||||
|
let v = vec3a(q.x.max(0_f32), q.y.max(0_f32), q.z.max(0_f32));
|
||||||
|
v.length() + q.x.max(q.y.max(q.z)).min(0_f32)
|
||||||
|
}
|
||||||
|
Shape::Cylinder(CylinderShape { length, radius }) => {
|
||||||
|
let d = vec2(p.xy().length().abs() - radius, p.z.abs() - (length * 0.5));
|
||||||
|
d.x.max(d.y).min(0.0) + d.max(vec2(0.0, 0.0)).length()
|
||||||
|
}
|
||||||
|
Shape::Sphere(radius) => p.length() - radius,
|
||||||
|
Shape::Torus(TorusShape { radius_a, radius_b }) => {
|
||||||
|
let q = vec2(p.xz().length() - radius_a, p.y);
|
||||||
|
q.length() - radius_b
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,73 +247,39 @@ impl Deref for Field {
|
|||||||
create_interface!(FieldInterface);
|
create_interface!(FieldInterface);
|
||||||
pub struct FieldInterface;
|
pub struct FieldInterface;
|
||||||
impl InterfaceAspect for FieldInterface {
|
impl InterfaceAspect for FieldInterface {
|
||||||
fn create_box_field(
|
async fn import_field_ref(
|
||||||
|
_node: Arc<Node>,
|
||||||
|
calling_client: Arc<Client>,
|
||||||
|
uid: u64,
|
||||||
|
) -> Result<Arc<Node>> {
|
||||||
|
EXPORTED_FIELDS
|
||||||
|
.lock()
|
||||||
|
.get(&uid)
|
||||||
|
.map(|s| {
|
||||||
|
Alias::create(
|
||||||
|
s,
|
||||||
|
&calling_client,
|
||||||
|
FIELD_REF_ASPECT_ALIAS_INFO.clone(),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
})
|
||||||
|
.ok_or_eyre("Couldn't find spatial with that ID")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_field(
|
||||||
_node: Arc<Node>,
|
_node: Arc<Node>,
|
||||||
calling_client: Arc<Client>,
|
calling_client: Arc<Client>,
|
||||||
id: u64,
|
id: u64,
|
||||||
parent: Arc<Node>,
|
parent: Arc<Node>,
|
||||||
transform: Transform,
|
transform: Transform,
|
||||||
size: mint::Vector3<f32>,
|
shape: Shape,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let transform = transform.to_mat4(true, true, false);
|
let transform = transform.to_mat4(true, true, false);
|
||||||
let parent = parent.get_aspect::<Spatial>()?;
|
let parent = parent.get_aspect::<Spatial>()?;
|
||||||
let node = Node::from_id(&calling_client, id, true).add_to_scenegraph()?;
|
let node = Node::from_id(&calling_client, id, true).add_to_scenegraph()?;
|
||||||
Spatial::add_to(&node, Some(parent.clone()), transform, false);
|
Spatial::add_to(&node, Some(parent.clone()), transform, false);
|
||||||
BoxField::add_to(&node, size);
|
Field::add_to(&node, shape)?;
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_cylinder_field(
|
|
||||||
_node: Arc<Node>,
|
|
||||||
calling_client: Arc<Client>,
|
|
||||||
id: u64,
|
|
||||||
parent: Arc<Node>,
|
|
||||||
transform: Transform,
|
|
||||||
length: f32,
|
|
||||||
radius: f32,
|
|
||||||
) -> Result<()> {
|
|
||||||
let transform = transform.to_mat4(true, true, false);
|
|
||||||
let parent = parent.get_aspect::<Spatial>()?;
|
|
||||||
let node = Node::from_id(&calling_client, id, true).add_to_scenegraph()?;
|
|
||||||
Spatial::add_to(&node, Some(parent.clone()), transform, false);
|
|
||||||
CylinderField::add_to(&node, length, radius);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_sphere_field(
|
|
||||||
_node: Arc<Node>,
|
|
||||||
calling_client: Arc<Client>,
|
|
||||||
id: u64,
|
|
||||||
parent: Arc<Node>,
|
|
||||||
position: mint::Vector3<f32>,
|
|
||||||
radius: f32,
|
|
||||||
) -> Result<()> {
|
|
||||||
let parent = parent.get_aspect::<Spatial>()?;
|
|
||||||
let node = Node::from_id(&calling_client, id, true).add_to_scenegraph()?;
|
|
||||||
Spatial::add_to(
|
|
||||||
&node,
|
|
||||||
Some(parent.clone()),
|
|
||||||
Mat4::from_translation(position.into()),
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
SphereField::add_to(&node, radius);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_torus_field(
|
|
||||||
_node: Arc<Node>,
|
|
||||||
calling_client: Arc<Client>,
|
|
||||||
id: u64,
|
|
||||||
parent: Arc<Node>,
|
|
||||||
transform: Transform,
|
|
||||||
radius_a: f32,
|
|
||||||
radius_b: f32,
|
|
||||||
) -> Result<()> {
|
|
||||||
let transform = transform.to_mat4(true, true, false);
|
|
||||||
let parent = parent.get_aspect::<Spatial>()?;
|
|
||||||
let node = Node::from_id(&calling_client, id, true).add_to_scenegraph()?;
|
|
||||||
Spatial::add_to(&node, Some(parent.clone()), transform, false);
|
|
||||||
TorusField::add_to(&node, radius_a, radius_b);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
use super::{BoxFieldAspect, FieldTrait, Node};
|
|
||||||
use crate::nodes::fields::FieldAspect;
|
|
||||||
use crate::nodes::spatial::Spatial;
|
|
||||||
use crate::{core::client::Client, nodes::fields::Field};
|
|
||||||
use color_eyre::eyre::Result;
|
|
||||||
use glam::{vec3, vec3a, Vec3, Vec3A};
|
|
||||||
use mint::Vector3;
|
|
||||||
use parking_lot::Mutex;
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub struct BoxField {
|
|
||||||
space: Arc<Spatial>,
|
|
||||||
size: Mutex<Vec3>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BoxField {
|
|
||||||
pub fn add_to(node: &Arc<Node>, size: Vector3<f32>) {
|
|
||||||
let box_field = BoxField {
|
|
||||||
space: node.get_aspect::<Spatial>().unwrap().clone(),
|
|
||||||
size: Mutex::new(size.into()),
|
|
||||||
};
|
|
||||||
<BoxField as FieldAspect>::add_node_members(node);
|
|
||||||
<BoxField as BoxFieldAspect>::add_node_members(node);
|
|
||||||
node.add_aspect(Field::Box(box_field));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_size(&self, size: Vector3<f32>) {
|
|
||||||
*self.size.lock() = size.into();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FieldTrait for BoxField {
|
|
||||||
fn local_distance(&self, p: Vec3A) -> f32 {
|
|
||||||
let size = self.size.lock();
|
|
||||||
let q = vec3(
|
|
||||||
p.x.abs() - (size.x * 0.5_f32),
|
|
||||||
p.y.abs() - (size.y * 0.5_f32),
|
|
||||||
p.z.abs() - (size.z * 0.5_f32),
|
|
||||||
);
|
|
||||||
let v = vec3a(q.x.max(0_f32), q.y.max(0_f32), q.z.max(0_f32));
|
|
||||||
v.length() + q.x.max(q.y.max(q.z)).min(0_f32)
|
|
||||||
}
|
|
||||||
fn spatial_ref(&self) -> &Spatial {
|
|
||||||
self.space.as_ref()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl BoxFieldAspect for BoxField {
|
|
||||||
fn set_size(
|
|
||||||
node: Arc<Node>,
|
|
||||||
_calling_client: Arc<Client>,
|
|
||||||
size: mint::Vector3<f32>,
|
|
||||||
) -> Result<()> {
|
|
||||||
let this_field = node.get_aspect::<Field>()?;
|
|
||||||
let Field::Box(this_field) = &*this_field else {
|
|
||||||
return Ok(());
|
|
||||||
};
|
|
||||||
this_field.set_size(size);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
use super::{CylinderFieldAspect, Field, FieldTrait, Node};
|
|
||||||
use crate::core::client::Client;
|
|
||||||
use crate::nodes::fields::FieldAspect;
|
|
||||||
use crate::nodes::spatial::Spatial;
|
|
||||||
use color_eyre::eyre::Result;
|
|
||||||
use glam::{swizzles::*, vec2, Vec3A};
|
|
||||||
use portable_atomic::AtomicF32;
|
|
||||||
|
|
||||||
use std::sync::atomic::Ordering;
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub struct CylinderField {
|
|
||||||
space: Arc<Spatial>,
|
|
||||||
length: AtomicF32,
|
|
||||||
radius: AtomicF32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CylinderField {
|
|
||||||
pub fn add_to(node: &Arc<Node>, length: f32, radius: f32) {
|
|
||||||
let cylinder_field = CylinderField {
|
|
||||||
space: node.get_aspect::<Spatial>().unwrap().clone(),
|
|
||||||
length: AtomicF32::new(length.abs()),
|
|
||||||
radius: AtomicF32::new(radius.abs()),
|
|
||||||
};
|
|
||||||
<CylinderField as FieldAspect>::add_node_members(node);
|
|
||||||
<CylinderField as CylinderFieldAspect>::add_node_members(node);
|
|
||||||
node.add_aspect(Field::Cylinder(cylinder_field));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_size(&self, length: f32, radius: f32) {
|
|
||||||
self.length.store(length.abs(), Ordering::Relaxed);
|
|
||||||
self.radius.store(radius.abs(), Ordering::Relaxed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl FieldTrait for CylinderField {
|
|
||||||
fn local_distance(&self, p: Vec3A) -> f32 {
|
|
||||||
let radius = self.radius.load(Ordering::Relaxed);
|
|
||||||
let length = self.length.load(Ordering::Relaxed);
|
|
||||||
let d = vec2(p.xy().length().abs() - radius, p.z.abs() - (length * 0.5));
|
|
||||||
|
|
||||||
d.x.max(d.y).min(0.0) + d.max(vec2(0.0, 0.0)).length()
|
|
||||||
}
|
|
||||||
fn spatial_ref(&self) -> &Spatial {
|
|
||||||
self.space.as_ref()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl CylinderFieldAspect for CylinderField {
|
|
||||||
fn set_size(
|
|
||||||
node: Arc<Node>,
|
|
||||||
_calling_client: Arc<Client>,
|
|
||||||
length: f32,
|
|
||||||
radius: f32,
|
|
||||||
) -> Result<()> {
|
|
||||||
let this_field = node.get_aspect::<Field>()?;
|
|
||||||
let Field::Cylinder(this_field) = &*this_field else {
|
|
||||||
return Ok(());
|
|
||||||
};
|
|
||||||
this_field.set_size(length, radius);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
use super::{Field, FieldTrait, Node, SphereFieldAspect};
|
|
||||||
use crate::core::client::Client;
|
|
||||||
use crate::nodes::fields::FieldAspect;
|
|
||||||
use crate::nodes::spatial::Spatial;
|
|
||||||
use color_eyre::eyre::Result;
|
|
||||||
use glam::Vec3A;
|
|
||||||
use portable_atomic::AtomicF32;
|
|
||||||
use std::sync::atomic::Ordering;
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub struct SphereField {
|
|
||||||
space: Arc<Spatial>,
|
|
||||||
radius: AtomicF32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SphereField {
|
|
||||||
pub fn add_to(node: &Arc<Node>, radius: f32) {
|
|
||||||
let sphere_field = SphereField {
|
|
||||||
space: node.get_aspect::<Spatial>().unwrap().clone(),
|
|
||||||
radius: AtomicF32::new(radius),
|
|
||||||
};
|
|
||||||
<SphereField as FieldAspect>::add_node_members(node);
|
|
||||||
<SphereField as SphereFieldAspect>::add_node_members(node);
|
|
||||||
node.add_aspect(Field::Sphere(sphere_field));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_radius(&self, radius: f32) {
|
|
||||||
self.radius.store(radius, Ordering::Relaxed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FieldTrait for SphereField {
|
|
||||||
fn local_distance(&self, p: Vec3A) -> f32 {
|
|
||||||
p.length() - self.radius.load(Ordering::Relaxed)
|
|
||||||
}
|
|
||||||
fn local_normal(&self, p: Vec3A, _r: f32) -> Vec3A {
|
|
||||||
-p.normalize()
|
|
||||||
}
|
|
||||||
fn local_closest_point(&self, p: Vec3A, _r: f32) -> Vec3A {
|
|
||||||
p.normalize() * self.radius.load(Ordering::Relaxed)
|
|
||||||
}
|
|
||||||
fn spatial_ref(&self) -> &Spatial {
|
|
||||||
self.space.as_ref()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl SphereFieldAspect for SphereField {
|
|
||||||
fn set_radius(node: Arc<Node>, _calling_client: Arc<Client>, radius: f32) -> Result<()> {
|
|
||||||
let this_field = node.get_aspect::<Field>()?;
|
|
||||||
let Field::Sphere(this_field) = &*this_field else {
|
|
||||||
return Ok(());
|
|
||||||
};
|
|
||||||
this_field.set_radius(radius);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
use super::{Field, FieldTrait, Node, TorusFieldAspect};
|
|
||||||
use crate::core::client::Client;
|
|
||||||
use crate::nodes::fields::FieldAspect;
|
|
||||||
use crate::nodes::spatial::Spatial;
|
|
||||||
use color_eyre::eyre::Result;
|
|
||||||
use glam::{swizzles::*, vec2, Vec3A};
|
|
||||||
use portable_atomic::AtomicF32;
|
|
||||||
|
|
||||||
use std::sync::atomic::Ordering;
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub struct TorusField {
|
|
||||||
space: Arc<Spatial>,
|
|
||||||
radius_a: AtomicF32,
|
|
||||||
radius_b: AtomicF32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TorusField {
|
|
||||||
pub fn add_to(node: &Arc<Node>, radius_a: f32, radius_b: f32) {
|
|
||||||
let torus_field = TorusField {
|
|
||||||
space: node.get_aspect::<Spatial>().unwrap().clone(),
|
|
||||||
radius_a: AtomicF32::new(radius_a.abs()),
|
|
||||||
radius_b: AtomicF32::new(radius_b.abs()),
|
|
||||||
};
|
|
||||||
<TorusField as FieldAspect>::add_node_members(node);
|
|
||||||
<TorusField as TorusFieldAspect>::add_node_members(node);
|
|
||||||
node.add_aspect(Field::Torus(torus_field));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_size(&self, radius_a: f32, radius_b: f32) {
|
|
||||||
self.radius_a.store(radius_a.abs(), Ordering::Relaxed);
|
|
||||||
self.radius_b.store(radius_b.abs(), Ordering::Relaxed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl FieldTrait for TorusField {
|
|
||||||
fn local_distance(&self, p: Vec3A) -> f32 {
|
|
||||||
let radius_a = self.radius_a.load(Ordering::Relaxed);
|
|
||||||
let radius_b = self.radius_b.load(Ordering::Relaxed);
|
|
||||||
let q = vec2(p.xz().length() - radius_a, p.y);
|
|
||||||
q.length() - radius_b
|
|
||||||
}
|
|
||||||
fn spatial_ref(&self) -> &Spatial {
|
|
||||||
self.space.as_ref()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl TorusFieldAspect for TorusField {
|
|
||||||
fn set_size(
|
|
||||||
node: Arc<Node>,
|
|
||||||
_calling_client: Arc<Client>,
|
|
||||||
radius_a: f32,
|
|
||||||
radius_b: f32,
|
|
||||||
) -> Result<()> {
|
|
||||||
let this_field = node.get_aspect::<Field>()?;
|
|
||||||
let Field::Torus(this_field) = &*this_field else {
|
|
||||||
return Ok(());
|
|
||||||
};
|
|
||||||
this_field.set_size(radius_a, radius_b);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
use super::{Finger, Hand, InputDataTrait, InputLink, Joint, Thumb};
|
use super::{Finger, Hand, InputDataTrait, InputLink, Joint, Thumb};
|
||||||
use crate::nodes::fields::Field;
|
use crate::nodes::fields::{Field, FieldTrait};
|
||||||
use crate::nodes::spatial::Spatial;
|
use crate::nodes::spatial::Spatial;
|
||||||
use glam::{vec3a, Mat4, Quat};
|
use glam::{vec3a, Mat4, Quat};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ impl InputMethod {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(handler_field_node) = handler.field.spatial_ref().node() else {
|
let Some(handler_field_node) = handler.field.spatial.node() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
// Handler's field
|
// Handler's field
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use super::{InputDataTrait, InputLink, Pointer};
|
use super::{InputDataTrait, InputLink, Pointer};
|
||||||
use crate::nodes::{
|
use crate::nodes::{
|
||||||
fields::{Field, Ray, RayMarchResult},
|
fields::{Field, FieldTrait, Ray, RayMarchResult},
|
||||||
spatial::Spatial,
|
spatial::Spatial,
|
||||||
};
|
};
|
||||||
use glam::{vec3, Mat4, Quat};
|
use glam::{vec3, Mat4, Quat};
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
use super::{InputDataTrait, InputLink, Tip};
|
use super::{InputDataTrait, InputLink, Tip};
|
||||||
use crate::nodes::{fields::Field, spatial::Spatial};
|
use crate::nodes::{
|
||||||
|
fields::{Field, FieldTrait},
|
||||||
|
spatial::Spatial,
|
||||||
|
};
|
||||||
use glam::{Mat4, Quat};
|
use glam::{Mat4, Quat};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ impl ItemUI {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(acceptor_field_node) = acceptor.field.spatial_ref().node() else {
|
let Some(acceptor_field_node) = acceptor.field.spatial.node() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let Ok(acceptor_field_alias) = Alias::create(
|
let Ok(acceptor_field_alias) = Alias::create(
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
pub mod zone;
|
pub mod zone;
|
||||||
|
|
||||||
use self::zone::Zone;
|
use self::zone::Zone;
|
||||||
use super::fields::Field;
|
use super::alias::Alias;
|
||||||
use super::{Aspect, Node};
|
use super::fields::{Field, FieldTrait};
|
||||||
|
use super::Aspect;
|
||||||
use crate::core::client::Client;
|
use crate::core::client::Client;
|
||||||
use crate::core::registry::Registry;
|
use crate::core::registry::Registry;
|
||||||
use crate::create_interface;
|
use crate::create_interface;
|
||||||
use crate::nodes::OWNED_ASPECT_ALIAS_INFO;
|
use crate::nodes::{Node, OWNED_ASPECT_ALIAS_INFO};
|
||||||
use color_eyre::eyre::{eyre, Result};
|
use color_eyre::eyre::{eyre, OptionExt, Result};
|
||||||
use glam::{vec3a, Mat4, Quat, Vec3};
|
use glam::{vec3a, Mat4, Quat, Vec3};
|
||||||
use mint::Vector3;
|
use mint::Vector3;
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use rustc_hash::FxHashMap;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::sync::{Arc, Weak};
|
use std::sync::{Arc, Weak};
|
||||||
@@ -37,6 +39,10 @@ impl Transform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lazy_static::lazy_static! {
|
||||||
|
pub static ref EXPORTED_SPATIALS: Mutex<FxHashMap<u64, Arc<Node>>> = Mutex::new(FxHashMap::default());
|
||||||
|
}
|
||||||
|
|
||||||
static ZONEABLE_REGISTRY: Registry<Spatial> = Registry::new();
|
static ZONEABLE_REGISTRY: Registry<Spatial> = Registry::new();
|
||||||
|
|
||||||
pub struct Spatial {
|
pub struct Spatial {
|
||||||
@@ -354,6 +360,13 @@ impl SpatialAspect for Spatial {
|
|||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// legit gotta find a way to remove old ones, this just keeps the node alive
|
||||||
|
async fn export_spatial(node: Arc<Node>, _calling_client: Arc<Client>) -> Result<u64> {
|
||||||
|
let id = rand::random();
|
||||||
|
EXPORTED_SPATIALS.lock().insert(id, node);
|
||||||
|
Ok(id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
impl PartialEq for Spatial {
|
impl PartialEq for Spatial {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
@@ -426,6 +439,26 @@ impl InterfaceAspect for SpatialInterface {
|
|||||||
Zone::add_to(&node, space, field);
|
Zone::add_to(&node, space, field);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn import_spatial_ref(
|
||||||
|
_node: Arc<Node>,
|
||||||
|
calling_client: Arc<Client>,
|
||||||
|
uid: u64,
|
||||||
|
) -> Result<Arc<Node>> {
|
||||||
|
EXPORTED_SPATIALS
|
||||||
|
.lock()
|
||||||
|
.get(&uid)
|
||||||
|
.map(|s| {
|
||||||
|
Alias::create(
|
||||||
|
s,
|
||||||
|
&calling_client,
|
||||||
|
SPATIAL_REF_ASPECT_ALIAS_INFO.clone(),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
})
|
||||||
|
.ok_or_eyre("Couldn't find spatial with that ID")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
create_interface!(SpatialInterface);
|
create_interface!(SpatialInterface);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use crate::{
|
|||||||
core::{client::Client, registry::Registry},
|
core::{client::Client, registry::Registry},
|
||||||
nodes::{
|
nodes::{
|
||||||
alias::{get_original, Alias, AliasList},
|
alias::{get_original, Alias, AliasList},
|
||||||
fields::Field,
|
fields::{Field, FieldTrait},
|
||||||
Aspect, Node,
|
Aspect, Node,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
core::client::INTERNAL_CLIENT,
|
core::client::INTERNAL_CLIENT,
|
||||||
nodes::{
|
nodes::{
|
||||||
fields::Ray,
|
fields::{FieldTrait, Ray},
|
||||||
input::{InputDataType, InputMethod, Pointer, INPUT_HANDLER_REGISTRY},
|
input::{InputDataType, InputMethod, Pointer, INPUT_HANDLER_REGISTRY},
|
||||||
spatial::Spatial,
|
spatial::Spatial,
|
||||||
Node,
|
Node,
|
||||||
@@ -46,9 +46,11 @@ impl EyePointer {
|
|||||||
}
|
}
|
||||||
pub fn update(&self) {
|
pub fn update(&self) {
|
||||||
let ray = Input::get_eyes();
|
let ray = Input::get_eyes();
|
||||||
self.spatial.set_local_transform(
|
self.spatial
|
||||||
Mat4::from_rotation_translation(ray.orientation.into(), ray.position.into()),
|
.set_local_transform(Mat4::from_rotation_translation(
|
||||||
);
|
ray.orientation.into(),
|
||||||
|
ray.position.into(),
|
||||||
|
));
|
||||||
{
|
{
|
||||||
// Set pointer input datamap
|
// Set pointer input datamap
|
||||||
*self.pointer.datamap.lock() = Datamap::from_typed(EyeDatamap { eye: 2 }).unwrap();
|
*self.pointer.datamap.lock() = Datamap::from_typed(EyeDatamap { eye: 2 }).unwrap();
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use crate::{
|
|||||||
data::{
|
data::{
|
||||||
mask_matches, pulse_receiver_client, PulseSender, KEYMAPS, PULSE_RECEIVER_REGISTRY,
|
mask_matches, pulse_receiver_client, PulseSender, KEYMAPS, PULSE_RECEIVER_REGISTRY,
|
||||||
},
|
},
|
||||||
fields::Ray,
|
fields::{FieldTrait, Ray},
|
||||||
input::{InputDataType, InputHandler, InputMethod, Pointer, INPUT_HANDLER_REGISTRY},
|
input::{InputDataType, InputHandler, InputMethod, Pointer, INPUT_HANDLER_REGISTRY},
|
||||||
spatial::Spatial,
|
spatial::Spatial,
|
||||||
Node,
|
Node,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
core::client::INTERNAL_CLIENT,
|
core::client::INTERNAL_CLIENT,
|
||||||
nodes::{
|
nodes::{
|
||||||
|
fields::FieldTrait,
|
||||||
input::{InputDataType, InputHandler, InputMethod, Tip, INPUT_HANDLER_REGISTRY},
|
input::{InputDataType, InputHandler, InputMethod, Tip, INPUT_HANDLER_REGISTRY},
|
||||||
spatial::Spatial,
|
spatial::Spatial,
|
||||||
Node,
|
Node,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::core::client::INTERNAL_CLIENT;
|
use crate::core::client::INTERNAL_CLIENT;
|
||||||
use crate::nodes::fields::Field;
|
use crate::nodes::fields::{Field, FieldTrait};
|
||||||
use crate::nodes::input::{InputDataType, InputHandler, INPUT_HANDLER_REGISTRY};
|
use crate::nodes::input::{InputDataType, InputHandler, INPUT_HANDLER_REGISTRY};
|
||||||
use crate::nodes::{
|
use crate::nodes::{
|
||||||
input::{Hand, InputMethod, Joint},
|
input::{Hand, InputMethod, Joint},
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use crate::{
|
|||||||
core::client::INTERNAL_CLIENT,
|
core::client::INTERNAL_CLIENT,
|
||||||
nodes::{
|
nodes::{
|
||||||
data::PulseReceiver,
|
data::PulseReceiver,
|
||||||
fields::{r#box::BoxField, Field},
|
fields::{Field, Shape},
|
||||||
spatial::Spatial,
|
spatial::Spatial,
|
||||||
Node,
|
Node,
|
||||||
},
|
},
|
||||||
@@ -41,7 +41,7 @@ impl PlaySpace {
|
|||||||
pub fn new() -> Result<Self> {
|
pub fn new() -> Result<Self> {
|
||||||
let node = Node::generate(&INTERNAL_CLIENT, false).add_to_scenegraph()?;
|
let node = Node::generate(&INTERNAL_CLIENT, false).add_to_scenegraph()?;
|
||||||
let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false);
|
let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false);
|
||||||
BoxField::add_to(&node, [0.0; 3].into());
|
Field::add_to(&node, Shape::Box([0.0; 3].into()))?;
|
||||||
let field = node.get_aspect::<Field>()?.clone();
|
let field = node.get_aspect::<Field>()?.clone();
|
||||||
|
|
||||||
let pulse_rx = PulseReceiver::add_to(
|
let pulse_rx = PulseReceiver::add_to(
|
||||||
@@ -59,12 +59,12 @@ impl PlaySpace {
|
|||||||
}
|
}
|
||||||
pub fn update(&self) {
|
pub fn update(&self) {
|
||||||
let pose = World::get_bounds_pose();
|
let pose = World::get_bounds_pose();
|
||||||
self.spatial.set_local_transform(
|
self.spatial
|
||||||
Mat4::from_rotation_translation(pose.orientation.into(), pose.position.into()),
|
.set_local_transform(Mat4::from_rotation_translation(
|
||||||
);
|
pose.orientation.into(),
|
||||||
let Field::Box(box_field) = self.field.as_ref() else {
|
pose.position.into(),
|
||||||
return;
|
));
|
||||||
};
|
*self.field.shape.lock() =
|
||||||
box_field.set_size([World::get_bounds_size().x, 0.0, World::get_bounds_size().y].into());
|
Shape::Box([World::get_bounds_size().x, 0.0, World::get_bounds_size().y].into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user