refactor: use typemap for aspects!

This commit is contained in:
Nova
2024-02-05 05:09:48 -05:00
parent 36dacb3322
commit d4b7c3f61a
36 changed files with 518 additions and 528 deletions

View File

@@ -30,7 +30,7 @@ impl EyePointer {
pub fn new() -> Result<Self> {
let node = Node::create_parent_name(&INTERNAL_CLIENT, "", &nanoid!(), false)
.add_to_scenegraph()?;
let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false).unwrap();
let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false);
let pointer =
InputMethod::add_to(&node, InputType::Pointer(Pointer::default()), None).unwrap();

View File

@@ -4,7 +4,7 @@ use crate::{
data::{
mask_matches, pulse_receiver_client, PulseSender, KEYMAPS, PULSE_RECEIVER_REGISTRY,
},
fields::Ray,
fields::{Field, Ray},
input::{pointer::Pointer, InputMethod, InputType},
spatial::Spatial,
Node,
@@ -60,7 +60,7 @@ impl MousePointer {
pub fn new() -> Result<Self> {
let node = Node::create_parent_name(&INTERNAL_CLIENT, "", &nanoid!(), false)
.add_to_scenegraph()?;
let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false).unwrap();
let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false);
let pointer =
InputMethod::add_to(&node, InputType::Pointer(Pointer::default()), None).unwrap();
@@ -140,7 +140,7 @@ impl MousePointer {
.into_iter()
.filter(|rx| mask_matches(&rx.mask, &self.keyboard_sender.mask))
.map(|rx| {
let result = rx.field_node.field.get().unwrap().ray_march(Ray {
let result = rx.field_node.get_aspect::<Field>().unwrap().ray_march(Ray {
origin: vec3(0.0, 0.0, 0.0),
direction: vec3(0.0, 0.0, -1.0),
space: self.spatial.clone(),

View File

@@ -43,7 +43,7 @@ impl SkController {
false,
)
.add_to_scenegraph()?;
Spatial::add_to(&_node, None, Mat4::IDENTITY, false)?;
Spatial::add_to(&_node, None, Mat4::IDENTITY, false);
let model = sk.model_create_mem("cursor.glb", include_bytes!("cursor.glb"), None)?;
let tip = InputType::Tip(Tip::default());
let input = InputMethod::add_to(&_node, tip, None)?;

View File

@@ -42,7 +42,7 @@ impl SkHand {
pub fn new(handed: Handed) -> Result<Self> {
let _node = Node::create_parent_name(&INTERNAL_CLIENT, "", &nanoid!(), false)
.add_to_scenegraph()?;
Spatial::add_to(&_node, None, Mat4::IDENTITY, false)?;
Spatial::add_to(&_node, None, Mat4::IDENTITY, false);
let hand = InputType::Hand(Box::new(Hand {
base: FlatHand {
right: handed == Handed::Right,

View File

@@ -42,8 +42,9 @@ impl PlaySpace {
pub fn new() -> Result<Self> {
let node = Node::create_parent_name(&INTERNAL_CLIENT, "", &nanoid!(), false)
.add_to_scenegraph()?;
let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false)?;
let field = BoxField::add_to(&node, [0.0; 3].into())?;
let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false);
BoxField::add_to(&node, [0.0; 3].into());
let field = node.get_aspect::<Field>()?.clone();
let pulse_rx = PulseReceiver::add_to(
&node,