Compare commits

..

1 commit

Author SHA1 Message Date
64394127a8 Update Rust crate itertools to 0.14.0 2025-02-27 15:02:24 +00:00
3 changed files with 12 additions and 29 deletions

View file

@ -14,13 +14,13 @@ pub struct WorldBuilder {
pub(crate) updates: Updates, pub(crate) updates: Updates,
pub events: Events, pub events: Events,
pub resources: Resources, pub resources: Resources,
systems: Vec<Box<dyn Fn(&mut World) -> Result<bool> + Send + Sync + 'static>>, systems: Vec<Box<dyn Fn(&mut World) -> Result<()> + Send + Sync + 'static>>,
} }
impl WorldBuilder { impl WorldBuilder {
pub fn add_system<F>(&mut self, f: F) pub fn add_system<F>(&mut self, f: F)
where where
F: Fn(&mut World) -> Result<bool> + Send + Sync + 'static, F: Fn(&mut World) -> Result<()> + Send + Sync + 'static,
{ {
self.systems.push(Box::new(f)); self.systems.push(Box::new(f));
} }
@ -66,7 +66,7 @@ pub struct World {
start_time: Instant, start_time: Instant,
systems: Vec<Box<dyn Fn(&mut World) -> Result<bool> + Send + Sync + 'static>>, systems: Vec<Box<dyn Fn(&mut World) -> Result<()> + Send + Sync + 'static>>,
} }
impl World { impl World {
@ -349,9 +349,7 @@ impl World {
self.commit_entity_changes()?; self.commit_entity_changes()?;
for system in systems.iter() { for system in systems.iter() {
if !system(self)? { system(self)?;
return Ok(());
}
} }
} }
} }

View file

@ -207,15 +207,6 @@ impl Engine {
world.resources.insert(engine); world.resources.insert(engine);
world.resources.insert(engine_settings); world.resources.insert(engine_settings);
let scene = Scene::new(
create_info.rasterizer_info,
create_info.raytracing_info,
create_info.graphics_info,
world,
)?;
world.resources.insert(scene);
world.add_system(Self::main_system); world.add_system(Self::main_system);
Ok(()) Ok(())
@ -256,13 +247,10 @@ impl Engine {
pub fn build_path(&self, path: &str) -> AssetPath { pub fn build_path(&self, path: &str) -> AssetPath {
(self.resource_base_path.as_str(), path).into() (self.resource_base_path.as_str(), path).into()
} }
}
impl Engine { pub fn main_system(world: &mut World) -> Result<()> {
fn main_system(world: &mut World) -> Result<bool> { //
world
.resources Ok(())
.get_mut_unchecked::<Context>()
.next_frame::<()>(world)
} }
} }

View file

@ -55,18 +55,15 @@ pub struct Scene {
impl Scene { impl Scene {
pub(crate) fn new( pub(crate) fn new(
device: &Arc<Device>,
queue: &Arc<Mutex<Queue>>,
(screen_width, screen_height): (f32, f32),
images: &TargetMode<Vec<Arc<Image>>>,
rasterizer_info: RasterizerInfo, rasterizer_info: RasterizerInfo,
raytracer_info: RaytracingInfo, raytracer_info: RaytracingInfo,
graphics_info: GraphicsInfo, graphics_info: GraphicsInfo,
world: &mut WorldBuilder, world: &mut WorldBuilder,
) -> Result<()> { ) -> Result<()> {
let context = world.resources.get::<Context>();
let device = context.device();
let queue = context.queue();
let (screen_width, screen_height) = (context.width() as f32, context.height() as f32);
let images = &context.images();
let (renderer, render_type): (Box<dyn RenderingFrontEnd + Send + Sync>, SceneType) = let (renderer, render_type): (Box<dyn RenderingFrontEnd + Send + Sync>, SceneType) =
Self::create_rendering_front_end( Self::create_rendering_front_end(
device, device,