Skip to content

Commit

Permalink
update to bevy 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-an committed Nov 30, 2024
1 parent 933f2cd commit e4ff3a9
Show file tree
Hide file tree
Showing 13 changed files with 288 additions and 243 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ jobs:
cache-android-cargo-${{ hashFiles('**/Cargo.toml') }}
cache-android-cargo
- run: |
CC=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang \
AR=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar \
CC=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang \
CXX=$ANDROID_NDK_LATEST_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang++ \
cargo clippy --target=aarch64-linux-android --no-default-features --all-targets --features=${{ matrix.features }} -- -D warnings
clippy_ios:
Expand Down
89 changes: 46 additions & 43 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ manage_clipboard = ["arboard", "thread_local"]
open_url = ["webbrowser"]
default_fonts = ["egui/default_fonts"]
render = [
"bevy_render",
"bevy_asset",
"encase",
"bytemuck",
"egui/bytemuck",
"wgpu-types",
"bevy_image",
"bevy_render",
"bevy_asset",
"encase",
"bytemuck",
"egui/bytemuck",
"wgpu-types",
]
serde = ["egui/serde"]
# The enabled logs will print with the info log level, to make it less cumbersome to debug in browsers.
Expand Down Expand Up @@ -59,28 +60,28 @@ required-features = ["render"]

[dependencies]
egui = { version = "0.29", default-features = false }

bevy_app = "0.14"
bevy_derive = "0.14"
bevy_ecs = "0.14"
bevy_input = "0.14"
bevy_log = "0.14"
bevy_math = "0.14"
bevy_reflect = "0.14"
bevy_time = "0.14"
bevy_utils = "0.14"
bevy_winit = "0.14"
bevy_window = "0.14"
bevy_app = "0.15.0"
bevy_derive = "0.15.0"
bevy_ecs = "0.15.0"
bevy_input = "0.15.0"
bevy_log = "0.15.0"
bevy_math = "0.15.0"
bevy_reflect = "0.15.0"
bevy_time = "0.15.0"
bevy_utils = "0.15.0"
bevy_winit = { version = "0.15.0", features = ["custom_cursor"] }
bevy_window = "0.15.0"

# `open_url` feature
webbrowser = { version = "1.0.1", optional = true }

# `render` feature
bytemuck = { version = "1", optional = true }
bevy_asset = { version = "0.14", optional = true }
bevy_render = { version = "0.14", optional = true }
encase = { version = "0.8", optional = true }
wgpu-types = { version = "0.20", optional = true }
bevy_asset = { version = "0.15.0", optional = true }
bevy_image = { version = "0.15.0", optional = true }
bevy_render = { version = "0.15.0", optional = true }
encase = { version = "0.10", optional = true }
wgpu-types = { version = "23.0", optional = true }

# `manage_clipboard` feature
[target.'cfg(not(any(target_arch = "wasm32", target_os = "android")))'.dependencies]
Expand All @@ -89,33 +90,35 @@ thread_local = { version = "1.1.0", optional = true }

