enforce cargo fmt --check
This commit is contained in:
parent
ece54e963e
commit
d138647818
12
.github/workflows/rust.yml
vendored
12
.github/workflows/rust.yml
vendored
@ -17,14 +17,26 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
override: true
|
override: true
|
||||||
|
|
||||||
|
- uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: nightly
|
||||||
|
components: rustfmt
|
||||||
|
|
||||||
- name: Install alsa
|
- name: Install alsa
|
||||||
run: sudo apt-get install libasound2-dev
|
run: sudo apt-get install libasound2-dev
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cargo check
|
run: cargo check
|
||||||
|
|
||||||
|
- name: Check the format
|
||||||
|
run: cargo +nightly fmt --all -- --check
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test --workspace
|
run: cargo test --workspace
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#[cfg(feature = "filesystem_watcher")]
|
|
||||||
mod filesystem_watcher;
|
|
||||||
mod asset_server;
|
mod asset_server;
|
||||||
mod assets;
|
mod assets;
|
||||||
|
#[cfg(feature = "filesystem_watcher")]
|
||||||
|
mod filesystem_watcher;
|
||||||
mod handle;
|
mod handle;
|
||||||
mod load_request;
|
mod load_request;
|
||||||
mod loader;
|
mod loader;
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
//! also be useful for serialization, or other row-oriented generic operations.
|
//! also be useful for serialization, or other row-oriented generic operations.
|
||||||
|
|
||||||
fn format_entity(entity: bevy_hecs::EntityRef<'_>) -> String {
|
fn format_entity(entity: bevy_hecs::EntityRef<'_>) -> String {
|
||||||
fn fmt<T: bevy_hecs::Component + std::fmt::Display>(entity: bevy_hecs::EntityRef<'_>) -> Option<String> {
|
fn fmt<T: bevy_hecs::Component + std::fmt::Display>(
|
||||||
|
entity: bevy_hecs::EntityRef<'_>,
|
||||||
|
) -> Option<String> {
|
||||||
Some(entity.get::<T>()?.to_string())
|
Some(entity.get::<T>()?.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,12 +3,12 @@ use crate::{
|
|||||||
system::{SystemId, TypeAccess},
|
system::{SystemId, TypeAccess},
|
||||||
Resource, ResourceIndex,
|
Resource, ResourceIndex,
|
||||||
};
|
};
|
||||||
|
use bevy_hecs::smaller_tuples_too;
|
||||||
use core::{
|
use core::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
ptr::NonNull,
|
ptr::NonNull,
|
||||||
};
|
};
|
||||||
use bevy_hecs::smaller_tuples_too;
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
/// Shared borrow of a Resource
|
/// Shared borrow of a Resource
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::{FetchResource, ResourceQuery};
|
use super::{FetchResource, ResourceQuery};
|
||||||
use crate::system::SystemId;
|
use crate::system::SystemId;
|
||||||
use core::any::TypeId;
|
|
||||||
use bevy_hecs::{Archetype, Ref, RefMut, TypeInfo};
|
use bevy_hecs::{Archetype, Ref, RefMut, TypeInfo};
|
||||||
|
use core::any::TypeId;
|
||||||
use std::{collections::HashMap, ptr::NonNull};
|
use std::{collections::HashMap, ptr::NonNull};
|
||||||
|
|
||||||
/// A Resource type
|
/// A Resource type
|
||||||
|
@ -3,9 +3,9 @@ use crate::{
|
|||||||
resource::Resources,
|
resource::Resources,
|
||||||
system::{ArchetypeAccess, System, ThreadLocalExecution, TypeAccess},
|
system::{ArchetypeAccess, System, ThreadLocalExecution, TypeAccess},
|
||||||
};
|
};
|
||||||
|
use bevy_hecs::{ArchetypesGeneration, World};
|
||||||
use crossbeam_channel::{Receiver, Sender};
|
use crossbeam_channel::{Receiver, Sender};
|
||||||
use fixedbitset::FixedBitSet;
|
use fixedbitset::FixedBitSet;
|
||||||
use bevy_hecs::{ArchetypesGeneration, World};
|
|
||||||
use rayon::ScopeFifo;
|
use rayon::ScopeFifo;
|
||||||
use std::{
|
use std::{
|
||||||
ops::Range,
|
ops::Range,
|
||||||
@ -68,7 +68,6 @@ impl ParallelExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// This can be added as an app resource to control the global `rayon::ThreadPool` used by ecs.
|
/// This can be added as an app resource to control the global `rayon::ThreadPool` used by ecs.
|
||||||
// Dev internal note: We cannot directly expose a ThreadPoolBuilder here as it does not implement Send and Sync.
|
// Dev internal note: We cannot directly expose a ThreadPoolBuilder here as it does not implement Send and Sync.
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
@ -360,19 +359,22 @@ impl ExecutorStage {
|
|||||||
self.running_systems.clear();
|
self.running_systems.clear();
|
||||||
|
|
||||||
let mut run_ready_result = RunReadyResult::Ok;
|
let mut run_ready_result = RunReadyResult::Ok;
|
||||||
let run_ready_system_index_range = if let Some(index) = self
|
let run_ready_system_index_range =
|
||||||
.thread_local_system_indices
|
if let Some(index) = self.thread_local_system_indices.get(0) {
|
||||||
.get(0)
|
// if there is an upcoming thread local system, run up to (and including) it
|
||||||
{
|
0..(*index + 1)
|
||||||
// if there is an upcoming thread local system, run up to (and including) it
|
} else {
|
||||||
0..(*index + 1)
|
// if there are no upcoming thread local systems, run everything right now
|
||||||
} else {
|
0..systems.len()
|
||||||
// if there are no upcoming thread local systems, run everything right now
|
};
|
||||||
0..systems.len()
|
|
||||||
};
|
|
||||||
rayon::scope_fifo(|scope| {
|
rayon::scope_fifo(|scope| {
|
||||||
run_ready_result =
|
run_ready_result = self.run_ready_systems(
|
||||||
self.run_ready_systems(systems, RunReadyType::Range(run_ready_system_index_range), scope, world, resources);
|
systems,
|
||||||
|
RunReadyType::Range(run_ready_system_index_range),
|
||||||
|
scope,
|
||||||
|
world,
|
||||||
|
resources,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
loop {
|
loop {
|
||||||
// if all systems in the stage are finished, break out of the loop
|
// if all systems in the stage are finished, break out of the loop
|
||||||
@ -442,8 +444,8 @@ mod tests {
|
|||||||
system::{IntoQuerySystem, IntoThreadLocalSystem, Query},
|
system::{IntoQuerySystem, IntoThreadLocalSystem, Query},
|
||||||
Commands,
|
Commands,
|
||||||
};
|
};
|
||||||
use fixedbitset::FixedBitSet;
|
|
||||||
use bevy_hecs::{Entity, World};
|
use bevy_hecs::{Entity, World};
|
||||||
|
use fixedbitset::FixedBitSet;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -2,12 +2,12 @@ mod commands;
|
|||||||
mod into_system;
|
mod into_system;
|
||||||
#[cfg(feature = "profiler")]
|
#[cfg(feature = "profiler")]
|
||||||
mod profiler;
|
mod profiler;
|
||||||
mod system;
|
|
||||||
mod query;
|
mod query;
|
||||||
|
mod system;
|
||||||
|
|
||||||
pub use commands::*;
|
pub use commands::*;
|
||||||
pub use into_system::*;
|
pub use into_system::*;
|
||||||
#[cfg(feature = "profiler")]
|
#[cfg(feature = "profiler")]
|
||||||
pub use profiler::*;
|
pub use profiler::*;
|
||||||
pub use system::*;
|
|
||||||
pub use query::*;
|
pub use query::*;
|
||||||
|
pub use system::*;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::resource::Resources;
|
use crate::resource::Resources;
|
||||||
use fixedbitset::FixedBitSet;
|
|
||||||
use bevy_hecs::{Access, Query, World};
|
use bevy_hecs::{Access, Query, World};
|
||||||
|
use fixedbitset::FixedBitSet;
|
||||||
use std::{any::TypeId, borrow::Cow, collections::HashSet};
|
use std::{any::TypeId, borrow::Cow, collections::HashSet};
|
||||||
|
|
||||||
/// Determines the strategy used to run the `run_thread_local` function in a [System]
|
/// Determines the strategy used to run the `run_thread_local` function in a [System]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::Input;
|
use crate::Input;
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_ecs::{Res, ResMut, Local};
|
use bevy_ecs::{Local, Res, ResMut};
|
||||||
|
|
||||||
/// A key input event from a keyboard device
|
/// A key input event from a keyboard device
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -11,9 +11,7 @@ pub mod prelude {
|
|||||||
|
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use keyboard::{keyboard_input_system, KeyCode, KeyboardInput};
|
use keyboard::{keyboard_input_system, KeyCode, KeyboardInput};
|
||||||
use mouse::{
|
use mouse::{mouse_button_input_system, MouseButton, MouseButtonInput, MouseMotion};
|
||||||
mouse_button_input_system, MouseButton, MouseButtonInput, MouseMotion,
|
|
||||||
};
|
|
||||||
|
|
||||||
use bevy_ecs::IntoQuerySystem;
|
use bevy_ecs::IntoQuerySystem;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::keyboard::ElementState;
|
use super::keyboard::ElementState;
|
||||||
use crate::Input;
|
use crate::Input;
|
||||||
use bevy_app::prelude::{EventReader, Events};
|
use bevy_app::prelude::{EventReader, Events};
|
||||||
use bevy_ecs::{Res, ResMut, Local};
|
use bevy_ecs::{Local, Res, ResMut};
|
||||||
use bevy_math::Vec2;
|
use bevy_math::Vec2;
|
||||||
|
|
||||||
/// A mouse button input event
|
/// A mouse button input event
|
||||||
|
@ -16,6 +16,7 @@ pub mod uniform {
|
|||||||
pub const LIGHTS: &str = "Lights";
|
pub const LIGHTS: &str = "Lights";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use crate::prelude::StandardMaterial;
|
||||||
use bevy_asset::Assets;
|
use bevy_asset::Assets;
|
||||||
use bevy_ecs::Resources;
|
use bevy_ecs::Resources;
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
@ -24,7 +25,6 @@ use bevy_render::{
|
|||||||
shader::Shader,
|
shader::Shader,
|
||||||
};
|
};
|
||||||
use bevy_transform::prelude::Transform;
|
use bevy_transform::prelude::Transform;
|
||||||
use crate::prelude::StandardMaterial;
|
|
||||||
|
|
||||||
pub(crate) fn add_pbr_graph(graph: &mut RenderGraph, resources: &Resources) {
|
pub(crate) fn add_pbr_graph(graph: &mut RenderGraph, resources: &Resources) {
|
||||||
graph.add_system_node(node::TRANSFORM, RenderResourcesNode::<Transform>::new(true));
|
graph.add_system_node(node::TRANSFORM, RenderResourcesNode::<Transform>::new(true));
|
||||||
@ -41,10 +41,13 @@ pub(crate) fn add_pbr_graph(graph: &mut RenderGraph, resources: &Resources) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// TODO: replace these with "autowire" groups
|
// TODO: replace these with "autowire" groups
|
||||||
graph.add_node_edge(node::STANDARD_MATERIAL, base::node::MAIN_PASS)
|
graph
|
||||||
|
.add_node_edge(node::STANDARD_MATERIAL, base::node::MAIN_PASS)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
graph.add_node_edge(node::TRANSFORM, base::node::MAIN_PASS)
|
graph
|
||||||
|
.add_node_edge(node::TRANSFORM, base::node::MAIN_PASS)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
graph.add_node_edge(node::LIGHTS, base::node::MAIN_PASS)
|
graph
|
||||||
|
.add_node_edge(node::LIGHTS, base::node::MAIN_PASS)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
use super::DepthCalculation;
|
||||||
use bevy_math::Mat4;
|
use bevy_math::Mat4;
|
||||||
use bevy_property::{Properties, Property};
|
use bevy_property::{Properties, Property};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use super::DepthCalculation;
|
|
||||||
|
|
||||||
pub trait CameraProjection {
|
pub trait CameraProjection {
|
||||||
fn get_projection_matrix(&self) -> Mat4;
|
fn get_projection_matrix(&self) -> Mat4;
|
||||||
|
@ -2,8 +2,8 @@ use super::{Camera, DepthCalculation};
|
|||||||
use crate::Draw;
|
use crate::Draw;
|
||||||
use bevy_core::FloatOrd;
|
use bevy_core::FloatOrd;
|
||||||
use bevy_ecs::{Entity, Query};
|
use bevy_ecs::{Entity, Query};
|
||||||
use bevy_transform::prelude::Transform;
|
|
||||||
use bevy_property::Properties;
|
use bevy_property::Properties;
|
||||||
|
use bevy_transform::prelude::Transform;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct VisibleEntity {
|
pub struct VisibleEntity {
|
||||||
|
@ -421,9 +421,7 @@ pub mod shape {
|
|||||||
|
|
||||||
let points = raw_points
|
let points = raw_points
|
||||||
.iter()
|
.iter()
|
||||||
.map(|&p| {
|
.map(|&p| (p * sphere.radius).into())
|
||||||
(p * sphere.radius).into()
|
|
||||||
})
|
|
||||||
.collect::<Vec<[f32; 3]>>();
|
.collect::<Vec<[f32; 3]>>();
|
||||||
|
|
||||||
let normals = raw_points
|
let normals = raw_points
|
||||||
@ -447,7 +445,7 @@ pub mod shape {
|
|||||||
VertexAttribute::normal(normals),
|
VertexAttribute::normal(normals),
|
||||||
VertexAttribute::uv(uvs),
|
VertexAttribute::uv(uvs),
|
||||||
],
|
],
|
||||||
indices: Some(indices)
|
indices: Some(indices),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@ use crate::{
|
|||||||
shader::{Shader, ShaderSource},
|
shader::{Shader, ShaderSource},
|
||||||
};
|
};
|
||||||
use bevy_asset::{Assets, Handle};
|
use bevy_asset::{Assets, Handle};
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
use bevy_property::{Properties, Property};
|
use bevy_property::{Properties, Property};
|
||||||
use serde::{Serialize, Deserialize};
|
use once_cell::sync::Lazy;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
#[derive(Clone, Eq, PartialEq, Debug, Properties)]
|
#[derive(Clone, Eq, PartialEq, Debug, Properties)]
|
||||||
pub struct PipelineSpecialization {
|
pub struct PipelineSpecialization {
|
||||||
pub shader_specialization: ShaderSpecialization,
|
pub shader_specialization: ShaderSpecialization,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::texture::TextureFormat;
|
use crate::texture::TextureFormat;
|
||||||
use serde::{Serialize, Deserialize};
|
|
||||||
use bevy_property::Property;
|
use bevy_property::Property;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct DepthStencilStateDescriptor {
|
pub struct DepthStencilStateDescriptor {
|
||||||
|
@ -3,8 +3,8 @@ use crate::{
|
|||||||
draw::{Draw, RenderCommand},
|
draw::{Draw, RenderCommand},
|
||||||
pass::{ClearColor, LoadOp, PassDescriptor, TextureAttachment},
|
pass::{ClearColor, LoadOp, PassDescriptor, TextureAttachment},
|
||||||
pipeline::{
|
pipeline::{
|
||||||
BindGroupDescriptor, BindType, BindingDescriptor, PipelineDescriptor, UniformProperty,
|
BindGroupDescriptor, BindType, BindingDescriptor, BindingShaderStage, PipelineDescriptor,
|
||||||
BindingShaderStage,
|
UniformProperty,
|
||||||
},
|
},
|
||||||
render_graph::{Node, ResourceSlotInfo, ResourceSlots},
|
render_graph::{Node, ResourceSlotInfo, ResourceSlots},
|
||||||
renderer::{
|
renderer::{
|
||||||
@ -12,7 +12,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use bevy_asset::{Assets, Handle};
|
use bevy_asset::{Assets, Handle};
|
||||||
use bevy_ecs::{Resources, World, HecsQuery};
|
use bevy_ecs::{HecsQuery, Resources, World};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
struct CameraInfo {
|
struct CameraInfo {
|
||||||
@ -136,8 +136,9 @@ impl<Q: HecsQuery + Send + Sync + 'static> Node for PassNode<Q> {
|
|||||||
TextureAttachment::Id(input.get(input_index).unwrap().get_texture().unwrap());
|
TextureAttachment::Id(input.get(input_index).unwrap().get_texture().unwrap());
|
||||||
}
|
}
|
||||||
if let Some(input_index) = self.color_resolve_target_indices[i] {
|
if let Some(input_index) = self.color_resolve_target_indices[i] {
|
||||||
color_attachment.resolve_target =
|
color_attachment.resolve_target = Some(TextureAttachment::Id(
|
||||||
Some(TextureAttachment::Id(input.get(input_index).unwrap().get_texture().unwrap()));
|
input.get(input_index).unwrap().get_texture().unwrap(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,7 +660,7 @@ fn asset_render_resources_node_system<T: RenderResources>(
|
|||||||
|
|
||||||
for (asset_handle, draw, mut render_pipelines) in &mut query.iter() {
|
for (asset_handle, draw, mut render_pipelines) in &mut query.iter() {
|
||||||
if !draw.is_visible {
|
if !draw.is_visible {
|
||||||
continue
|
continue;
|
||||||
}
|
}
|
||||||
if let Some(asset_bindings) = asset_render_resource_bindings.get(*asset_handle) {
|
if let Some(asset_bindings) = asset_render_resource_bindings.get(*asset_handle) {
|
||||||
render_pipelines.bindings.extend(asset_bindings);
|
render_pipelines.bindings.extend(asset_bindings);
|
||||||
|
@ -261,7 +261,7 @@ impl Default for RenderResourceBindingsId {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::pipeline::{BindType, BindingDescriptor, UniformProperty, BindingShaderStage};
|
use crate::pipeline::{BindType, BindingDescriptor, BindingShaderStage, UniformProperty};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_bind_groups() {
|
fn test_bind_groups() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
pipeline::{
|
pipeline::{
|
||||||
BindGroupDescriptor, BindType, BindingDescriptor, InputStepMode, UniformProperty,
|
BindGroupDescriptor, BindType, BindingDescriptor, BindingShaderStage, InputStepMode,
|
||||||
VertexAttributeDescriptor, VertexBufferDescriptor, VertexFormat, BindingShaderStage,
|
UniformProperty, VertexAttributeDescriptor, VertexBufferDescriptor, VertexFormat,
|
||||||
},
|
},
|
||||||
texture::{TextureComponentType, TextureViewDimension},
|
texture::{TextureComponentType, TextureViewDimension},
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
use serde::{ser, Deserialize, Serialize};
|
use serde::{ser, Deserialize, Serialize};
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use crate::error::{Error, Result};
|
use crate::{
|
||||||
use crate::extensions::Extensions;
|
error::{Error, Result},
|
||||||
|
extensions::Extensions,
|
||||||
|
};
|
||||||
|
|
||||||
mod value;
|
mod value;
|
||||||
|
|
||||||
|
@ -44,7 +44,10 @@ impl Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move to AssetSaver when it is implemented
|
// TODO: move to AssetSaver when it is implemented
|
||||||
pub fn serialize_ron(&self, registry: &PropertyTypeRegistry) -> Result<String, bevy_ron::Error> {
|
pub fn serialize_ron(
|
||||||
|
&self,
|
||||||
|
registry: &PropertyTypeRegistry,
|
||||||
|
) -> Result<String, bevy_ron::Error> {
|
||||||
serialize_ron(SceneSerializer::new(self, registry))
|
serialize_ron(SceneSerializer::new(self, registry))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,6 @@ impl SceneSpawner {
|
|||||||
component_registration.apply_component_to_entity(world, entity, component);
|
component_registration.apply_component_to_entity(world, entity, component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
world.spawn_as_entity(entity, (1,));
|
world.spawn_as_entity(entity, (1,));
|
||||||
for component in scene_entity.components.iter() {
|
for component in scene_entity.components.iter() {
|
||||||
@ -122,7 +121,8 @@ impl SceneSpawner {
|
|||||||
.ok_or_else(|| SceneSpawnError::UnregisteredComponent {
|
.ok_or_else(|| SceneSpawnError::UnregisteredComponent {
|
||||||
type_name: component.type_name.to_string(),
|
type_name: component.type_name.to_string(),
|
||||||
})?;
|
})?;
|
||||||
component_registration.add_component_to_entity(world, resources, entity, component);
|
component_registration
|
||||||
|
.add_component_to_entity(world, resources, entity, component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,7 +209,6 @@ pub fn scene_spawner_system(world: &mut World, resources: &mut Resources) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
scene_spawner.load_queued_scenes(world, resources).unwrap();
|
scene_spawner.load_queued_scenes(world, resources).unwrap();
|
||||||
scene_spawner.spawn_queued_scenes(world, resources).unwrap();
|
scene_spawner.spawn_queued_scenes(world, resources).unwrap();
|
||||||
scene_spawner
|
scene_spawner
|
||||||
|
@ -7,10 +7,11 @@ use bevy_render::{
|
|||||||
draw::{Draw, DrawContext, DrawError, Drawable},
|
draw::{Draw, DrawContext, DrawError, Drawable},
|
||||||
mesh,
|
mesh,
|
||||||
pipeline::PipelineSpecialization,
|
pipeline::PipelineSpecialization,
|
||||||
|
prelude::Msaa,
|
||||||
renderer::{
|
renderer::{
|
||||||
AssetRenderResourceBindings, BindGroup, BufferUsage, RenderResourceBindings,
|
AssetRenderResourceBindings, BindGroup, BufferUsage, RenderResourceBindings,
|
||||||
RenderResourceId,
|
RenderResourceId,
|
||||||
}, prelude::Msaa,
|
},
|
||||||
};
|
};
|
||||||
use bevy_sprite::{TextureAtlas, TextureAtlasSprite};
|
use bevy_sprite::{TextureAtlas, TextureAtlasSprite};
|
||||||
|
|
||||||
|
@ -4,8 +4,9 @@ use bevy_ecs::{Changed, Query, Res, ResMut};
|
|||||||
use bevy_math::{Size, Vec3};
|
use bevy_math::{Size, Vec3};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
draw::{Draw, DrawContext, Drawable},
|
draw::{Draw, DrawContext, Drawable},
|
||||||
|
prelude::Msaa,
|
||||||
renderer::{AssetRenderResourceBindings, RenderResourceBindings},
|
renderer::{AssetRenderResourceBindings, RenderResourceBindings},
|
||||||
texture::Texture, prelude::Msaa,
|
texture::Texture,
|
||||||
};
|
};
|
||||||
use bevy_sprite::TextureAtlas;
|
use bevy_sprite::TextureAtlas;
|
||||||
use bevy_text::{DrawableText, Font, FontAtlasSet, TextStyle};
|
use bevy_text::{DrawableText, Font, FontAtlasSet, TextStyle};
|
||||||
@ -59,7 +60,8 @@ pub fn draw_text_system(
|
|||||||
mut query: Query<(&mut Draw, &Text, &Node, &Transform)>,
|
mut query: Query<(&mut Draw, &Text, &Node, &Transform)>,
|
||||||
) {
|
) {
|
||||||
for (mut draw, text, node, transform) in &mut query.iter() {
|
for (mut draw, text, node, transform) in &mut query.iter() {
|
||||||
let position = Vec3::from(transform.value.w_axis().truncate()) - (node.size / 2.0).extend(0.0);
|
let position =
|
||||||
|
Vec3::from(transform.value.w_axis().truncate()) - (node.size / 2.0).extend(0.0);
|
||||||
|
|
||||||
let mut drawable_text = DrawableText {
|
let mut drawable_text = DrawableText {
|
||||||
font: fonts.get(&text.font).unwrap(),
|
font: fonts.get(&text.font).unwrap(),
|
||||||
|
@ -5,7 +5,9 @@ use crate::{
|
|||||||
|
|
||||||
use bevy_asset::{Assets, Handle, HandleUntyped};
|
use bevy_asset::{Assets, Handle, HandleUntyped};
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
pipeline::{BindGroupDescriptor, BindGroupDescriptorId, BindingShaderStage, PipelineDescriptor},
|
pipeline::{
|
||||||
|
BindGroupDescriptor, BindGroupDescriptorId, BindingShaderStage, PipelineDescriptor,
|
||||||
|
},
|
||||||
renderer::{
|
renderer::{
|
||||||
BindGroup, BufferId, BufferInfo, RenderResourceBinding, RenderResourceContext,
|
BindGroup, BufferId, BufferInfo, RenderResourceBinding, RenderResourceContext,
|
||||||
RenderResourceId, SamplerId, TextureId,
|
RenderResourceId, SamplerId, TextureId,
|
||||||
@ -113,7 +115,9 @@ impl WgpuRenderResourceContext {
|
|||||||
.bindings
|
.bindings
|
||||||
.iter()
|
.iter()
|
||||||
.map(|binding| {
|
.map(|binding| {
|
||||||
let shader_stage = if binding.shader_stage == BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT {
|
let shader_stage = if binding.shader_stage
|
||||||
|
== BindingShaderStage::VERTEX | BindingShaderStage::FRAGMENT
|
||||||
|
{
|
||||||
wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT
|
wgpu::ShaderStage::VERTEX | wgpu::ShaderStage::FRAGMENT
|
||||||
} else if binding.shader_stage == BindingShaderStage::VERTEX {
|
} else if binding.shader_stage == BindingShaderStage::VERTEX {
|
||||||
wgpu::ShaderStage::VERTEX
|
wgpu::ShaderStage::VERTEX
|
||||||
|
@ -31,7 +31,10 @@ fn setup(
|
|||||||
})
|
})
|
||||||
// sphere
|
// sphere
|
||||||
.spawn(PbrComponents {
|
.spawn(PbrComponents {
|
||||||
mesh: meshes.add(Mesh::from(shape::Icosphere { subdivisions: 4, radius: 0.5 })),
|
mesh: meshes.add(Mesh::from(shape::Icosphere {
|
||||||
|
subdivisions: 4,
|
||||||
|
radius: 0.5,
|
||||||
|
})),
|
||||||
material: materials.add(Color::rgb(0.1, 0.4, 0.8).into()),
|
material: materials.add(Color::rgb(0.1, 0.4, 0.8).into()),
|
||||||
translation: Translation::new(1.5, 1.5, 1.5),
|
translation: Translation::new(1.5, 1.5, 1.5),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -18,7 +18,9 @@ fn setup(
|
|||||||
// mesh
|
// mesh
|
||||||
.spawn(PbrComponents {
|
.spawn(PbrComponents {
|
||||||
// load the mesh
|
// load the mesh
|
||||||
mesh: asset_server.load("assets/models/monkey/Monkey.gltf").unwrap(),
|
mesh: asset_server
|
||||||
|
.load("assets/models/monkey/Monkey.gltf")
|
||||||
|
.unwrap(),
|
||||||
// create a material for the mesh
|
// create a material for the mesh
|
||||||
material: materials.add(Color::rgb(0.5, 0.4, 0.3).into()),
|
material: materials.add(Color::rgb(0.5, 0.4, 0.3).into()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
unstable_features = true
|
||||||
merge_imports = true
|
merge_imports = true
|
||||||
use_field_init_shorthand = true
|
use_field_init_shorthand = true
|
||||||
reorder_impl_items = true
|
reorder_impl_items = true
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
pub use crate::{
|
pub use crate::{
|
||||||
app::prelude::*, asset::prelude::*, core::prelude::*, ecs::prelude::*,
|
app::prelude::*, asset::prelude::*, core::prelude::*, ecs::prelude::*, input::prelude::*,
|
||||||
input::prelude::*, math::prelude::*, pbr::prelude::*, property::prelude::*, render::prelude::*,
|
math::prelude::*, pbr::prelude::*, property::prelude::*, render::prelude::*, scene::prelude::*,
|
||||||
scene::prelude::*, sprite::prelude::*, text::prelude::*, transform::prelude::*,
|
sprite::prelude::*, text::prelude::*, transform::prelude::*, type_registry::RegisterType,
|
||||||
type_registry::RegisterType, ui::prelude::*, window::prelude::*, AddDefaultPlugins,
|
ui::prelude::*, window::prelude::*, AddDefaultPlugins,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "bevy_audio")]
|
#[cfg(feature = "bevy_audio")]
|
||||||
|
Loading…
Reference in New Issue
Block a user