mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
enforce cargo fmt --check
This commit is contained in:
parent
ece54e963e
commit
d138647818
42 changed files with 115 additions and 82 deletions
12
.github/workflows/rust.yml
vendored
12
.github/workflows/rust.yml
vendored
|
@ -17,14 +17,26 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
components: rustfmt
|
||||
|
||||
- name: Install alsa
|
||||
run: sudo apt-get install libasound2-dev
|
||||
|
||||
- name: Build
|
||||
run: cargo check
|
||||
|
||||
- name: Check the format
|
||||
run: cargo +nightly fmt --all -- --check
|
||||
|
||||
- name: Run tests
|
||||
run: cargo test --workspace
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ fn map_instance_event<T>(event_instance: &EventInstance<T>) -> &T {
|
|||
&event_instance.event
|
||||
}
|
||||
|
||||
/// Reads events of type `T` in order and tracks which events have already been read.
|
||||
/// Reads events of type `T` in order and tracks which events have already been read.
|
||||
pub struct EventReader<T> {
|
||||
last_event_count: usize,
|
||||
_marker: PhantomData<T>,
|
||||
|
|
|
@ -24,7 +24,7 @@ impl HandleId {
|
|||
|
||||
/// A handle into a specific Asset of type `T`
|
||||
///
|
||||
/// Handles contain a unique id that corresponds to a specific asset in the [Assets](crate::Assets) collection.
|
||||
/// Handles contain a unique id that corresponds to a specific asset in the [Assets](crate::Assets) collection.
|
||||
#[derive(Properties)]
|
||||
pub struct Handle<T>
|
||||
where
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#[cfg(feature = "filesystem_watcher")]
|
||||
mod filesystem_watcher;
|
||||
mod asset_server;
|
||||
mod assets;
|
||||
#[cfg(feature = "filesystem_watcher")]
|
||||
mod filesystem_watcher;
|
||||
mod handle;
|
||||
mod load_request;
|
||||
mod loader;
|
||||
|
|
|
@ -53,7 +53,7 @@ impl<T> AssetChannel<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Reads [AssetResult]s from an [AssetChannel] and updates the [Assets] collection and [LoadState] accordingly
|
||||
/// Reads [AssetResult]s from an [AssetChannel] and updates the [Assets] collection and [LoadState] accordingly
|
||||
pub fn update_asset_storage_system<T: Resource>(
|
||||
asset_channel: Res<AssetChannel<T>>,
|
||||
asset_server: Res<AssetServer>,
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::{
|
|||
|
||||
/// A wrapper type that enables ordering floats. This is a work around for the famous "rust float ordering" problem.
|
||||
/// By using it, you acknowledge that sorting NaN is undefined according to spec. This implementation treats NaN as the
|
||||
/// "smallest" float.
|
||||
/// "smallest" float.
|
||||
#[derive(Debug, Copy, Clone, PartialOrd)]
|
||||
pub struct FloatOrd(pub f32);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ use bevy_core::{Time, Timer};
|
|||
use bevy_ecs::{IntoQuerySystem, Res, ResMut};
|
||||
use std::time::Duration;
|
||||
|
||||
/// An App Plugin that prints diagnostics to the console
|
||||
/// An App Plugin that prints diagnostics to the console
|
||||
pub struct PrintDiagnosticsPlugin {
|
||||
pub debug: bool,
|
||||
pub wait_duration: Duration,
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
//! also be useful for serialization, or other row-oriented generic operations.
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,12 @@ use crate::{
|
|||
system::{SystemId, TypeAccess},
|
||||
Resource, ResourceIndex,
|
||||
};
|
||||
use bevy_hecs::smaller_tuples_too;
|
||||
use core::{
|
||||
any::TypeId,
|
||||
ops::{Deref, DerefMut},
|
||||
ptr::NonNull,
|
||||
};
|
||||
use bevy_hecs::smaller_tuples_too;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
/// Shared borrow of a Resource
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::{FetchResource, ResourceQuery};
|
||||
use crate::system::SystemId;
|
||||
use core::any::TypeId;
|
||||
use bevy_hecs::{Archetype, Ref, RefMut, TypeInfo};
|
||||
use core::any::TypeId;
|
||||
use std::{collections::HashMap, ptr::NonNull};
|
||||
|
||||
/// A Resource type
|
||||
|
@ -19,7 +19,7 @@ pub enum ResourceIndex {
|
|||
System(SystemId),
|
||||
}
|
||||
|
||||
/// A collection of resource instances identified by their type.
|
||||
/// A collection of resource instances identified by their type.
|
||||
#[derive(Default)]
|
||||
pub struct Resources {
|
||||
pub(crate) resource_data: HashMap<TypeId, ResourceData>,
|
||||
|
|
|
@ -3,9 +3,9 @@ use crate::{
|
|||
resource::Resources,
|
||||
system::{ArchetypeAccess, System, ThreadLocalExecution, TypeAccess},
|
||||
};
|
||||
use bevy_hecs::{ArchetypesGeneration, World};
|
||||
use crossbeam_channel::{Receiver, Sender};
|
||||
use fixedbitset::FixedBitSet;
|
||||
use bevy_hecs::{ArchetypesGeneration, World};
|
||||
use rayon::ScopeFifo;
|
||||
use std::{
|
||||
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.
|
||||
// Dev internal note: We cannot directly expose a ThreadPoolBuilder here as it does not implement Send and Sync.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
|
@ -360,19 +359,22 @@ impl ExecutorStage {
|
|||
self.running_systems.clear();
|
||||
|
||||
let mut run_ready_result = RunReadyResult::Ok;
|
||||
let run_ready_system_index_range = if let Some(index) = self
|
||||
.thread_local_system_indices
|
||||
.get(0)
|
||||
{
|
||||
// if there is an upcoming thread local system, run up to (and including) it
|
||||
0..(*index + 1)
|
||||
} else {
|
||||
// if there are no upcoming thread local systems, run everything right now
|
||||
0..systems.len()
|
||||
};
|
||||
let run_ready_system_index_range =
|
||||
if let Some(index) = self.thread_local_system_indices.get(0) {
|
||||
// if there is an upcoming thread local system, run up to (and including) it
|
||||
0..(*index + 1)
|
||||
} else {
|
||||
// if there are no upcoming thread local systems, run everything right now
|
||||
0..systems.len()
|
||||
};
|
||||
rayon::scope_fifo(|scope| {
|
||||
run_ready_result =
|
||||
self.run_ready_systems(systems, RunReadyType::Range(run_ready_system_index_range), scope, world, resources);
|
||||
run_ready_result = self.run_ready_systems(
|
||||
systems,
|
||||
RunReadyType::Range(run_ready_system_index_range),
|
||||
scope,
|
||||
world,
|
||||
resources,
|
||||
);
|
||||
});
|
||||
loop {
|
||||
// if all systems in the stage are finished, break out of the loop
|
||||
|
@ -442,8 +444,8 @@ mod tests {
|
|||
system::{IntoQuerySystem, IntoThreadLocalSystem, Query},
|
||||
Commands,
|
||||
};
|
||||
use fixedbitset::FixedBitSet;
|
||||
use bevy_hecs::{Entity, World};
|
||||
use fixedbitset::FixedBitSet;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
|
@ -2,12 +2,12 @@ mod commands;
|
|||
mod into_system;
|
||||
#[cfg(feature = "profiler")]
|
||||
mod profiler;
|
||||
mod system;
|
||||
mod query;
|
||||
mod system;
|
||||
|
||||
pub use commands::*;
|
||||
pub use into_system::*;
|
||||
#[cfg(feature = "profiler")]
|
||||
pub use profiler::*;
|
||||
pub use system::*;
|
||||
pub use query::*;
|
||||
pub use system::*;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::resource::Resources;
|
||||
use fixedbitset::FixedBitSet;
|
||||
use bevy_hecs::{Access, Query, World};
|
||||
use fixedbitset::FixedBitSet;
|
||||
use std::{any::TypeId, borrow::Cow, collections::HashSet};
|
||||
|
||||
/// Determines the strategy used to run the `run_thread_local` function in a [System]
|
||||
|
@ -19,7 +19,7 @@ impl SystemId {
|
|||
}
|
||||
}
|
||||
|
||||
/// An ECS system that can be added to a [Schedule](crate::Schedule)
|
||||
/// An ECS system that can be added to a [Schedule](crate::Schedule)
|
||||
pub trait System: Send + Sync {
|
||||
fn name(&self) -> Cow<'static, str>;
|
||||
fn id(&self) -> SystemId;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::Input;
|
||||
use bevy_app::prelude::*;
|
||||
use bevy_ecs::{Res, ResMut, Local};
|
||||
use bevy_ecs::{Local, Res, ResMut};
|
||||
|
||||
/// A key input event from a keyboard device
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
|
@ -11,9 +11,7 @@ pub mod prelude {
|
|||
|
||||
use bevy_app::prelude::*;
|
||||
use keyboard::{keyboard_input_system, KeyCode, KeyboardInput};
|
||||
use mouse::{
|
||||
mouse_button_input_system, MouseButton, MouseButtonInput, MouseMotion,
|
||||
};
|
||||
use mouse::{mouse_button_input_system, MouseButton, MouseButtonInput, MouseMotion};
|
||||
|
||||
use bevy_ecs::IntoQuerySystem;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::keyboard::ElementState;
|
||||
use crate::Input;
|
||||
use bevy_app::prelude::{EventReader, Events};
|
||||
use bevy_ecs::{Res, ResMut, Local};
|
||||
use bevy_ecs::{Local, Res, ResMut};
|
||||
use bevy_math::Vec2;
|
||||
|
||||
/// A mouse button input event
|
||||
|
|
|
@ -16,6 +16,7 @@ pub mod uniform {
|
|||
pub const LIGHTS: &str = "Lights";
|
||||
}
|
||||
|
||||
use crate::prelude::StandardMaterial;
|
||||
use bevy_asset::Assets;
|
||||
use bevy_ecs::Resources;
|
||||
use bevy_render::{
|
||||
|
@ -24,7 +25,6 @@ use bevy_render::{
|
|||
shader::Shader,
|
||||
};
|
||||
use bevy_transform::prelude::Transform;
|
||||
use crate::prelude::StandardMaterial;
|
||||
|
||||
pub(crate) fn add_pbr_graph(graph: &mut RenderGraph, resources: &Resources) {
|
||||
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
|
||||
graph.add_node_edge(node::STANDARD_MATERIAL, base::node::MAIN_PASS)
|
||||
graph
|
||||
.add_node_edge(node::STANDARD_MATERIAL, base::node::MAIN_PASS)
|
||||
.unwrap();
|
||||
graph.add_node_edge(node::TRANSFORM, base::node::MAIN_PASS)
|
||||
graph
|
||||
.add_node_edge(node::TRANSFORM, base::node::MAIN_PASS)
|
||||
.unwrap();
|
||||
graph.add_node_edge(node::LIGHTS, base::node::MAIN_PASS)
|
||||
graph
|
||||
.add_node_edge(node::LIGHTS, base::node::MAIN_PASS)
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ where
|
|||
if let Some(properties) = value.as_properties() {
|
||||
let len = properties.prop_len();
|
||||
self.resize_with(len, || T::default());
|
||||
|
||||
|
||||
if properties.property_type() != self.property_type() {
|
||||
panic!(
|
||||
"Properties type mismatch. This type is {:?} but the applied type is {:?}",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::DepthCalculation;
|
||||
use bevy_math::Mat4;
|
||||
use bevy_property::{Properties, Property};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use super::DepthCalculation;
|
||||
|
||||
pub trait CameraProjection {
|
||||
fn get_projection_matrix(&self) -> Mat4;
|
||||
|
|
|
@ -2,8 +2,8 @@ use super::{Camera, DepthCalculation};
|
|||
use crate::Draw;
|
||||
use bevy_core::FloatOrd;
|
||||
use bevy_ecs::{Entity, Query};
|
||||
use bevy_transform::prelude::Transform;
|
||||
use bevy_property::Properties;
|
||||
use bevy_transform::prelude::Transform;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct VisibleEntity {
|
||||
|
|
|
@ -421,9 +421,7 @@ pub mod shape {
|
|||
|
||||
let points = raw_points
|
||||
.iter()
|
||||
.map(|&p| {
|
||||
(p * sphere.radius).into()
|
||||
})
|
||||
.map(|&p| (p * sphere.radius).into())
|
||||
.collect::<Vec<[f32; 3]>>();
|
||||
|
||||
let normals = raw_points
|
||||
|
@ -447,7 +445,7 @@ pub mod shape {
|
|||
VertexAttribute::normal(normals),
|
||||
VertexAttribute::uv(uvs),
|
||||
],
|
||||
indices: Some(indices)
|
||||
indices: Some(indices),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ use crate::{
|
|||
shader::{Shader, ShaderSource},
|
||||
};
|
||||
use bevy_asset::{Assets, Handle};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
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)]
|
||||
pub struct PipelineSpecialization {
|
||||
pub shader_specialization: ShaderSpecialization,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::texture::TextureFormat;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use bevy_property::Property;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct DepthStencilStateDescriptor {
|
||||
|
|
|
@ -3,8 +3,8 @@ use crate::{
|
|||
draw::{Draw, RenderCommand},
|
||||
pass::{ClearColor, LoadOp, PassDescriptor, TextureAttachment},
|
||||
pipeline::{
|
||||
BindGroupDescriptor, BindType, BindingDescriptor, PipelineDescriptor, UniformProperty,
|
||||
BindingShaderStage,
|
||||
BindGroupDescriptor, BindType, BindingDescriptor, BindingShaderStage, PipelineDescriptor,
|
||||
UniformProperty,
|
||||
},
|
||||
render_graph::{Node, ResourceSlotInfo, ResourceSlots},
|
||||
renderer::{
|
||||
|
@ -12,7 +12,7 @@ use crate::{
|
|||
},
|
||||
};
|
||||
use bevy_asset::{Assets, Handle};
|
||||
use bevy_ecs::{Resources, World, HecsQuery};
|
||||
use bevy_ecs::{HecsQuery, Resources, World};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
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());
|
||||
}
|
||||
if let Some(input_index) = self.color_resolve_target_indices[i] {
|
||||
color_attachment.resolve_target =
|
||||
Some(TextureAttachment::Id(input.get(input_index).unwrap().get_texture().unwrap()));
|
||||
color_attachment.resolve_target = Some(TextureAttachment::Id(
|
||||
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() {
|
||||
if !draw.is_visible {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
if let Some(asset_bindings) = asset_render_resource_bindings.get(*asset_handle) {
|
||||
render_pipelines.bindings.extend(asset_bindings);
|
||||
|
|
|
@ -261,7 +261,7 @@ impl Default for RenderResourceBindingsId {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::pipeline::{BindType, BindingDescriptor, UniformProperty, BindingShaderStage};
|
||||
use crate::pipeline::{BindType, BindingDescriptor, BindingShaderStage, UniformProperty};
|
||||
|
||||
#[test]
|
||||
fn test_bind_groups() {
|
||||
|
|
|
@ -56,7 +56,7 @@ impl ShaderSource {
|
|||
}
|
||||
}
|
||||
|
||||
/// A shader, as defined by its [ShaderSource] and [ShaderStage]
|
||||
/// A shader, as defined by its [ShaderSource] and [ShaderStage]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Shader {
|
||||
pub source: ShaderSource,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
pipeline::{
|
||||
BindGroupDescriptor, BindType, BindingDescriptor, InputStepMode, UniformProperty,
|
||||
VertexAttributeDescriptor, VertexBufferDescriptor, VertexFormat, BindingShaderStage,
|
||||
BindGroupDescriptor, BindType, BindingDescriptor, BindingShaderStage, InputStepMode,
|
||||
UniformProperty, VertexAttributeDescriptor, VertexBufferDescriptor, VertexFormat,
|
||||
},
|
||||
texture::{TextureComponentType, TextureViewDimension},
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@ use bevy_asset::AssetLoader;
|
|||
use bevy_math::Vec2;
|
||||
use std::path::Path;
|
||||
|
||||
/// Loads HDR textures as Texture assets
|
||||
/// Loads HDR textures as Texture assets
|
||||
#[derive(Clone, Default)]
|
||||
pub struct HdrTextureLoader;
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
use serde::{ser, Deserialize, Serialize};
|
||||
use std::io;
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
use crate::extensions::Extensions;
|
||||
use crate::{
|
||||
error::{Error, Result},
|
||||
extensions::Extensions,
|
||||
};
|
||||
|
||||
mod value;
|
||||
|
||||
|
|
|
@ -44,7 +44,10 @@ impl Scene {
|
|||
}
|
||||
|
||||
// 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))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,7 +113,6 @@ impl SceneSpawner {
|
|||
component_registration.apply_component_to_entity(world, entity, component);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
world.spawn_as_entity(entity, (1,));
|
||||
for component in scene_entity.components.iter() {
|
||||
|
@ -122,7 +121,8 @@ impl SceneSpawner {
|
|||
.ok_or_else(|| SceneSpawnError::UnregisteredComponent {
|
||||
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.spawn_queued_scenes(world, resources).unwrap();
|
||||
scene_spawner
|
||||
|
|
|
@ -7,10 +7,11 @@ use bevy_render::{
|
|||
draw::{Draw, DrawContext, DrawError, Drawable},
|
||||
mesh,
|
||||
pipeline::PipelineSpecialization,
|
||||
prelude::Msaa,
|
||||
renderer::{
|
||||
AssetRenderResourceBindings, BindGroup, BufferUsage, RenderResourceBindings,
|
||||
RenderResourceId,
|
||||
}, prelude::Msaa,
|
||||
},
|
||||
};
|
||||
use bevy_sprite::{TextureAtlas, TextureAtlasSprite};
|
||||
|
||||
|
|
|
@ -4,8 +4,9 @@ use bevy_ecs::{Changed, Query, Res, ResMut};
|
|||
use bevy_math::{Size, Vec3};
|
||||
use bevy_render::{
|
||||
draw::{Draw, DrawContext, Drawable},
|
||||
prelude::Msaa,
|
||||
renderer::{AssetRenderResourceBindings, RenderResourceBindings},
|
||||
texture::Texture, prelude::Msaa,
|
||||
texture::Texture,
|
||||
};
|
||||
use bevy_sprite::TextureAtlas;
|
||||
use bevy_text::{DrawableText, Font, FontAtlasSet, TextStyle};
|
||||
|
@ -59,7 +60,8 @@ pub fn draw_text_system(
|
|||
mut query: Query<(&mut Draw, &Text, &Node, &Transform)>,
|
||||
) {
|
||||
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 {
|
||||
font: fonts.get(&text.font).unwrap(),
|
||||
|
|
|
@ -5,7 +5,9 @@ use crate::{
|
|||
|
||||
use bevy_asset::{Assets, Handle, HandleUntyped};
|
||||
use bevy_render::{
|
||||
pipeline::{BindGroupDescriptor, BindGroupDescriptorId, BindingShaderStage, PipelineDescriptor},
|
||||
pipeline::{
|
||||
BindGroupDescriptor, BindGroupDescriptorId, BindingShaderStage, PipelineDescriptor,
|
||||
},
|
||||
renderer::{
|
||||
BindGroup, BufferId, BufferInfo, RenderResourceBinding, RenderResourceContext,
|
||||
RenderResourceId, SamplerId, TextureId,
|
||||
|
@ -113,7 +115,9 @@ impl WgpuRenderResourceContext {
|
|||
.bindings
|
||||
.iter()
|
||||
.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
|
||||
} else if binding.shader_stage == BindingShaderStage::VERTEX {
|
||||
wgpu::ShaderStage::VERTEX
|
||||
|
|
|
@ -31,7 +31,10 @@ fn setup(
|
|||
})
|
||||
// sphere
|
||||
.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()),
|
||||
translation: Translation::new(1.5, 1.5, 1.5),
|
||||
..Default::default()
|
||||
|
|
|
@ -18,7 +18,9 @@ fn setup(
|
|||
// mesh
|
||||
.spawn(PbrComponents {
|
||||
// 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
|
||||
material: materials.add(Color::rgb(0.5, 0.4, 0.3).into()),
|
||||
..Default::default()
|
||||
|
|
|
@ -68,7 +68,7 @@ fn setup(
|
|||
AssetRenderResourcesNode::<MyMaterial>::new(true),
|
||||
);
|
||||
|
||||
// Add a Render Graph edge connecting our new "my_material" node to the main pass node. This ensures "my_material" runs before the main pass
|
||||
// Add a Render Graph edge connecting our new "my_material" node to the main pass node. This ensures "my_material" runs before the main pass
|
||||
render_graph
|
||||
.add_node_edge("my_material", base::node::MAIN_PASS)
|
||||
.unwrap();
|
||||
|
|
|
@ -80,7 +80,7 @@ fn setup(
|
|||
AssetRenderResourcesNode::<MyMaterial>::new(true),
|
||||
);
|
||||
|
||||
// Add a Render Graph edge connecting our new "my_material" node to the main pass node. This ensures "my_material" runs before the main pass
|
||||
// Add a Render Graph edge connecting our new "my_material" node to the main pass node. This ensures "my_material" runs before the main pass
|
||||
render_graph
|
||||
.add_node_edge("my_material", base::node::MAIN_PASS)
|
||||
.unwrap();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
unstable_features = true
|
||||
merge_imports = true
|
||||
use_field_init_shorthand = true
|
||||
reorder_impl_items = true
|
||||
newline_style = "Unix"
|
||||
newline_style = "Unix"
|
||||
|
|
|
@ -69,4 +69,4 @@ pub use bevy_gltf as gltf;
|
|||
pub use bevy_winit as winit;
|
||||
|
||||
#[cfg(feature = "bevy_wgpu")]
|
||||
pub use bevy_wgpu as wgpu;
|
||||
pub use bevy_wgpu as wgpu;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
pub use crate::{
|
||||
app::prelude::*, asset::prelude::*, core::prelude::*, ecs::prelude::*,
|
||||
input::prelude::*, math::prelude::*, pbr::prelude::*, property::prelude::*, render::prelude::*,
|
||||
scene::prelude::*, sprite::prelude::*, text::prelude::*, transform::prelude::*,
|
||||
type_registry::RegisterType, ui::prelude::*, window::prelude::*, AddDefaultPlugins,
|
||||
app::prelude::*, asset::prelude::*, core::prelude::*, ecs::prelude::*, input::prelude::*,
|
||||
math::prelude::*, pbr::prelude::*, property::prelude::*, render::prelude::*, scene::prelude::*,
|
||||
sprite::prelude::*, text::prelude::*, transform::prelude::*, type_registry::RegisterType,
|
||||
ui::prelude::*, window::prelude::*, AddDefaultPlugins,
|
||||
};
|
||||
|
||||
#[cfg(feature = "bevy_audio")]
|
||||
|
|
Loading…
Reference in a new issue