diff --git a/.gitignore b/.gitignore index e3e65ee..dccf5ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ /target target + +Cargo.lock + +imgui.ini diff --git a/src/draw.rs b/src/draw.rs deleted file mode 100644 index 01d21b5..0000000 --- a/src/draw.rs +++ /dev/null @@ -1,71 +0,0 @@ -use std::collections::HashMap; -use std::rc::Rc; - -use crate::entity::EntityHandle; -use crate::loaders::mesh::Mesh; -use crate::render::{DrawCall, Pipeline}; - -pub type DrawHandle = usize; - -struct DrawEntry -{ - mesh: Rc, - entity: EntityHandle, - pipeline: Pipeline, -} - -pub struct DrawManager -{ - entries: HashMap, - next_handle: DrawHandle, -} - -impl DrawManager -{ - pub fn new() -> Self - { - Self { - entries: HashMap::new(), - next_handle: 0, - } - } - - pub fn draw_mesh_internal( - &mut self, - mesh: Rc, - entity: EntityHandle, - pipeline: Pipeline, - ) -> DrawHandle - { - let handle = self.next_handle; - self.next_handle += 1; - - self.entries.insert( - handle, - DrawEntry { - mesh, - entity, - pipeline, - }, - ); - - handle - } - - pub fn clear_mesh_internal(&mut self, handle: DrawHandle) - { - self.entries.remove(&handle); - } - - pub fn collect_draw_calls(&self) -> Vec - { - vec![] - } - - pub fn draw_mesh(_mesh: Rc, _entity: EntityHandle, _pipeline: Pipeline) -> DrawHandle - { - 0 - } - - pub fn clear_mesh(_handle: DrawHandle) {} -} diff --git a/src/event.rs b/src/event.rs deleted file mode 100644 index 285c91f..0000000 --- a/src/event.rs +++ /dev/null @@ -1,70 +0,0 @@ -use std::any::{Any, TypeId}; -use std::cell::RefCell; -use std::collections::HashMap; - -pub trait Event: std::fmt::Debug {} - -type EventHandler = Box; - -pub struct EventBus -{ - handlers: HashMap>, -} - -impl EventBus -{ - fn new() -> Self - { - Self { - handlers: HashMap::new(), - } - } - - fn subscribe_internal(&mut self, handler: F) - { - let type_id = TypeId::of::(); - let handlers: &mut Vec> = self - .handlers - .entry(type_id) - .or_insert_with(|| Box::new(Vec::>::new())) - .downcast_mut() - .unwrap(); - - handlers.push(Box::new(handler)); - } - - fn publish_internal(&mut self, event: &T) - { - let type_id = TypeId::of::(); - - if let Some(handlers) = self.handlers.get_mut(&type_id) - { - let typed_handlers = handlers.downcast_mut::>>().unwrap(); - for handler in typed_handlers - { - handler(event); - } - } - } - - pub fn subscribe(handler: F) - { - EVENT_BUS.with(|bus| bus.borrow_mut().subscribe_internal(handler)); - } - - pub fn publish(event: &T) - { - EVENT_BUS.with(|bus| bus.borrow_mut().publish_internal(event)); - } -} - -thread_local! { - static EVENT_BUS: RefCell = RefCell::new(EventBus::new()); -} - -#[derive(Debug, Clone)] -pub struct UpdateEvent -{ - pub delta: f32, -} -impl Event for UpdateEvent {} diff --git a/src/main.rs b/src/main.rs index bf16560..62016d9 100755 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,6 @@ mod components; mod debug; mod editor; mod entity; -mod event; mod loaders; mod physics; mod postprocess;