mirror of
https://github.com/bevyengine/bevy
synced 2024-11-28 15:40:21 +00:00
cargo fmt
This commit is contained in:
parent
f68909ac00
commit
3b0b40a79d
52 changed files with 529 additions and 406 deletions
|
@ -1,11 +1,18 @@
|
|||
use bevy::prelude::*;
|
||||
|
||||
fn main() {
|
||||
AppBuilder::new().add_defaults_legacy().setup_world(setup).run();
|
||||
AppBuilder::new()
|
||||
.add_defaults_legacy()
|
||||
.setup_world(setup)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn create_entities_insert_vec(world: &mut World, plane_handle: Handle<Mesh>, cube_handle: Handle<Mesh>) {
|
||||
fn create_entities_insert_vec(
|
||||
world: &mut World,
|
||||
plane_handle: Handle<Mesh>,
|
||||
cube_handle: Handle<Mesh>,
|
||||
) {
|
||||
// plane
|
||||
world.insert(
|
||||
(),
|
||||
|
@ -70,55 +77,65 @@ fn create_entities_insert_vec(world: &mut World, plane_handle: Handle<Mesh>, cub
|
|||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn create_entities_builder_add_component(world: &mut World, plane_handle: Handle<Mesh>, cube_handle: Handle<Mesh>) {
|
||||
world.build()
|
||||
fn create_entities_builder_add_component(
|
||||
world: &mut World,
|
||||
plane_handle: Handle<Mesh>,
|
||||
cube_handle: Handle<Mesh>,
|
||||
) {
|
||||
world
|
||||
.build()
|
||||
// plane
|
||||
.build_entity()
|
||||
.add(plane_handle.clone())
|
||||
.add(Material::new(Albedo::Color(math::vec4(0.1, 0.2, 0.1, 1.0))))
|
||||
.add(LocalToWorld::identity())
|
||||
.add(Translation::new(0.0, 0.0, 0.0))
|
||||
.add(plane_handle.clone())
|
||||
.add(Material::new(Albedo::Color(math::vec4(0.1, 0.2, 0.1, 1.0))))
|
||||
.add(LocalToWorld::identity())
|
||||
.add(Translation::new(0.0, 0.0, 0.0))
|
||||
// cube
|
||||
.build_entity()
|
||||
.add(cube_handle)
|
||||
.add(Material::new(Albedo::Color(math::vec4(0.5, 0.3, 0.3, 1.0))))
|
||||
.add(LocalToWorld::identity())
|
||||
.add(Translation::new(0.0, 0.0, 1.0))
|
||||
.add(cube_handle)
|
||||
.add(Material::new(Albedo::Color(math::vec4(0.5, 0.3, 0.3, 1.0))))
|
||||
.add(LocalToWorld::identity())
|
||||
.add(Translation::new(0.0, 0.0, 1.0))
|
||||
// light
|
||||
.build_entity()
|
||||
.add(Light {
|
||||
color: wgpu::Color {
|
||||
r: 0.8,
|
||||
g: 0.8,
|
||||
b: 0.5,
|
||||
a: 1.0,
|
||||
},
|
||||
fov: f32::to_radians(60.0),
|
||||
depth: 0.1..50.0,
|
||||
target_view: None,
|
||||
})
|
||||
.add(LocalToWorld::identity())
|
||||
.add(Translation::new(4.0, -4.0, 5.0))
|
||||
.add(Rotation::from_euler_angles(0.0, 0.0, 0.0))
|
||||
.add(Light {
|
||||
color: wgpu::Color {
|
||||
r: 0.8,
|
||||
g: 0.8,
|
||||
b: 0.5,
|
||||
a: 1.0,
|
||||
},
|
||||
fov: f32::to_radians(60.0),
|
||||
depth: 0.1..50.0,
|
||||
target_view: None,
|
||||
})
|
||||
.add(LocalToWorld::identity())
|
||||
.add(Translation::new(4.0, -4.0, 5.0))
|
||||
.add(Rotation::from_euler_angles(0.0, 0.0, 0.0))
|
||||
// camera
|
||||
.build_entity()
|
||||
.add(Camera::new(CameraType::Projection {
|
||||
fov: std::f32::consts::PI / 4.0,
|
||||
near: 1.0,
|
||||
far: 1000.0,
|
||||
aspect_ratio: 1.0,
|
||||
}))
|
||||
.add(ActiveCamera)
|
||||
.add(LocalToWorld(Mat4::look_at_rh(
|
||||
Vec3::new(3.0, 8.0, 5.0),
|
||||
Vec3::new(0.0, 0.0, 0.0),
|
||||
Vec3::new(0.0, 0.0, 1.0),
|
||||
)))
|
||||
.build();
|
||||
.add(Camera::new(CameraType::Projection {
|
||||
fov: std::f32::consts::PI / 4.0,
|
||||
near: 1.0,
|
||||
far: 1000.0,
|
||||
aspect_ratio: 1.0,
|
||||
}))
|
||||
.add(ActiveCamera)
|
||||
.add(LocalToWorld(Mat4::look_at_rh(
|
||||
Vec3::new(3.0, 8.0, 5.0),
|
||||
Vec3::new(0.0, 0.0, 0.0),
|
||||
Vec3::new(0.0, 0.0, 1.0),
|
||||
)))
|
||||
.build();
|
||||
}
|
||||
|
||||
fn create_entities_builder_archetype(world: &mut World, plane_handle: Handle<Mesh>, cube_handle: Handle<Mesh>) {
|
||||
world.build()
|
||||
fn create_entities_builder_archetype(
|
||||
world: &mut World,
|
||||
plane_handle: Handle<Mesh>,
|
||||
cube_handle: Handle<Mesh>,
|
||||
) {
|
||||
world
|
||||
.build()
|
||||
// plane
|
||||
.add_archetype(MeshEntity {
|
||||
mesh: plane_handle.clone(),
|
||||
|
@ -165,7 +182,7 @@ fn create_entities_builder_archetype(world: &mut World, plane_handle: Handle<Mes
|
|||
Vec3::new(0.0, 0.0, 1.0),
|
||||
)),
|
||||
})
|
||||
.build();
|
||||
.build();
|
||||
}
|
||||
|
||||
fn setup(world: &mut World) {
|
||||
|
@ -185,6 +202,6 @@ fn setup(world: &mut World) {
|
|||
// noarchetype precompile: .93
|
||||
// create_entities_builder_add_component(world, plane_handle, cube_handle);
|
||||
|
||||
// archetype precompile: 0.65
|
||||
// archetype precompile: 0.65
|
||||
create_entities_builder_archetype(world, plane_handle, cube_handle);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,10 @@ use bevy::{prelude::*, serialization::*};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use type_uuid::TypeUuid;
|
||||
fn main() {
|
||||
let app = AppBuilder::new().add_defaults_legacy().setup_world(setup).build();
|
||||
let app = AppBuilder::new()
|
||||
.add_defaults_legacy()
|
||||
.setup_world(setup)
|
||||
.build();
|
||||
|
||||
let comp_registrations = [ComponentRegistration::of::<Test>()];
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
use bevy::prelude::*;
|
||||
|
||||
fn main() {
|
||||
AppBuilder::new().add_defaults_legacy().setup_world(setup).run();
|
||||
AppBuilder::new()
|
||||
.add_defaults_legacy()
|
||||
.setup_world(setup)
|
||||
.run();
|
||||
}
|
||||
|
||||
fn setup(world: &mut World) {
|
||||
|
@ -12,8 +15,9 @@ fn setup(world: &mut World) {
|
|||
let mut mesh_storage = world.resources.get_mut::<AssetStorage<Mesh>>().unwrap();
|
||||
(mesh_storage.add(cube), mesh_storage.add(plane))
|
||||
};
|
||||
|
||||
world.build()
|
||||
|
||||
world
|
||||
.build()
|
||||
// plane
|
||||
.add_archetype(MeshEntity {
|
||||
mesh: plane_handle.clone(),
|
||||
|
@ -60,5 +64,5 @@ fn setup(world: &mut World) {
|
|||
Vec3::new(0.0, 0.0, 1.0),
|
||||
)),
|
||||
})
|
||||
.build();
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
use bevy::prelude::*;
|
||||
use std::collections::VecDeque;
|
||||
use rand::{rngs::StdRng, Rng, SeedableRng};
|
||||
use std::collections::VecDeque;
|
||||
fn main() {
|
||||
AppBuilder::new().add_defaults_legacy().add_system(build_move_system()).add_system(build_print_status_system()).setup_world(setup).run();
|
||||
AppBuilder::new()
|
||||
.add_defaults_legacy()
|
||||
.add_system(build_move_system())
|
||||
.add_system(build_print_status_system())
|
||||
.setup_world(setup)
|
||||
.run();
|
||||
}
|
||||
|
||||
fn build_move_system() -> Box<dyn Schedulable> {
|
||||
|
@ -53,8 +58,9 @@ fn setup(world: &mut World) {
|
|||
let mut mesh_storage = world.resources.get_mut::<AssetStorage<Mesh>>().unwrap();
|
||||
(mesh_storage.add(cube), mesh_storage.add(plane))
|
||||
};
|
||||
|
||||
let mut builder = world.build()
|
||||
|
||||
let mut builder = world
|
||||
.build()
|
||||
// plane
|
||||
.add_archetype(MeshEntity {
|
||||
mesh: plane_handle.clone(),
|
||||
|
@ -102,15 +108,19 @@ fn setup(world: &mut World) {
|
|||
)),
|
||||
});
|
||||
|
||||
let mut rng = StdRng::from_entropy();
|
||||
for _ in 0..10000 {
|
||||
builder = builder.add_archetype(MeshEntity {
|
||||
let mut rng = StdRng::from_entropy();
|
||||
for _ in 0..10000 {
|
||||
builder = builder.add_archetype(MeshEntity {
|
||||
mesh: cube_handle.clone(),
|
||||
material: Material::new(Albedo::Color(math::vec4(0.5, 0.3, 0.3, 1.0))),
|
||||
local_to_world: LocalToWorld::identity(),
|
||||
translation: Translation::new(rng.gen_range(-50.0, 50.0), rng.gen_range(-50.0, 50.0), 0.0),
|
||||
});
|
||||
}
|
||||
|
||||
builder.build()
|
||||
translation: Translation::new(
|
||||
rng.gen_range(-50.0, 50.0),
|
||||
rng.gen_range(-50.0, 50.0),
|
||||
0.0,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
builder.build()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy::render::render_graph_2::{StandardMaterial, ShaderUniforms};
|
||||
use bevy::render::render_graph_2::{ShaderUniforms, StandardMaterial};
|
||||
|
||||
fn main() {
|
||||
AppBuilder::new().add_defaults().setup_world(setup).run();
|
||||
|
@ -13,8 +13,9 @@ fn setup(world: &mut World) {
|
|||
let mut mesh_storage = world.resources.get_mut::<AssetStorage<Mesh>>().unwrap();
|
||||
(mesh_storage.add(cube), mesh_storage.add(plane))
|
||||
};
|
||||
|
||||
world.build()
|
||||
|
||||
world
|
||||
.build()
|
||||
// plane
|
||||
.add_archetype(NewMeshEntity {
|
||||
mesh: plane_handle.clone(),
|
||||
|
@ -67,5 +68,5 @@ fn setup(world: &mut World) {
|
|||
Vec3::new(0.0, 0.0, 1.0),
|
||||
)),
|
||||
})
|
||||
.build();
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy::render::render_graph_2::{StandardMaterial, ShaderUniforms, uniform_selector};
|
||||
use std::collections::VecDeque;
|
||||
use bevy::render::render_graph_2::{uniform_selector, ShaderUniforms, StandardMaterial};
|
||||
use rand::{rngs::StdRng, Rng, SeedableRng};
|
||||
use std::collections::VecDeque;
|
||||
|
||||
fn main() {
|
||||
AppBuilder::new().add_defaults().add_system(build_move_system()).add_system(build_print_status_system()).setup_world(setup).run();
|
||||
AppBuilder::new()
|
||||
.add_defaults()
|
||||
.add_system(build_move_system())
|
||||
.add_system(build_print_status_system())
|
||||
.setup_world(setup)
|
||||
.run();
|
||||
}
|
||||
|
||||
fn build_move_system() -> Box<dyn Schedulable> {
|
||||
|
@ -14,7 +19,13 @@ fn build_move_system() -> Box<dyn Schedulable> {
|
|||
.build(move |_, world, time, person_query| {
|
||||
for (mut translation, mut material) in person_query.iter_mut(world) {
|
||||
translation.0 += math::vec3(1.0, 0.0, 0.0) * time.delta_seconds;
|
||||
material.albedo = material.albedo + math::vec4(-time.delta_seconds, -time.delta_seconds, time.delta_seconds, 0.0);
|
||||
material.albedo = material.albedo
|
||||
+ math::vec4(
|
||||
-time.delta_seconds,
|
||||
-time.delta_seconds,
|
||||
time.delta_seconds,
|
||||
0.0,
|
||||
);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -57,7 +68,8 @@ fn setup(world: &mut World) {
|
|||
(mesh_storage.add(cube), mesh_storage.add(plane))
|
||||
};
|
||||
|
||||
let mut builder = world.build()
|
||||
let mut builder = world
|
||||
.build()
|
||||
// plane
|
||||
.add_archetype(NewMeshEntity {
|
||||
mesh: plane_handle.clone(),
|
||||
|
@ -66,8 +78,8 @@ fn setup(world: &mut World) {
|
|||
},
|
||||
shader_uniforms: ShaderUniforms {
|
||||
uniform_selectors: vec![
|
||||
uniform_selector::<StandardMaterial>,
|
||||
uniform_selector::<LocalToWorld>,
|
||||
uniform_selector::<StandardMaterial>,
|
||||
uniform_selector::<LocalToWorld>,
|
||||
],
|
||||
},
|
||||
local_to_world: LocalToWorld::identity(),
|
||||
|
@ -81,8 +93,8 @@ fn setup(world: &mut World) {
|
|||
},
|
||||
shader_uniforms: ShaderUniforms {
|
||||
uniform_selectors: vec![
|
||||
uniform_selector::<StandardMaterial>,
|
||||
uniform_selector::<LocalToWorld>,
|
||||
uniform_selector::<StandardMaterial>,
|
||||
uniform_selector::<LocalToWorld>,
|
||||
],
|
||||
},
|
||||
local_to_world: LocalToWorld::identity(),
|
||||
|
@ -95,8 +107,8 @@ fn setup(world: &mut World) {
|
|||
},
|
||||
shader_uniforms: ShaderUniforms {
|
||||
uniform_selectors: vec![
|
||||
uniform_selector::<StandardMaterial>,
|
||||
uniform_selector::<LocalToWorld>,
|
||||
uniform_selector::<StandardMaterial>,
|
||||
uniform_selector::<LocalToWorld>,
|
||||
],
|
||||
},
|
||||
local_to_world: LocalToWorld::identity(),
|
||||
|
@ -137,20 +149,28 @@ fn setup(world: &mut World) {
|
|||
|
||||
let mut rng = StdRng::from_entropy();
|
||||
for _ in 0..10000 {
|
||||
|
||||
builder = builder.add_archetype(NewMeshEntity {
|
||||
mesh: cube_handle.clone(),
|
||||
material: StandardMaterial {
|
||||
albedo: math::vec4(rng.gen_range(0.0, 1.0), rng.gen_range(0.0, 1.0), rng.gen_range(0.0, 1.0), 1.0),
|
||||
albedo: math::vec4(
|
||||
rng.gen_range(0.0, 1.0),
|
||||
rng.gen_range(0.0, 1.0),
|
||||
rng.gen_range(0.0, 1.0),
|
||||
1.0,
|
||||
),
|
||||
},
|
||||
shader_uniforms: ShaderUniforms {
|
||||
uniform_selectors: vec![
|
||||
uniform_selector::<StandardMaterial>,
|
||||
uniform_selector::<LocalToWorld>,
|
||||
uniform_selector::<StandardMaterial>,
|
||||
uniform_selector::<LocalToWorld>,
|
||||
],
|
||||
},
|
||||
local_to_world: LocalToWorld::identity(),
|
||||
translation: Translation::new(rng.gen_range(-50.0, 50.0), rng.gen_range(-50.0, 50.0), 0.0),
|
||||
translation: Translation::new(
|
||||
rng.gen_range(-50.0, 50.0),
|
||||
rng.gen_range(-50.0, 50.0),
|
||||
0.0,
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
use bevy::{asset, prelude::*};
|
||||
|
||||
fn main() {
|
||||
AppBuilder::new().add_defaults_legacy().setup_world(setup).run();
|
||||
AppBuilder::new()
|
||||
.add_defaults_legacy()
|
||||
.setup_world(setup)
|
||||
.run();
|
||||
}
|
||||
|
||||
fn setup(world: &mut World) {
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
use bevy::prelude::*;
|
||||
|
||||
fn main() {
|
||||
AppBuilder::new().add_defaults_legacy().setup_world(setup).run();
|
||||
AppBuilder::new()
|
||||
.add_defaults_legacy()
|
||||
.setup_world(setup)
|
||||
.run();
|
||||
}
|
||||
|
||||
fn setup(world: &mut World) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy::render::render_graph_2::{StandardMaterial, ShaderUniforms};
|
||||
use bevy::render::render_graph_2::{ShaderUniforms, StandardMaterial};
|
||||
|
||||
fn main() {
|
||||
AppBuilder::new().add_defaults().setup_world(setup).run();
|
||||
|
@ -12,7 +12,8 @@ fn setup(world: &mut World) {
|
|||
mesh_storage.add(cube)
|
||||
};
|
||||
|
||||
world.build()
|
||||
world
|
||||
.build()
|
||||
// cube
|
||||
.add_archetype(NewMeshEntity {
|
||||
mesh: cube_handle.clone(),
|
||||
|
@ -69,7 +70,6 @@ fn setup(world: &mut World) {
|
|||
})
|
||||
.build();
|
||||
|
||||
|
||||
// bottom left anchor with vertical fill
|
||||
world.insert(
|
||||
(),
|
||||
|
|
|
@ -6,7 +6,12 @@ use winit::{
|
|||
|
||||
use legion::prelude::*;
|
||||
|
||||
use crate::{core::Time, render, app::AppBuilder, render::render_graph_2::{Renderer, RenderGraph}};
|
||||
use crate::{
|
||||
app::AppBuilder,
|
||||
core::Time,
|
||||
render,
|
||||
render::render_graph_2::{RenderGraph, Renderer},
|
||||
};
|
||||
|
||||
pub struct App {
|
||||
pub universe: Universe,
|
||||
|
@ -95,13 +100,16 @@ impl App {
|
|||
..
|
||||
} => {
|
||||
if let Some(ref mut render_graph) = self.legacy_render_graph {
|
||||
render_graph
|
||||
.resize(size.width, size.height, &mut self.world);
|
||||
render_graph.resize(size.width, size.height, &mut self.world);
|
||||
}
|
||||
|
||||
if let Some(ref mut renderer) = self.renderer {
|
||||
renderer
|
||||
.resize(&mut self.world, &mut self.render_graph, size.width, size.height);
|
||||
renderer.resize(
|
||||
&mut self.world,
|
||||
&mut self.render_graph,
|
||||
size.width,
|
||||
size.height,
|
||||
);
|
||||
}
|
||||
}
|
||||
event::Event::WindowEvent { event, .. } => match event {
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
use crate::{
|
||||
app::{App, system_stage},
|
||||
app::{system_stage, App},
|
||||
asset::*,
|
||||
core::Time,
|
||||
legion::prelude::{Runnable, Schedulable, Schedule, Universe, World},
|
||||
render::render_graph_2,
|
||||
render::render_graph_2::{pipelines::*, passes::*, renderers::wgpu_renderer::WgpuRenderer, resource_providers::*, UniformResourceProvider, StandardMaterial},
|
||||
render::{passes::*, *},
|
||||
plugin::load_plugin,
|
||||
render::render_graph_2,
|
||||
render::render_graph_2::{
|
||||
passes::*, pipelines::*, renderers::wgpu_renderer::WgpuRenderer, resource_providers::*,
|
||||
StandardMaterial, UniformResourceProvider,
|
||||
},
|
||||
render::{passes::*, *},
|
||||
ui,
|
||||
};
|
||||
|
||||
use bevy_transform::{transform_system_bundle, prelude::LocalToWorld};
|
||||
use bevy_transform::{prelude::LocalToWorld, transform_system_bundle};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct AppBuilder {
|
||||
|
|
|
@ -1 +1 @@
|
|||
pub const UPDATE: &str = "update";
|
||||
pub const UPDATE: &str = "update";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::prelude::*;
|
||||
use crate::render::render_graph_2::{StandardMaterial, ShaderUniforms};
|
||||
use crate::render::render_graph_2::{ShaderUniforms, StandardMaterial};
|
||||
use bevy_derive::EntityArchetype;
|
||||
|
||||
#[derive(EntityArchetype)]
|
||||
|
@ -43,4 +43,4 @@ pub struct Camera2dEntity {
|
|||
#[derive(EntityArchetype)]
|
||||
pub struct UiEntity {
|
||||
pub node: Node,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,4 +10,4 @@ pub trait EntityArchetype {
|
|||
|
||||
// generate by macro. maybe a separate macro?
|
||||
// fn query() -> Query
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
mod entity_builder;
|
||||
mod entity_archetype;
|
||||
pub mod default_archetypes;
|
||||
mod entity_archetype;
|
||||
mod entity_builder;
|
||||
|
||||
pub use entity_builder::*;
|
||||
pub use entity_archetype::*;
|
||||
pub use entity_builder::*;
|
||||
|
||||
use legion::{prelude::{Entity, World}, system::SubWorld};
|
||||
use bevy_transform::prelude::Children;
|
||||
use legion::{
|
||||
prelude::{Entity, World},
|
||||
system::SubWorld,
|
||||
};
|
||||
|
||||
pub fn run_on_hierarchy<T>(
|
||||
world: &World,
|
||||
|
@ -20,11 +23,9 @@ pub fn run_on_hierarchy<T>(
|
|||
|
||||
if let Some(result) = result {
|
||||
match world.get_component::<Children>(entity) {
|
||||
Some(children) => Some(
|
||||
for child in children.iter() {
|
||||
run_on_hierarchy(world, *child, result, func);
|
||||
}
|
||||
),
|
||||
Some(children) => Some(for child in children.iter() {
|
||||
run_on_hierarchy(world, *child, result, func);
|
||||
}),
|
||||
None => None,
|
||||
};
|
||||
}
|
||||
|
@ -72,11 +73,9 @@ pub fn run_on_hierarchy_subworld<T>(
|
|||
|
||||
if let Some(result) = result {
|
||||
match world.get_component::<Children>(entity) {
|
||||
Some(children) => Some(
|
||||
for child in children.iter() {
|
||||
run_on_hierarchy_subworld(world, *child, result, func);
|
||||
}
|
||||
),
|
||||
Some(children) => Some(for child in children.iter() {
|
||||
run_on_hierarchy_subworld(world, *child, result, func);
|
||||
}),
|
||||
None => None,
|
||||
};
|
||||
}
|
||||
|
@ -110,4 +109,4 @@ pub fn run_on_hierarchy_subworld_mut<T>(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
pub mod app;
|
||||
pub mod asset;
|
||||
pub mod ecs;
|
||||
pub mod core;
|
||||
pub mod ecs;
|
||||
pub mod plugin;
|
||||
pub mod prelude;
|
||||
pub mod render;
|
||||
pub mod serialization;
|
||||
pub mod ui;
|
||||
pub mod plugin;
|
||||
|
||||
pub use bevy_transform as transform;
|
||||
pub use glam as math;
|
||||
pub use legion;
|
||||
pub use bevy_transform as transform;
|
||||
pub use wgpu;
|
||||
pub use wgpu;
|
||||
|
|
|
@ -17,4 +17,4 @@ pub fn load_plugin(path: &str) -> (Library, Box<dyn AppPlugin>) {
|
|||
let plugin = Box::from_raw(func());
|
||||
(lib, plugin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,14 @@ pub use crate::{
|
|||
asset::{Asset, AssetStorage, Handle, Mesh, MeshType, Texture, TextureType},
|
||||
core::Time,
|
||||
ecs,
|
||||
ecs::{EntityArchetype, EntityBuilder, EntityBuilderSource},
|
||||
ecs::default_archetypes::*,
|
||||
ecs::{EntityArchetype, EntityBuilder, EntityBuilderSource},
|
||||
render::{
|
||||
ActiveCamera, ActiveCamera2d, Albedo, Camera, CameraType, Instanced, Light, Material,
|
||||
},
|
||||
ui::{Anchors, Margins, Node},
|
||||
};
|
||||
pub use bevy_transform::prelude::*;
|
||||
pub use glam as math;
|
||||
pub use legion::{
|
||||
prelude::*,
|
||||
|
@ -17,5 +18,4 @@ pub use legion::{
|
|||
system::SubWorld,
|
||||
system::SystemBuilder,
|
||||
};
|
||||
pub use bevy_transform::prelude::*;
|
||||
pub use math::{Mat3, Mat4, Quat, Vec2, Vec3, Vec4};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
pub mod camera;
|
||||
pub mod instancing;
|
||||
pub mod passes;
|
||||
pub mod render_graph_2;
|
||||
pub mod render_resources;
|
||||
pub mod shader;
|
||||
pub mod render_graph_2;
|
||||
|
||||
mod light;
|
||||
mod material;
|
||||
|
|
|
@ -22,7 +22,8 @@ impl ForwardPipeline {
|
|||
|
||||
impl Pipeline for ForwardPipeline {
|
||||
fn initialize(&mut self, render_graph: &mut RenderGraphData, _: &mut World) {
|
||||
let vs_bytes = shader::glsl_to_spirv(include_str!("forward.vert"), shader::ShaderStage::Vertex);
|
||||
let vs_bytes =
|
||||
shader::glsl_to_spirv(include_str!("forward.vert"), shader::ShaderStage::Vertex);
|
||||
let fs_bytes =
|
||||
shader::glsl_to_spirv(include_str!("forward.frag"), shader::ShaderStage::Fragment);
|
||||
|
||||
|
|
|
@ -102,7 +102,8 @@ impl Pipeline for ShadowPipeline {
|
|||
let vertex_buffer_descriptor = get_vertex_buffer_descriptor();
|
||||
|
||||
// Create the render pipeline
|
||||
let vs_bytes = shader::glsl_to_spirv(include_str!("shadow.vert"), shader::ShaderStage::Vertex);
|
||||
let vs_bytes =
|
||||
shader::glsl_to_spirv(include_str!("shadow.vert"), shader::ShaderStage::Vertex);
|
||||
let fs_bytes =
|
||||
shader::glsl_to_spirv(include_str!("shadow.frag"), shader::ShaderStage::Fragment);
|
||||
let vs_module = render_graph.device.create_shader_module(&vs_bytes);
|
||||
|
|
|
@ -96,7 +96,8 @@ impl UiPipeline {
|
|||
impl Pipeline for UiPipeline {
|
||||
fn initialize(&mut self, render_graph: &mut RenderGraphData, world: &mut World) {
|
||||
let vs_bytes = shader::glsl_to_spirv(include_str!("ui.vert"), shader::ShaderStage::Vertex);
|
||||
let fs_bytes = shader::glsl_to_spirv(include_str!("ui.frag"), shader::ShaderStage::Fragment);
|
||||
let fs_bytes =
|
||||
shader::glsl_to_spirv(include_str!("ui.frag"), shader::ShaderStage::Fragment);
|
||||
|
||||
let bind_group_layout =
|
||||
render_graph
|
||||
|
@ -177,7 +178,7 @@ impl Pipeline for UiPipeline {
|
|||
let vs_module = render_graph.device.create_shader_module(&vs_bytes);
|
||||
let fs_module = render_graph.device.create_shader_module(&fs_bytes);
|
||||
|
||||
let pipedesc = wgpu::RenderPipelineDescriptor {
|
||||
let pipedesc = wgpu::RenderPipelineDescriptor {
|
||||
layout: &pipeline_layout,
|
||||
vertex_stage: wgpu::ProgrammableStageDescriptor {
|
||||
module: &vs_module,
|
||||
|
@ -225,8 +226,7 @@ impl Pipeline for UiPipeline {
|
|||
alpha_to_coverage_enabled: false,
|
||||
};
|
||||
|
||||
self.pipeline = Some(render_graph.device.create_render_pipeline(&pipedesc
|
||||
));
|
||||
self.pipeline = Some(render_graph.device.create_render_pipeline(&pipedesc));
|
||||
}
|
||||
|
||||
fn render(
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::{
|
|||
asset::{AssetStorage, Handle, Mesh},
|
||||
legion::prelude::*,
|
||||
render::{
|
||||
render_graph_2::{RenderPass, ShaderUniforms, resource_name},
|
||||
render_graph_2::{resource_name, RenderPass, ShaderUniforms},
|
||||
Instanced,
|
||||
},
|
||||
};
|
||||
|
@ -42,7 +42,11 @@ pub fn mesh_draw_target(world: &World, render_pass: &mut dyn RenderPass) {
|
|||
|
||||
// TODO: Verify buffer format matches render pass
|
||||
render_pass.set_index_buffer(resource_name::buffer::TEMP_MESH_INDEX_BUFFER_NAME, 0);
|
||||
render_pass.set_vertex_buffer(0, resource_name::buffer::TEMP_MESH_VERTEX_BUFFER_NAME, 0);
|
||||
render_pass.set_vertex_buffer(
|
||||
0,
|
||||
resource_name::buffer::TEMP_MESH_VERTEX_BUFFER_NAME,
|
||||
0,
|
||||
);
|
||||
current_mesh_id = Some(mesh.id);
|
||||
current_mesh_index_length = mesh_asset.indices.len() as u32;
|
||||
};
|
||||
|
@ -57,4 +61,4 @@ pub fn mesh_draw_target(world: &World, render_pass: &mut dyn RenderPass) {
|
|||
let renderer = render_pass.get_renderer();
|
||||
renderer.remove_buffer(resource_name::buffer::TEMP_MESH_VERTEX_BUFFER_NAME);
|
||||
renderer.remove_buffer(resource_name::buffer::TEMP_MESH_INDEX_BUFFER_NAME);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
mod ui_draw_target;
|
||||
|
||||
pub use ui_draw_target::*;
|
||||
pub use ui_draw_target::*;
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
use crate::{
|
||||
asset::{AssetStorage, Mesh},
|
||||
legion::prelude::*,
|
||||
render::{
|
||||
render_graph_2::{RenderPass, resource_name, ResourceInfo},
|
||||
},
|
||||
render::render_graph_2::{resource_name, RenderPass, ResourceInfo},
|
||||
};
|
||||
|
||||
use zerocopy::AsBytes;
|
||||
|
@ -40,7 +38,6 @@ pub fn ui_draw_target(world: &World, render_pass: &mut dyn RenderPass) {
|
|||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
};
|
||||
if let Some((instance_count, indices_length)) = result {
|
||||
render_pass.setup_bind_groups(None);
|
||||
|
@ -49,4 +46,4 @@ pub fn ui_draw_target(world: &World, render_pass: &mut dyn RenderPass) {
|
|||
render_pass.set_vertex_buffer(1, resource_name::buffer::UI_INSTANCES, 0);
|
||||
render_pass.draw_indexed(0..indices_length as u32, 0, 0..(instance_count as u32));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
mod draw_target;
|
||||
pub mod draw_targets;
|
||||
mod pass;
|
||||
pub mod passes;
|
||||
mod pipeline;
|
||||
mod pipeline_layout;
|
||||
pub mod pipelines;
|
||||
mod render_graph;
|
||||
mod renderer;
|
||||
pub mod renderers;
|
||||
mod resource;
|
||||
pub mod resource_name;
|
||||
pub mod resource_provider;
|
||||
pub mod resource_providers;
|
||||
pub mod passes;
|
||||
pub mod draw_targets;
|
||||
pub mod renderers;
|
||||
mod resource;
|
||||
mod pipeline;
|
||||
mod pipeline_layout;
|
||||
mod pass;
|
||||
mod renderer;
|
||||
mod shader;
|
||||
mod render_graph;
|
||||
mod draw_target;
|
||||
|
||||
pub use draw_target::*;
|
||||
pub use pass::*;
|
||||
pub use pipeline::*;
|
||||
pub use pipeline_layout::*;
|
||||
pub use pass::*;
|
||||
pub use renderer::*;
|
||||
pub use shader::*;
|
||||
pub use render_graph::*;
|
||||
pub use draw_target::*;
|
||||
pub use renderer::*;
|
||||
pub use resource::*;
|
||||
pub use resource_provider::*;
|
||||
pub use resource_provider::*;
|
||||
pub use shader::*;
|
||||
|
|
|
@ -30,4 +30,4 @@ pub struct PassDescriptor {
|
|||
pub color_attachments: Vec<RenderPassColorAttachmentDescriptor>,
|
||||
pub depth_stencil_attachment: Option<RenderPassDepthStencilAttachmentDescriptor>,
|
||||
pub sample_count: u32,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::render::render_graph_2::{
|
||||
resource_name, PassDescriptor, RenderGraphBuilder, RenderPassColorAttachmentDescriptor,
|
||||
resource_name, resource_providers::FrameTextureResourceProvider, PassDescriptor,
|
||||
RenderGraphBuilder, RenderPassColorAttachmentDescriptor,
|
||||
RenderPassDepthStencilAttachmentDescriptor, TextureDescriptor, TextureDimension,
|
||||
resource_providers::FrameTextureResourceProvider,
|
||||
};
|
||||
|
||||
pub trait ForwardPassBuilder {
|
||||
|
@ -10,19 +10,22 @@ pub trait ForwardPassBuilder {
|
|||
|
||||
impl ForwardPassBuilder for RenderGraphBuilder {
|
||||
fn add_forward_pass(self) -> Self {
|
||||
self.add_resource_provider(Box::new(FrameTextureResourceProvider::new(resource_name::texture::DEPTH, TextureDescriptor {
|
||||
size: wgpu::Extent3d {
|
||||
depth: 1,
|
||||
width: 1,
|
||||
height: 1,
|
||||
self.add_resource_provider(Box::new(FrameTextureResourceProvider::new(
|
||||
resource_name::texture::DEPTH,
|
||||
TextureDescriptor {
|
||||
size: wgpu::Extent3d {
|
||||
depth: 1,
|
||||
width: 1,
|
||||
height: 1,
|
||||
},
|
||||
array_layer_count: 1,
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
dimension: TextureDimension::D2,
|
||||
format: wgpu::TextureFormat::Depth32Float,
|
||||
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT,
|
||||
},
|
||||
array_layer_count: 1,
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
dimension: TextureDimension::D2,
|
||||
format: wgpu::TextureFormat::Depth32Float,
|
||||
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT,
|
||||
})))
|
||||
)))
|
||||
.add_pass(
|
||||
"main",
|
||||
PassDescriptor {
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
mod forward;
|
||||
|
||||
pub use forward::*;
|
||||
pub use forward::*;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::render::{
|
||||
render_graph_2::{DrawTarget, PipelineLayout, BindGroup},
|
||||
render_graph_2::{BindGroup, DrawTarget, PipelineLayout},
|
||||
shader::{Shader, ShaderStages},
|
||||
};
|
||||
|
||||
|
|
|
@ -179,4 +179,4 @@ impl From<TextureDescriptor> for wgpu::TextureDescriptor {
|
|||
usage: texture_descriptor.usage,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,7 @@ use crate::render::{
|
|||
Vertex,
|
||||
{
|
||||
render_graph_2::{
|
||||
mesh_draw_target, pipeline_layout::*, PipelineDescriptor,
|
||||
RenderGraphBuilder,
|
||||
mesh_draw_target, pipeline_layout::*, PipelineDescriptor, RenderGraphBuilder,
|
||||
},
|
||||
shader::{Shader, ShaderStage},
|
||||
},
|
||||
|
@ -24,73 +23,63 @@ impl ForwardPipelineBuilder for RenderGraphBuilder {
|
|||
include_str!("forward.frag"),
|
||||
ShaderStage::Fragment,
|
||||
))
|
||||
.add_bind_group(BindGroup::new(
|
||||
vec![
|
||||
Binding {
|
||||
name: "Camera".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: false,
|
||||
properties: vec![
|
||||
UniformProperty {
|
||||
name: "ViewProj".to_string(),
|
||||
property_type: UniformPropertyType::Mat4,
|
||||
},
|
||||
]
|
||||
}
|
||||
.add_bind_group(BindGroup::new(vec![
|
||||
Binding {
|
||||
name: "Camera".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: false,
|
||||
properties: vec![UniformProperty {
|
||||
name: "ViewProj".to_string(),
|
||||
property_type: UniformPropertyType::Mat4,
|
||||
}],
|
||||
},
|
||||
Binding {
|
||||
name: "Lights".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: false,
|
||||
properties: vec![
|
||||
UniformProperty {
|
||||
name: "NumLights".to_string(),
|
||||
property_type: UniformPropertyType::UVec4,
|
||||
},
|
||||
UniformProperty {
|
||||
name: "SceneLights".to_string(),
|
||||
property_type: UniformPropertyType::Array(
|
||||
Box::new(UniformPropertyType::Struct(vec![
|
||||
UniformPropertyType::Mat4, // proj
|
||||
UniformPropertyType::Vec4, // pos
|
||||
UniformPropertyType::Vec4, // color
|
||||
])),
|
||||
10, // max lights
|
||||
),
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
Binding {
|
||||
name: "Lights".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: false,
|
||||
properties: vec![
|
||||
UniformProperty {
|
||||
name: "NumLights".to_string(),
|
||||
property_type: UniformPropertyType::UVec4,
|
||||
},
|
||||
UniformProperty {
|
||||
name: "SceneLights".to_string(),
|
||||
property_type: UniformPropertyType::Array(
|
||||
Box::new(UniformPropertyType::Struct(vec![
|
||||
UniformPropertyType::Mat4, // proj
|
||||
UniformPropertyType::Vec4, // pos
|
||||
UniformPropertyType::Vec4, // color
|
||||
])),
|
||||
10, // max lights
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
))
|
||||
.add_bind_group(BindGroup::new(
|
||||
vec![
|
||||
Binding {
|
||||
name: "Object".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: true,
|
||||
properties: vec![
|
||||
UniformProperty {
|
||||
name: "Model".to_string(),
|
||||
property_type: UniformPropertyType::Mat4,
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
]))
|
||||
.add_bind_group(BindGroup::new(vec![
|
||||
Binding {
|
||||
name: "Object".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: true,
|
||||
properties: vec![UniformProperty {
|
||||
name: "Model".to_string(),
|
||||
property_type: UniformPropertyType::Mat4,
|
||||
}],
|
||||
},
|
||||
Binding {
|
||||
name: "StandardMaterial".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: true,
|
||||
properties: vec![
|
||||
UniformProperty {
|
||||
name: "Albedo".to_string(),
|
||||
property_type: UniformPropertyType::Vec4,
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
Binding {
|
||||
name: "StandardMaterial".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: true,
|
||||
properties: vec![UniformProperty {
|
||||
name: "Albedo".to_string(),
|
||||
property_type: UniformPropertyType::Vec4,
|
||||
}],
|
||||
},
|
||||
]
|
||||
))
|
||||
},
|
||||
]))
|
||||
.with_rasterization_state(wgpu::RasterizationStateDescriptor {
|
||||
front_face: wgpu::FrontFace::Ccw,
|
||||
cull_mode: wgpu::CullMode::Back,
|
||||
|
@ -118,4 +107,4 @@ impl ForwardPipelineBuilder for RenderGraphBuilder {
|
|||
.build(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,7 @@ use crate::render::{
|
|||
Vertex,
|
||||
{
|
||||
render_graph_2::{
|
||||
mesh_draw_target, pipeline_layout::*, PipelineDescriptor,
|
||||
RenderGraphBuilder,
|
||||
mesh_draw_target, pipeline_layout::*, PipelineDescriptor, RenderGraphBuilder,
|
||||
},
|
||||
shader::{Shader, ShaderStage},
|
||||
},
|
||||
|
@ -24,50 +23,38 @@ impl ForwardFlatPipelineBuilder for RenderGraphBuilder {
|
|||
include_str!("forward_flat.frag"),
|
||||
ShaderStage::Fragment,
|
||||
))
|
||||
.add_bind_group(BindGroup::new(
|
||||
vec![
|
||||
Binding {
|
||||
name: "Camera".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: false,
|
||||
properties: vec![
|
||||
UniformProperty {
|
||||
name: "ViewProj".to_string(),
|
||||
property_type: UniformPropertyType::Mat4,
|
||||
},
|
||||
]
|
||||
}
|
||||
.add_bind_group(BindGroup::new(vec![Binding {
|
||||
name: "Camera".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: false,
|
||||
properties: vec![UniformProperty {
|
||||
name: "ViewProj".to_string(),
|
||||
property_type: UniformPropertyType::Mat4,
|
||||
}],
|
||||
},
|
||||
}]))
|
||||
.add_bind_group(BindGroup::new(vec![
|
||||
Binding {
|
||||
name: "Object".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: true,
|
||||
properties: vec![UniformProperty {
|
||||
name: "Model".to_string(),
|
||||
property_type: UniformPropertyType::Mat4,
|
||||
}],
|
||||
},
|
||||
]
|
||||
))
|
||||
.add_bind_group(BindGroup::new(
|
||||
vec![
|
||||
Binding {
|
||||
name: "Object".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: true,
|
||||
properties: vec![
|
||||
UniformProperty {
|
||||
name: "Model".to_string(),
|
||||
property_type: UniformPropertyType::Mat4,
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
Binding {
|
||||
name: "StandardMaterial".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: true,
|
||||
properties: vec![UniformProperty {
|
||||
name: "Albedo".to_string(),
|
||||
property_type: UniformPropertyType::Vec4,
|
||||
}],
|
||||
},
|
||||
Binding {
|
||||
name: "StandardMaterial".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: true,
|
||||
properties: vec![
|
||||
UniformProperty {
|
||||
name: "Albedo".to_string(),
|
||||
property_type: UniformPropertyType::Vec4,
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
]
|
||||
))
|
||||
},
|
||||
]))
|
||||
.with_rasterization_state(wgpu::RasterizationStateDescriptor {
|
||||
front_face: wgpu::FrontFace::Ccw,
|
||||
cull_mode: wgpu::CullMode::Back,
|
||||
|
@ -95,4 +82,4 @@ impl ForwardFlatPipelineBuilder for RenderGraphBuilder {
|
|||
.build(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,4 +4,4 @@ mod ui;
|
|||
|
||||
pub use forward::*;
|
||||
pub use forward_flat::*;
|
||||
pub use ui::*;
|
||||
pub use ui::*;
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
use crate::render::render_graph_2::resource_providers::RectData;
|
||||
use crate::render::render_graph_2::VertexBufferDescriptor;
|
||||
use crate::render::{
|
||||
Vertex,
|
||||
{
|
||||
render_graph_2::{
|
||||
pipeline_layout::*, PipelineDescriptor,
|
||||
draw_targets::ui_draw_target, pipeline_layout::*, PipelineDescriptor,
|
||||
RenderGraphBuilder,
|
||||
draw_targets::ui_draw_target,
|
||||
},
|
||||
shader::{Shader, ShaderStage},
|
||||
},
|
||||
};
|
||||
use crate::render::render_graph_2::VertexBufferDescriptor;
|
||||
use crate::render::render_graph_2::resource_providers::RectData;
|
||||
pub trait UiPipelineBuilder {
|
||||
fn add_ui_pipeline(self) -> Self;
|
||||
}
|
||||
|
@ -27,22 +26,16 @@ impl UiPipelineBuilder for RenderGraphBuilder {
|
|||
include_str!("ui.frag"),
|
||||
ShaderStage::Fragment,
|
||||
))
|
||||
.add_bind_group(BindGroup::new(
|
||||
vec![
|
||||
Binding {
|
||||
name: "Camera2d".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: false,
|
||||
properties: vec![
|
||||
UniformProperty {
|
||||
name: "ViewProj".to_string(),
|
||||
property_type: UniformPropertyType::Mat4,
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
]
|
||||
))
|
||||
.add_bind_group(BindGroup::new(vec![Binding {
|
||||
name: "Camera2d".to_string(),
|
||||
bind_type: BindType::Uniform {
|
||||
dynamic: false,
|
||||
properties: vec![UniformProperty {
|
||||
name: "ViewProj".to_string(),
|
||||
property_type: UniformPropertyType::Mat4,
|
||||
}],
|
||||
},
|
||||
}]))
|
||||
.with_rasterization_state(wgpu::RasterizationStateDescriptor {
|
||||
front_face: wgpu::FrontFace::Ccw,
|
||||
cull_mode: wgpu::CullMode::None,
|
||||
|
@ -74,36 +67,34 @@ impl UiPipelineBuilder for RenderGraphBuilder {
|
|||
write_mask: wgpu::ColorWrite::ALL,
|
||||
})
|
||||
.add_vertex_buffer_descriptor(Vertex::get_vertex_buffer_descriptor())
|
||||
.add_vertex_buffer_descriptor(
|
||||
VertexBufferDescriptor {
|
||||
stride: std::mem::size_of::<RectData>() as u64,
|
||||
step_mode: wgpu::InputStepMode::Instance,
|
||||
attributes: vec![
|
||||
wgpu::VertexAttributeDescriptor {
|
||||
format: wgpu::VertexFormat::Float2,
|
||||
offset: 0,
|
||||
shader_location: 3,
|
||||
},
|
||||
wgpu::VertexAttributeDescriptor {
|
||||
format: wgpu::VertexFormat::Float2,
|
||||
offset: 2 * 4,
|
||||
shader_location: 4,
|
||||
},
|
||||
wgpu::VertexAttributeDescriptor {
|
||||
format: wgpu::VertexFormat::Float4,
|
||||
offset: 4 * 4,
|
||||
shader_location: 5,
|
||||
},
|
||||
wgpu::VertexAttributeDescriptor {
|
||||
format: wgpu::VertexFormat::Float,
|
||||
offset: 8 * 4,
|
||||
shader_location: 6,
|
||||
},
|
||||
],
|
||||
}
|
||||
)
|
||||
.add_vertex_buffer_descriptor(VertexBufferDescriptor {
|
||||
stride: std::mem::size_of::<RectData>() as u64,
|
||||
step_mode: wgpu::InputStepMode::Instance,
|
||||
attributes: vec![
|
||||
wgpu::VertexAttributeDescriptor {
|
||||
format: wgpu::VertexFormat::Float2,
|
||||
offset: 0,
|
||||
shader_location: 3,
|
||||
},
|
||||
wgpu::VertexAttributeDescriptor {
|
||||
format: wgpu::VertexFormat::Float2,
|
||||
offset: 2 * 4,
|
||||
shader_location: 4,
|
||||
},
|
||||
wgpu::VertexAttributeDescriptor {
|
||||
format: wgpu::VertexFormat::Float4,
|
||||
offset: 4 * 4,
|
||||
shader_location: 5,
|
||||
},
|
||||
wgpu::VertexAttributeDescriptor {
|
||||
format: wgpu::VertexFormat::Float,
|
||||
offset: 8 * 4,
|
||||
shader_location: 6,
|
||||
},
|
||||
],
|
||||
})
|
||||
.add_draw_target(ui_draw_target)
|
||||
.build(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
use crate::render::render_graph_2::{PassDescriptor, PipelineDescriptor, ResourceProvider, TextureDescriptor};
|
||||
use crate::render::render_graph_2::{
|
||||
PassDescriptor, PipelineDescriptor, ResourceProvider, TextureDescriptor,
|
||||
};
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct RenderGraph {
|
||||
pub pipeline_descriptors: HashMap<String, PipelineDescriptor>,
|
||||
// TODO: make this ordered
|
||||
// TODO: make this ordered
|
||||
pub pass_descriptors: HashMap<String, PassDescriptor>,
|
||||
pub pass_pipelines: HashMap<String, Vec<String>>,
|
||||
pub resource_providers: Vec<Box<dyn ResourceProvider>>,
|
||||
|
@ -47,13 +49,19 @@ impl RenderGraphBuilder {
|
|||
self.render_graph
|
||||
.pipeline_descriptors
|
||||
.insert(name.to_string(), pipeline);
|
||||
|
||||
|
||||
if let Some(current_pass) = self.current_pass.as_ref() {
|
||||
if let None = self.render_graph.pass_pipelines.get(current_pass) {
|
||||
self.render_graph.pass_pipelines.insert(current_pass.to_string(), Vec::new());
|
||||
self.render_graph
|
||||
.pass_pipelines
|
||||
.insert(current_pass.to_string(), Vec::new());
|
||||
}
|
||||
|
||||
let pass_pipelines = self.render_graph.pass_pipelines.get_mut(current_pass).unwrap();
|
||||
let pass_pipelines = self
|
||||
.render_graph
|
||||
.pass_pipelines
|
||||
.get_mut(current_pass)
|
||||
.unwrap();
|
||||
pass_pipelines.push(name.to_string());
|
||||
}
|
||||
|
||||
|
@ -66,11 +74,13 @@ impl RenderGraphBuilder {
|
|||
}
|
||||
|
||||
pub fn add_texture(mut self, name: &str, texture_descriptor: TextureDescriptor) -> Self {
|
||||
self.render_graph.queued_textures.push((name.to_string(), texture_descriptor));
|
||||
self.render_graph
|
||||
.queued_textures
|
||||
.push((name.to_string(), texture_descriptor));
|
||||
self
|
||||
}
|
||||
|
||||
pub fn build(self) -> RenderGraph {
|
||||
self.render_graph
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,23 @@ pub trait Renderer {
|
|||
) -> Option<&mut DynamicUniformBufferInfo>;
|
||||
fn add_dynamic_uniform_buffer_info(&mut self, name: &str, info: DynamicUniformBufferInfo);
|
||||
fn create_buffer(&mut self, name: &str, size: u64, buffer_usage: wgpu::BufferUsage);
|
||||
fn create_instance_buffer(&mut self, name: &str, mesh_id: usize, size: usize, count: usize, buffer_usage: wgpu::BufferUsage);
|
||||
fn create_instance_buffer_with_data(&mut self, name: &str, mesh_id: usize, data: &[u8], size: usize, count: usize, buffer_usage: wgpu::BufferUsage);
|
||||
fn create_instance_buffer(
|
||||
&mut self,
|
||||
name: &str,
|
||||
mesh_id: usize,
|
||||
size: usize,
|
||||
count: usize,
|
||||
buffer_usage: wgpu::BufferUsage,
|
||||
);
|
||||
fn create_instance_buffer_with_data(
|
||||
&mut self,
|
||||
name: &str,
|
||||
mesh_id: usize,
|
||||
data: &[u8],
|
||||
size: usize,
|
||||
count: usize,
|
||||
buffer_usage: wgpu::BufferUsage,
|
||||
);
|
||||
fn create_buffer_mapped(
|
||||
&mut self,
|
||||
name: &str,
|
||||
|
|
|
@ -1 +1 @@
|
|||
pub mod wgpu_renderer;
|
||||
pub mod wgpu_renderer;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::{
|
||||
legion::prelude::*,
|
||||
render::render_graph_2::{
|
||||
resource_name, BindGroup, BindType, PassDescriptor, PipelineDescriptor, RenderGraph,
|
||||
RenderPass, RenderPassColorAttachmentDescriptor,
|
||||
resource_name, BindGroup, BindType, DynamicUniformBufferInfo, PassDescriptor,
|
||||
PipelineDescriptor, RenderGraph, RenderPass, RenderPassColorAttachmentDescriptor,
|
||||
RenderPassDepthStencilAttachmentDescriptor, Renderer, ResourceInfo, ShaderUniforms,
|
||||
TextureDescriptor, DynamicUniformBufferInfo,
|
||||
TextureDescriptor,
|
||||
},
|
||||
};
|
||||
use std::{collections::HashMap, ops::Deref};
|
||||
|
@ -235,7 +235,10 @@ impl WgpuRenderer {
|
|||
// if a uniform resource buffer doesn't exist, create a new empty one
|
||||
for binding in bind_group.bindings.iter() {
|
||||
if let None = self.resource_info.get(&binding.name) {
|
||||
println!("Warning: creating new empty buffer for binding {}", binding.name);
|
||||
println!(
|
||||
"Warning: creating new empty buffer for binding {}",
|
||||
binding.name
|
||||
);
|
||||
unset_uniforms.push(binding.name.to_string());
|
||||
if let BindType::Uniform { .. } = &binding.bind_type {
|
||||
let size = binding.bind_type.get_uniform_size().unwrap();
|
||||
|
@ -471,7 +474,7 @@ impl Renderer for WgpuRenderer {
|
|||
|
||||
for (name, texture_descriptor) in render_graph.queued_textures.drain(..) {
|
||||
self.create_texture(&name, &texture_descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
let mut encoder = self.encoder.take().unwrap();
|
||||
|
||||
|
@ -565,7 +568,14 @@ impl Renderer for WgpuRenderer {
|
|||
self.buffers.insert(name.to_string(), buffer);
|
||||
}
|
||||
|
||||
fn create_instance_buffer(&mut self, name: &str, mesh_id: usize, size: usize, count: usize, buffer_usage: wgpu::BufferUsage) {
|
||||
fn create_instance_buffer(
|
||||
&mut self,
|
||||
name: &str,
|
||||
mesh_id: usize,
|
||||
size: usize,
|
||||
count: usize,
|
||||
buffer_usage: wgpu::BufferUsage,
|
||||
) {
|
||||
let buffer = self.device.create_buffer(&wgpu::BufferDescriptor {
|
||||
size: (size * count) as u64,
|
||||
usage: buffer_usage,
|
||||
|
@ -584,7 +594,15 @@ impl Renderer for WgpuRenderer {
|
|||
self.buffers.insert(name.to_string(), buffer);
|
||||
}
|
||||
|
||||
fn create_instance_buffer_with_data(&mut self, name: &str, mesh_id: usize, data: &[u8], size: usize, count: usize, buffer_usage: wgpu::BufferUsage) {
|
||||
fn create_instance_buffer_with_data(
|
||||
&mut self,
|
||||
name: &str,
|
||||
mesh_id: usize,
|
||||
data: &[u8],
|
||||
size: usize,
|
||||
count: usize,
|
||||
buffer_usage: wgpu::BufferUsage,
|
||||
) {
|
||||
let buffer = self.device.create_buffer_with_data(data, buffer_usage);
|
||||
|
||||
self.add_resource_info(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use std::collections::HashMap;
|
||||
use legion::prelude::Entity;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub enum ResourceInfo {
|
||||
BufferMapped {
|
||||
|
@ -38,4 +38,4 @@ impl DynamicUniformBufferInfo {
|
|||
size: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,4 +13,4 @@ pub mod buffer {
|
|||
pub const UI_INSTANCES: &str = "UiInstances";
|
||||
pub const TEMP_MESH_VERTEX_BUFFER_NAME: &str = "TempMeshVertexBuffer";
|
||||
pub const TEMP_MESH_INDEX_BUFFER_NAME: &str = "TempMeshIndexBuffer";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,4 +5,4 @@ pub trait ResourceProvider {
|
|||
fn initialize(&mut self, renderer: &mut dyn Renderer, world: &mut World);
|
||||
fn update(&mut self, renderer: &mut dyn Renderer, world: &mut World);
|
||||
fn resize(&mut self, renderer: &mut dyn Renderer, world: &mut World, width: u32, height: u32);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::{render::{
|
||||
use crate::render::render_graph_2::ResourceProvider;
|
||||
use crate::render::{
|
||||
render_graph_2::{resource_name, Renderer},
|
||||
ActiveCamera2d, Camera,
|
||||
}};
|
||||
};
|
||||
use legion::prelude::*;
|
||||
use zerocopy::AsBytes;
|
||||
use crate::render::render_graph_2::ResourceProvider;
|
||||
|
||||
pub struct Camera2dResourceProvider;
|
||||
|
||||
|
@ -20,12 +20,9 @@ impl ResourceProvider for Camera2dResourceProvider {
|
|||
fn update(&mut self, _renderer: &mut dyn Renderer, _world: &mut World) {}
|
||||
fn resize(&mut self, renderer: &mut dyn Renderer, world: &mut World, width: u32, height: u32) {
|
||||
let matrix_size = std::mem::size_of::<[[f32; 4]; 4]>();
|
||||
for (mut camera, _) in
|
||||
<(Write<Camera>, Read<ActiveCamera2d>)>::query().iter_mut(world)
|
||||
{
|
||||
for (mut camera, _) in <(Write<Camera>, Read<ActiveCamera2d>)>::query().iter_mut(world) {
|
||||
camera.update(width, height);
|
||||
let camera_matrix: [[f32; 4]; 4] =
|
||||
camera.view_matrix.to_cols_array_2d();
|
||||
let camera_matrix: [[f32; 4]; 4] = camera.view_matrix.to_cols_array_2d();
|
||||
|
||||
renderer.create_buffer_mapped(
|
||||
"camera2d_tmp",
|
||||
|
@ -45,4 +42,4 @@ impl ResourceProvider for Camera2dResourceProvider {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use crate::{render::{
|
||||
use crate::render::render_graph_2::ResourceProvider;
|
||||
use crate::render::{
|
||||
render_graph_2::{resource_name, Renderer},
|
||||
ActiveCamera, Camera,
|
||||
}};
|
||||
};
|
||||
use bevy_transform::prelude::LocalToWorld;
|
||||
use legion::prelude::*;
|
||||
use zerocopy::AsBytes;
|
||||
use crate::render::render_graph_2::ResourceProvider;
|
||||
|
||||
pub struct CameraResourceProvider;
|
||||
|
||||
|
@ -46,4 +46,4 @@ impl ResourceProvider for CameraResourceProvider {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,13 @@ impl ResourceProvider for FrameTextureResourceProvider {
|
|||
|
||||
fn update(&mut self, _renderer: &mut dyn Renderer, _world: &mut World) {}
|
||||
|
||||
fn resize(&mut self, renderer: &mut dyn Renderer, world: &mut World, _width: u32, _height: u32) {
|
||||
fn resize(
|
||||
&mut self,
|
||||
renderer: &mut dyn Renderer,
|
||||
world: &mut World,
|
||||
_width: u32,
|
||||
_height: u32,
|
||||
) {
|
||||
self.update(renderer, world);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use zerocopy::AsBytes;
|
||||
use legion::prelude::*;
|
||||
use crate::render::render_graph_2::ResourceProvider;
|
||||
use crate::render::render_graph_2::resource_name;
|
||||
use crate::render::render_graph_2::Renderer;
|
||||
use crate::render::render_graph_2::ResourceProvider;
|
||||
use crate::render::{Light, LightRaw};
|
||||
use bevy_transform::prelude::{LocalToWorld, Translation};
|
||||
use legion::prelude::*;
|
||||
use zerocopy::AsBytes;
|
||||
|
||||
pub struct LightResourceProvider {
|
||||
pub lights_are_dirty: bool,
|
||||
|
@ -28,8 +28,9 @@ impl LightResourceProvider {
|
|||
|
||||
impl ResourceProvider for LightResourceProvider {
|
||||
fn initialize(&mut self, renderer: &mut dyn Renderer, _world: &mut World) {
|
||||
let light_uniform_size =
|
||||
(std::mem::size_of::<LightCount>() + self.max_lights * std::mem::size_of::<LightRaw>()) as wgpu::BufferAddress;
|
||||
let light_uniform_size = (std::mem::size_of::<LightCount>()
|
||||
+ self.max_lights * std::mem::size_of::<LightRaw>())
|
||||
as wgpu::BufferAddress;
|
||||
|
||||
renderer.create_buffer(
|
||||
resource_name::uniform::LIGHTS,
|
||||
|
@ -51,21 +52,28 @@ impl ResourceProvider for LightResourceProvider {
|
|||
let size = std::mem::size_of::<LightRaw>();
|
||||
let total_size = size * light_count;
|
||||
let light_count_size = std::mem::size_of::<LightCount>();
|
||||
renderer
|
||||
.create_buffer_mapped("LIGHT_TMP", total_size, wgpu::BufferUsage::COPY_SRC, &mut |data| {
|
||||
for ((light, local_to_world, translation), slot) in light_query
|
||||
.iter(world)
|
||||
.zip(data.chunks_exact_mut(size))
|
||||
renderer.create_buffer_mapped(
|
||||
"LIGHT_TMP",
|
||||
total_size,
|
||||
wgpu::BufferUsage::COPY_SRC,
|
||||
&mut |data| {
|
||||
for ((light, local_to_world, translation), slot) in
|
||||
light_query.iter(world).zip(data.chunks_exact_mut(size))
|
||||
{
|
||||
slot.copy_from_slice(
|
||||
LightRaw::from(&light, &local_to_world.0, &translation).as_bytes(),
|
||||
);
|
||||
}
|
||||
});
|
||||
renderer
|
||||
.create_buffer_mapped("LIGHT_COUNT_TMP", light_count_size, wgpu::BufferUsage::COPY_SRC, &mut |data| {
|
||||
},
|
||||
);
|
||||
renderer.create_buffer_mapped(
|
||||
"LIGHT_COUNT_TMP",
|
||||
light_count_size,
|
||||
wgpu::BufferUsage::COPY_SRC,
|
||||
&mut |data| {
|
||||
data.copy_from_slice([light_count as u32, 0, 0, 0].as_bytes());
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
renderer.copy_buffer_to_buffer(
|
||||
"LIGHT_COUNT_TMP",
|
||||
|
@ -85,5 +93,12 @@ impl ResourceProvider for LightResourceProvider {
|
|||
}
|
||||
}
|
||||
|
||||
fn resize(&mut self, _renderer: &mut dyn Renderer, _world: &mut World, _width: u32, _height: u32) {}
|
||||
}
|
||||
fn resize(
|
||||
&mut self,
|
||||
_renderer: &mut dyn Renderer,
|
||||
_world: &mut World,
|
||||
_width: u32,
|
||||
_height: u32,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
mod ui_resource_provider;
|
||||
mod camera2d_resource_provider;
|
||||
mod camera_resource_provider;
|
||||
mod frame_texture_resource_provider;
|
||||
mod light_resource_provider;
|
||||
mod camera_resource_provider;
|
||||
mod camera2d_resource_provider;
|
||||
mod ui_resource_provider;
|
||||
|
||||
pub use ui_resource_provider::*;
|
||||
pub use camera2d_resource_provider::*;
|
||||
pub use camera_resource_provider::*;
|
||||
pub use frame_texture_resource_provider::*;
|
||||
pub use light_resource_provider::*;
|
||||
pub use camera_resource_provider::*;
|
||||
pub use camera2d_resource_provider::*;
|
||||
pub use ui_resource_provider::*;
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
use crate::asset::MeshType;
|
||||
use crate::prelude::Node;
|
||||
use crate::render::render_graph_2::resource_name;
|
||||
use crate::render::render_graph_2::ResourceProvider;
|
||||
use crate::{ecs, render::render_graph_2::Renderer, asset::{Handle, Mesh, Asset, AssetStorage}, math};
|
||||
use crate::{
|
||||
asset::{Asset, AssetStorage, Handle, Mesh},
|
||||
ecs, math,
|
||||
render::render_graph_2::Renderer,
|
||||
};
|
||||
use bevy_transform::prelude::Parent;
|
||||
use legion::prelude::*;
|
||||
use zerocopy::{AsBytes, FromBytes};
|
||||
use crate::asset::MeshType;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, AsBytes, FromBytes)]
|
||||
|
@ -22,9 +26,7 @@ pub struct UiResourceProvider {
|
|||
|
||||
impl UiResourceProvider {
|
||||
pub fn new() -> Self {
|
||||
UiResourceProvider {
|
||||
quad: None,
|
||||
}
|
||||
UiResourceProvider { quad: None }
|
||||
}
|
||||
|
||||
pub fn update(&mut self, renderer: &mut dyn Renderer, world: &World) {
|
||||
|
@ -60,7 +62,7 @@ impl UiResourceProvider {
|
|||
}
|
||||
|
||||
if data.len() == 0 {
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
let size = std::mem::size_of::<RectData>();
|
||||
|
@ -95,6 +97,12 @@ impl ResourceProvider for UiResourceProvider {
|
|||
self.update(renderer, world);
|
||||
}
|
||||
|
||||
fn resize(&mut self, _renderer: &mut dyn Renderer, _world: &mut World, _width: u32, _height: u32) {
|
||||
fn resize(
|
||||
&mut self,
|
||||
_renderer: &mut dyn Renderer,
|
||||
_world: &mut World,
|
||||
_width: u32,
|
||||
_height: u32,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ use crate::{
|
|||
},
|
||||
};
|
||||
use legion::{prelude::*, storage::Component};
|
||||
use zerocopy::AsBytes;
|
||||
use std::marker::PhantomData;
|
||||
use zerocopy::AsBytes;
|
||||
|
||||
pub type ShaderUniformSelector = fn(Entity, &World) -> Option<RefMap<&dyn AsUniforms>>;
|
||||
pub struct ShaderUniforms {
|
||||
|
|
|
@ -18,13 +18,19 @@ impl Into<shaderc::ShaderKind> for ShaderStage {
|
|||
}
|
||||
|
||||
pub fn glsl_to_spirv(glsl_source: &str, stage: ShaderStage) -> Vec<u32> {
|
||||
let shader_kind: shaderc::ShaderKind = stage.into();
|
||||
let shader_kind: shaderc::ShaderKind = stage.into();
|
||||
let mut compiler = shaderc::Compiler::new().unwrap();
|
||||
let options = shaderc::CompileOptions::new().unwrap();
|
||||
let binary_result = compiler.compile_into_spirv(
|
||||
glsl_source, shader_kind,
|
||||
"shader.glsl", "main", Some(&options)).unwrap();
|
||||
|
||||
let binary_result = compiler
|
||||
.compile_into_spirv(
|
||||
glsl_source,
|
||||
shader_kind,
|
||||
"shader.glsl",
|
||||
"main",
|
||||
Some(&options),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
binary_result.as_binary().into()
|
||||
}
|
||||
|
||||
|
@ -74,4 +80,4 @@ impl ShaderStages {
|
|||
fragment: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::render::render_graph_2::VertexBufferDescriptor;
|
||||
use std::convert::From;
|
||||
use zerocopy::{AsBytes, FromBytes};
|
||||
use crate::render::render_graph_2::VertexBufferDescriptor;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, AsBytes, FromBytes)]
|
||||
|
|
|
@ -13,7 +13,7 @@ use serde::{
|
|||
Deserialize, Deserializer, Serialize, Serializer,
|
||||
};
|
||||
use std::{
|
||||
any::{type_name}, cell::RefCell, collections::HashMap, iter::FromIterator, marker::PhantomData,
|
||||
any::type_name, cell::RefCell, collections::HashMap, iter::FromIterator, marker::PhantomData,
|
||||
ptr::NonNull,
|
||||
};
|
||||
use type_uuid::TypeUuid;
|
||||
|
@ -209,7 +209,9 @@ impl SerializeImpl {
|
|||
.map(|reg| (reg.ty.clone(), reg.clone())),
|
||||
),
|
||||
tag_types: HashMap::from_iter(
|
||||
tag_registrations.iter().map(|reg| (reg.ty.clone(), reg.clone())),
|
||||
tag_registrations
|
||||
.iter()
|
||||
.map(|reg| (reg.ty.clone(), reg.clone())),
|
||||
),
|
||||
entity_map: RefCell::new(HashMap::new()),
|
||||
}
|
||||
|
@ -227,7 +229,9 @@ impl SerializeImpl {
|
|||
.map(|reg| (reg.ty.clone(), reg.clone())),
|
||||
),
|
||||
tag_types: HashMap::from_iter(
|
||||
tag_registrations.iter().map(|reg| (reg.ty.clone(), reg.clone())),
|
||||
tag_registrations
|
||||
.iter()
|
||||
.map(|reg| (reg.ty.clone(), reg.clone())),
|
||||
),
|
||||
entity_map: RefCell::new(HashMap::from_iter(
|
||||
entity_map.into_iter().map(|(uuid, e)| (e, uuid)),
|
||||
|
|
Loading…
Reference in a new issue