[dev-dependencies]
version-sync = "0.9.4"
bevy = { version = "0.14.0", default-features = false, features = [
"x11",
"png",
"bevy_pbr",
"bevy_core_pipeline",
"bevy_asset",
"bevy_winit",
"tonemapping_luts",
"webgl2",
bevy = { version = "0.15.0", default-features = false, features = [
"x11",
"png",
"bevy_pbr",
"bevy_core_pipeline",
"bevy_asset",
"bevy_winit",
"bevy_window",
"tonemapping_luts",
"webgl2",
"android-game-activity",
] }
egui = { version = "0.29", default-features = false, features = ["bytemuck"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
winit = "0.30"
web-sys = { version = "0.3.63", features = [
"Clipboard",
"ClipboardEvent",
"CompositionEvent",
"DataTransfer",
"Document",
"EventTarget",
"HtmlInputElement",
"InputEvent",
"KeyboardEvent",
"Navigator",
"TouchEvent",
"Window",
"Clipboard",
"ClipboardEvent",
"CompositionEvent",
"DataTransfer",
"Document",
"EventTarget",
"HtmlInputElement",
"InputEvent",
"KeyboardEvent",
"Navigator",
"TouchEvent",
"Window",
] }
js-sys = "0.3.63"
wasm-bindgen = "0.2.84"
Expand Down
30 changes: 16 additions & 14 deletions examples/paint_callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use bevy::{
MultisampleState, PipelineCache, PolygonMode, PrimitiveState, RenderPipelineDescriptor,
SpecializedRenderPipeline, SpecializedRenderPipelines,
},
sync_world::RenderEntity,
RenderApp,
},
};
Expand Down Expand Up @@ -52,7 +53,7 @@ impl EguiBevyPaintCallbackImpl for CustomPaintCallback {
fn update(
&self,
_info: egui::PaintCallbackInfo,
window_entity: Entity,
window_entity: RenderEntity,
key: EguiPipelineKey,
world: &mut World,
) {
Expand All @@ -72,7 +73,7 @@ impl EguiBevyPaintCallbackImpl for CustomPaintCallback {
);

world
.entity_mut(window_entity)
.entity_mut(window_entity.id())
.insert(CustomPaintPipelineIdComp { pipeline_id });
pipeline_id
},
Expand All @@ -86,12 +87,13 @@ impl EguiBevyPaintCallbackImpl for CustomPaintCallback {
&self,
_info: egui::PaintCallbackInfo,
render_pass: &mut bevy::render::render_phase::TrackedRenderPass<'pass>,
window_entity: Entity,
window_entity: RenderEntity,
_key: EguiPipelineKey,
world: &'pass World,
) {
let Some(pipeline) = world
.get_entity(window_entity)
.get_entity(window_entity.id())
.ok()
.and_then(|entity| entity.get::<CustomPaintPipelineIdComp>())
.and_then(|comp| {
world
Expand Down Expand Up @@ -128,6 +130,7 @@ impl SpecializedRenderPipeline for CustomPipeline {

fn specialize(&self, key: Self::Key) -> RenderPipelineDescriptor {
RenderPipelineDescriptor {
zero_initialize_workgroup_memory: true,
label: Some("custom pipeline".into()),
layout: vec![],
push_constant_ranges: Vec::new(),
Expand Down Expand Up @@ -202,23 +205,22 @@ fn setup_worldspace(
output_texture
});

commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0).mesh()),
material: materials.add(StandardMaterial {
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0).mesh())),
MeshMaterial3d(materials.add(StandardMaterial {
base_color: Color::WHITE,
base_color_texture: Some(Handle::clone(&output_texture)),
alpha_mode: AlphaMode::Blend,
// Remove this if you want it to use the world's lighting.
unlit: true,
..default()
}),
..default()
});
})),
));
commands.spawn(EguiRenderToTextureHandle(output_texture));
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(1.5, 1.5, 1.5).looking_at(Vec3::new(0., 0., 0.), Vec3::Y),
..default()
});
commands.spawn((
Camera3d::default(),
Transform::from_xyz(1.5, 1.5, 1.5).looking_at(Vec3::new(0., 0., 0.), Vec3::Y),
));
}

fn ui_render_to_texture_example_system(
Expand Down
19 changes: 9 additions & 10 deletions examples/render_egui_to_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,20 @@ fn setup_worldspace(
output_texture
});

commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0).mesh()),
material: materials.add(StandardMaterial {
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0).mesh())),
MeshMaterial3d(materials.add(StandardMaterial {
base_color: Color::WHITE,
base_color_texture: Some(Handle::clone(&output_texture)),
alpha_mode: AlphaMode::Blend,
// Remove this if you want it to use the world's lighting.
unlit: true,
..default()
}),
..default()
});
})),
));
commands.spawn(EguiRenderToTextureHandle(output_texture));
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(1.5, 1.5, 1.5).looking_at(Vec3::new(0., 0., 0.), Vec3::Y),
..default()
});
commands.spawn((
Camera3d::default(),
Transform::from_xyz(1.5, 1.5, 1.5).looking_at(Vec3::new(0., 0., 0.), Vec3::Y),
));
}
57 changes: 27 additions & 30 deletions examples/render_to_image_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,37 +82,36 @@ fn setup(

// The cube that will be rendered to the texture.
commands
.spawn(PbrBundle {
mesh: cube_handle,
material: preview_material_handle,
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 1.0)),
..default()
})
.spawn((
Mesh3d(cube_handle),
MeshMaterial3d(preview_material_handle),
Transform::from_translation(Vec3::new(0.0, 0.0, 1.0)),
))
.insert(PreviewPassCube)
.insert(preview_pass_layer.clone());

// The same light is reused for both passes,
// you can specify different lights for preview and main pass by setting appropriate RenderLayers.
commands
.spawn(PointLightBundle {
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 10.0)),
..default()
})
.spawn((
PointLight::default(),
Transform::from_translation(Vec3::new(0.0, 0.0, 10.0)),
))
.insert(RenderLayers::default().with(1));

commands
.spawn(Camera3dBundle {
camera: Camera {
.spawn((
Camera3d::default(),
Camera {
// render before the "main pass" camera
order: -1,
target: RenderTarget::Image(image_handle),
clear_color: ClearColorConfig::Custom(Color::srgba(1.0, 1.0, 1.0, 0.0)),
..default()
},
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 15.0))
Transform::from_translation(Vec3::new(0.0, 0.0, 15.0))
.looking_at(Vec3::default(), Vec3::Y),
..default()
})
))
.insert(preview_pass_layer);

let cube_size = 4.0;
Expand All @@ -122,30 +121,28 @@ fn setup(

// Main pass cube.
commands
.spawn(PbrBundle {
mesh: cube_handle,
material: main_material_handle,
transform: Transform {
.spawn((
Mesh3d(cube_handle),
MeshMaterial3d(main_material_handle),
Transform {
translation: Vec3::new(0.0, 0.0, 1.5),
rotation: Quat::from_rotation_x(-std::f32::consts::PI / 5.0),
..default()
},
..default()
})
))
.insert(MainPassCube);

// The main pass camera.
commands.spawn(Camera3dBundle {
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 15.0))
.looking_at(Vec3::default(), Vec3::Y),
..default()
});
commands.spawn((
Camera3d::default(),
Transform::from_translation(Vec3::new(0.0, 0.0, 15.0)).looking_at(Vec3::default(), Vec3::Y),
));
}

fn render_to_image_example_system(
cube_preview_image: Res<CubePreviewImage>,
preview_cube_query: Query<&Handle<StandardMaterial>, With<PreviewPassCube>>,
main_cube_query: Query<&Handle<StandardMaterial>, With<MainPassCube>>,
preview_cube_query: Query<&MeshMaterial3d<StandardMaterial>, With<PreviewPassCube>>,
main_cube_query: Query<&MeshMaterial3d<StandardMaterial>, With<MainPassCube>>,
mut materials: ResMut<Assets<StandardMaterial>>,
mut contexts: EguiContexts,
) {
Expand Down Expand Up @@ -225,7 +222,7 @@ fn rotator_system(
mut query: Query<&mut Transform, Or<(With<PreviewPassCube>, With<MainPassCube>)>>,
) {
for mut transform in &mut query {
transform.rotate_x(1.5 * time.delta_seconds());
transform.rotate_z(1.3 * time.delta_seconds());
transform.rotate_x(1.5 * time.delta_secs());
transform.rotate_z(1.3 * time.delta_secs());
}
}
Loading

0 comments on commit e4ff3a9

Please sign in to comment.