From be690d90d5e67e18f6ab2f3add7b0969c19a52a3 Mon Sep 17 00:00:00 2001 From: Aevyrie Date: Fri, 5 Jul 2024 00:21:09 -0700 Subject: [PATCH] Bevy 0.14 (#26) --- Cargo.toml | 35 ++++++++++---------- README.md | 1 + examples/debug.rs | 5 +-- examples/demo.rs | 16 ++++++--- examples/error.rs | 2 +- examples/error_child.rs | 27 ++++++++-------- examples/planets.rs | 15 +++++---- examples/split_screen.rs | 21 ++++++------ src/camera.rs | 50 ++++++++++++++++++++++++----- src/debug.rs | 13 +++++--- src/plugin.rs | 6 ++-- src/reference_frame/local_origin.rs | 46 +++++++++++++------------- src/reference_frame/mod.rs | 2 +- src/tests.rs | 26 +++++++-------- 14 files changed, 158 insertions(+), 107 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index dfeafe0..d127a51 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "big_space" -version = "0.6.0" +version = "0.7.0-rc.0" edition = "2021" description = "A floating origin plugin for bevy" license = "MIT OR Apache-2.0" @@ -9,22 +9,23 @@ repository = "https://github.com/aevyrie/big_space" documentation = "https://docs.rs/crate/big_space/latest" [dependencies] -bevy_app = { version = "0.13", default_features = false } -bevy_ecs = { version = "0.13", default_features = false } -bevy_hierarchy = { version = "0.13", default_features = false } -bevy_log = { version = "0.13", default_features = false } -bevy_math = { version = "0.13", default_features = false } -bevy_reflect = { version = "0.13", default_features = false } -bevy_transform = { version = "0.13", default_features = false } -bevy_utils = { version = "0.13", default_features = false } +bevy_app = { version = "0.14.0-rc.4", default_features = false } +bevy_ecs = { version = "0.14.0-rc.4", default_features = false } +bevy_hierarchy = { version = "0.14.0-rc.4", default_features = false } +bevy_log = { version = "0.14.0-rc.4", default_features = false } +bevy_math = { version = "0.14.0-rc.4", default_features = false } +bevy_reflect = { version = "0.14.0-rc.4", default_features = false } +bevy_transform = { version = "0.14.0-rc.4", default_features = false } +bevy_utils = { version = "0.14.0-rc.4", default_features = false } # Optional -bevy_gizmos = { version = "0.13", default_features = false, optional = true } -bevy_render = { version = "0.13", default_features = false, optional = true } -bevy_input = { version = "0.13", default_features = false, optional = true } -bevy_time = { version = "0.13", default_features = false, optional = true } +bevy_color = { version = "0.14.0-rc.4", default_features = false, optional = true } +bevy_gizmos = { version = "0.14.0-rc.4", default_features = false, optional = true } +bevy_render = { version = "0.14.0-rc.4", default_features = false, optional = true } +bevy_input = { version = "0.14.0-rc.4", default_features = false, optional = true } +bevy_time = { version = "0.14.0-rc.4", default_features = false, optional = true } [dev-dependencies] -bevy = { version = "0.13", default-features = false, features = [ +bevy = { version = "0.14.0-rc.4", default-features = false, features = [ "bevy_scene", "bevy_gltf", "bevy_winit", @@ -34,14 +35,14 @@ bevy = { version = "0.13", default-features = false, features = [ "bevy_gizmos", "x11", "tonemapping_luts", - "multi-threaded", + "multi_threaded", ] } -bevy-inspector-egui = "0.24" +# bevy-inspector-egui = "0.24" rand = "0.8.5" [features] default = ["debug", "camera", "bevy_render"] -debug = ["bevy_gizmos", "bevy_render"] +debug = ["bevy_gizmos", "bevy_color"] camera = ["bevy_render", "bevy_time", "bevy_input"] [[example]] diff --git a/README.md b/README.md index 1ce0c23..298e307 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ From the docs: https://docs.rs/big_space/latest/big_space/precision/trait.GridPr | bevy | big_space | | ---- | --------- | +| 0.14 | 0.7 | | 0.13 | 0.5, 0.6 | | 0.12 | 0.4 | | 0.11 | 0.3 | diff --git a/examples/debug.rs b/examples/debug.rs index 65a5aa9..58b9263 100644 --- a/examples/debug.rs +++ b/examples/debug.rs @@ -1,6 +1,7 @@ #![allow(clippy::type_complexity)] use bevy::prelude::*; +use bevy_color::palettes; use big_space::{commands::BigSpaceCommands, reference_frame::ReferenceFrame, FloatingOrigin}; fn main() { @@ -13,7 +14,7 @@ fn main() { .insert_resource(ClearColor(Color::BLACK)) .add_systems(Startup, setup) .add_systems(Update, (movement, rotation)) - .run() + .run(); } #[derive(Component)] @@ -61,7 +62,7 @@ fn setup( ) { let mesh_handle = meshes.add(Sphere::new(0.1).mesh().ico(16).unwrap()); let matl_handle = materials.add(StandardMaterial { - base_color: Color::YELLOW, + base_color: Color::Srgba(palettes::basic::YELLOW), ..default() }); diff --git a/examples/demo.rs b/examples/demo.rs index 9c4b620..9c57c44 100644 --- a/examples/demo.rs +++ b/examples/demo.rs @@ -3,6 +3,7 @@ use bevy::{ transform::TransformSystem, window::{CursorGrabMode, PrimaryWindow}, }; +use bevy_color::palettes; use big_space::{ camera::{CameraController, CameraInput}, commands::BigSpaceCommands, @@ -26,7 +27,7 @@ fn main() { PostUpdate, highlight_nearest_sphere.after(TransformSystem::TransformPropagate), ) - .run() + .run(); } fn setup( @@ -54,7 +55,7 @@ fn setup( let mesh_handle = meshes.add(Sphere::new(0.5).mesh().ico(32).unwrap()); let matl_handle = materials.add(StandardMaterial { - base_color: Color::BLUE, + base_color: Color::Srgba(palettes::basic::BLUE), perceptual_roughness: 0.8, reflectance: 1.0, ..default() @@ -78,7 +79,7 @@ fn setup( // light root.spawn_spatial(DirectionalLightBundle { directional_light: DirectionalLight { - illuminance: 100_000.0, + illuminance: 10_000.0, ..default() }, ..default() @@ -147,8 +148,13 @@ fn highlight_nearest_sphere( // Ignore rotation due to panicking in gizmos, as of bevy 0.13 let (scale, rotation, translation) = transform.to_scale_rotation_translation(); gizmos - .sphere(translation, rotation, scale.x * 0.505, Color::RED) - .circle_segments(128); + .sphere( + translation, + rotation, + scale.x * 0.505, + Color::Srgba(palettes::basic::RED), + ) + .resolution(128); } #[allow(clippy::type_complexity)] diff --git a/examples/error.rs b/examples/error.rs index cb5d7e0..4e4e9fb 100644 --- a/examples/error.rs +++ b/examples/error.rs @@ -20,7 +20,7 @@ fn main() { )) .add_systems(Startup, (setup_scene, setup_ui)) .add_systems(Update, (rotator_system, toggle_plugin)) - .run() + .run(); } /// You can put things really, really far away from the origin. The distance we use here is actually diff --git a/examples/error_child.rs b/examples/error_child.rs index 3fd19d7..1e9298b 100644 --- a/examples/error_child.rs +++ b/examples/error_child.rs @@ -1,18 +1,19 @@ //! This example demonstrates error accumulating from parent to children in nested reference frames. use bevy::{math::DVec3, prelude::*}; +use bevy_color::palettes; use big_space::{commands::BigSpaceCommands, reference_frame::ReferenceFrame, FloatingOrigin}; fn main() { App::new() .add_plugins(( DefaultPlugins.build().disable::(), - bevy_inspector_egui::quick::WorldInspectorPlugin::new(), + // bevy_inspector_egui::quick::WorldInspectorPlugin::new(), big_space::BigSpacePlugin::::default(), big_space::camera::CameraControllerPlugin::::default(), big_space::debug::FloatingOriginDebugPlugin::::default(), )) .add_systems(Startup, setup_scene) - .run() + .run(); } // The nearby object is NEARBY meters away from us. The distance object is DISTANT meters away from @@ -28,7 +29,7 @@ fn setup_scene( ) { let mesh_handle = meshes.add(Sphere::new(SPHERE_RADIUS).mesh()); let matl_handle = materials.add(StandardMaterial { - base_color: Color::rgb(0.8, 0.7, 0.6), + base_color: Color::srgb(0.8, 0.7, 0.6), ..default() }); @@ -37,7 +38,7 @@ fn setup_scene( |root_frame| { root_frame.spawn_spatial(PbrBundle { mesh: mesh_handle.clone(), - material: materials.add(Color::BLUE), + material: materials.add(Color::from(palettes::css::BLUE)), transform: Transform::from_translation(NEARBY), ..default() }); @@ -46,8 +47,8 @@ fn setup_scene( root_frame.with_frame( ReferenceFrame::new(SPHERE_RADIUS * 100.0, 0.0), |parent_frame| { - // This function introduces a small amount of error, because it can only work up to - // double precision floats. (f64). + // This function introduces a small amount of error, because it can only work up + // to double precision floats. (f64). let child = parent_frame .frame() .translation_to_grid(-DISTANT + NEARBY.as_dvec3()); @@ -60,16 +61,16 @@ fn setup_scene( parent_frame.insert(parent.0); parent_frame.with_children(|child_builder| { - // A green sphere that is a child of the sphere very far from the origin. This - // child is very far from its parent, and should be located exactly at the - // origin (if there was no floating point error). The distance from the green - // sphere to the red sphere is the error caused by float imprecision. Note that - // the sphere does not have any rendering artifacts, its position just has a - // fixed error. + // A green sphere that is a child of the sphere very far from the origin. + // This child is very far from its parent, and should be located exactly at + // the origin (if there was no floating point error). The distance from the + // green sphere to the red sphere is the error caused by float imprecision. + // Note that the sphere does not have any rendering artifacts, its position + // just has a fixed error. child_builder.spawn(( PbrBundle { mesh: mesh_handle, - material: materials.add(Color::GREEN), + material: materials.add(Color::from(palettes::css::GREEN)), transform: Transform::from_translation(child.1), ..default() }, diff --git a/examples/planets.rs b/examples/planets.rs index d12907a..946e8e4 100644 --- a/examples/planets.rs +++ b/examples/planets.rs @@ -11,6 +11,7 @@ use bevy::{ render::camera::Exposure, transform::TransformSystem, }; +use bevy_color::palettes; use big_space::{ camera::{CameraController, CameraInput}, commands::BigSpaceCommands, @@ -51,7 +52,7 @@ fn main() { ) .register_type::() .register_type::() - .run() + .run(); } const EARTH_ORBIT_RADIUS_M: f64 = 149.60e9; @@ -129,7 +130,7 @@ fn spawn_solar_system( let earth_mesh_handle = meshes.add(Sphere::new(1.0).mesh().ico(35).unwrap()); let moon_mesh_handle = meshes.add(Sphere::new(MOON_RADIUS_M as f32).mesh().ico(15).unwrap()); let ball_mesh_handle = meshes.add(Sphere::new(5.0).mesh().ico(5).unwrap()); - let plane_mesh_handle = meshes.add(Plane3d::new(Vec3::X)); + let plane_mesh_handle = meshes.add(Plane3d::new(Vec3::X, Vec2::splat(0.5))); commands.spawn(( PrimaryLight, @@ -160,7 +161,7 @@ fn spawn_solar_system( mesh: sun_mesh_handle, material: materials.add(StandardMaterial { base_color: Color::WHITE, - emissive: Color::rgb_linear(100000000., 100000000., 100000000.), + emissive: LinearRgba::rgb(100000., 100000., 100000.), ..default() }), ..default() @@ -177,7 +178,7 @@ fn spawn_solar_system( PbrBundle { mesh: earth_mesh_handle, material: materials.add(StandardMaterial { - base_color: Color::BLUE, + base_color: Color::Srgba(palettes::css::BLUE), perceptual_roughness: 0.8, reflectance: 1.0, ..default() @@ -197,7 +198,7 @@ fn spawn_solar_system( PbrBundle { mesh: moon_mesh_handle, material: materials.add(StandardMaterial { - base_color: Color::GRAY, + base_color: Color::Srgba(palettes::css::GRAY), perceptual_roughness: 1.0, reflectance: 0.0, ..default() @@ -226,7 +227,7 @@ fn spawn_solar_system( children.spawn((PbrBundle { mesh: plane_mesh_handle, material: materials.add(StandardMaterial { - base_color: Color::DARK_GREEN, + base_color: Color::Srgba(palettes::css::DARK_GREEN), perceptual_roughness: 1.0, reflectance: 0.0, ..default() @@ -282,7 +283,7 @@ fn spawn_solar_system( let star_mat = materials.add(StandardMaterial { base_color: Color::WHITE, - emissive: Color::rgb_linear(100000., 100000., 100000.), + emissive: LinearRgba::rgb(2., 2., 2.), ..default() }); let star_mesh_handle = meshes.add(Sphere::new(1e10).mesh().ico(5).unwrap()); diff --git a/examples/split_screen.rs b/examples/split_screen.rs index fee73df..7090bce 100644 --- a/examples/split_screen.rs +++ b/examples/split_screen.rs @@ -9,6 +9,7 @@ use bevy::{ render::{camera::Viewport, view::RenderLayers}, transform::TransformSystem, }; +use bevy_color::palettes; use big_space::{ camera::{CameraController, CameraControllerPlugin}, commands::BigSpaceCommands, @@ -33,7 +34,7 @@ fn main() { .after(big_space::camera::camera_controller::) .before(TransformSystem::TransformPropagate), ) - .run() + .run(); } #[derive(Component)] @@ -58,7 +59,7 @@ fn setup( transform: Transform::default().looking_to(Vec3::NEG_ONE, Vec3::Y), ..default() }, - RenderLayers::all(), + RenderLayers::from_layers(&[1, 2]), )); // Big Space 1 @@ -80,7 +81,7 @@ fn setup( PbrBundle { mesh: meshes.add(Cuboid::new(1.0, 2.0, 1.0)), material: materials.add(StandardMaterial { - base_color: Color::YELLOW, + base_color: Color::Srgba(palettes::css::YELLOW), ..default() }), ..default() @@ -94,7 +95,7 @@ fn setup( PbrBundle { mesh: meshes.add(Cuboid::new(1.0, 2.0, 1.0)), material: materials.add(StandardMaterial { - base_color: Color::PINK, + base_color: Color::Srgba(palettes::css::FUCHSIA), ..default() }), ..default() @@ -106,7 +107,7 @@ fn setup( PbrBundle { mesh: meshes.add(Sphere::new(1.0).mesh().ico(35).unwrap()), material: materials.add(StandardMaterial { - base_color: Color::BLUE, + base_color: Color::Srgba(palettes::css::BLUE), ..default() }), transform: Transform::from_xyz(1_000_000.0, 0.0, 0.0) @@ -120,7 +121,7 @@ fn setup( PbrBundle { mesh: meshes.add(Sphere::new(1.0).mesh().ico(35).unwrap()), material: materials.add(StandardMaterial { - base_color: Color::GREEN, + base_color: Color::Srgba(palettes::css::GREEN), ..default() }), transform: Transform::from_xyz(-1_000_000.0, 0.0, 0.0) @@ -154,7 +155,7 @@ fn setup( PbrBundle { mesh: meshes.add(Cuboid::new(1.0, 2.0, 1.0)), material: materials.add(StandardMaterial { - base_color: Color::PINK, + base_color: Color::Srgba(palettes::css::PINK), ..default() }), ..default() @@ -168,7 +169,7 @@ fn setup( PbrBundle { mesh: meshes.add(Cuboid::new(1.0, 2.0, 1.0)), material: materials.add(StandardMaterial { - base_color: Color::YELLOW, + base_color: Color::Srgba(palettes::css::YELLOW), ..default() }), ..default() @@ -180,7 +181,7 @@ fn setup( PbrBundle { mesh: meshes.add(Sphere::new(1.0).mesh().ico(35).unwrap()), material: materials.add(StandardMaterial { - base_color: Color::BLUE, + base_color: Color::Srgba(palettes::css::BLUE), ..default() }), transform: Transform::from_xyz(1_000_000.0, 0.0, 0.0) @@ -194,7 +195,7 @@ fn setup( PbrBundle { mesh: meshes.add(Sphere::new(1.0).mesh().ico(35).unwrap()), material: materials.add(StandardMaterial { - base_color: Color::GREEN, + base_color: Color::Srgba(palettes::css::GREEN), ..default() }), transform: Transform::from_xyz(-1_000_000.0, 0.0, 0.0) diff --git a/src/camera.rs b/src/camera.rs index 78051e3..56aeafa 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -45,6 +45,12 @@ pub struct CameraController { pub rotational_smoothness: f64, /// Base speed. pub speed: f64, + /// Rotational yaw speed multiplier. + pub speed_yaw: f64, + /// Rotational pitch speed multiplier. + pub speed_pitch: f64, + /// Rotational roll speed multiplier. + pub speed_roll: f64, /// Minimum and maximum speed. pub speed_bounds: [f64; 2], /// Whether the camera should slow down when approaching an entity's [`Aabb`]. @@ -73,6 +79,25 @@ impl CameraController { self.speed = speed; self } + + /// Sets the yaw angular velocity of the controller, and returns the modified result. + pub fn with_speed_yaw(mut self, speed: f64) -> Self { + self.speed_yaw = speed; + self + } + + /// Sets the pitch angular velocity of the controller, and returns the modified result. + pub fn with_speed_pitch(mut self, speed: f64) -> Self { + self.speed_pitch = speed; + self + } + + /// Sets the pitch angular velocity of the controller, and returns the modified result. + pub fn with_speed_roll(mut self, speed: f64) -> Self { + self.speed_roll = speed; + self + } + /// Sets the speed of the controller, and returns the modified result. pub fn with_speed_bounds(mut self, speed_limits: [f64; 2]) -> Self { self.speed_bounds = speed_limits; @@ -96,6 +121,9 @@ impl Default for CameraController { smoothness: 0.8, rotational_smoothness: 0.5, speed: 1.0, + speed_pitch: 1.0, + speed_yaw: 1.0, + speed_roll: 1.0, speed_bounds: [1e-17, 1e30], slow_near_objects: true, nearest_object: None, @@ -137,12 +165,17 @@ impl CameraInput { } /// Returns the desired velocity transform. - pub fn target_velocity(&self, speed: f64, dt: f64) -> (DVec3, DQuat) { + pub fn target_velocity( + &self, + controller: &CameraController, + speed: f64, + dt: f64, + ) -> (DVec3, DQuat) { let rotation = DQuat::from_euler( EulerRot::XYZ, - self.pitch * dt, - self.yaw * dt, - self.roll * dt, + self.pitch * dt * controller.speed_pitch, + self.yaw * dt * controller.speed_yaw, + self.roll * dt * controller.speed_roll, ); let translation = DVec3::new(self.right, self.up, self.forward) * speed * dt; @@ -196,15 +229,15 @@ pub fn nearest_objects_in_frame( let Ok((cam_entity, mut camera, cam_pos, cam_layer)) = camera.get_single_mut() else { return; }; - let cam_layer = cam_layer.copied().unwrap_or(RenderLayers::all()); + let cam_layer = cam_layer.to_owned().unwrap_or_default(); let cam_children: HashSet = children.iter_descendants(cam_entity).collect(); let nearest_object = objects .iter() .filter(|(entity, ..)| !cam_children.contains(entity)) .filter(|(.., obj_layer)| { - let obj_layer = obj_layer.copied().unwrap_or(RenderLayers::layer(0)); - cam_layer.intersects(&obj_layer) + let obj_layer = obj_layer.unwrap_or_default(); + cam_layer.intersects(obj_layer) }) .map(|(entity, object_local, obj_pos, aabb, _)| { let center_distance = @@ -243,7 +276,8 @@ pub fn camera_controller( let lerp_rotation = 1.0 - controller.rotational_smoothness.clamp(0.0, 0.999); let (vel_t_current, vel_r_current) = (controller.vel_translation, controller.vel_rotation); - let (vel_t_target, vel_r_target) = input.target_velocity(speed, time.delta_seconds_f64()); + let (vel_t_target, vel_r_target) = + input.target_velocity(&controller, speed, time.delta_seconds_f64()); let cam_rot = position.transform.rotation.as_dquat(); let vel_t_next = cam_rot * vel_t_target; // Orients the translation to match the camera diff --git a/src/debug.rs b/src/debug.rs index 852c8d2..907fdd7 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -3,10 +3,13 @@ use std::marker::PhantomData; use bevy_app::prelude::*; +use bevy_color::{ + palettes::css::{BLUE, GREEN, RED}, + prelude::*, +}; use bevy_ecs::prelude::*; use bevy_gizmos::prelude::*; use bevy_math::prelude::*; -use bevy_render::prelude::*; use bevy_transform::prelude::*; use crate::{ @@ -44,7 +47,7 @@ pub fn update_debug_bounds( &Transform::from_scale(Vec3::splat(frame.cell_edge_length() * 0.999)), ); if origin.is_none() { - gizmos.cuboid(transform, Color::GREEN) + gizmos.cuboid(transform, Color::Srgba(GREEN)) } else { // gizmos.cuboid(transform, Color::rgba(0.0, 0.0, 1.0, 0.5)) } @@ -59,8 +62,8 @@ pub fn update_reference_frame_axes( for (transform, frame) in frames.iter() { let start = transform.translation(); let len = frame.cell_edge_length() * 2.0; - gizmos.ray(start, transform.right() * len, Color::RED); - gizmos.ray(start, transform.up() * len, Color::GREEN); - gizmos.ray(start, transform.back() * len, Color::BLUE); + gizmos.ray(start, transform.right() * len, Color::Srgba(RED)); + gizmos.ray(start, transform.up() * len, Color::Srgba(GREEN)); + gizmos.ray(start, transform.back() * len, Color::Srgba(BLUE)); } } diff --git a/src/plugin.rs b/src/plugin.rs index 832e7fe..1eaf5b1 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -2,7 +2,7 @@ use bevy_app::prelude::*; use bevy_ecs::prelude::*; -use bevy_reflect::prelude::*; +use bevy_reflect::{prelude::*, GetTypeRegistration}; use bevy_transform::{prelude::*, TransformSystem}; use std::marker::PhantomData; @@ -52,7 +52,9 @@ pub enum FloatingOriginSet { PropagateLowPrecision, } -impl Plugin for BigSpacePlugin

{ +impl Plugin + for BigSpacePlugin

+{ fn build(&self, app: &mut App) { let system_set_config = || { ( diff --git a/src/reference_frame/local_origin.rs b/src/reference_frame/local_origin.rs index 01f38aa..0decd54 100644 --- a/src/reference_frame/local_origin.rs +++ b/src/reference_frame/local_origin.rs @@ -506,18 +506,18 @@ mod tests { ReferenceFrame::::default(), ); - let child_1 = app.world.spawn(frame_bundle.clone()).id(); - let child_2 = app.world.spawn(frame_bundle.clone()).id(); - let parent = app.world.spawn(frame_bundle.clone()).id(); - let root = app.world.spawn(frame_bundle.clone()).id(); + let child_1 = app.world_mut().spawn(frame_bundle.clone()).id(); + let child_2 = app.world_mut().spawn(frame_bundle.clone()).id(); + let parent = app.world_mut().spawn(frame_bundle.clone()).id(); + let root = app.world_mut().spawn(frame_bundle.clone()).id(); - app.world.entity_mut(root).push_children(&[parent]); - app.world + app.world_mut().entity_mut(root).push_children(&[parent]); + app.world_mut() .entity_mut(parent) .push_children(&[child_1, child_2]); - let mut state = SystemState::>::new(&mut app.world); - let mut ref_frames = state.get_mut(&mut app.world); + let mut state = SystemState::>::new(app.world_mut()); + let mut ref_frames = state.get_mut(app.world_mut()); // Children let result = ref_frames.child_frames(root); @@ -559,12 +559,12 @@ mod tests { ..default() }; let root = app - .world + .world_mut() .spawn((Transform::default(), GridCell::::default(), root_frame)) .id(); let child = app - .world + .world_mut() .spawn(( Transform::from_rotation(Quat::from_rotation_z(std::f32::consts::FRAC_PI_2)) .with_translation(Vec3::new(1.0, 1.0, 0.0)), @@ -573,10 +573,10 @@ mod tests { )) .id(); - app.world.entity_mut(root).push_children(&[child]); + app.world_mut().entity_mut(root).push_children(&[child]); - let mut state = SystemState::>::new(&mut app.world); - let mut reference_frames = state.get_mut(&mut app.world); + let mut state = SystemState::>::new(app.world_mut()); + let mut reference_frames = state.get_mut(app.world_mut()); // The function we are testing propagate_origin_to_child(root, &mut reference_frames, child); @@ -615,10 +615,10 @@ mod tests { GridCell::::default(), ReferenceFrame::::default(), ); - let root = app.world.spawn(frame_bundle.clone()).id(); + let root = app.world_mut().spawn(frame_bundle.clone()).id(); let child = app - .world + .world_mut() .spawn(( Transform::from_rotation(Quat::from_rotation_z(std::f32::consts::FRAC_PI_2)) .with_translation(Vec3::new(1.0, 1.0, 0.0)), @@ -634,10 +634,10 @@ mod tests { )) .id(); - app.world.entity_mut(root).push_children(&[child]); + app.world_mut().entity_mut(root).push_children(&[child]); - let mut state = SystemState::>::new(&mut app.world); - let mut reference_frames = state.get_mut(&mut app.world); + let mut state = SystemState::>::new(app.world_mut()); + let mut reference_frames = state.get_mut(app.world_mut()); // The function we are testing propagate_origin_to_parent(child, &mut reference_frames, root); @@ -672,7 +672,7 @@ mod tests { app.add_plugins(BigSpacePlugin::::default()); let root = app - .world + .world_mut() .spawn(( Transform::default(), GridCell::::default(), @@ -688,7 +688,7 @@ mod tests { .id(); let child = app - .world + .world_mut() .spawn(( Transform::default() .with_rotation(Quat::from_rotation_z(-std::f32::consts::FRAC_PI_2)) @@ -698,10 +698,10 @@ mod tests { )) .id(); - app.world.entity_mut(root).push_children(&[child]); + app.world_mut().entity_mut(root).push_children(&[child]); - let mut state = SystemState::>::new(&mut app.world); - let mut reference_frames = state.get_mut(&mut app.world); + let mut state = SystemState::>::new(app.world_mut()); + let mut reference_frames = state.get_mut(app.world_mut()); propagate_origin_to_child(root, &mut reference_frames, child); diff --git a/src/reference_frame/mod.rs b/src/reference_frame/mod.rs index 16b0d72..3d90b42 100644 --- a/src/reference_frame/mod.rs +++ b/src/reference_frame/mod.rs @@ -34,7 +34,7 @@ pub mod propagation; /// the same rotating reference frame, instead of moving rapidly through space around a star, or /// worse, around the center of the galaxy. #[derive(Debug, Clone, Reflect, Component)] -pub struct ReferenceFrame { +pub struct ReferenceFrame { /// The high-precision position of the floating origin's current grid cell local to this /// reference frame. local_floating_origin: LocalFloatingOrigin

, diff --git a/src/tests.rs b/src/tests.rs index b1c9a04..509ea3f 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -8,7 +8,7 @@ fn changing_floating_origin_updates_global_transform() { app.add_plugins(BigSpacePlugin::::default()); let first = app - .world + .world_mut() .spawn(( TransformBundle::from_transform(Transform::from_translation(Vec3::new( 150.0, 0.0, 0.0, @@ -19,7 +19,7 @@ fn changing_floating_origin_updates_global_transform() { .id(); let second = app - .world + .world_mut() .spawn(( TransformBundle::from_transform(Transform::from_translation(Vec3::new( 0.0, 0.0, 300.0, @@ -28,18 +28,18 @@ fn changing_floating_origin_updates_global_transform() { )) .id(); - app.world + app.world_mut() .spawn(BigSpaceRootBundle::::default()) .push_children(&[first, second]); app.update(); - app.world.entity_mut(first).remove::(); - app.world.entity_mut(second).insert(FloatingOrigin); + app.world_mut().entity_mut(first).remove::(); + app.world_mut().entity_mut(second).insert(FloatingOrigin); app.update(); - let second_global_transform = app.world.get::(second).unwrap(); + let second_global_transform = app.world_mut().get::(second).unwrap(); assert_eq!( second_global_transform.translation(), @@ -53,7 +53,7 @@ fn child_global_transforms_are_updated_when_floating_origin_changes() { app.add_plugins(BigSpacePlugin::::default()); let first = app - .world + .world_mut() .spawn(( TransformBundle::from_transform(Transform::from_translation(Vec3::new( 150.0, 0.0, 0.0, @@ -64,7 +64,7 @@ fn child_global_transforms_are_updated_when_floating_origin_changes() { .id(); let second = app - .world + .world_mut() .spawn(( TransformBundle::from_transform(Transform::from_translation(Vec3::new( 0.0, 0.0, 300.0, @@ -78,19 +78,19 @@ fn child_global_transforms_are_updated_when_floating_origin_changes() { }) .id(); - app.world + app.world_mut() .spawn(BigSpaceRootBundle::::default()) .push_children(&[first, second]); app.update(); - app.world.entity_mut(first).remove::(); - app.world.entity_mut(second).insert(FloatingOrigin); + app.world_mut().entity_mut(first).remove::(); + app.world_mut().entity_mut(second).insert(FloatingOrigin); app.update(); - let child = app.world.get::(second).unwrap()[0]; - let child_transform = app.world.get::(child).unwrap(); + let child = app.world_mut().get::(second).unwrap()[0]; + let child_transform = app.world_mut().get::(child).unwrap(); assert_eq!(child_transform.translation(), Vec3::new(0.0, 0.0, 600.0)); }