Compare commits
2 commits
25a87274ef
...
6f56ec8d83
Author | SHA1 | Date | |
---|---|---|---|
6f56ec8d83 | |||
b90a81bcc5 |
4 changed files with 30 additions and 13 deletions
|
@ -37,7 +37,7 @@ chrono = { version = "0.4.35", features = ["serde"] }
|
|||
anyhow = { version = "1.0.86", features = ["backtrace"] }
|
||||
indexmap = { version = "2.2.6", features = ["rayon"] }
|
||||
shaderc = { version = "0.8.3", features = ["build-from-source"] }
|
||||
rusqlite = { version = "0.32.0", features = ["bundled"] }
|
||||
rusqlite = { version = "0.33.0", features = ["bundled"] }
|
||||
cgmath = "0.18.0"
|
||||
http = "1.1.0"
|
||||
iterchunks = "0.5.0"
|
||||
|
|
|
@ -14,13 +14,13 @@ pub struct WorldBuilder {
|
|||
pub(crate) updates: Updates,
|
||||
pub events: Events,
|
||||
pub resources: Resources,
|
||||
systems: Vec<Box<dyn Fn(&mut World) -> Result<()> + Send + Sync + 'static>>,
|
||||
systems: Vec<Box<dyn Fn(&mut World) -> Result<bool> + Send + Sync + 'static>>,
|
||||
}
|
||||
|
||||
impl WorldBuilder {
|
||||
pub fn add_system<F>(&mut self, f: F)
|
||||
where
|
||||
F: Fn(&mut World) -> Result<()> + Send + Sync + 'static,
|
||||
F: Fn(&mut World) -> Result<bool> + Send + Sync + 'static,
|
||||
{
|
||||
self.systems.push(Box::new(f));
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ pub struct World {
|
|||
|
||||
start_time: Instant,
|
||||
|
||||
systems: Vec<Box<dyn Fn(&mut World) -> Result<()> + Send + Sync + 'static>>,
|
||||
systems: Vec<Box<dyn Fn(&mut World) -> Result<bool> + Send + Sync + 'static>>,
|
||||
}
|
||||
|
||||
impl World {
|
||||
|
@ -349,7 +349,9 @@ impl World {
|
|||
self.commit_entity_changes()?;
|
||||
|
||||
for system in systems.iter() {
|
||||
system(self)?;
|
||||
if !system(self)? {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,6 +207,15 @@ impl Engine {
|
|||
world.resources.insert(engine);
|
||||
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);
|
||||
|
||||
Ok(())
|
||||
|
@ -247,10 +256,13 @@ impl Engine {
|
|||
pub fn build_path(&self, path: &str) -> AssetPath {
|
||||
(self.resource_base_path.as_str(), path).into()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main_system(world: &mut World) -> Result<()> {
|
||||
//
|
||||
|
||||
Ok(())
|
||||
impl Engine {
|
||||
fn main_system(world: &mut World) -> Result<bool> {
|
||||
world
|
||||
.resources
|
||||
.get_mut_unchecked::<Context>()
|
||||
.next_frame::<()>(world)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,15 +55,18 @@ pub struct Scene {
|
|||
|
||||
impl Scene {
|
||||
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,
|
||||
raytracer_info: RaytracingInfo,
|
||||
graphics_info: GraphicsInfo,
|
||||
world: &mut WorldBuilder,
|
||||
) -> 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) =
|
||||
Self::create_rendering_front_end(
|
||||
device,
|
||||
|
|
Loading…
Reference in a new issue