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

Port to Bevy 0.13 #29

Merged
merged 13 commits into from
Mar 4, 2024
Merged
11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_mod_outline"
version = "0.6.2"
version = "0.7.0"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "A mesh outlining plugin for Bevy."
Expand All @@ -11,7 +11,7 @@ keywords = ["gamedev", "bevy", "outline"]
categories = ["game-engines", "rendering"]

[dependencies]
bevy = { version = "0.12", default-features = false, features = [
bevy = { version = "0.13", default-features = false, features = [
"bevy_asset",
"bevy_render",
"bevy_pbr",
Expand All @@ -21,13 +21,12 @@ bevy = { version = "0.12", default-features = false, features = [
"bevy_core_pipeline",
] }
bitfield = "0.14"
interpolation = "0.2"
interpolation_03 = { package = "interpolation", version = "0.3", optional = true }
interpolation = "0.3"
thiserror = "1.0"
wgpu-types = "0.17"
wgpu-types = "0.19"

[dev-dependencies]
bevy = { version = "0.12", default-features = false, features = [
bevy = { version = "0.13", default-features = false, features = [
"animation",
"bevy_gltf",
"bevy_pbr",
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ vertex extrusion method.

```toml
[dependencies]
bevy_mod_outline = "0.6"
bevy_mod_outline = "0.7"
```

## Examples
Expand Down Expand Up @@ -66,6 +66,7 @@ cargo run --example morph_targets

| This Version | Bevy version |
|--------------|--------------|
| 0.7.x | 0.13.x |
| 0.6.x | 0.12.x |
| 0.5.x | 0.11.x |
| 0.4.x | 0.10.x |
Expand All @@ -78,9 +79,6 @@ cargo run --example morph_targets
- `bevy_ui` _(default)_ - Adds a render graph edge to prevent clashing with the
UI. This adds a dependency on the `bevy_ui` crate and can be disabled if it is
not used.
- `interpolation_03` - Define `Lerp` trait impls using version 0.3 of the
`interpolation` crate in addition to 0.2. This will become the default in the
next breaking release.

## Licence

Expand Down
23 changes: 9 additions & 14 deletions examples/animated_fox.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
use std::f32::consts::PI;

use bevy::{
prelude::{shape::Plane, *},
scene::SceneInstance,
window::close_on_esc,
};
use bevy::{prelude::*, scene::SceneInstance, window::close_on_esc};
use bevy_mod_outline::{
AutoGenerateOutlineNormalsPlugin, InheritOutlineBundle, OutlineBundle, OutlinePlugin,
OutlineVolume,
Expand All @@ -20,10 +16,7 @@ fn main() {
OutlinePlugin,
AutoGenerateOutlineNormalsPlugin,
))
.insert_resource(AmbientLight {
color: Color::WHITE,
brightness: 1.0,
})
.insert_resource(AmbientLight::default())
.add_systems(Startup, setup)
.add_systems(Update, (setup_scene_once_loaded, close_on_esc))
.run();
Expand All @@ -47,11 +40,13 @@ fn setup(

// Plane
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(Plane {
size: 500000.0,
subdivisions: 0,
})),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
mesh: meshes.add(
Plane3d::new(Vec3::Y)
.mesh()
.size(500000.0, 500000.0)
.build(),
),
material: materials.add(StandardMaterial::from(Color::rgb(0.3, 0.5, 0.3))),
..default()
});

Expand Down
22 changes: 8 additions & 14 deletions examples/flying_objects.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use std::{f32::consts::TAU, num::Wrapping, time::Duration};

use bevy::{
prelude::{shape::Capsule, *},
window::close_on_esc,
};
use bevy::{prelude::*, window::close_on_esc};

use bevy_mod_outline::*;

Expand Down Expand Up @@ -37,17 +34,14 @@ fn setup(
) {
commands.insert_resource(MyAssets {
mesh: meshes.add(
Capsule {
radius: 1.0,
rings: 10,
depth: 2.0,
latitudes: 15,
longitudes: 15,
..default()
}
.into(),
Capsule3d::new(1.0, 2.0)
.mesh()
.rings(10)
.latitudes(15)
.longitudes(15)
.build(),
),
material: materials.add(Color::BEIGE.into()),
material: materials.add(StandardMaterial::from(Color::BEIGE)),
});

// Add light source and camera
Expand Down
5 changes: 1 addition & 4 deletions examples/hollow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ fn main() {
),
)
.add_plugins(OutlinePlugin)
.insert_resource(AmbientLight {
color: Color::WHITE,
brightness: 1.0,
})
.insert_resource(AmbientLight::default())
.add_systems(Startup, setup)
.add_systems(
Update,
Expand Down
5 changes: 1 addition & 4 deletions examples/morph_targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ fn main() {
OutlinePlugin,
AutoGenerateOutlineNormalsPlugin,
))
.insert_resource(AmbientLight {
brightness: 1.0,
..default()
})
.insert_resource(AmbientLight::default())
.add_systems(Startup, setup)
.add_systems(Update, (name_morphs, setup_outlines, setup_animations))
.run();
Expand Down
57 changes: 19 additions & 38 deletions examples/pieces.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
use std::f32::consts::TAU;

use bevy::{
prelude::{
shape::{Capsule, Plane, Torus, UVSphere},
*,
},
window::close_on_esc,
};
use bevy::{prelude::*, window::close_on_esc};

use bevy_mod_outline::*;

Expand All @@ -32,15 +26,8 @@ fn setup(
// Add sphere with child meshes sticking out of it
commands
.spawn(PbrBundle {
mesh: meshes.add(
UVSphere {
radius: 0.75,
sectors: 30,
stacks: 30,
}
.into(),
),
material: materials.add(Color::rgb(0.9, 0.1, 0.1).into()),
mesh: meshes.add(Sphere::new(0.75).mesh().uv(30, 30)),
material: materials.add(StandardMaterial::from(Color::rgb(0.9, 0.1, 0.1))),
transform: Transform::from_translation(Vec3::new(0.0, 1.0, 0.0)),
..default()
})
Expand All @@ -61,17 +48,14 @@ fn setup(
parent
.spawn(PbrBundle {
mesh: meshes.add(
Capsule {
radius: 0.2,
rings: 15,
depth: 1.0,
latitudes: 15,
longitudes: 15,
..Default::default()
}
.into(),
Capsule3d::new(0.2, 1.0)
.mesh()
.rings(15)
.latitudes(15)
.longitudes(15)
.build(),
),
material: materials.add(Color::rgb(0.1, 0.1, 0.9).into()),
material: materials.add(StandardMaterial::from(Color::rgb(0.1, 0.1, 0.9))),
transform: Transform::from_rotation(Quat::from_axis_angle(Vec3::X, TAU / 4.0))
.with_translation(Vec3::new(0.0, 0.0, 0.75)),
..default()
Expand All @@ -81,14 +65,15 @@ fn setup(
.spawn(PbrBundle {
mesh: meshes.add(
Torus {
radius: 0.5,
ring_radius: 0.1,
subdivisions_segments: 30,
subdivisions_sides: 15,
minor_radius: 0.1,
major_radius: 0.5,
}
.into(),
.mesh()
.minor_resolution(15)
.major_resolution(30)
.build(),
),
material: materials.add(Color::rgb(0.1, 0.1, 0.9).into()),
material: materials.add(StandardMaterial::from(Color::rgb(0.1, 0.1, 0.9))),
transform: Transform::from_rotation(Quat::from_axis_angle(Vec3::Z, TAU / 4.0))
.with_translation(Vec3::new(0.0, 0.0, -0.75)),
..default()
Expand All @@ -98,16 +83,12 @@ fn setup(

// Add plane, light source, and camera
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(Plane {
size: 5.0,
subdivisions: 0,
})),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
mesh: meshes.add(Plane3d::new(Vec3::Y).mesh().size(5.0, 5.0).build()),
material: materials.add(StandardMaterial::from(Color::rgb(0.3, 0.5, 0.3))),
..default()
});
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
shadows_enabled: true,
..default()
},
Expand Down
44 changes: 19 additions & 25 deletions examples/render_layers.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use std::f32::consts::PI;

use bevy::{
core_pipeline::clear_color::ClearColorConfig,
prelude::{
shape::{Plane, Torus},
*,
},
prelude::*,
render::{camera::Viewport, view::RenderLayers},
window::{close_on_esc, PrimaryWindow},
};
Expand All @@ -14,7 +10,7 @@ use bevy_mod_outline::{OutlineBundle, OutlinePlugin, OutlineRenderLayers, Outlin
#[bevy_main]
fn main() {
App::new()
.insert_resource(Msaa::Sample4)
.insert_resource(Msaa::Off) // Disabled temporarily due to bevyengine/bevy#11968.
.insert_resource(ClearColor(Color::BLACK))
.add_plugins((DefaultPlugins, OutlinePlugin))
.add_systems(Startup, setup)
Expand All @@ -39,13 +35,17 @@ fn setup(
// Add torus using the regular surface normals for outlining
commands
.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(Torus {
radius: 0.6,
ring_radius: 0.2,
subdivisions_segments: 40,
subdivisions_sides: 20,
})),
material: materials.add(Color::rgb(0.1, 0.1, 0.9).into()),
mesh: meshes.add(
Torus {
minor_radius: 0.2,
major_radius: 0.6,
}
.mesh()
.minor_resolution(20)
.major_resolution(40)
.build(),
),
material: materials.add(StandardMaterial::from(Color::rgb(0.1, 0.1, 0.9))),
transform: Transform::from_rotation(Quat::from_rotation_x(0.5 * PI))
.with_translation(0.8 * Vec3::Y),
..default()
Expand All @@ -63,16 +63,12 @@ fn setup(

// Add plane and light source
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(Plane {
size: 5.0,
subdivisions: 0,
})),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
mesh: meshes.add(Plane3d::new(Vec3::Y).mesh().size(5.0, 5.0).build()),
material: materials.add(StandardMaterial::from(Color::rgb(0.3, 0.5, 0.3))),
..default()
});
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 1500.0,
shadows_enabled: true,
..default()
},
Expand All @@ -95,16 +91,14 @@ fn setup(
.spawn(Camera3dBundle {
camera: Camera {
order: i,
..default()
},
camera_3d: Camera3d {
clear_color: if i > 0 {
ClearColorConfig::None
} else {
ClearColorConfig::Default
},
..default()
},
camera_3d: Camera3d { ..default() },
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
})
Expand All @@ -117,11 +111,11 @@ fn setup(
}

fn set_camera_viewports(
win_query: Query<(&Window, Changed<Window>), With<PrimaryWindow>>,
win_query: Query<Ref<Window>, With<PrimaryWindow>>,
mut query: Query<(&mut Camera, &CameraMode)>,
) {
let (win, win_changed) = win_query.get_single().unwrap();
if win_changed {
let win = win_query.get_single().unwrap();
if win.is_changed() {
// Divide window into quadrants
let size = UVec2::new(win.physical_width() / 2, win.physical_height() / 2);
for (mut camera, mode) in query.iter_mut() {
Expand Down
Loading
Loading