fixes across crates after changes to ecs
This commit is contained in:
parent
c0df9f2d65
commit
70fecc8cdd
|
@ -1,8 +1,5 @@
|
||||||
use lyra_engine::{
|
use lyra_engine::{
|
||||||
game::Game,
|
ecs::{query::{Res, View}, Component}, game::Game, input::ActionHandler, math::{EulerRot, Quat, Vec3}, plugin::Plugin, scene::CameraComponent, DeltaTime
|
||||||
input::{ActionHandler, CommonActionLabel},
|
|
||||||
math::{Quat, Vec3, EulerRot},
|
|
||||||
plugin::Plugin, ecs::{Component, query::{Res, View}}, DeltaTime, scene::CameraComponent,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* enum FreeFlyCameraActions {
|
/* enum FreeFlyCameraActions {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::ptr::NonNull;
|
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};
|
use lyra_engine::assets::{ResourceManager, Model};
|
||||||
|
|
||||||
mod free_fly_camera;
|
mod free_fly_camera;
|
||||||
|
@ -88,6 +88,7 @@ async fn main() {
|
||||||
//let cube_model = resman.request::<Model>("assets/cube-texture-bin.glb").unwrap();
|
//let cube_model = resman.request::<Model>("assets/cube-texture-bin.glb").unwrap();
|
||||||
let cube_model = resman.request::<Model>("assets/texture-sep/texture-sep.gltf").unwrap();
|
let cube_model = resman.request::<Model>("assets/texture-sep/texture-sep.gltf").unwrap();
|
||||||
let crate_model = resman.request::<Model>("assets/crate/crate.gltf").unwrap();
|
let crate_model = resman.request::<Model>("assets/crate/crate.gltf").unwrap();
|
||||||
|
//let sponza_model = resman.request::<Model>("assets/sponza/Sponza.gltf").unwrap();
|
||||||
drop(resman);
|
drop(resman);
|
||||||
|
|
||||||
/* world.spawn((
|
/* world.spawn((
|
||||||
|
@ -95,6 +96,11 @@ async fn main() {
|
||||||
Transform::from_xyz(0.0, -5.0, -10.0),
|
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);
|
let cube_tran = Transform::from_xyz(-3.5, 0.0, -8.0);
|
||||||
//cube_tran.rotate_y(math::Angle::Degrees(180.0));
|
//cube_tran.rotate_y(math::Angle::Degrees(180.0));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use instant::Instant;
|
use instant::Instant;
|
||||||
use lyra_ecs::{Component, world::World};
|
use lyra_ecs::{Component, World};
|
||||||
use lyra_reflect::Reflect;
|
use lyra_reflect::Reflect;
|
||||||
|
|
||||||
use crate::{plugin::Plugin, game::GameStages};
|
use crate::{plugin::Plugin, game::GameStages};
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::{sync::Arc, collections::VecDeque, ptr::NonNull};
|
||||||
|
|
||||||
use async_std::task::block_on;
|
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::{info, error, Level};
|
||||||
use tracing_appender::non_blocking;
|
use tracing_appender::non_blocking;
|
||||||
use tracing_subscriber::{
|
use tracing_subscriber::{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::{collections::HashMap, ops::Deref, hash::{Hash, DefaultHasher, Hasher}, fmt::Debug};
|
use std::{collections::HashMap, ops::Deref, hash::{Hash, DefaultHasher, Hasher}, fmt::Debug};
|
||||||
|
|
||||||
use glam::Vec2;
|
use glam::Vec2;
|
||||||
use lyra_ecs::world::World;
|
use lyra_ecs::World;
|
||||||
use lyra_reflect::Reflect;
|
use lyra_reflect::Reflect;
|
||||||
|
|
||||||
use crate::{plugin::Plugin, game::GameStages, EventQueue};
|
use crate::{plugin::Plugin, game::GameStages, EventQueue};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
use glam::Vec2;
|
use glam::Vec2;
|
||||||
use lyra_ecs::{world::World, system::IntoSystem};
|
use lyra_ecs::{World, system::IntoSystem};
|
||||||
use winit::event::MouseScrollDelta;
|
use winit::event::MouseScrollDelta;
|
||||||
|
|
||||||
use crate::{EventQueue, plugin::Plugin, game::GameStages};
|
use crate::{EventQueue, plugin::Plugin, game::GameStages};
|
||||||
|
|
|
@ -2,7 +2,7 @@ pub mod point;
|
||||||
pub mod directional;
|
pub mod directional;
|
||||||
pub mod spotlight;
|
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 point::*;
|
||||||
pub use spotlight::*;
|
pub use spotlight::*;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use instant::Instant;
|
||||||
use itertools::izip;
|
use itertools::izip;
|
||||||
use lyra_ecs::Entity;
|
use lyra_ecs::Entity;
|
||||||
use lyra_ecs::query::{Entities, TickOf};
|
use lyra_ecs::query::{Entities, TickOf};
|
||||||
use lyra_ecs::world::World;
|
use lyra_ecs::World;
|
||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
use wgpu::{BindGroupLayout, Limits};
|
use wgpu::{BindGroupLayout, Limits};
|
||||||
use wgpu::util::DeviceExt;
|
use wgpu::util::DeviceExt;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use glam::{Vec2, IVec2};
|
use glam::{Vec2, IVec2};
|
||||||
use lyra_ecs::world::World;
|
use lyra_ecs::World;
|
||||||
use tracing::{warn, error};
|
use tracing::{warn, error};
|
||||||
use winit::{window::{Window, Fullscreen}, dpi::{LogicalPosition, LogicalSize, PhysicalPosition}, error::ExternalError};
|
use winit::{window::{Window, Fullscreen}, dpi::{LogicalPosition, LogicalSize, PhysicalPosition}, error::ExternalError};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use std::{any::TypeId, any::Any, cell::{Ref, RefMut}};
|
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;
|
extern crate self as lyra_reflect;
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,8 @@ impl ModelLoader {
|
||||||
|
|
||||||
fn process_node(buffers: &Vec<Vec<u8>>, materials: &Vec<Material>, node: gltf::Node<'_>) -> Vec<Mesh> {
|
fn process_node(buffers: &Vec<Vec<u8>>, materials: &Vec<Material>, node: gltf::Node<'_>) -> Vec<Mesh> {
|
||||||
let mut meshes = vec![];
|
let mut meshes = vec![];
|
||||||
|
//node.transform()
|
||||||
|
|
||||||
if let Some(mesh) = node.mesh() {
|
if let Some(mesh) = node.mesh() {
|
||||||
for prim in mesh.primitives() {
|
for prim in mesh.primitives() {
|
||||||
let reader = prim.reader(|buf| Some(buffers[buf.index()].as_slice()));
|
let reader = prim.reader(|buf| Some(buffers[buf.index()].as_slice()));
|
||||||
|
|
|
@ -27,7 +27,7 @@ impl<'a> Fetch<'a> for FetchDynamicType {
|
||||||
unsafe fn get_item(&mut self, entity: ArchetypeEntityId) -> Self::Item {
|
unsafe fn get_item(&mut self, entity: ArchetypeEntityId) -> Self::Item {
|
||||||
let ptr = unsafe { self.col.as_ref().borrow_ptr() };
|
let ptr = unsafe { self.col.as_ref().borrow_ptr() };
|
||||||
let ptr = NonNull::new_unchecked(ptr.as_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 {
|
DynamicType {
|
||||||
info: self.info,
|
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 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 {
|
let row = DynamicViewRow {
|
||||||
entity,
|
entity,
|
||||||
item: fetch_res,
|
item: fetch_res,
|
||||||
|
@ -112,7 +112,7 @@ impl Iterator for DynamicViewIter {
|
||||||
self.next_archetype += 1;
|
self.next_archetype += 1;
|
||||||
let arch = unsafe { self.archetypes.get_unchecked(arch_id).as_ref() };
|
let arch = unsafe { self.archetypes.get_unchecked(arch_id).as_ref() };
|
||||||
|
|
||||||
if arch.entities().len() == 0 {
|
if arch.entity_indexes().len() == 0 {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ impl Iterator for DynamicViewIter {
|
||||||
.map(|q| unsafe { q.fetch(world, ArchetypeId(arch_id as u64), arch) } )
|
.map(|q| unsafe { q.fetch(world, ArchetypeId(arch_id as u64), arch) } )
|
||||||
.map(|f| FetchDynamicType::from(f))
|
.map(|f| FetchDynamicType::from(f))
|
||||||
.collect();
|
.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![];
|
let mut dynamic_row = vec![];
|
||||||
for d in row.item.iter() {
|
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 =
|
let reflected_components =
|
||||||
unsafe { self.reflected_components.as_ref().unwrap().as_ref() };
|
unsafe { self.reflected_components.as_ref().unwrap().as_ref() };
|
||||||
|
|
||||||
|
|
|
@ -192,14 +192,14 @@ impl elua::Userdata for ScriptWorldPtr {
|
||||||
let lua_comp = reflect_user_data(ud);
|
let lua_comp = reflect_user_data(ud);
|
||||||
let refl_comp =
|
let refl_comp =
|
||||||
lua_comp.reflect_branch.as_component_unchecked();
|
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) => {
|
elua::Value::Table(tbl) => {
|
||||||
let name: String = tbl.get(elua::MetaMethod::Name)?;
|
let name: String = tbl.get(elua::MetaMethod::Name)?;
|
||||||
|
|
||||||
let lookup = world.get_resource::<LuaTableProxyLookup>();
|
let lookup = world.get_resource::<LuaTableProxyLookup>();
|
||||||
*lookup.typeid_from_name.get(&name).unwrap()
|
*lookup.typeid_from_name.get(&name).unwrap()
|
||||||
}
|
},
|
||||||
_ => {
|
_ => {
|
||||||
panic!("A userdata or table value was not returned!");
|
panic!("A userdata or table value was not returned!");
|
||||||
// TODO: Handle properly
|
// TODO: Handle properly
|
||||||
|
@ -209,8 +209,8 @@ impl elua::Userdata for ScriptWorldPtr {
|
||||||
// update the component tick
|
// update the component tick
|
||||||
let world = unsafe { this.inner.as_mut() };
|
let world = unsafe { this.inner.as_mut() };
|
||||||
let arch = world.entity_archetype_mut(row.entity).unwrap();
|
let arch = world.entity_archetype_mut(row.entity).unwrap();
|
||||||
let idx = arch.entities().get(&row.entity).unwrap().clone();
|
let idx = arch.entity_indexes().get(&row.entity).unwrap().clone();
|
||||||
let c = arch.get_column_mut(lua_typeid.into()).unwrap();
|
let c = arch.get_column_mut(lua_typeid).unwrap();
|
||||||
c.entity_ticks[idx.0 as usize] = current;
|
c.entity_ticks[idx.0 as usize] = current;
|
||||||
|
|
||||||
// apply the new component data
|
// apply the new component data
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
use lyra_ecs::{world::World, Entity};
|
use lyra_ecs::{World, Entity};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ScriptEntity(pub Entity);
|
pub struct ScriptEntity(pub Entity);
|
||||||
|
|
Loading…
Reference in New Issue