Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bevy 0.15 rc #5

Merged
merged 6 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ name = "render_egui_to_texture"
required-features = ["render"]

[dependencies]
bevy = { version = "0.15.0-dev", default-features = false, features = [
bevy = { version = "0.15.0-rc.2", default-features = false, features = [
"bevy_asset",
"bevy_winit",
] }
Expand All @@ -66,13 +66,14 @@ thread_local = { version = "1.1.0", optional = true }

[dev-dependencies]
version-sync = "0.9.4"
bevy = { version = "0.15.0-dev", default-features = false, features = [
bevy = { version = "0.15.0-rc.2", default-features = false, features = [
"x11",
"png",
"bevy_pbr",
"bevy_core_pipeline",
"tonemapping_luts",
"webgl2",
"custom_cursor",
] }
egui = { version = "0.29", default-features = false, features = ["bytemuck"] }

Expand Down Expand Up @@ -102,4 +103,19 @@ crossbeam-channel = "0.5.8"
members = ["run-wasm"]

[patch.crates-io]
bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "9386bd0114c44c9f00a2e9c41db1225aaa78d15" }
# doesnt work:
# bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "a2b53d46e73b98f7f5d074ed2bb8ddfedfcc5d4d" }
# doesnt work:
#bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "cab00766d99c2bf0519464a60e8a91e05c83d0fd" }
# doesnt work:
# bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "1df8238e8d8fe968d682468301ad4140c95b7604" }
# doesnt work, breakage appears here!
# bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "56f8e526dde49b4e4ad62efb7ad27bfe0bd6f617" }
# works:
# bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "01dce4742f77a572a1ef21ce8f64ce3b6d2328a8" }
# works:
# bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "7ee5143d45f9246f9cffc52e916ae12d85a71779" }
# works:
# bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "3139b03e7400313d947dc912e12d7c2d98207653" }
# works:
#bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "9386bd0114c44c9f00a2e9c41db1225aaa78d15" }
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,19 +87,21 @@ 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
.get_resource::<PipelineCache>()
.and_then(|cache| cache.get_render_pipeline(comp.pipeline_id))
})
else {
warn!("Could not find pipeline.");
return;
};

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());
}
}
34 changes: 14 additions & 20 deletions examples/side_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,36 +88,30 @@ fn setup_system(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands.spawn(PbrBundle {
mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)),
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
..Default::default()
});
commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::srgb(0.8, 0.7, 0.6)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..Default::default()
});
commands.spawn(PointLightBundle {
point_light: PointLight {
commands.spawn((
Mesh3d(meshes.add(Plane3d::default().mesh().size(5.0, 5.0))),
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
));
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(Color::srgb(0.8, 0.7, 0.6))),
Transform::from_xyz(0.0, 0.5, 0.0),
));
commands.spawn((
PointLight {
intensity: 1500.0,
shadows_enabled: true,
..Default::default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..Default::default()
});
Transform::from_xyz(4.0, 8.0, 4.0),
));

let camera_pos = Vec3::new(-2.0, 2.5, 5.0);
let camera_transform =
Transform::from_translation(camera_pos).looking_at(CAMERA_TARGET, Vec3::Y);
commands.insert_resource(OriginalCameraTransform(camera_transform));

commands.spawn(Camera3dBundle {
transform: camera_transform,
..Default::default()
});
commands.spawn((Camera3d::default(), camera_transform));
}

fn update_camera_transform_system(
Expand Down
12 changes: 7 additions & 5 deletions examples/two_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ fn create_new_window_system(mut commands: Commands) {
.id();

// second window camera
commands.spawn(Camera3dBundle {
camera: Camera {
commands.spawn((
Camera3d::default(),
Camera {
target: RenderTarget::Window(WindowRef::Entity(second_window_id)),
..Default::default()
},
transform: Transform::from_xyz(6.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
..Default::default()
});
Transform::from_xyz(6.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}

fn load_assets_system(mut commands: Commands, assets: Res<AssetServer>) {
Expand Down Expand Up @@ -70,6 +70,7 @@ fn ui_first_window_system(
) {
let bevy_texture_id = egui_user_textures.add_image(images.bevy_icon.clone_weak());
let Ok(mut ctx) = egui_ctx.get_single_mut() else {
warn!("Could not find ctx.");
return;
};
egui::Window::new("First Window")
Expand Down Expand Up @@ -100,6 +101,7 @@ fn ui_second_window_system(
) {
let bevy_texture_id = egui_user_textures.add_image(images.bevy_icon.clone_weak());
let Ok(mut ctx) = egui_ctx.get_single_mut() else {
warn!("Could not find ctx(2).");
return;
};
egui::Window::new("Second Window")
Expand Down
Loading