Compare commits

..

No commits in common. "4816b7333e60a6a82d1cf544db99c0069762ec30" and "f02d3c6b2f8613a8d6fdbfde8d4a2e87cc87bea2" have entirely different histories.

287 changed files with 365 additions and 471 deletions

4
.gitmodules vendored
View File

@ -1,6 +1,6 @@
[submodule "lyra-scripting/elua"] [submodule "lyra-scripting/elua"]
path = crates/lyra-scripting/elua path = lyra-scripting/elua
url = ../elua.git # git@git.seanomik.net:SeanOMik/elua.git url = ../elua.git # git@git.seanomik.net:SeanOMik/elua.git
[submodule "wgsl-preprocessor"] [submodule "wgsl-preprocessor"]
path = crates/wgsl-preprocessor path = wgsl-preprocessor
url = git@git.seanomik.net:SeanOMik/wgsl-preprocessor.git url = git@git.seanomik.net:SeanOMik/wgsl-preprocessor.git

44
Cargo.lock generated
View File

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 4 version = 3
[[package]] [[package]]
name = "ab_glyph" name = "ab_glyph"
@ -854,16 +854,6 @@ dependencies = [
"crypto-common", "crypto-common",
] ]
[[package]]
name = "dim_2d"
version = "0.1.0"
dependencies = [
"anyhow",
"async-std",
"lyra-engine",
"tracing",
]
[[package]] [[package]]
name = "dispatch" name = "dispatch"
version = "0.2.0" version = "0.2.0"
@ -1829,7 +1819,6 @@ dependencies = [
"itertools 0.13.0", "itertools 0.13.0",
"lyra-ecs", "lyra-ecs",
"lyra-game-derive", "lyra-game-derive",
"lyra-gltf",
"lyra-math", "lyra-math",
"lyra-reflect", "lyra-reflect",
"lyra-resource", "lyra-resource",
@ -1861,34 +1850,6 @@ dependencies = [
"syn 2.0.77", "syn 2.0.77",
] ]
[[package]]
name = "lyra-gltf"
version = "0.0.1"
dependencies = [
"anyhow",
"async-std",
"base64 0.21.7",
"crossbeam",
"glam",
"gltf",
"image",
"infer",
"instant",
"lyra-ecs",
"lyra-math",
"lyra-reflect",
"lyra-resource",
"lyra-scene",
"mime",
"notify",
"notify-debouncer-full",
"percent-encoding",
"rand",
"thiserror",
"tracing",
"uuid",
]
[[package]] [[package]]
name = "lyra-math" name = "lyra-math"
version = "0.1.0" version = "0.1.0"
@ -1923,12 +1884,14 @@ dependencies = [
"base64 0.21.7", "base64 0.21.7",
"crossbeam", "crossbeam",
"glam", "glam",
"gltf",
"image", "image",
"infer", "infer",
"instant", "instant",
"lyra-ecs", "lyra-ecs",
"lyra-math", "lyra-math",
"lyra-reflect", "lyra-reflect",
"lyra-scene",
"mime", "mime",
"notify", "notify",
"notify-debouncer-full", "notify-debouncer-full",
@ -1947,7 +1910,6 @@ dependencies = [
"lyra-ecs", "lyra-ecs",
"lyra-math", "lyra-math",
"lyra-reflect", "lyra-reflect",
"lyra-resource",
] ]
[[package]] [[package]]

View File

@ -5,15 +5,20 @@ edition = "2021"
[workspace] [workspace]
members = [ members = [
"crates/*", "lyra-resource",
"lyra-ecs",
"examples/2d", "lyra-reflect",
"lyra-scripting",
"lyra-game",
"lyra-math",
"lyra-scene",
"examples/testbed",
"examples/many-lights",
"examples/fixed-timestep-rotating-model", "examples/fixed-timestep-rotating-model",
"examples/lua-scripting", "examples/lua-scripting",
"examples/many-lights",
"examples/shadows",
"examples/simple_scene", "examples/simple_scene",
"examples/testbed", "examples/shadows",
] ]
[features] [features]
@ -22,11 +27,11 @@ lua_scripting = ["scripting", "lyra-scripting/lua"]
tracy = ["lyra-game/tracy"] tracy = ["lyra-game/tracy"]
[dependencies] [dependencies]
lyra-game = { path = "crates/lyra-game" } lyra-game = { path = "lyra-game" }
lyra-scripting = { path = "crates/lyra-scripting", optional = true } lyra-scripting = { path = "lyra-scripting", optional = true }
#[profile.dev] #[profile.dev]
#opt-level = 1 #opt-level = 1
[profile.release] [profile.release]
debug = true debug = true

