Merge pull request #374 from SludgePhD/update-bevy-wgpu
Update bevy (and thus wgpu)
This commit is contained in:
@@ -38,17 +38,17 @@ bincode = "1"
|
|||||||
Inflector = "0.11"
|
Inflector = "0.11"
|
||||||
md5 = "0.7"
|
md5 = "0.7"
|
||||||
|
|
||||||
bevy_egui = "0.14"
|
bevy_egui = "0.15"
|
||||||
bevy_ecs = "0.7"
|
bevy_ecs = "0.8"
|
||||||
#bevy_prototype_debug_lines = "0.7"
|
#bevy_prototype_debug_lines = "0.7"
|
||||||
|
|
||||||
# Dependencies for native only.
|
# Dependencies for native only.
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render", "x11"]}
|
bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render", "x11"]}
|
||||||
|
|
||||||
# Dependencies for WASM only.
|
# Dependencies for WASM only.
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render"]}
|
bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render"]}
|
||||||
#bevy_webgl2 = "0.5"
|
#bevy_webgl2 = "0.5"
|
||||||
|
|
||||||
[dependencies.rapier]
|
[dependencies.rapier]
|
||||||
|
|||||||
@@ -38,17 +38,17 @@ bincode = "1"
|
|||||||
Inflector = "0.11"
|
Inflector = "0.11"
|
||||||
md5 = "0.7"
|
md5 = "0.7"
|
||||||
|
|
||||||
bevy_egui = "0.14"
|
bevy_egui = "0.15"
|
||||||
bevy_ecs = "0.7"
|
bevy_ecs = "0.8"
|
||||||
#bevy_prototype_debug_lines = "0.7"
|
#bevy_prototype_debug_lines = "0.7"
|
||||||
|
|
||||||
# Dependencies for native only.
|
# Dependencies for native only.
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render", "x11"]}
|
bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render", "x11"]}
|
||||||
|
|
||||||
# Dependencies for WASM only.
|
# Dependencies for WASM only.
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render"]}
|
bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render"]}
|
||||||
#bevy_webgl2 = "0.5"
|
#bevy_webgl2 = "0.5"
|
||||||
|
|
||||||
[dependencies.rapier]
|
[dependencies.rapier]
|
||||||
|
|||||||
@@ -36,17 +36,17 @@ md5 = "0.7"
|
|||||||
Inflector = "0.11"
|
Inflector = "0.11"
|
||||||
serde = { version = "1", features = [ "derive" ] }
|
serde = { version = "1", features = [ "derive" ] }
|
||||||
|
|
||||||
bevy_egui = "0.14"
|
bevy_egui = "0.15"
|
||||||
bevy_ecs = "0.7"
|
bevy_ecs = "0.8"
|
||||||
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }
|
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }
|
||||||
|
|
||||||
# Dependencies for native only.
|
# Dependencies for native only.
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render", "x11"]}
|
bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render", "x11"]}
|
||||||
|
|
||||||
# Dependencies for WASM only.
|
# Dependencies for WASM only.
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render"]}
|
bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render"]}
|
||||||
#bevy_webgl2 = "0.5"
|
#bevy_webgl2 = "0.5"
|
||||||
|
|
||||||
[dependencies.rapier]
|
[dependencies.rapier]
|
||||||
|
|||||||
@@ -40,17 +40,17 @@ md5 = "0.7"
|
|||||||
Inflector = "0.11"
|
Inflector = "0.11"
|
||||||
serde = { version = "1", features = [ "derive" ] }
|
serde = { version = "1", features = [ "derive" ] }
|
||||||
|
|
||||||
bevy_egui = "0.14"
|
bevy_egui = "0.15"
|
||||||
bevy_ecs = "0.7"
|
bevy_ecs = "0.8"
|
||||||
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }
|
#bevy_prototype_debug_lines = { version = "0.7", features = [ "3d" ] }
|
||||||
|
|
||||||
# Dependencies for native only.
|
# Dependencies for native only.
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render", "x11"]}
|
bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render", "x11"]}
|
||||||
|
|
||||||
# Dependencies for WASM only.
|
# Dependencies for WASM only.
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
bevy = {version = "0.7", default-features = false, features = ["bevy_winit", "render"]}
|
bevy = {version = "0.8", default-features = false, features = ["bevy_winit", "render"]}
|
||||||
#bevy_webgl2 = "0.5"
|
#bevy_webgl2 = "0.5"
|
||||||
|
|
||||||
[dependencies.rapier]
|
[dependencies.rapier]
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
#![allow(warnings)]
|
#![allow(warnings)]
|
||||||
|
use bevy::render::mesh::MeshVertexAttribute;
|
||||||
|
use bevy::render::render_resource::VertexFormat;
|
||||||
use bevy::render::view::NoFrustumCulling;
|
use bevy::render::view::NoFrustumCulling;
|
||||||
|
use bevy::render::MainWorld;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* NOTE: this module and its submodules are only temporary. It is a copy-paste of the bevy-debug-lines
|
* NOTE: this module and its submodules are only temporary. It is a copy-paste of the bevy-debug-lines
|
||||||
@@ -35,7 +38,7 @@ mod render_dim;
|
|||||||
#[cfg(feature = "dim3")]
|
#[cfg(feature = "dim3")]
|
||||||
mod dim {
|
mod dim {
|
||||||
pub(crate) use super::render_dim::r3d::{queue, DebugLinePipeline, DrawDebugLines};
|
pub(crate) use super::render_dim::r3d::{queue, DebugLinePipeline, DrawDebugLines};
|
||||||
pub(crate) use bevy::core_pipeline::Opaque3d as Phase;
|
pub(crate) use bevy::core_pipeline::core_3d::Opaque3d as Phase;
|
||||||
use bevy::{asset::Handle, render::mesh::Mesh};
|
use bevy::{asset::Handle, render::mesh::Mesh};
|
||||||
|
|
||||||
pub(crate) type MeshHandle = Handle<Mesh>;
|
pub(crate) type MeshHandle = Handle<Mesh>;
|
||||||
@@ -51,7 +54,7 @@ mod dim {
|
|||||||
#[cfg(feature = "dim2")]
|
#[cfg(feature = "dim2")]
|
||||||
mod dim {
|
mod dim {
|
||||||
pub(crate) use super::render_dim::r2d::{queue, DebugLinePipeline, DrawDebugLines};
|
pub(crate) use super::render_dim::r2d::{queue, DebugLinePipeline, DrawDebugLines};
|
||||||
pub(crate) use bevy::core_pipeline::Transparent2d as Phase;
|
pub(crate) use bevy::core_pipeline::core_2d::Transparent2d as Phase;
|
||||||
use bevy::{asset::Handle, render::mesh::Mesh, sprite::Mesh2dHandle};
|
use bevy::{asset::Handle, render::mesh::Mesh, sprite::Mesh2dHandle};
|
||||||
|
|
||||||
pub(crate) type MeshHandle = Mesh2dHandle;
|
pub(crate) type MeshHandle = Mesh2dHandle;
|
||||||
@@ -153,6 +156,9 @@ pub const MAX_POINTS: usize = MAX_POINTS_PER_MESH * MESH_COUNT;
|
|||||||
/// Maximum number of unique lines to draw at once.
|
/// Maximum number of unique lines to draw at once.
|
||||||
pub const MAX_LINES: usize = MAX_POINTS / 2;
|
pub const MAX_LINES: usize = MAX_POINTS / 2;
|
||||||
|
|
||||||
|
const ATTRIBUTE_COLOR: MeshVertexAttribute =
|
||||||
|
MeshVertexAttribute::new("Vertex_Color", 1, VertexFormat::Uint32);
|
||||||
|
|
||||||
fn setup(mut cmds: Commands, mut meshes: ResMut<Assets<Mesh>>) {
|
fn setup(mut cmds: Commands, mut meshes: ResMut<Assets<Mesh>>) {
|
||||||
// Spawn a bunch of meshes to use for lines.
|
// Spawn a bunch of meshes to use for lines.
|
||||||
for i in 0..MESH_COUNT {
|
for i in 0..MESH_COUNT {
|
||||||
@@ -163,7 +169,7 @@ fn setup(mut cmds: Commands, mut meshes: ResMut<Assets<Mesh>>) {
|
|||||||
VertexAttributeValues::Float32x3(Vec::with_capacity(MAX_POINTS_PER_MESH)),
|
VertexAttributeValues::Float32x3(Vec::with_capacity(MAX_POINTS_PER_MESH)),
|
||||||
);
|
);
|
||||||
mesh.insert_attribute(
|
mesh.insert_attribute(
|
||||||
Mesh::ATTRIBUTE_COLOR,
|
ATTRIBUTE_COLOR,
|
||||||
VertexAttributeValues::Uint32(Vec::with_capacity(MAX_POINTS_PER_MESH)),
|
VertexAttributeValues::Uint32(Vec::with_capacity(MAX_POINTS_PER_MESH)),
|
||||||
);
|
);
|
||||||
// https://github.com/Toqozz/bevy_debug_lines/issues/16
|
// https://github.com/Toqozz/bevy_debug_lines/issues/16
|
||||||
@@ -204,7 +210,7 @@ fn update(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(Uint32(cbuffer)) = mesh.attribute_mut(Mesh::ATTRIBUTE_COLOR) {
|
if let Some(Uint32(cbuffer)) = mesh.attribute_mut(ATTRIBUTE_COLOR) {
|
||||||
cbuffer.clear();
|
cbuffer.clear();
|
||||||
if let Some(new_content) = lines
|
if let Some(new_content) = lines
|
||||||
.colors
|
.colors
|
||||||
@@ -233,7 +239,7 @@ fn update(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Move the DebugLinesMesh marker Component to the render context.
|
/// Move the DebugLinesMesh marker Component to the render context.
|
||||||
fn extract(mut commands: Commands, query: Query<Entity, With<DebugLinesMesh>>) {
|
fn extract(mut commands: Commands, query: Query<Entity, With<DebugLinesMesh>>, _: Res<MainWorld>) {
|
||||||
for entity in query.iter() {
|
for entity in query.iter() {
|
||||||
commands.get_or_spawn(entity).insert(RenderDebugLinesMesh);
|
commands.get_or_spawn(entity).insert(RenderDebugLinesMesh);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
pub mod r3d {
|
pub mod r3d {
|
||||||
use bevy::{
|
use bevy::{
|
||||||
core_pipeline::Opaque3d,
|
core_pipeline::core_3d::Opaque3d,
|
||||||
pbr::{
|
pbr::{
|
||||||
DrawMesh, MeshPipeline, MeshPipelineKey, MeshUniform, SetMeshBindGroup,
|
DrawMesh, MeshPipeline, MeshPipelineKey, MeshUniform, SetMeshBindGroup,
|
||||||
SetMeshViewBindGroup,
|
SetMeshViewBindGroup,
|
||||||
@@ -89,11 +89,11 @@ pub mod r3d {
|
|||||||
shader: self.shader.clone_weak(),
|
shader: self.shader.clone_weak(),
|
||||||
shader_defs,
|
shader_defs,
|
||||||
entry_point: "fragment".into(),
|
entry_point: "fragment".into(),
|
||||||
targets: vec![ColorTargetState {
|
targets: vec![Some(ColorTargetState {
|
||||||
format: TextureFormat::bevy_default(),
|
format: TextureFormat::bevy_default(),
|
||||||
blend,
|
blend,
|
||||||
write_mask: ColorWrites::ALL,
|
write_mask: ColorWrites::ALL,
|
||||||
}],
|
})],
|
||||||
}),
|
}),
|
||||||
layout: Some(vec![self.mesh_pipeline.view_layout.clone()]),
|
layout: Some(vec![self.mesh_pipeline.view_layout.clone()]),
|
||||||
primitive: PrimitiveState {
|
primitive: PrimitiveState {
|
||||||
@@ -182,8 +182,7 @@ pub mod r3d {
|
|||||||
pub mod r2d {
|
pub mod r2d {
|
||||||
use bevy::{
|
use bevy::{
|
||||||
asset::Handle,
|
asset::Handle,
|
||||||
core::FloatOrd,
|
core_pipeline::core_2d::Transparent2d,
|
||||||
core_pipeline::Transparent2d,
|
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::{
|
render::{
|
||||||
mesh::MeshVertexBufferLayout,
|
mesh::MeshVertexBufferLayout,
|
||||||
@@ -204,6 +203,7 @@ pub mod r2d {
|
|||||||
DrawMesh2d, Mesh2dHandle, Mesh2dPipeline, Mesh2dPipelineKey, Mesh2dUniform,
|
DrawMesh2d, Mesh2dHandle, Mesh2dPipeline, Mesh2dPipelineKey, Mesh2dUniform,
|
||||||
SetMesh2dBindGroup, SetMesh2dViewBindGroup,
|
SetMesh2dBindGroup, SetMesh2dViewBindGroup,
|
||||||
},
|
},
|
||||||
|
utils::FloatOrd,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::lines::{RenderDebugLinesMesh, DEBUG_LINES_SHADER_HANDLE};
|
use crate::lines::{RenderDebugLinesMesh, DEBUG_LINES_SHADER_HANDLE};
|
||||||
@@ -256,11 +256,11 @@ pub mod r2d {
|
|||||||
shader: self.shader.clone_weak(),
|
shader: self.shader.clone_weak(),
|
||||||
shader_defs: vec![],
|
shader_defs: vec![],
|
||||||
entry_point: "fragment".into(),
|
entry_point: "fragment".into(),
|
||||||
targets: vec![ColorTargetState {
|
targets: vec![Some(ColorTargetState {
|
||||||
format: TextureFormat::bevy_default(),
|
format: TextureFormat::bevy_default(),
|
||||||
blend: Some(BlendState::ALPHA_BLENDING),
|
blend: Some(BlendState::ALPHA_BLENDING),
|
||||||
write_mask: ColorWrites::ALL,
|
write_mask: ColorWrites::ALL,
|
||||||
}],
|
})],
|
||||||
}),
|
}),
|
||||||
layout: Some(vec![self.mesh_pipeline.view_layout.clone()]),
|
layout: Some(vec![self.mesh_pipeline.view_layout.clone()]),
|
||||||
primitive: PrimitiveState {
|
primitive: PrimitiveState {
|
||||||
|
|||||||
@@ -836,7 +836,7 @@ fn setup_graphics_environment(mut commands: Commands) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
commands
|
commands
|
||||||
.spawn_bundle(PerspectiveCameraBundle {
|
.spawn_bundle(Camera3dBundle {
|
||||||
transform: Transform::from_matrix(
|
transform: Transform::from_matrix(
|
||||||
Mat4::look_at_rh(
|
Mat4::look_at_rh(
|
||||||
Vec3::new(-30.0, 30.0, 100.0),
|
Vec3::new(-30.0, 30.0, 100.0),
|
||||||
@@ -869,13 +869,13 @@ fn setup_graphics_environment(mut commands: Commands) {
|
|||||||
// ..Default::default()
|
// ..Default::default()
|
||||||
// });
|
// });
|
||||||
commands
|
commands
|
||||||
.spawn_bundle(OrthographicCameraBundle {
|
.spawn_bundle(Camera2dBundle {
|
||||||
transform: Transform {
|
transform: Transform {
|
||||||
translation: Vec3::new(0.0, 0.0, 0.0),
|
translation: Vec3::new(0.0, 0.0, 0.0),
|
||||||
rotation: Quat::IDENTITY,
|
rotation: Quat::IDENTITY,
|
||||||
scale: Vec3::new(0.01, 0.01, 1.0),
|
scale: Vec3::new(0.01, 0.01, 1.0),
|
||||||
},
|
},
|
||||||
..OrthographicCameraBundle::new_2d()
|
..Camera2dBundle::default()
|
||||||
})
|
})
|
||||||
.insert(OrbitCamera {
|
.insert(OrbitCamera {
|
||||||
zoom: 100.0,
|
zoom: 100.0,
|
||||||
@@ -1298,7 +1298,7 @@ fn highlight_hovered_body(
|
|||||||
|
|
||||||
if let Some(cursor) = window.cursor_position() {
|
if let Some(cursor) = window.cursor_position() {
|
||||||
let ndc_cursor = (cursor / Vec2::new(window.width(), window.height()) * 2.0) - Vec2::ONE;
|
let ndc_cursor = (cursor / Vec2::new(window.width(), window.height()) * 2.0) - Vec2::ONE;
|
||||||
let ndc_to_world = camera_transform.compute_matrix() * camera.projection_matrix.inverse();
|
let ndc_to_world = camera_transform.compute_matrix() * camera.projection_matrix().inverse();
|
||||||
let ray_pt1 = ndc_to_world.project_point3(Vec3::new(ndc_cursor.x, ndc_cursor.y, -1.0));
|
let ray_pt1 = ndc_to_world.project_point3(Vec3::new(ndc_cursor.x, ndc_cursor.y, -1.0));
|
||||||
let ray_pt2 = ndc_to_world.project_point3(Vec3::new(ndc_cursor.x, ndc_cursor.y, 1.0));
|
let ray_pt2 = ndc_to_world.project_point3(Vec3::new(ndc_cursor.x, ndc_cursor.y, 1.0));
|
||||||
let ray_dir = ray_pt2 - ray_pt1;
|
let ray_dir = ray_pt2 - ray_pt1;
|
||||||
|
|||||||
Reference in New Issue
Block a user