Skip to content

Commit

Permalink
fix(items): add the proper aspects
Browse files Browse the repository at this point in the history
  • Loading branch information
technobaboo committed Sep 11, 2024
1 parent de1efd4 commit cdb4370
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
30 changes: 15 additions & 15 deletions src/nodes/items/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,19 @@ pub struct CameraItem {
#[allow(unused)]
impl CameraItem {
pub fn add_to(node: &Arc<Node>, proj_matrix: Mat4, px_size: Vector2<u32>) {
Item::add_to(
node,
&ITEM_TYPE_INFO_CAMERA,
ItemType::Camera(CameraItem {
space: node.get_aspect::<Spatial>().unwrap().clone(),
frame_info: Mutex::new(FrameInfo {
proj_matrix,
px_size,
}),
sk_tex: OnceCell::new(),
sk_mat: OnceCell::new(),
applied_to: Registry::new(),
apply_to: Registry::new(),
let item = Arc::new(CameraItem {
space: node.get_aspect::<Spatial>().unwrap().clone(),
frame_info: Mutex::new(FrameInfo {
proj_matrix,
px_size,
}),
);
node.add_aspect(CameraItemUi);
sk_tex: OnceCell::new(),
sk_mat: OnceCell::new(),
applied_to: Registry::new(),
apply_to: Registry::new(),
});
Item::add_to(node, &ITEM_TYPE_INFO_CAMERA, ItemType::Camera(item.clone()));
node.add_aspect_raw(item);
}

fn frame_flex(
Expand Down Expand Up @@ -171,6 +168,9 @@ impl CameraItem {
}
}
}
impl Aspect for CameraItem {
impl_aspect_for_camera_item_aspect! {}
}
impl CameraItemAspect for CameraItem {}

pub struct CameraItemUi;
Expand Down
2 changes: 1 addition & 1 deletion src/nodes/items/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl Drop for Item {
}

pub enum ItemType {
Camera(CameraItem),
Camera(Arc<CameraItem>),
Panel(Arc<dyn PanelItemTrait>),
}
impl ItemType {
Expand Down
1 change: 1 addition & 0 deletions src/nodes/items/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl<B: Backend> PanelItem<B> {
&ITEM_TYPE_INFO_PANEL,
ItemType::Panel(generic_panel_item),
);
node.add_aspect_raw(panel_item.clone());

(node, panel_item)
}
Expand Down

0 comments on commit cdb4370

Please sign in to comment.