View File

@ -1,44 +0,0 @@
mod has;
use std::marker::PhantomData;
pub use has::*;
mod or;
pub use or::*;
mod not;
pub use not::*;
mod changed;
pub use changed::*;
use super::Fetch;
/// A fetcher that just returns a provided value
pub struct StaticFetcher<T: Clone> {
value: T,
}
impl<'a, T: Clone> StaticFetcher<T> {
pub fn new(value: T) -> Self {
Self {
value
}
}
}
impl<'a, T> Fetch<'a> for StaticFetcher<T>
where
T: Clone + 'a,
{
type Item = T;
fn dangling() -> Self {
unreachable!()
}
unsafe fn get_item(&mut self, _: crate::world::ArchetypeEntityId) -> Self::Item {
self.value.clone()
}
}

View File

@ -1,34 +0,0 @@
use lyra_math::Transform;
use lyra_resource::{optionally_add_to_dep, ResourceData, UntypedResHandle};
use super::Mesh;
use crate::ResHandle;
/// A Node in the Gltf file
#[derive(Clone, Default)]
pub struct GltfNode {
pub name: Option<String>,
pub mesh: Option<ResHandle<Mesh>>,
pub transform: Transform,
pub children: Vec<GltfNode>,
}
impl ResourceData for GltfNode {
fn dependencies(&self) -> Vec<crate::UntypedResHandle> {
let mut deps: Vec<UntypedResHandle> = self.children.iter()
.flat_map(|c| c.mesh.as_ref().map(|h| h.untyped_clone()))
.collect();
optionally_add_to_dep(&mut deps, &self.mesh);
deps
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
}

View File

@ -1,31 +0,0 @@
[package]
name = "lyra-resource"
version = "0.0.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
lyra-ecs = { path = "../lyra-ecs", features = [ "math" ] }
lyra-reflect = { path = "../lyra-reflect", features = [ "math" ] }
lyra-math = { path = "../lyra-math" }
anyhow = "1.0.75"
base64 = "0.21.4"
crossbeam = { version = "0.8.4", features = [ "crossbeam-channel" ] }
glam = "0.29.0"
image = "0.25.2"
# not using custom matcher, or file type from file path
infer = { version = "0.15.0", default-features = false }
mime = "0.3.17"
notify = "6.1.1"
notify-debouncer-full = "0.3.1"
#notify = { version = "6.1.1", default-features = false, features = [ "fsevent-sys", "macos_fsevent" ]} # disables crossbeam-channel
percent-encoding = "2.3.0"
thiserror = "1.0.48"
tracing = "0.1.37"
uuid = { version = "1.4.1", features = ["v4"] }
instant = "0.1"
async-std = "1.12.0"
[dev-dependencies]
rand = "0.8.5"

View File

@ -1 +0,0 @@
use base64::Engine;

View File

@ -1,5 +1,5 @@
[package] [package]
name = "dim_2d" name = "simple_scene"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"

View File

@ -1,5 +1,5 @@
use lyra_engine::{ use lyra_engine::{
assets::ResourceManager, gltf::Gltf, ecs::query::View, game::App, input::{ assets::{gltf::Gltf, ResourceManager}, ecs::query::View, game::App, input::{
Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource, Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource,
InputActionPlugin, KeyCode, LayoutId, InputActionPlugin, KeyCode, LayoutId,
}, math::{self, Transform, Vec3}, render::light::directional::DirectionalLight, scene::{ }, math::{self, Transform, Vec3}, render::light::directional::DirectionalLight, scene::{

View File

@ -1,7 +1,7 @@
use std::ptr::NonNull; use std::ptr::NonNull;
use lyra_engine::{ use lyra_engine::{
assets::ResourceManager, gltf::Gltf, assets::{gltf::Gltf, ResourceManager},
ecs::{ ecs::{
query::{Res, View}, query::{Res, View},
system::{BatchedSystem, Criteria, CriteriaSchedule, IntoSystem}, system::{BatchedSystem, Criteria, CriteriaSchedule, IntoSystem},

View File

@ -1,5 +1,5 @@
use lyra_engine::{ use lyra_engine::{
assets::ResourceManager, gltf::Gltf, game::App, input::{ assets::{gltf::Gltf, ResourceManager}, game::App, input::{
Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource, Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource,
InputActionPlugin, KeyCode, LayoutId, MouseAxis, MouseInput, InputActionPlugin, KeyCode, LayoutId, MouseAxis, MouseInput,
}, math::{self, Transform, Vec3}, render::light::directional::DirectionalLight, scene::{ }, math::{self, Transform, Vec3}, render::light::directional::DirectionalLight, scene::{

View File

@ -1,4 +1,4 @@
use lyra_engine::{assets::ResourceManager, gltf::Gltf, ecs::query::{Res, View}, game::App, input::{Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource, InputActionPlugin, KeyCode, LayoutId, MouseAxis, MouseInput}, math::{self, Quat, Transform, Vec3}, render::light::{directional::DirectionalLight, PointLight}, scene::{CameraComponent, FreeFlyCamera, FreeFlyCameraPlugin, ACTLBL_LOOK_LEFT_RIGHT, ACTLBL_LOOK_ROLL, ACTLBL_LOOK_UP_DOWN, ACTLBL_MOVE_FORWARD_BACKWARD, ACTLBL_MOVE_LEFT_RIGHT, ACTLBL_MOVE_UP_DOWN}, DeltaTime}; use lyra_engine::{assets::{gltf::Gltf, ResourceManager}, ecs::query::{Res, View}, game::App, input::{Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource, InputActionPlugin, KeyCode, LayoutId, MouseAxis, MouseInput}, math::{self, Quat, Transform, Vec3}, render::light::{directional::DirectionalLight, PointLight}, scene::{CameraComponent, FreeFlyCamera, FreeFlyCameraPlugin, ACTLBL_LOOK_LEFT_RIGHT, ACTLBL_LOOK_ROLL, ACTLBL_LOOK_UP_DOWN, ACTLBL_MOVE_FORWARD_BACKWARD, ACTLBL_MOVE_LEFT_RIGHT, ACTLBL_MOVE_UP_DOWN}, DeltaTime};
use rand::Rng; use rand::Rng;
use tracing::info; use tracing::info;

View File

@ -1,5 +1,5 @@
use lyra_engine::{ use lyra_engine::{
assets::ResourceManager, gltf::Gltf, assets::{gltf::Gltf, ResourceManager},
game::App, game::App,
input::{ input::{
Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource, Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource,

View File

@ -1,5 +1,5 @@
use lyra_engine::{ use lyra_engine::{
assets::ResourceManager, gltf::Gltf, ecs::query::View, game::App, input::{ assets::{gltf::Gltf, ResourceManager}, ecs::query::View, game::App, input::{
Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource, Action, ActionHandler, ActionKind, ActionMapping, ActionMappingId, ActionSource,
InputActionPlugin, KeyCode, LayoutId, InputActionPlugin, KeyCode, LayoutId,
}, math::{self, Transform, Vec3}, render::light::directional::DirectionalLight, scene::{ }, math::{self, Transform, Vec3}, render::light::directional::DirectionalLight, scene::{

View File

@ -2,7 +2,7 @@ use std::ptr::NonNull;
use lyra_engine::assets::ResourceManager; use lyra_engine::assets::ResourceManager;
use lyra_engine::{ use lyra_engine::{
gltf::Gltf, assets::gltf::Gltf,
ecs::{ ecs::{
query::{Res, View}, query::{Res, View},
system::{Criteria, CriteriaSchedule, IntoSystem}, system::{Criteria, CriteriaSchedule, IntoSystem},

View File

@ -90,7 +90,7 @@ impl<T: Component> AsQuery for Changed<T> {
type Query = Self; type Query = Self;
} }
impl<T: Component> Filter for Changed<T> { } impl<'a, T: Component> Filter for Changed<T> { }
impl<T: Component> AsFilter for Changed<T> { impl<T: Component> AsFilter for Changed<T> {
type Filter = Self; type Filter = Self;

View File

@ -1,8 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use crate::{query::{AsFilter, AsQuery, Filter, Query}, Archetype, Component, DynTypeId, World}; use crate::{query::{AsQuery, Query}, Archetype, Component, DynTypeId, World};
use super::StaticFetcher;
/// A filter query that fetches when the entity has the component `C`. /// A filter query that fetches when the entity has the component `C`.
/// ///
@ -22,8 +20,9 @@ impl<C: Component> Clone for Has<C> {
} }
impl<C: Component> Query for Has<C> { impl<C: Component> Query for Has<C> {
type Item<'a> = bool; type Item<'a> = ();
type Fetch<'a> = StaticFetcher<bool>;
type Fetch<'a> = ();
fn new() -> Self { fn new() -> Self {
Has { Has {
@ -36,17 +35,10 @@ impl<C: Component> Query for Has<C> {
} }
unsafe fn fetch<'a>(&self, _world: &'a World, _: &'a Archetype, _: crate::Tick) -> Self::Fetch<'a> { unsafe fn fetch<'a>(&self, _world: &'a World, _: &'a Archetype, _: crate::Tick) -> Self::Fetch<'a> {
// if fetch is called, it means that 'can_visit_archetype' returned true ()
StaticFetcher::new(true)
} }
} }
impl<C: Component> AsQuery for Has<C> { impl<C: Component> AsQuery for Has<C> {
type Query = Self; type Query = Self;
}
impl<C: Component> Filter for Has<C> { }
impl<C: Component> AsFilter for Has<C> {
type Filter = Self;
} }

View File

@ -0,0 +1,11 @@
mod has;
pub use has::*;
mod or;
pub use or::*;
mod not;
pub use not::*;
mod changed;
pub use changed::*;

View File

@ -1,6 +1,4 @@
use crate::{query::{AsFilter, AsQuery, Filter, Query}, Archetype, World}; use crate::{query::{AsQuery, Query}, Archetype, World};
use super::StaticFetcher;
/// A filter query that fetches the inverse of `Q`. /// A filter query that fetches the inverse of `Q`.
/// ///
@ -22,8 +20,9 @@ pub struct Not<Q: Query> {
} }
impl<Q: Query> Query for Not<Q> { impl<Q: Query> Query for Not<Q> {
type Item<'a> = bool; type Item<'a> = ();
type Fetch<'a> = StaticFetcher<bool>;
type Fetch<'a> = ();
fn new() -> Self { fn new() -> Self {
Not { Not {
@ -36,17 +35,10 @@ impl<Q: Query> Query for Not<Q> {
} }
unsafe fn fetch<'a>(&self, _world: &'a World, _: &'a Archetype, _: crate::Tick) -> Self::Fetch<'a> { unsafe fn fetch<'a>(&self, _world: &'a World, _: &'a Archetype, _: crate::Tick) -> Self::Fetch<'a> {
// if fetch is called, it means that 'can_visit_archetype' returned true ()
StaticFetcher::new(true)
} }
} }
impl<Q: Query> AsQuery for Not<Q> { impl<Q: Query> AsQuery for Not<Q> {
type Query = Self; type Query = Self;
}
impl<Q: Query> Filter for Not<Q> { }
impl<Q: Query> AsFilter for Not<Q> {
type Filter = Self;
} }

View File

@ -10,7 +10,6 @@ lyra-ecs = { path = "../lyra-ecs", features = [ "math" ] }
lyra-reflect = { path = "../lyra-reflect", features = [ "math" ] } lyra-reflect = { path = "../lyra-reflect", features = [ "math" ] }
lyra-math = { path = "../lyra-math" } lyra-math = { path = "../lyra-math" }
lyra-scene = { path = "../lyra-scene" } lyra-scene = { path = "../lyra-scene" }
lyra-gltf = { path = "../lyra-gltf" }
wgsl_preprocessor = { path = "../wgsl-preprocessor" } wgsl_preprocessor = { path = "../wgsl-preprocessor" }
winit = "0.30.5" winit = "0.30.5"

View File

@ -29,6 +29,5 @@ pub use lyra_resource as assets;
pub use lyra_ecs as ecs; pub use lyra_ecs as ecs;
pub use lyra_math as math; pub use lyra_math as math;
pub use lyra_reflect as reflect; pub use lyra_reflect as reflect;
pub use lyra_gltf as gltf;
pub use plugin::DefaultPlugins; pub use plugin::DefaultPlugins;

View File

@ -1,6 +1,4 @@
use lyra_ecs::query::ResMut;
use lyra_ecs::CommandQueue; use lyra_ecs::CommandQueue;
use lyra_gltf::GltfLoader;
use lyra_resource::ResourceManager; use lyra_resource::ResourceManager;
use crate::game::App; use crate::game::App;
@ -115,7 +113,6 @@ impl Plugin for DefaultPlugins {
CommandQueuePlugin.setup(app); CommandQueuePlugin.setup(app);
InputPlugin.setup(app); InputPlugin.setup(app);
ResourceManagerPlugin.setup(app); ResourceManagerPlugin.setup(app);
GltfPlugin.setup(app);
WindowPlugin::default().setup(app); WindowPlugin::default().setup(app);
DeltaTimePlugin.setup(app); DeltaTimePlugin.setup(app);
} }
@ -130,14 +127,4 @@ impl Plugin for CommandQueuePlugin {
fn setup(&mut self, app: &mut App) { fn setup(&mut self, app: &mut App) {
app.world.add_resource(CommandQueue::default()); app.world.add_resource(CommandQueue::default());
} }
}
#[derive(Default)]
pub struct GltfPlugin;
impl Plugin for GltfPlugin {
fn setup(&mut self, app: &mut App) {
let man: ResMut<ResourceManager> = app.world.get_resource_or_default();
man.register_loader::<GltfLoader>();
}
} }

View File

Before

Width:  |  Height:  |  Size: 545 B

After

Width:  |  Height:  |  Size: 545 B

View File

@ -12,8 +12,7 @@ use lyra_ecs::{
Entity, ResourceObject, World, Entity, ResourceObject, World,
}; };
use lyra_game_derive::RenderGraphLabel; use lyra_game_derive::RenderGraphLabel;
use lyra_resource::ResHandle; use lyra_resource::{gltf::Mesh, ResHandle};
use lyra_gltf::Mesh;
use lyra_scene::SceneGraph; use lyra_scene::SceneGraph;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
use tracing::{debug, instrument}; use tracing::{debug, instrument};
@ -94,10 +93,10 @@ impl MeshPrepNode {
if let Some(index_buffer) = buffers.buffer_indices.as_ref() { if let Some(index_buffer) = buffers.buffer_indices.as_ref() {
let aligned_indices = match mesh.indices.as_ref().unwrap() { let aligned_indices = match mesh.indices.as_ref().unwrap() {
// U16 indices need to be aligned to u32, for wpgu, which are 4-bytes in size. // U16 indices need to be aligned to u32, for wpgu, which are 4-bytes in size.
lyra_gltf::MeshIndices::U16(v) => { lyra_resource::gltf::MeshIndices::U16(v) => {
bytemuck::pod_align_to::<u16, u32>(v).1 bytemuck::pod_align_to::<u16, u32>(v).1
} }
lyra_gltf::MeshIndices::U32(v) => { lyra_resource::gltf::MeshIndices::U32(v) => {
bytemuck::pod_align_to::<u32, u32>(v).1 bytemuck::pod_align_to::<u32, u32>(v).1
} }
}; };
@ -138,10 +137,10 @@ impl MeshPrepNode {
let indices = match mesh.indices.as_ref() { let indices = match mesh.indices.as_ref() {
Some(indices) => { Some(indices) => {
let (idx_type, len, contents) = match indices { let (idx_type, len, contents) = match indices {
lyra_gltf::MeshIndices::U16(v) => { lyra_resource::gltf::MeshIndices::U16(v) => {
(wgpu::IndexFormat::Uint16, v.len(), bytemuck::cast_slice(v)) (wgpu::IndexFormat::Uint16, v.len(), bytemuck::cast_slice(v))
} }
lyra_gltf::MeshIndices::U32(v) => { lyra_resource::gltf::MeshIndices::U32(v) => {
(wgpu::IndexFormat::Uint32, v.len(), bytemuck::cast_slice(v)) (wgpu::IndexFormat::Uint32, v.len(), bytemuck::cast_slice(v))
} }
}; };
@ -519,7 +518,7 @@ impl GpuMaterial {
device: &wgpu::Device, device: &wgpu::Device,
queue: &wgpu::Queue, queue: &wgpu::Queue,
layout: &Arc<wgpu::BindGroupLayout>, layout: &Arc<wgpu::BindGroupLayout>,
mat: &lyra_gltf::Material, mat: &lyra_resource::gltf::Material,
) -> Self { ) -> Self {
//let specular = mat.specular.as_ref().unwrap_or_default(); //let specular = mat.specular.as_ref().unwrap_or_default();
//let specular_ //let specular_

View File

@ -1,8 +1,9 @@
use lyra_ecs::{ use lyra_ecs::{
query::{ query::{
filter::Or, filter::{Has, Not, Or},
Entities, Entities, TickOf,
}, },
relation::{ChildOf, RelationOriginComponent},
Component, Entity, Component, Entity,
}; };
use lyra_game_derive::RenderGraphLabel; use lyra_game_derive::RenderGraphLabel;
@ -63,6 +64,7 @@ fn update_transforms(
buffers: &mut TransformBuffers, buffers: &mut TransformBuffers,
parent_transform: Transform, parent_transform: Transform,
) { ) {
let current_tick = world.current_tick();
let mut component_queue = vec![]; let mut component_queue = vec![];
let view = world.view_iter::<( let view = world.view_iter::<(
@ -70,7 +72,7 @@ fn update_transforms(
Or<&WorldTransform, &Transform>, Or<&WorldTransform, &Transform>,
Option<&mut InterpTransform>, Option<&mut InterpTransform>,
Option<&TransformIndex>, Option<&TransformIndex>,
Option<&ResHandle<SceneGraph>>, Option<(&ResHandle<SceneGraph>, TickOf<ResHandle<SceneGraph>>)>,
)>(); )>();
for (entity, transform, interp_tran, transform_index, scene_graph) in view { for (entity, transform, interp_tran, transform_index, scene_graph) in view {
@ -139,8 +141,20 @@ fn update_transforms(
glam::Mat3::from_quat(transform.rotation), glam::Mat3::from_quat(transform.rotation),
); );
if let Some(scene) = scene_graph { if let Some((scene, scene_tick)) = scene_graph {
if let Some(mut scene) = scene.data_mut() { if let Some(mut scene) = scene.data_mut() {
if *scene_tick + 1 >= *current_tick {
// Must manually call the world transform update system for scenes
// TODO: Separate gltf from lyra-resource so lyra-scene can depend on resource to
// query for scenes in the system.
let view = scene.world().view::<(
Entities,
&mut WorldTransform,
&Transform,
Not<Has<RelationOriginComponent<ChildOf>>>,
)>();
lyra_scene::system_update_world_transforms(scene.world(), view).unwrap();
}
update_transforms( update_transforms(
device, device,

Some files were not shown because too many files have changed in this diff Show More