From 70fecc8cdde61678a3a22ec4cbc0e6c5cd769a08 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Sat, 2 Mar 2024 21:37:21 -0500 Subject: [PATCH] fixes across crates after changes to ecs --- examples/testbed/src/free_fly_camera.rs | 5 +---- examples/testbed/src/main.rs | 8 +++++++- lyra-game/src/delta_time.rs | 2 +- lyra-game/src/game.rs | 2 +- lyra-game/src/input/action.rs | 2 +- lyra-game/src/input/system.rs | 2 +- lyra-game/src/render/light/mod.rs | 2 +- lyra-game/src/render/renderer.rs | 2 +- lyra-game/src/render/window.rs | 2 +- lyra-reflect/src/lib.rs | 2 +- lyra-resource/src/loader/model.rs | 2 ++ lyra-scripting/src/lua/dynamic_iter.rs | 10 +++++----- lyra-scripting/src/lua/world.rs | 10 +++++----- lyra-scripting/src/world.rs | 2 +- 14 files changed, 29 insertions(+), 24 deletions(-) diff --git a/examples/testbed/src/free_fly_camera.rs b/examples/testbed/src/free_fly_camera.rs index f4d7411..f2fd972 100644 --- a/examples/testbed/src/free_fly_camera.rs +++ b/examples/testbed/src/free_fly_camera.rs @@ -1,8 +1,5 @@ use lyra_engine::{ - game::Game, - input::{ActionHandler, CommonActionLabel}, - math::{Quat, Vec3, EulerRot}, - plugin::Plugin, ecs::{Component, query::{Res, View}}, DeltaTime, scene::CameraComponent, + ecs::{query::{Res, View}, Component}, game::Game, input::ActionHandler, math::{EulerRot, Quat, Vec3}, plugin::Plugin, scene::CameraComponent, DeltaTime }; /* enum FreeFlyCameraActions { diff --git a/examples/testbed/src/main.rs b/examples/testbed/src/main.rs index 36db6dc..cc34877 100644 --- a/examples/testbed/src/main.rs +++ b/examples/testbed/src/main.rs @@ -1,6 +1,6 @@ use std::ptr::NonNull; -use lyra_engine::{math::{self, Vec3}, math::Transform, input::{KeyCode, ActionHandler, Action, ActionKind, LayoutId, ActionMapping, ActionSource, ActionMappingId, InputActionPlugin, MouseInput, MouseAxis, CommonActionLabel}, game::Game, render::{window::{CursorGrabMode, WindowOptions}, light::{PointLight, directional::DirectionalLight, SpotLight}}, change_tracker::Ct, ecs::{system::{Criteria, CriteriaSchedule, BatchedSystem, IntoSystem}, world::World, Component}, DeltaTime, scene::{ModelComponent, CameraComponent}, lua::{LuaScriptingPlugin, LuaScript}, Script, ScriptList}; +use lyra_engine::{math::{self, Vec3}, math::Transform, input::{KeyCode, ActionHandler, Action, ActionKind, LayoutId, ActionMapping, ActionSource, ActionMappingId, InputActionPlugin, MouseInput, MouseAxis, CommonActionLabel}, game::Game, render::{window::{CursorGrabMode, WindowOptions}, light::{PointLight, directional::DirectionalLight, SpotLight}}, change_tracker::Ct, ecs::{system::{Criteria, CriteriaSchedule, BatchedSystem, IntoSystem}, World, Component}, DeltaTime, scene::{ModelComponent, CameraComponent}, lua::{LuaScriptingPlugin, LuaScript}, Script, ScriptList}; use lyra_engine::assets::{ResourceManager, Model}; mod free_fly_camera; @@ -88,6 +88,7 @@ async fn main() { //let cube_model = resman.request::("assets/cube-texture-bin.glb").unwrap(); let cube_model = resman.request::("assets/texture-sep/texture-sep.gltf").unwrap(); let crate_model = resman.request::("assets/crate/crate.gltf").unwrap(); + //let sponza_model = resman.request::("assets/sponza/Sponza.gltf").unwrap(); drop(resman); /* world.spawn(( @@ -95,6 +96,11 @@ async fn main() { Transform::from_xyz(0.0, -5.0, -10.0), )); */ + /* world.spawn(( + ModelComponent(sponza_model), + Transform::from_xyz(0.0, 0.0, 0.0), + )); */ + { let cube_tran = Transform::from_xyz(-3.5, 0.0, -8.0); //cube_tran.rotate_y(math::Angle::Degrees(180.0)); diff --git a/lyra-game/src/delta_time.rs b/lyra-game/src/delta_time.rs index d074677..2c19944 100644 --- a/lyra-game/src/delta_time.rs +++ b/lyra-game/src/delta_time.rs @@ -1,5 +1,5 @@ use instant::Instant; -use lyra_ecs::{Component, world::World}; +use lyra_ecs::{Component, World}; use lyra_reflect::Reflect; use crate::{plugin::Plugin, game::GameStages}; diff --git a/lyra-game/src/game.rs b/lyra-game/src/game.rs index 953b462..fe9f9d9 100755 --- a/lyra-game/src/game.rs +++ b/lyra-game/src/game.rs @@ -2,7 +2,7 @@ use std::{sync::Arc, collections::VecDeque, ptr::NonNull}; use async_std::task::block_on; -use lyra_ecs::{world::World, system::{System, IntoSystem}}; +use lyra_ecs::{World, system::{System, IntoSystem}}; use tracing::{info, error, Level}; use tracing_appender::non_blocking; use tracing_subscriber::{ diff --git a/lyra-game/src/input/action.rs b/lyra-game/src/input/action.rs index aa756bf..bbb5f10 100644 --- a/lyra-game/src/input/action.rs +++ b/lyra-game/src/input/action.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, ops::Deref, hash::{Hash, DefaultHasher, Hasher}, fmt::Debug}; use glam::Vec2; -use lyra_ecs::world::World; +use lyra_ecs::World; use lyra_reflect::Reflect; use crate::{plugin::Plugin, game::GameStages, EventQueue}; diff --git a/lyra-game/src/input/system.rs b/lyra-game/src/input/system.rs index ec6b20f..fb04a0f 100755 --- a/lyra-game/src/input/system.rs +++ b/lyra-game/src/input/system.rs @@ -1,7 +1,7 @@ use std::ptr::NonNull; use glam::Vec2; -use lyra_ecs::{world::World, system::IntoSystem}; +use lyra_ecs::{World, system::IntoSystem}; use winit::event::MouseScrollDelta; use crate::{EventQueue, plugin::Plugin, game::GameStages}; diff --git a/lyra-game/src/render/light/mod.rs b/lyra-game/src/render/light/mod.rs index adbe0b5..ee3c81b 100644 --- a/lyra-game/src/render/light/mod.rs +++ b/lyra-game/src/render/light/mod.rs @@ -2,7 +2,7 @@ pub mod point; pub mod directional; pub mod spotlight; -use lyra_ecs::{Entity, Tick, world::World, query::{Entities, TickOf}}; +use lyra_ecs::{Entity, Tick, World, query::{Entities, TickOf}}; pub use point::*; pub use spotlight::*; diff --git a/lyra-game/src/render/renderer.rs b/lyra-game/src/render/renderer.rs index a513d8f..48d77d2 100755 --- a/lyra-game/src/render/renderer.rs +++ b/lyra-game/src/render/renderer.rs @@ -7,7 +7,7 @@ use instant::Instant; use itertools::izip; use lyra_ecs::Entity; use lyra_ecs::query::{Entities, TickOf}; -use lyra_ecs::world::World; +use lyra_ecs::World; use tracing::{debug, warn}; use wgpu::{BindGroupLayout, Limits}; use wgpu::util::DeviceExt; diff --git a/lyra-game/src/render/window.rs b/lyra-game/src/render/window.rs index d577996..c63c632 100644 --- a/lyra-game/src/render/window.rs +++ b/lyra-game/src/render/window.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use glam::{Vec2, IVec2}; -use lyra_ecs::world::World; +use lyra_ecs::World; use tracing::{warn, error}; use winit::{window::{Window, Fullscreen}, dpi::{LogicalPosition, LogicalSize, PhysicalPosition}, error::ExternalError}; diff --git a/lyra-reflect/src/lib.rs b/lyra-reflect/src/lib.rs index 0b8437f..6389a0a 100644 --- a/lyra-reflect/src/lib.rs +++ b/lyra-reflect/src/lib.rs @@ -2,7 +2,7 @@ use std::{any::TypeId, any::Any, cell::{Ref, RefMut}}; -use lyra_ecs::{world::World, DynamicBundle, Component, Entity, ComponentInfo}; +use lyra_ecs::World; extern crate self as lyra_reflect; diff --git a/lyra-resource/src/loader/model.rs b/lyra-resource/src/loader/model.rs index 396eae5..b5ed36d 100644 --- a/lyra-resource/src/loader/model.rs +++ b/lyra-resource/src/loader/model.rs @@ -62,6 +62,8 @@ impl ModelLoader { fn process_node(buffers: &Vec>, materials: &Vec, node: gltf::Node<'_>) -> Vec { let mut meshes = vec![]; + //node.transform() + if let Some(mesh) = node.mesh() { for prim in mesh.primitives() { let reader = prim.reader(|buf| Some(buffers[buf.index()].as_slice())); diff --git a/lyra-scripting/src/lua/dynamic_iter.rs b/lyra-scripting/src/lua/dynamic_iter.rs index c504470..9a9cc46 100644 --- a/lyra-scripting/src/lua/dynamic_iter.rs +++ b/lyra-scripting/src/lua/dynamic_iter.rs @@ -27,7 +27,7 @@ impl<'a> Fetch<'a> for FetchDynamicType { unsafe fn get_item(&mut self, entity: ArchetypeEntityId) -> Self::Item { let ptr = unsafe { self.col.as_ref().borrow_ptr() }; let ptr = NonNull::new_unchecked(ptr.as_ptr() - .add(entity.0 as usize * self.info.layout.size)); + .add(entity.0 as usize * self.info.layout().size())); DynamicType { info: self.info, @@ -96,7 +96,7 @@ impl Iterator for DynamicViewIter { } let arch = unsafe { self.archetypes.get_unchecked(self.next_archetype - 1).as_ref() }; - let entity = arch.entity_of_index(entity_index).unwrap(); + let entity = arch.entity_at_index(entity_index).unwrap(); let row = DynamicViewRow { entity, item: fetch_res, @@ -112,7 +112,7 @@ impl Iterator for DynamicViewIter { self.next_archetype += 1; let arch = unsafe { self.archetypes.get_unchecked(arch_id).as_ref() }; - if arch.entities().len() == 0 { + if arch.entity_indexes().len() == 0 { continue; } @@ -126,7 +126,7 @@ impl Iterator for DynamicViewIter { .map(|q| unsafe { q.fetch(world, ArchetypeId(arch_id as u64), arch) } ) .map(|f| FetchDynamicType::from(f)) .collect(); - self.component_indices = 0..arch.entities().len() as u64; + self.component_indices = 0..arch.entity_indexes().len() as u64; } } } @@ -167,7 +167,7 @@ impl ReflectedIterator { let mut dynamic_row = vec![]; for d in row.item.iter() { - let id = d.info.type_id.as_rust(); + let id = d.info.type_id().as_rust(); let reflected_components = unsafe { self.reflected_components.as_ref().unwrap().as_ref() }; diff --git a/lyra-scripting/src/lua/world.rs b/lyra-scripting/src/lua/world.rs index 848bd86..83e316b 100644 --- a/lyra-scripting/src/lua/world.rs +++ b/lyra-scripting/src/lua/world.rs @@ -192,14 +192,14 @@ impl elua::Userdata for ScriptWorldPtr { let lua_comp = reflect_user_data(ud); let refl_comp = lua_comp.reflect_branch.as_component_unchecked(); - refl_comp.info.type_id.as_rust() - } + refl_comp.info.type_id().as_rust() + }, elua::Value::Table(tbl) => { let name: String = tbl.get(elua::MetaMethod::Name)?; let lookup = world.get_resource::(); *lookup.typeid_from_name.get(&name).unwrap() - } + }, _ => { panic!("A userdata or table value was not returned!"); // TODO: Handle properly @@ -209,8 +209,8 @@ impl elua::Userdata for ScriptWorldPtr { // update the component tick let world = unsafe { this.inner.as_mut() }; let arch = world.entity_archetype_mut(row.entity).unwrap(); - let idx = arch.entities().get(&row.entity).unwrap().clone(); - let c = arch.get_column_mut(lua_typeid.into()).unwrap(); + let idx = arch.entity_indexes().get(&row.entity).unwrap().clone(); + let c = arch.get_column_mut(lua_typeid).unwrap(); c.entity_ticks[idx.0 as usize] = current; // apply the new component data diff --git a/lyra-scripting/src/world.rs b/lyra-scripting/src/world.rs index c2b2a1f..fd27bc8 100644 --- a/lyra-scripting/src/world.rs +++ b/lyra-scripting/src/world.rs @@ -1,6 +1,6 @@ use std::ptr::NonNull; -use lyra_ecs::{world::World, Entity}; +use lyra_ecs::{World, Entity}; #[derive(Clone)] pub struct ScriptEntity(pub Entity);