2023-03-20 20:57:54 +00:00
|
|
|
//! This example demonstrates Bevy's immediate mode drawing API intended for visual debugging.
|
2023-06-13 06:49:47 +00:00
|
|
|
|
2023-03-20 20:57:54 +00:00
|
|
|
use std::f32::consts::PI;
|
|
|
|
|
2024-02-02 21:13:03 +00:00
|
|
|
use bevy::math::primitives::{
|
|
|
|
Capsule3d, Cone, ConicalFrustum, Cuboid, Cylinder, Line3d, Plane3d, Segment3d, Sphere, Torus,
|
|
|
|
};
|
2023-03-20 20:57:54 +00:00
|
|
|
use bevy::prelude::*;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
App::new()
|
2024-02-02 21:13:03 +00:00
|
|
|
.insert_state(PrimitiveState::Nothing)
|
|
|
|
.init_resource::<PrimitiveSegments>()
|
2023-03-20 20:57:54 +00:00
|
|
|
.add_plugins(DefaultPlugins)
|
2024-01-18 15:52:50 +00:00
|
|
|
.init_gizmo_group::<MyRoundGizmos>()
|
2023-03-20 20:57:54 +00:00
|
|
|
.add_systems(Startup, setup)
|
2024-02-02 21:13:03 +00:00
|
|
|
.add_systems(Update, rotate_camera)
|
|
|
|
.add_systems(Update, (draw_example_collection, update_config))
|
|
|
|
.add_systems(Update, (draw_primitives, update_primitives))
|
2023-03-20 20:57:54 +00:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
2024-01-18 15:52:50 +00:00
|
|
|
// We can create our own gizmo config group!
|
|
|
|
#[derive(Default, Reflect, GizmoConfigGroup)]
|
|
|
|
struct MyRoundGizmos {}
|
|
|
|
|
2024-02-02 21:13:03 +00:00
|
|
|
#[derive(Debug, Clone, Resource)]
|
2024-02-03 21:40:55 +00:00
|
|
|
struct PrimitiveSegments(usize);
|
2024-02-02 21:13:03 +00:00
|
|
|
impl Default for PrimitiveSegments {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self(10)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, States)]
|
|
|
|
enum PrimitiveState {
|
|
|
|
Nothing,
|
|
|
|
Sphere,
|
|
|
|
Plane,
|
|
|
|
Line,
|
|
|
|
LineSegment,
|
|
|
|
Cuboid,
|
|
|
|
Cylinder,
|
|
|
|
Capsule,
|
|
|
|
Cone,
|
|
|
|
ConicalFrustum,
|
|
|
|
Torus,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl PrimitiveState {
|
|
|
|
const ALL: [Self; 11] = [
|
|
|
|
Self::Sphere,
|
|
|
|
Self::Plane,
|
|
|
|
Self::Line,
|
|
|
|
Self::LineSegment,
|
|
|
|
Self::Cuboid,
|
|
|
|
Self::Cylinder,
|
|
|
|
Self::Capsule,
|
|
|
|
Self::Cone,
|
|
|
|
Self::ConicalFrustum,
|
|
|
|
Self::Torus,
|
|
|
|
Self::Nothing,
|
|
|
|
];
|
|
|
|
fn next(self) -> Self {
|
|
|
|
Self::ALL
|
|
|
|
.into_iter()
|
|
|
|
.cycle()
|
|
|
|
.skip_while(|&x| x != self)
|
|
|
|
.nth(1)
|
|
|
|
.unwrap()
|
|
|
|
}
|
|
|
|
fn last(self) -> Self {
|
|
|
|
Self::ALL
|
|
|
|
.into_iter()
|
|
|
|
.rev()
|
|
|
|
.cycle()
|
|
|
|
.skip_while(|&x| x != self)
|
|
|
|
.nth(1)
|
|
|
|
.unwrap()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-20 20:57:54 +00:00
|
|
|
fn setup(
|
|
|
|
mut commands: Commands,
|
|
|
|
mut meshes: ResMut<Assets<Mesh>>,
|
|
|
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
|
|
|
) {
|
|
|
|
commands.spawn(Camera3dBundle {
|
|
|
|
transform: Transform::from_xyz(0., 1.5, 6.).looking_at(Vec3::ZERO, Vec3::Y),
|
|
|
|
..default()
|
|
|
|
});
|
|
|
|
// plane
|
|
|
|
commands.spawn(PbrBundle {
|
Use `impl Into<A>` for `Assets::add` (#10878)
# Motivation
When spawning entities into a scene, it is very common to create assets
like meshes and materials and to add them via asset handles. A common
setup might look like this:
```rust
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(StandardMaterial::from(Color::RED)),
..default()
});
}
```
Let's take a closer look at the part that adds the assets using `add`.
```rust
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(StandardMaterial::from(Color::RED)),
```
Here, "mesh" and "material" are both repeated three times. It's very
explicit, but I find it to be a bit verbose. In addition to being more
code to read and write, the extra characters can sometimes also lead to
the code being formatted to span multiple lines even though the core
task, adding e.g. a primitive mesh, is extremely simple.
A way to address this is by using `.into()`:
```rust
mesh: meshes.add(shape::Cube { size: 1.0 }.into()),
material: materials.add(Color::RED.into()),
```
This is fine, but from the names and the type of `meshes`, we already
know what the type should be. It's very clear that `Cube` should be
turned into a `Mesh` because of the context it's used in. `.into()` is
just seven characters, but it's so common that it quickly adds up and
gets annoying.
It would be nice if you could skip all of the conversion and let Bevy
handle it for you:
```rust
mesh: meshes.add(shape::Cube { size: 1.0 }),
material: materials.add(Color::RED),
```
# Objective
Make adding assets more ergonomic by making `Assets::add` take an `impl
Into<A>` instead of `A`.
## Solution
`Assets::add` now takes an `impl Into<A>` instead of `A`, so e.g. this
works:
```rust
commands.spawn(PbrBundle {
mesh: meshes.add(shape::Cube { size: 1.0 }),
material: materials.add(Color::RED),
..default()
});
```
I also changed all examples to use this API, which increases consistency
as well because `Mesh::from` and `into` were being used arbitrarily even
in the same file. This also gets rid of some lines of code because
formatting is nicer.
---
## Changelog
- `Assets::add` now takes an `impl Into<A>` instead of `A`
- Examples don't use `T::from(K)` or `K.into()` when adding assets
## Migration Guide
Some `into` calls that worked previously might now be broken because of
the new trait bounds. You need to either remove `into` or perform the
conversion explicitly with `from`:
```rust
// Doesn't compile
let mesh_handle = meshes.add(shape::Cube { size: 1.0 }.into()),
// These compile
let mesh_handle = meshes.add(shape::Cube { size: 1.0 }),
let mesh_handle = meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
```
## Concerns
I believe the primary concerns might be:
1. Is this too implicit?
2. Does this increase codegen bloat?
Previously, the two APIs were using `into` or `from`, and now it's
"nothing" or `from`. You could argue that `into` is slightly more
explicit than "nothing" in cases like the earlier examples where a
`Color` gets converted to e.g. a `StandardMaterial`, but I personally
don't think `into` adds much value even in this case, and you could
still see the actual type from the asset type.
As for codegen bloat, I doubt it adds that much, but I'm not very
familiar with the details of codegen. I personally value the user-facing
code reduction and ergonomics improvements that these changes would
provide, but it might be worth checking the other effects in more
detail.
Another slight concern is migration pain; apps might have a ton of
`into` calls that would need to be removed, and it did take me a while
to do so for Bevy itself (maybe around 20-40 minutes). However, I think
the fact that there *are* so many `into` calls just highlights that the
API could be made nicer, and I'd gladly migrate my own projects for it.
2024-01-08 22:14:43 +00:00
|
|
|
mesh: meshes.add(shape::Plane::from_size(5.0)),
|
|
|
|
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
|
2023-03-20 20:57:54 +00:00
|
|
|
..default()
|
|
|
|
});
|
|
|
|
// cube
|
|
|
|
commands.spawn(PbrBundle {
|
Use `impl Into<A>` for `Assets::add` (#10878)
# Motivation
When spawning entities into a scene, it is very common to create assets
like meshes and materials and to add them via asset handles. A common
setup might look like this:
```rust
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(StandardMaterial::from(Color::RED)),
..default()
});
}
```
Let's take a closer look at the part that adds the assets using `add`.
```rust
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
material: materials.add(StandardMaterial::from(Color::RED)),
```
Here, "mesh" and "material" are both repeated three times. It's very
explicit, but I find it to be a bit verbose. In addition to being more
code to read and write, the extra characters can sometimes also lead to
the code being formatted to span multiple lines even though the core
task, adding e.g. a primitive mesh, is extremely simple.
A way to address this is by using `.into()`:
```rust
mesh: meshes.add(shape::Cube { size: 1.0 }.into()),
material: materials.add(Color::RED.into()),
```
This is fine, but from the names and the type of `meshes`, we already
know what the type should be. It's very clear that `Cube` should be
turned into a `Mesh` because of the context it's used in. `.into()` is
just seven characters, but it's so common that it quickly adds up and
gets annoying.
It would be nice if you could skip all of the conversion and let Bevy
handle it for you:
```rust
mesh: meshes.add(shape::Cube { size: 1.0 }),
material: materials.add(Color::RED),
```
# Objective
Make adding assets more ergonomic by making `Assets::add` take an `impl
Into<A>` instead of `A`.
## Solution
`Assets::add` now takes an `impl Into<A>` instead of `A`, so e.g. this
works:
```rust
commands.spawn(PbrBundle {
mesh: meshes.add(shape::Cube { size: 1.0 }),
material: materials.add(Color::RED),
..default()
});
```
I also changed all examples to use this API, which increases consistency
as well because `Mesh::from` and `into` were being used arbitrarily even
in the same file. This also gets rid of some lines of code because
formatting is nicer.
---
## Changelog
- `Assets::add` now takes an `impl Into<A>` instead of `A`
- Examples don't use `T::from(K)` or `K.into()` when adding assets
## Migration Guide
Some `into` calls that worked previously might now be broken because of
the new trait bounds. You need to either remove `into` or perform the
conversion explicitly with `from`:
```rust
// Doesn't compile
let mesh_handle = meshes.add(shape::Cube { size: 1.0 }.into()),
// These compile
let mesh_handle = meshes.add(shape::Cube { size: 1.0 }),
let mesh_handle = meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
```
## Concerns
I believe the primary concerns might be:
1. Is this too implicit?
2. Does this increase codegen bloat?
Previously, the two APIs were using `into` or `from`, and now it's
"nothing" or `from`. You could argue that `into` is slightly more
explicit than "nothing" in cases like the earlier examples where a
`Color` gets converted to e.g. a `StandardMaterial`, but I personally
don't think `into` adds much value even in this case, and you could
still see the actual type from the asset type.
As for codegen bloat, I doubt it adds that much, but I'm not very
familiar with the details of codegen. I personally value the user-facing
code reduction and ergonomics improvements that these changes would
provide, but it might be worth checking the other effects in more
detail.
Another slight concern is migration pain; apps might have a ton of
`into` calls that would need to be removed, and it did take me a while
to do so for Bevy itself (maybe around 20-40 minutes). However, I think
the fact that there *are* so many `into` calls just highlights that the
API could be made nicer, and I'd gladly migrate my own projects for it.
2024-01-08 22:14:43 +00:00
|
|
|
mesh: meshes.add(shape::Cube { size: 1.0 }),
|
|
|
|
material: materials.add(Color::rgb(0.8, 0.7, 0.6)),
|
2023-03-20 20:57:54 +00:00
|
|
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
|
|
|
..default()
|
|
|
|
});
|
|
|
|
// light
|
|
|
|
commands.spawn(PointLightBundle {
|
|
|
|
point_light: PointLight {
|
2024-01-16 14:53:21 +00:00
|
|
|
intensity: 250000.0,
|
2023-03-20 20:57:54 +00:00
|
|
|
shadows_enabled: true,
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
transform: Transform::from_xyz(4.0, 8.0, 4.0),
|
|
|
|
..default()
|
|
|
|
});
|
2023-04-26 19:52:31 +00:00
|
|
|
|
|
|
|
// example instructions
|
|
|
|
commands.spawn(
|
|
|
|
TextBundle::from_section(
|
2023-06-13 06:49:47 +00:00
|
|
|
"Press 'D' to toggle drawing gizmos on top of everything else in the scene\n\
|
|
|
|
Press 'P' to toggle perspective for line gizmos\n\
|
2024-01-18 15:52:50 +00:00
|
|
|
Hold 'Left' or 'Right' to change the line width of straight gizmos\n\
|
|
|
|
Hold 'Up' or 'Down' to change the line width of round gizmos\n\
|
|
|
|
Press '1' or '2' to toggle the visibility of straight gizmos or round gizmos\n\
|
2024-02-02 21:13:03 +00:00
|
|
|
Press 'A' to show all AABB boxes\n\
|
|
|
|
Press 'K' or 'J' to cycle through primitives rendered with gizmos\n\
|
|
|
|
Press 'H' or 'L' to decrease/increase the amount of segments in the primitives",
|
2023-04-26 19:52:31 +00:00
|
|
|
TextStyle {
|
|
|
|
font_size: 20.,
|
|
|
|
..default()
|
|
|
|
},
|
|
|
|
)
|
|
|
|
.with_style(Style {
|
|
|
|
position_type: PositionType::Absolute,
|
|
|
|
top: Val::Px(12.0),
|
|
|
|
left: Val::Px(12.0),
|
2023-04-21 22:30:18 +00:00
|
|
|
..default()
|
2023-04-26 19:52:31 +00:00
|
|
|
}),
|
|
|
|
);
|
2023-03-20 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
2024-02-02 21:13:03 +00:00
|
|
|
fn rotate_camera(mut query: Query<&mut Transform, With<Camera>>, time: Res<Time>) {
|
|
|
|
let mut transform = query.single_mut();
|
|
|
|
|
|
|
|
transform.rotate_around(Vec3::ZERO, Quat::from_rotation_y(time.delta_seconds() / 2.));
|
|
|
|
}
|
|
|
|
|
|
|
|
fn draw_example_collection(
|
|
|
|
mut gizmos: Gizmos,
|
|
|
|
mut my_gizmos: Gizmos<MyRoundGizmos>,
|
|
|
|
time: Res<Time>,
|
|
|
|
) {
|
2023-03-20 20:57:54 +00:00
|
|
|
gizmos.cuboid(
|
2024-01-18 15:52:50 +00:00
|
|
|
Transform::from_translation(Vec3::Y * 0.5).with_scale(Vec3::splat(1.25)),
|
2023-03-20 20:57:54 +00:00
|
|
|
Color::BLACK,
|
|
|
|
);
|
|
|
|
gizmos.rect(
|
|
|
|
Vec3::new(time.elapsed_seconds().cos() * 2.5, 1., 0.),
|
|
|
|
Quat::from_rotation_y(PI / 2.),
|
|
|
|
Vec2::splat(2.),
|
|
|
|
Color::GREEN,
|
|
|
|
);
|
|
|
|
|
2024-01-18 15:52:50 +00:00
|
|
|
my_gizmos.sphere(Vec3::new(1., 0.5, 0.), Quat::IDENTITY, 0.5, Color::RED);
|
2023-03-20 20:57:54 +00:00
|
|
|
|
|
|
|
for y in [0., 0.5, 1.] {
|
|
|
|
gizmos.ray(
|
|
|
|
Vec3::new(1., y, 0.),
|
|
|
|
Vec3::new(-3., (time.elapsed_seconds() * 3.).sin(), 0.),
|
|
|
|
Color::BLUE,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
Implement Arc3D for Gizmos (#11540)
# Objective
- Implement an arc3d API for gizmos
- Solves #11536
## Solution
### `arc_3d`
- The current `arc3d` method on gizmos only takes an angle
- It draws an "standard arc" by default, this is an arc starting at
`Vec3::X`, in the XZ plane, in counter clockwise direction with a normal
that is facing up
- The "standard arc" can be customized with the usual gizmo builder
pattern. This way you'll be able to draw arbitrary arcs
### `short/long_arc_3d_between`
- Given `center`, `from`, `to` draws an arc between `from` and `to`
---
## Changelog
> This section is optional. If this was a trivial fix, or has no
externally-visible impact, you can delete this section.
- Added: `Gizmos::arc3d(&mut self, angle)` method
- Added: `Gizmos::long_arc_3d_between(&mut self, center, from, to)`
method
- Added: `Gizmos::short_arc_3d_between(&mut self, center, from, to)`
method
---
This PR factors out an orthogonal part of another PR as mentioned in
[this
comment](https://github.com/bevyengine/bevy/pull/11072#issuecomment-1883859573)
2024-01-28 02:13:17 +00:00
|
|
|
my_gizmos
|
|
|
|
.arc_3d(
|
|
|
|
180.0_f32.to_radians(),
|
|
|
|
0.2,
|
|
|
|
Vec3::ONE,
|
|
|
|
Quat::from_rotation_arc(Vec3::Y, Vec3::ONE.normalize()),
|
|
|
|
Color::ORANGE,
|
|
|
|
)
|
|
|
|
.segments(10);
|
|
|
|
|
2023-03-20 20:57:54 +00:00
|
|
|
// Circles have 32 line-segments by default.
|
2024-01-21 18:03:26 +00:00
|
|
|
my_gizmos.circle(Vec3::ZERO, Direction3d::Y, 3., Color::BLACK);
|
2023-03-20 20:57:54 +00:00
|
|
|
// You may want to increase this for larger circles or spheres.
|
2024-01-18 15:52:50 +00:00
|
|
|
my_gizmos
|
2024-01-21 18:03:26 +00:00
|
|
|
.circle(Vec3::ZERO, Direction3d::Y, 3.1, Color::NAVY)
|
2023-03-20 20:57:54 +00:00
|
|
|
.segments(64);
|
2024-01-18 15:52:50 +00:00
|
|
|
my_gizmos
|
2023-03-20 20:57:54 +00:00
|
|
|
.sphere(Vec3::ZERO, Quat::IDENTITY, 3.2, Color::BLACK)
|
|
|
|
.circle_segments(64);
|
2023-11-15 14:19:15 +00:00
|
|
|
|
|
|
|
gizmos.arrow(Vec3::ZERO, Vec3::ONE * 1.5, Color::YELLOW);
|
2023-03-20 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
2024-02-02 21:13:03 +00:00
|
|
|
fn draw_primitives(
|
|
|
|
mut gizmos: Gizmos,
|
|
|
|
time: Res<Time>,
|
|
|
|
primitive_state: Res<State<PrimitiveState>>,
|
|
|
|
segments: Res<PrimitiveSegments>,
|
|
|
|
) {
|
|
|
|
let normal = Vec3::new(
|
|
|
|
time.elapsed_seconds().sin(),
|
|
|
|
time.elapsed_seconds().cos(),
|
|
|
|
time.elapsed_seconds().sin().cos(),
|
|
|
|
)
|
|
|
|
.try_normalize()
|
|
|
|
.unwrap_or(Vec3::X);
|
|
|
|
let angle = time.elapsed_seconds().to_radians() * 10.0;
|
|
|
|
let center = Quat::from_axis_angle(Vec3::Z, angle) * Vec3::X;
|
|
|
|
let rotation = Quat::from_rotation_arc(Vec3::Y, normal);
|
|
|
|
let segments = segments.0;
|
|
|
|
match primitive_state.get() {
|
|
|
|
PrimitiveState::Nothing => {}
|
|
|
|
PrimitiveState::Sphere => {
|
|
|
|
gizmos
|
|
|
|
.primitive_3d(Sphere { radius: 1.0 }, center, rotation, Color::default())
|
|
|
|
.segments(segments);
|
|
|
|
}
|
|
|
|
PrimitiveState::Plane => {
|
|
|
|
gizmos
|
|
|
|
.primitive_3d(
|
|
|
|
Plane3d {
|
|
|
|
normal: Direction3d::Y,
|
|
|
|
},
|
|
|
|
center,
|
|
|
|
rotation,
|
|
|
|
Color::default(),
|
|
|
|
)
|
|
|
|
.axis_count((segments / 5).max(4))
|
|
|
|
.segment_count(segments)
|
|
|
|
.segment_length(1.0 / segments as f32);
|
|
|
|
}
|
|
|
|
PrimitiveState::Line => {
|
|
|
|
gizmos.primitive_3d(
|
|
|
|
Line3d {
|
|
|
|
direction: Direction3d::X,
|
|
|
|
},
|
|
|
|
center,
|
|
|
|
rotation,
|
|
|
|
Color::default(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
PrimitiveState::LineSegment => {
|
|
|
|
gizmos.primitive_3d(
|
|
|
|
Segment3d {
|
|
|
|
direction: Direction3d::X,
|
|
|
|
half_length: 1.0,
|
|
|
|
},
|
|
|
|
center,
|
|
|
|
rotation,
|
|
|
|
Color::default(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
PrimitiveState::Cuboid => {
|
|
|
|
gizmos.primitive_3d(
|
|
|
|
Cuboid {
|
|
|
|
half_size: Vec3::new(1.0, 0.5, 2.0),
|
|
|
|
},
|
|
|
|
center,
|
|
|
|
rotation,
|
|
|
|
Color::default(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
PrimitiveState::Cylinder => {
|
|
|
|
gizmos
|
|
|
|
.primitive_3d(
|
|
|
|
Cylinder {
|
|
|
|
radius: 1.0,
|
|
|
|
half_height: 1.0,
|
|
|
|
},
|
|
|
|
center,
|
|
|
|
rotation,
|
|
|
|
Color::default(),
|
|
|
|
)
|
|
|
|
.segments(segments);
|
|
|
|
}
|
|
|
|
PrimitiveState::Capsule => {
|
|
|
|
gizmos
|
|
|
|
.primitive_3d(
|
|
|
|
Capsule3d {
|
|
|
|
radius: 1.0,
|
|
|
|
half_length: 1.0,
|
|
|
|
},
|
|
|
|
center,
|
|
|
|
rotation,
|
|
|
|
Color::default(),
|
|
|
|
)
|
|
|
|
.segments(segments);
|
|
|
|
}
|
|
|
|
PrimitiveState::Cone => {
|
|
|
|
gizmos
|
|
|
|
.primitive_3d(
|
|
|
|
Cone {
|
|
|
|
radius: 1.0,
|
|
|
|
height: 1.0,
|
|
|
|
},
|
|
|
|
center,
|
|
|
|
rotation,
|
|
|
|
Color::default(),
|
|
|
|
)
|
|
|
|
.segments(segments);
|
|
|
|
}
|
|
|
|
PrimitiveState::ConicalFrustum => {
|
|
|
|
gizmos
|
|
|
|
.primitive_3d(
|
|
|
|
ConicalFrustum {
|
|
|
|
radius_top: 0.5,
|
|
|
|
radius_bottom: 1.0,
|
|
|
|
height: 1.0,
|
|
|
|
},
|
|
|
|
center,
|
|
|
|
rotation,
|
|
|
|
Color::default(),
|
|
|
|
)
|
|
|
|
.segments(segments);
|
|
|
|
}
|
|
|
|
PrimitiveState::Torus => {
|
|
|
|
gizmos
|
|
|
|
.primitive_3d(
|
|
|
|
Torus {
|
|
|
|
minor_radius: 0.3,
|
|
|
|
major_radius: 1.0,
|
|
|
|
},
|
|
|
|
center,
|
|
|
|
rotation,
|
|
|
|
Color::default(),
|
|
|
|
)
|
|
|
|
.major_segments(segments)
|
|
|
|
.minor_segments((segments / 4).max(1));
|
|
|
|
}
|
|
|
|
}
|
2023-03-20 20:57:54 +00:00
|
|
|
}
|
|
|
|
|
2023-12-06 20:32:34 +00:00
|
|
|
fn update_config(
|
2024-01-18 15:52:50 +00:00
|
|
|
mut config_store: ResMut<GizmoConfigStore>,
|
2023-12-06 20:32:34 +00:00
|
|
|
keyboard: Res<ButtonInput<KeyCode>>,
|
|
|
|
time: Res<Time>,
|
|
|
|
) {
|
Update winit dependency to 0.29 (#10702)
# Objective
- Update winit dependency to 0.29
## Changelog
### KeyCode changes
- Removed `ScanCode`, as it was [replaced by
KeyCode](https://github.com/rust-windowing/winit/blob/master/CHANGELOG.md#0292).
- `ReceivedCharacter.char` is now a `SmolStr`, [relevant
doc](https://docs.rs/winit/latest/winit/event/struct.KeyEvent.html#structfield.text).
- Changed most `KeyCode` values, and added more.
KeyCode has changed meaning. With this PR, it refers to physical
position on keyboard rather than the printed letter on keyboard keys.
In practice this means:
- On QWERTY keyboard layouts, nothing changes
- On any other keyboard layout, `KeyCode` no longer reflects the label
on key.
- This is "good". In bevy 0.12, when you used WASD for movement, users
with non-QWERTY keyboards couldn't play your game! This was especially
bad for non-latin keyboards. Now, WASD represents the physical keys. A
French player will press the ZQSD keys, which are near each other,
Kyrgyz players will use "Цфыв".
- This is "bad" as well. You can't know in advance what the label of the
key for input is. Your UI says "press WASD to move", even if in reality,
they should be pressing "ZQSD" or "Цфыв". You also no longer can use
`KeyCode` for text inputs. In any case, it was a pretty bad API for text
input. You should use `ReceivedCharacter` now instead.
### Other changes
- Use `web-time` rather than `instant` crate.
(https://github.com/rust-windowing/winit/pull/2836)
- winit did split `run_return` in `run_onDemand` and `pump_events`, I
did the same change in bevy_winit and used `pump_events`.
- Removed `return_from_run` from `WinitSettings` as `winit::run` now
returns on supported platforms.
- I left the example "return_after_run" as I think it's still useful.
- This winit change is done partly to allow to create a new window after
quitting all windows: https://github.com/emilk/egui/issues/1918 ; this
PR doesn't address.
- added `width` and `height` properties in the `canvas` from wasm
example
(https://github.com/bevyengine/bevy/pull/10702#discussion_r1420567168)
## Known regressions (important follow ups?)
- Provide an API for reacting when a specific key from current layout
was released.
- possible solutions: use winit::Key from winit::KeyEvent ; mapping
between KeyCode and Key ; or .
- We don't receive characters through alt+numpad (e.g. alt + 151 = "ù")
anymore ; reproduced on winit example "ime". maybe related to
https://github.com/rust-windowing/winit/issues/2945
- (windows) Window content doesn't refresh at all when resizing. By
reading https://github.com/rust-windowing/winit/issues/2900 ; I suspect
we should just fire a `window.request_redraw();` from `AboutToWait`, and
handle actual redrawing within `RedrawRequested`. I'm not sure how to
move all that code so I'd appreciate it to be a follow up.
- (windows) unreleased winit fix for using set_control_flow in
AboutToWait https://github.com/rust-windowing/winit/issues/3215 ; ⚠️ I'm
not sure what the implications are, but that feels bad 🤔
## Follow up
I'd like to avoid bloating this PR, here are a few follow up tasks
worthy of a separate PR, or new issue to track them once this PR is
closed, as they would either complicate reviews, or at risk of being
controversial:
- remove CanvasParentResizePlugin
(https://github.com/bevyengine/bevy/pull/10702#discussion_r1417068856)
- avoid mentionning explicitly winit in docs from bevy_window ?
- NamedKey integration on bevy_input:
https://github.com/rust-windowing/winit/pull/3143 introduced a new
NamedKey variant. I implemented it only on the converters but we'd
benefit making the same changes to bevy_input.
- Add more info in KeyboardInput
https://github.com/bevyengine/bevy/pull/10702#pullrequestreview-1748336313
- https://github.com/bevyengine/bevy/pull/9905 added a workaround on a
bug allegedly fixed by winit 0.29. We should check if it's still
necessary.
- update to raw_window_handle 0.6
- blocked by wgpu
- Rename `KeyCode` to `PhysicalKeyCode`
https://github.com/bevyengine/bevy/pull/10702#discussion_r1404595015
- remove `instant` dependency, [replaced
by](https://github.com/rust-windowing/winit/pull/2836) `web_time`), we'd
need to update to :
- fastrand >= 2.0
- [`async-executor`](https://github.com/smol-rs/async-executor) >= 1.7
- [`futures-lite`](https://github.com/smol-rs/futures-lite) >= 2.0
- Verify license, see
[discussion](https://github.com/bevyengine/bevy/pull/8745#discussion_r1402439800)
- we might be missing a short notice or description of changes made
- Consider using https://github.com/rust-windowing/cursor-icon directly
rather than vendoring it in bevy.
- investigate [this
unwrap](https://github.com/bevyengine/bevy/pull/8745#discussion_r1387044986)
(`winit_window.canvas().unwrap();`)
- Use more good things about winit's update
- https://github.com/bevyengine/bevy/pull/10689#issuecomment-1823560428
## Migration Guide
This PR should have one.
2023-12-21 07:40:47 +00:00
|
|
|
if keyboard.just_pressed(KeyCode::KeyD) {
|
2024-01-18 15:52:50 +00:00
|
|
|
for (_, config, _) in config_store.iter_mut() {
|
|
|
|
config.depth_bias = if config.depth_bias == 0. { -1. } else { 0. };
|
|
|
|
}
|
2023-06-13 06:49:47 +00:00
|
|
|
}
|
Update winit dependency to 0.29 (#10702)
# Objective
- Update winit dependency to 0.29
## Changelog
### KeyCode changes
- Removed `ScanCode`, as it was [replaced by
KeyCode](https://github.com/rust-windowing/winit/blob/master/CHANGELOG.md#0292).
- `ReceivedCharacter.char` is now a `SmolStr`, [relevant
doc](https://docs.rs/winit/latest/winit/event/struct.KeyEvent.html#structfield.text).
- Changed most `KeyCode` values, and added more.
KeyCode has changed meaning. With this PR, it refers to physical
position on keyboard rather than the printed letter on keyboard keys.
In practice this means:
- On QWERTY keyboard layouts, nothing changes
- On any other keyboard layout, `KeyCode` no longer reflects the label
on key.
- This is "good". In bevy 0.12, when you used WASD for movement, users
with non-QWERTY keyboards couldn't play your game! This was especially
bad for non-latin keyboards. Now, WASD represents the physical keys. A
French player will press the ZQSD keys, which are near each other,
Kyrgyz players will use "Цфыв".
- This is "bad" as well. You can't know in advance what the label of the
key for input is. Your UI says "press WASD to move", even if in reality,
they should be pressing "ZQSD" or "Цфыв". You also no longer can use
`KeyCode` for text inputs. In any case, it was a pretty bad API for text
input. You should use `ReceivedCharacter` now instead.
### Other changes
- Use `web-time` rather than `instant` crate.
(https://github.com/rust-windowing/winit/pull/2836)
- winit did split `run_return` in `run_onDemand` and `pump_events`, I
did the same change in bevy_winit and used `pump_events`.
- Removed `return_from_run` from `WinitSettings` as `winit::run` now
returns on supported platforms.
- I left the example "return_after_run" as I think it's still useful.
- This winit change is done partly to allow to create a new window after
quitting all windows: https://github.com/emilk/egui/issues/1918 ; this
PR doesn't address.
- added `width` and `height` properties in the `canvas` from wasm
example
(https://github.com/bevyengine/bevy/pull/10702#discussion_r1420567168)
## Known regressions (important follow ups?)
- Provide an API for reacting when a specific key from current layout
was released.
- possible solutions: use winit::Key from winit::KeyEvent ; mapping
between KeyCode and Key ; or .
- We don't receive characters through alt+numpad (e.g. alt + 151 = "ù")
anymore ; reproduced on winit example "ime". maybe related to
https://github.com/rust-windowing/winit/issues/2945
- (windows) Window content doesn't refresh at all when resizing. By
reading https://github.com/rust-windowing/winit/issues/2900 ; I suspect
we should just fire a `window.request_redraw();` from `AboutToWait`, and
handle actual redrawing within `RedrawRequested`. I'm not sure how to
move all that code so I'd appreciate it to be a follow up.
- (windows) unreleased winit fix for using set_control_flow in
AboutToWait https://github.com/rust-windowing/winit/issues/3215 ; ⚠️ I'm
not sure what the implications are, but that feels bad 🤔
## Follow up
I'd like to avoid bloating this PR, here are a few follow up tasks
worthy of a separate PR, or new issue to track them once this PR is
closed, as they would either complicate reviews, or at risk of being
controversial:
- remove CanvasParentResizePlugin
(https://github.com/bevyengine/bevy/pull/10702#discussion_r1417068856)
- avoid mentionning explicitly winit in docs from bevy_window ?
- NamedKey integration on bevy_input:
https://github.com/rust-windowing/winit/pull/3143 introduced a new
NamedKey variant. I implemented it only on the converters but we'd
benefit making the same changes to bevy_input.
- Add more info in KeyboardInput
https://github.com/bevyengine/bevy/pull/10702#pullrequestreview-1748336313
- https://github.com/bevyengine/bevy/pull/9905 added a workaround on a
bug allegedly fixed by winit 0.29. We should check if it's still
necessary.
- update to raw_window_handle 0.6
- blocked by wgpu
- Rename `KeyCode` to `PhysicalKeyCode`
https://github.com/bevyengine/bevy/pull/10702#discussion_r1404595015
- remove `instant` dependency, [replaced
by](https://github.com/rust-windowing/winit/pull/2836) `web_time`), we'd
need to update to :
- fastrand >= 2.0
- [`async-executor`](https://github.com/smol-rs/async-executor) >= 1.7
- [`futures-lite`](https://github.com/smol-rs/futures-lite) >= 2.0
- Verify license, see
[discussion](https://github.com/bevyengine/bevy/pull/8745#discussion_r1402439800)
- we might be missing a short notice or description of changes made
- Consider using https://github.com/rust-windowing/cursor-icon directly
rather than vendoring it in bevy.
- investigate [this
unwrap](https://github.com/bevyengine/bevy/pull/8745#discussion_r1387044986)
(`winit_window.canvas().unwrap();`)
- Use more good things about winit's update
- https://github.com/bevyengine/bevy/pull/10689#issuecomment-1823560428
## Migration Guide
This PR should have one.
2023-12-21 07:40:47 +00:00
|
|
|
if keyboard.just_pressed(KeyCode::KeyP) {
|
2024-01-18 15:52:50 +00:00
|
|
|
for (_, config, _) in config_store.iter_mut() {
|
|
|
|
// Toggle line_perspective
|
|
|
|
config.line_perspective ^= true;
|
|
|
|
// Increase the line width when line_perspective is on
|
|
|
|
config.line_width *= if config.line_perspective { 5. } else { 1. / 5. };
|
|
|
|
}
|
2023-06-13 06:49:47 +00:00
|
|
|
}
|
|
|
|
|
2024-01-18 15:52:50 +00:00
|
|
|
let (config, _) = config_store.config_mut::<DefaultGizmoConfigGroup>();
|
Update winit dependency to 0.29 (#10702)
# Objective
- Update winit dependency to 0.29
## Changelog
### KeyCode changes
- Removed `ScanCode`, as it was [replaced by
KeyCode](https://github.com/rust-windowing/winit/blob/master/CHANGELOG.md#0292).
- `ReceivedCharacter.char` is now a `SmolStr`, [relevant
doc](https://docs.rs/winit/latest/winit/event/struct.KeyEvent.html#structfield.text).
- Changed most `KeyCode` values, and added more.
KeyCode has changed meaning. With this PR, it refers to physical
position on keyboard rather than the printed letter on keyboard keys.
In practice this means:
- On QWERTY keyboard layouts, nothing changes
- On any other keyboard layout, `KeyCode` no longer reflects the label
on key.
- This is "good". In bevy 0.12, when you used WASD for movement, users
with non-QWERTY keyboards couldn't play your game! This was especially
bad for non-latin keyboards. Now, WASD represents the physical keys. A
French player will press the ZQSD keys, which are near each other,
Kyrgyz players will use "Цфыв".
- This is "bad" as well. You can't know in advance what the label of the
key for input is. Your UI says "press WASD to move", even if in reality,
they should be pressing "ZQSD" or "Цфыв". You also no longer can use
`KeyCode` for text inputs. In any case, it was a pretty bad API for text
input. You should use `ReceivedCharacter` now instead.
### Other changes
- Use `web-time` rather than `instant` crate.
(https://github.com/rust-windowing/winit/pull/2836)
- winit did split `run_return` in `run_onDemand` and `pump_events`, I
did the same change in bevy_winit and used `pump_events`.
- Removed `return_from_run` from `WinitSettings` as `winit::run` now
returns on supported platforms.
- I left the example "return_after_run" as I think it's still useful.
- This winit change is done partly to allow to create a new window after
quitting all windows: https://github.com/emilk/egui/issues/1918 ; this
PR doesn't address.
- added `width` and `height` properties in the `canvas` from wasm
example
(https://github.com/bevyengine/bevy/pull/10702#discussion_r1420567168)
## Known regressions (important follow ups?)
- Provide an API for reacting when a specific key from current layout
was released.
- possible solutions: use winit::Key from winit::KeyEvent ; mapping
between KeyCode and Key ; or .
- We don't receive characters through alt+numpad (e.g. alt + 151 = "ù")
anymore ; reproduced on winit example "ime". maybe related to
https://github.com/rust-windowing/winit/issues/2945
- (windows) Window content doesn't refresh at all when resizing. By
reading https://github.com/rust-windowing/winit/issues/2900 ; I suspect
we should just fire a `window.request_redraw();` from `AboutToWait`, and
handle actual redrawing within `RedrawRequested`. I'm not sure how to
move all that code so I'd appreciate it to be a follow up.
- (windows) unreleased winit fix for using set_control_flow in
AboutToWait https://github.com/rust-windowing/winit/issues/3215 ; ⚠️ I'm
not sure what the implications are, but that feels bad 🤔
## Follow up
I'd like to avoid bloating this PR, here are a few follow up tasks
worthy of a separate PR, or new issue to track them once this PR is
closed, as they would either complicate reviews, or at risk of being
controversial:
- remove CanvasParentResizePlugin
(https://github.com/bevyengine/bevy/pull/10702#discussion_r1417068856)
- avoid mentionning explicitly winit in docs from bevy_window ?
- NamedKey integration on bevy_input:
https://github.com/rust-windowing/winit/pull/3143 introduced a new
NamedKey variant. I implemented it only on the converters but we'd
benefit making the same changes to bevy_input.
- Add more info in KeyboardInput
https://github.com/bevyengine/bevy/pull/10702#pullrequestreview-1748336313
- https://github.com/bevyengine/bevy/pull/9905 added a workaround on a
bug allegedly fixed by winit 0.29. We should check if it's still
necessary.
- update to raw_window_handle 0.6
- blocked by wgpu
- Rename `KeyCode` to `PhysicalKeyCode`
https://github.com/bevyengine/bevy/pull/10702#discussion_r1404595015
- remove `instant` dependency, [replaced
by](https://github.com/rust-windowing/winit/pull/2836) `web_time`), we'd
need to update to :
- fastrand >= 2.0
- [`async-executor`](https://github.com/smol-rs/async-executor) >= 1.7
- [`futures-lite`](https://github.com/smol-rs/futures-lite) >= 2.0
- Verify license, see
[discussion](https://github.com/bevyengine/bevy/pull/8745#discussion_r1402439800)
- we might be missing a short notice or description of changes made
- Consider using https://github.com/rust-windowing/cursor-icon directly
rather than vendoring it in bevy.
- investigate [this
unwrap](https://github.com/bevyengine/bevy/pull/8745#discussion_r1387044986)
(`winit_window.canvas().unwrap();`)
- Use more good things about winit's update
- https://github.com/bevyengine/bevy/pull/10689#issuecomment-1823560428
## Migration Guide
This PR should have one.
2023-12-21 07:40:47 +00:00
|
|
|
if keyboard.pressed(KeyCode::ArrowRight) {
|
2023-06-13 06:49:47 +00:00
|
|
|
config.line_width += 5. * time.delta_seconds();
|
2024-01-18 15:52:50 +00:00
|
|
|
config.line_width = config.line_width.clamp(0., 50.);
|
2023-06-13 06:49:47 +00:00
|
|
|
}
|
Update winit dependency to 0.29 (#10702)
# Objective
- Update winit dependency to 0.29
## Changelog
### KeyCode changes
- Removed `ScanCode`, as it was [replaced by
KeyCode](https://github.com/rust-windowing/winit/blob/master/CHANGELOG.md#0292).
- `ReceivedCharacter.char` is now a `SmolStr`, [relevant
doc](https://docs.rs/winit/latest/winit/event/struct.KeyEvent.html#structfield.text).
- Changed most `KeyCode` values, and added more.
KeyCode has changed meaning. With this PR, it refers to physical
position on keyboard rather than the printed letter on keyboard keys.
In practice this means:
- On QWERTY keyboard layouts, nothing changes
- On any other keyboard layout, `KeyCode` no longer reflects the label
on key.
- This is "good". In bevy 0.12, when you used WASD for movement, users
with non-QWERTY keyboards couldn't play your game! This was especially
bad for non-latin keyboards. Now, WASD represents the physical keys. A
French player will press the ZQSD keys, which are near each other,
Kyrgyz players will use "Цфыв".
- This is "bad" as well. You can't know in advance what the label of the
key for input is. Your UI says "press WASD to move", even if in reality,
they should be pressing "ZQSD" or "Цфыв". You also no longer can use
`KeyCode` for text inputs. In any case, it was a pretty bad API for text
input. You should use `ReceivedCharacter` now instead.
### Other changes
- Use `web-time` rather than `instant` crate.
(https://github.com/rust-windowing/winit/pull/2836)
- winit did split `run_return` in `run_onDemand` and `pump_events`, I
did the same change in bevy_winit and used `pump_events`.
- Removed `return_from_run` from `WinitSettings` as `winit::run` now
returns on supported platforms.
- I left the example "return_after_run" as I think it's still useful.
- This winit change is done partly to allow to create a new window after
quitting all windows: https://github.com/emilk/egui/issues/1918 ; this
PR doesn't address.
- added `width` and `height` properties in the `canvas` from wasm
example
(https://github.com/bevyengine/bevy/pull/10702#discussion_r1420567168)
## Known regressions (important follow ups?)
- Provide an API for reacting when a specific key from current layout
was released.
- possible solutions: use winit::Key from winit::KeyEvent ; mapping
between KeyCode and Key ; or .
- We don't receive characters through alt+numpad (e.g. alt + 151 = "ù")
anymore ; reproduced on winit example "ime". maybe related to
https://github.com/rust-windowing/winit/issues/2945
- (windows) Window content doesn't refresh at all when resizing. By
reading https://github.com/rust-windowing/winit/issues/2900 ; I suspect
we should just fire a `window.request_redraw();` from `AboutToWait`, and
handle actual redrawing within `RedrawRequested`. I'm not sure how to
move all that code so I'd appreciate it to be a follow up.
- (windows) unreleased winit fix for using set_control_flow in
AboutToWait https://github.com/rust-windowing/winit/issues/3215 ; ⚠️ I'm
not sure what the implications are, but that feels bad 🤔
## Follow up
I'd like to avoid bloating this PR, here are a few follow up tasks
worthy of a separate PR, or new issue to track them once this PR is
closed, as they would either complicate reviews, or at risk of being
controversial:
- remove CanvasParentResizePlugin
(https://github.com/bevyengine/bevy/pull/10702#discussion_r1417068856)
- avoid mentionning explicitly winit in docs from bevy_window ?
- NamedKey integration on bevy_input:
https://github.com/rust-windowing/winit/pull/3143 introduced a new
NamedKey variant. I implemented it only on the converters but we'd
benefit making the same changes to bevy_input.
- Add more info in KeyboardInput
https://github.com/bevyengine/bevy/pull/10702#pullrequestreview-1748336313
- https://github.com/bevyengine/bevy/pull/9905 added a workaround on a
bug allegedly fixed by winit 0.29. We should check if it's still
necessary.
- update to raw_window_handle 0.6
- blocked by wgpu
- Rename `KeyCode` to `PhysicalKeyCode`
https://github.com/bevyengine/bevy/pull/10702#discussion_r1404595015
- remove `instant` dependency, [replaced
by](https://github.com/rust-windowing/winit/pull/2836) `web_time`), we'd
need to update to :
- fastrand >= 2.0
- [`async-executor`](https://github.com/smol-rs/async-executor) >= 1.7
- [`futures-lite`](https://github.com/smol-rs/futures-lite) >= 2.0
- Verify license, see
[discussion](https://github.com/bevyengine/bevy/pull/8745#discussion_r1402439800)
- we might be missing a short notice or description of changes made
- Consider using https://github.com/rust-windowing/cursor-icon directly
rather than vendoring it in bevy.
- investigate [this
unwrap](https://github.com/bevyengine/bevy/pull/8745#discussion_r1387044986)
(`winit_window.canvas().unwrap();`)
- Use more good things about winit's update
- https://github.com/bevyengine/bevy/pull/10689#issuecomment-1823560428
## Migration Guide
This PR should have one.
2023-12-21 07:40:47 +00:00
|
|
|
if keyboard.pressed(KeyCode::ArrowLeft) {
|
2023-06-13 06:49:47 +00:00
|
|
|
config.line_width -= 5. * time.delta_seconds();
|
2024-01-18 15:52:50 +00:00
|
|
|
config.line_width = config.line_width.clamp(0., 50.);
|
|
|
|
}
|
|
|
|
if keyboard.just_pressed(KeyCode::Digit1) {
|
|
|
|
config.enabled ^= true;
|
|
|
|
}
|
|
|
|
|
|
|
|
let (my_config, _) = config_store.config_mut::<MyRoundGizmos>();
|
|
|
|
if keyboard.pressed(KeyCode::ArrowUp) {
|
|
|
|
my_config.line_width += 5. * time.delta_seconds();
|
|
|
|
my_config.line_width = my_config.line_width.clamp(0., 50.);
|
|
|
|
}
|
|
|
|
if keyboard.pressed(KeyCode::ArrowDown) {
|
|
|
|
my_config.line_width -= 5. * time.delta_seconds();
|
|
|
|
my_config.line_width = my_config.line_width.clamp(0., 50.);
|
|
|
|
}
|
|
|
|
if keyboard.just_pressed(KeyCode::Digit2) {
|
|
|
|
my_config.enabled ^= true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if keyboard.just_pressed(KeyCode::KeyA) {
|
|
|
|
// AABB gizmos are normally only drawn on entities with a ShowAabbGizmo component
|
|
|
|
// We can change this behaviour in the configuration of AabbGizmoGroup
|
|
|
|
config_store.config_mut::<AabbGizmoConfigGroup>().1.draw_all ^= true;
|
2023-03-20 20:57:54 +00:00
|
|
|
}
|
|
|
|
}
|
2024-02-02 21:13:03 +00:00
|
|
|
|
|
|
|
fn update_primitives(
|
|
|
|
keyboard: Res<ButtonInput<KeyCode>>,
|
|
|
|
primitive_state: Res<State<PrimitiveState>>,
|
|
|
|
mut next_primitive_state: ResMut<NextState<PrimitiveState>>,
|
|
|
|
mut segments: ResMut<PrimitiveSegments>,
|
|
|
|
mut segments_f: Local<f32>,
|
|
|
|
) {
|
|
|
|
if keyboard.just_pressed(KeyCode::KeyK) {
|
|
|
|
next_primitive_state.set(primitive_state.get().next());
|
|
|
|
}
|
|
|
|
if keyboard.just_pressed(KeyCode::KeyJ) {
|
|
|
|
next_primitive_state.set(primitive_state.get().last());
|
|
|
|
}
|
|
|
|
if keyboard.pressed(KeyCode::KeyL) {
|
|
|
|
*segments_f = (*segments_f + 0.05).max(2.0);
|
|
|
|
segments.0 = segments_f.floor() as usize;
|
|
|
|
}
|
|
|
|
if keyboard.pressed(KeyCode::KeyH) {
|
|
|
|
*segments_f = (*segments_f - 0.05).max(2.0);
|
|
|
|
segments.0 = segments_f.floor() as usize;
|
|
|
|
}
|
|
|
|
}
|