mirror of
https://github.com/eliasstepanik/big_space_with_trim.git
synced 2026-01-11 00:08:27 +00:00
Dependency Reduction (#23)
This commit is contained in:
parent
8721911b49
commit
27801da98c
23
Cargo.toml
23
Cargo.toml
@ -8,10 +8,20 @@ keywords = ["bevy", "floating-origin", "large-scale", "space"]
|
|||||||
repository = "https://github.com/aevyrie/big_space"
|
repository = "https://github.com/aevyrie/big_space"
|
||||||
documentation = "https://docs.rs/crate/big_space/latest"
|
documentation = "https://docs.rs/crate/big_space/latest"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = { version = "0.13", default_features = false }
|
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 }
|
||||||
|
# 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 }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bevy = { version = "0.13", default-features = false, features = [
|
bevy = { version = "0.13", default-features = false, features = [
|
||||||
@ -21,19 +31,18 @@ bevy = { version = "0.13", default-features = false, features = [
|
|||||||
"default_font",
|
"default_font",
|
||||||
"bevy_ui",
|
"bevy_ui",
|
||||||
"bevy_pbr",
|
"bevy_pbr",
|
||||||
|
"bevy_gizmos",
|
||||||
"x11",
|
"x11",
|
||||||
"tonemapping_luts",
|
"tonemapping_luts",
|
||||||
"multi-threaded",
|
"multi-threaded",
|
||||||
] }
|
] }
|
||||||
bevy-inspector-egui = "0.24"
|
bevy-inspector-egui = "0.24"
|
||||||
bevy_framepace = { version = "0.15", default-features = false }
|
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["debug", "camera", "bevy_render"]
|
default = ["debug", "camera", "bevy_render"]
|
||||||
debug = ["bevy/bevy_gizmos"]
|
debug = ["bevy_gizmos", "bevy_render"]
|
||||||
bevy_render = ["bevy/bevy_render"]
|
camera = ["bevy_render", "bevy_time", "bevy_input"]
|
||||||
camera = ["bevy_render"]
|
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "demo"
|
name = "demo"
|
||||||
|
|||||||
@ -18,7 +18,6 @@ fn main() {
|
|||||||
big_space::BigSpacePlugin::<i128>::default(),
|
big_space::BigSpacePlugin::<i128>::default(),
|
||||||
big_space::debug::FloatingOriginDebugPlugin::<i128>::default(),
|
big_space::debug::FloatingOriginDebugPlugin::<i128>::default(),
|
||||||
big_space::camera::CameraControllerPlugin::<i128>::default(),
|
big_space::camera::CameraControllerPlugin::<i128>::default(),
|
||||||
bevy_framepace::FramepacePlugin,
|
|
||||||
))
|
))
|
||||||
.insert_resource(ClearColor(Color::BLACK))
|
.insert_resource(ClearColor(Color::BLACK))
|
||||||
.add_systems(Startup, (setup, ui_setup))
|
.add_systems(Startup, (setup, ui_setup))
|
||||||
|
|||||||
@ -1,22 +1,24 @@
|
|||||||
//! Component bundles for big_space.
|
//! Component bundles for big_space.
|
||||||
|
|
||||||
use crate::{precision::GridPrecision, reference_frame::ReferenceFrame, BigSpace, GridCell};
|
use crate::{precision::GridPrecision, reference_frame::ReferenceFrame, BigSpace, GridCell};
|
||||||
use bevy::prelude::*;
|
|
||||||
|
use bevy_ecs::prelude::*;
|
||||||
|
use bevy_transform::prelude::*;
|
||||||
|
|
||||||
/// Minimal bundle needed to position an entity in floating origin space.
|
/// Minimal bundle needed to position an entity in floating origin space.
|
||||||
///
|
///
|
||||||
/// This is the floating origin equivalent of the [`bevy::prelude::SpatialBundle`].
|
/// This is the floating origin equivalent of the `bevy` `SpatialBundle`.
|
||||||
#[derive(Bundle, Default)]
|
#[derive(Bundle, Default)]
|
||||||
pub struct BigSpatialBundle<P: GridPrecision> {
|
pub struct BigSpatialBundle<P: GridPrecision> {
|
||||||
/// The visibility of the entity.
|
/// The visibility of the entity.
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
pub visibility: Visibility,
|
pub visibility: bevy_render::view::Visibility,
|
||||||
/// The inherited visibility of the entity.
|
/// The inherited visibility of the entity.
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
pub inherited: InheritedVisibility,
|
pub inherited: bevy_render::view::InheritedVisibility,
|
||||||
/// The view visibility of the entity.
|
/// The view visibility of the entity.
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
pub view: ViewVisibility,
|
pub view: bevy_render::view::ViewVisibility,
|
||||||
/// The transform of the entity.
|
/// The transform of the entity.
|
||||||
pub transform: Transform,
|
pub transform: Transform,
|
||||||
/// The global transform of the entity.
|
/// The global transform of the entity.
|
||||||
@ -25,21 +27,21 @@ pub struct BigSpatialBundle<P: GridPrecision> {
|
|||||||
pub cell: GridCell<P>,
|
pub cell: GridCell<P>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A [`SpatialBundle`] that also has a reference frame, allowing other high precision spatial
|
/// A `SpatialBundle` that also has a reference frame, allowing other high precision spatial bundles
|
||||||
/// bundles to be nested within that reference frame.
|
/// to be nested within that reference frame.
|
||||||
///
|
///
|
||||||
/// This is the floating origin equivalent of the [`SpatialBundle`].
|
/// This is the floating origin equivalent of the `bevy` `SpatialBundle`.
|
||||||
#[derive(Bundle, Default)]
|
#[derive(Bundle, Default)]
|
||||||
pub struct BigReferenceFrameBundle<P: GridPrecision> {
|
pub struct BigReferenceFrameBundle<P: GridPrecision> {
|
||||||
/// The visibility of the entity.
|
/// The visibility of the entity.
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
pub visibility: Visibility,
|
pub visibility: bevy_render::view::Visibility,
|
||||||
/// The inherited visibility of the entity.
|
/// The inherited visibility of the entity.
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
pub inherited: InheritedVisibility,
|
pub inherited: bevy_render::view::InheritedVisibility,
|
||||||
/// The view visibility of the entity.
|
/// The view visibility of the entity.
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
pub view: ViewVisibility,
|
pub view: bevy_render::view::ViewVisibility,
|
||||||
/// The transform of the entity.
|
/// The transform of the entity.
|
||||||
pub transform: Transform,
|
pub transform: Transform,
|
||||||
/// The global transform of the entity for rendering, computed relative to the floating origin.
|
/// The global transform of the entity for rendering, computed relative to the floating origin.
|
||||||
@ -55,13 +57,13 @@ pub struct BigReferenceFrameBundle<P: GridPrecision> {
|
|||||||
pub struct BigSpaceRootBundle<P: GridPrecision> {
|
pub struct BigSpaceRootBundle<P: GridPrecision> {
|
||||||
/// The visibility of the entity.
|
/// The visibility of the entity.
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
pub visibility: Visibility,
|
pub visibility: bevy_render::view::Visibility,
|
||||||
/// The inherited visibility of the entity.
|
/// The inherited visibility of the entity.
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
pub inherited: InheritedVisibility,
|
pub inherited: bevy_render::view::InheritedVisibility,
|
||||||
/// The view visibility of the entity.
|
/// The view visibility of the entity.
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
pub view: ViewVisibility,
|
pub view: bevy_render::view::ViewVisibility,
|
||||||
/// The root reference frame
|
/// The root reference frame
|
||||||
pub reference_frame: ReferenceFrame<P>,
|
pub reference_frame: ReferenceFrame<P>,
|
||||||
/// Tracks the current floating origin
|
/// Tracks the current floating origin
|
||||||
|
|||||||
@ -2,14 +2,16 @@
|
|||||||
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use bevy::{
|
use bevy_app::prelude::*;
|
||||||
input::mouse::MouseMotion,
|
use bevy_ecs::prelude::*;
|
||||||
math::{DQuat, DVec3},
|
use bevy_hierarchy::prelude::*;
|
||||||
prelude::*,
|
use bevy_input::{mouse::MouseMotion, prelude::*};
|
||||||
render::{primitives::Aabb, view::RenderLayers},
|
use bevy_math::{prelude::*, DQuat, DVec3};
|
||||||
transform::TransformSystem,
|
use bevy_reflect::prelude::*;
|
||||||
utils::hashbrown::HashSet,
|
use bevy_render::{primitives::Aabb, view::RenderLayers};
|
||||||
};
|
use bevy_time::prelude::*;
|
||||||
|
use bevy_transform::{prelude::*, TransformSystem};
|
||||||
|
use bevy_utils::HashSet;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
precision::GridPrecision, reference_frame::local_origin::ReferenceFrames,
|
precision::GridPrecision, reference_frame::local_origin::ReferenceFrames,
|
||||||
@ -130,7 +132,7 @@ impl CameraInput {
|
|||||||
pub fn reset(&mut self) {
|
pub fn reset(&mut self) {
|
||||||
*self = CameraInput {
|
*self = CameraInput {
|
||||||
defaults_disabled: self.defaults_disabled,
|
defaults_disabled: self.defaults_disabled,
|
||||||
..default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use crate::{reference_frame::ReferenceFrame, *};
|
use crate::{reference_frame::ReferenceFrame, *};
|
||||||
use bevy::prelude::*;
|
|
||||||
|
|
||||||
use self::precision::GridPrecision;
|
use self::precision::GridPrecision;
|
||||||
|
|
||||||
@ -25,11 +24,11 @@ impl<P: GridPrecision> BigSpaceCommands<P> for Commands<'_, '_> {
|
|||||||
) {
|
) {
|
||||||
let mut entity_commands = self.spawn((
|
let mut entity_commands = self.spawn((
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
Visibility::default(),
|
bevy_render::view::Visibility::default(),
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
InheritedVisibility::default(),
|
bevy_render::view::InheritedVisibility::default(),
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
ViewVisibility::default(),
|
bevy_render::view::ViewVisibility::default(),
|
||||||
BigSpace::default(),
|
BigSpace::default(),
|
||||||
));
|
));
|
||||||
let mut cmd = ReferenceFrameCommands {
|
let mut cmd = ReferenceFrameCommands {
|
||||||
@ -70,11 +69,11 @@ impl<'a, P: GridPrecision> ReferenceFrameCommands<'a, P> {
|
|||||||
let entity = commands
|
let entity = commands
|
||||||
.spawn((
|
.spawn((
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
Visibility::default(),
|
bevy_render::view::Visibility::default(),
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
InheritedVisibility::default(),
|
bevy_render::view::InheritedVisibility::default(),
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
ViewVisibility::default(),
|
bevy_render::view::ViewVisibility::default(),
|
||||||
Transform::default(),
|
Transform::default(),
|
||||||
GlobalTransform::default(),
|
GlobalTransform::default(),
|
||||||
GridCell::<P>::default(),
|
GridCell::<P>::default(),
|
||||||
@ -136,11 +135,11 @@ impl<'a, P: GridPrecision> ReferenceFrameCommands<'a, P> {
|
|||||||
let entity = commands
|
let entity = commands
|
||||||
.spawn((
|
.spawn((
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
Visibility::default(),
|
bevy_render::view::Visibility::default(),
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
InheritedVisibility::default(),
|
bevy_render::view::InheritedVisibility::default(),
|
||||||
#[cfg(feature = "bevy_render")]
|
#[cfg(feature = "bevy_render")]
|
||||||
ViewVisibility::default(),
|
bevy_render::view::ViewVisibility::default(),
|
||||||
Transform::default(),
|
Transform::default(),
|
||||||
GlobalTransform::default(),
|
GlobalTransform::default(),
|
||||||
GridCell::<P>::default(),
|
GridCell::<P>::default(),
|
||||||
|
|||||||
@ -2,7 +2,12 @@
|
|||||||
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
|
use bevy_ecs::prelude::*;
|
||||||
|
use bevy_gizmos::prelude::*;
|
||||||
|
use bevy_math::prelude::*;
|
||||||
|
use bevy_render::prelude::*;
|
||||||
|
use bevy_transform::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
precision::GridPrecision,
|
precision::GridPrecision,
|
||||||
@ -19,7 +24,7 @@ impl<P: GridPrecision> Plugin for FloatingOriginDebugPlugin<P> {
|
|||||||
PostUpdate,
|
PostUpdate,
|
||||||
(update_debug_bounds::<P>, update_reference_frame_axes::<P>)
|
(update_debug_bounds::<P>, update_reference_frame_axes::<P>)
|
||||||
.chain()
|
.chain()
|
||||||
.after(bevy::transform::TransformSystem::TransformPropagate),
|
.after(bevy_transform::TransformSystem::TransformPropagate),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,16 @@
|
|||||||
//! A floating origin for camera-relative rendering, to maximize precision when converting to f32.
|
//! A floating origin for camera-relative rendering, to maximize precision when converting to f32.
|
||||||
|
|
||||||
use bevy::{log::error, prelude::*, reflect::Reflect, utils::hashbrown::HashMap};
|
use bevy_ecs::prelude::*;
|
||||||
|
use bevy_hierarchy::prelude::*;
|
||||||
|
use bevy_log::prelude::*;
|
||||||
|
use bevy_reflect::prelude::*;
|
||||||
|
use bevy_utils::HashMap;
|
||||||
|
|
||||||
/// Marks the entity to use as the floating origin.
|
/// Marks the entity to use as the floating origin.
|
||||||
///
|
///
|
||||||
/// The [`GlobalTransform`] of all entities within this [`BigSpace`] will be computed relative to
|
/// The [`GlobalTransform`](bevy_transform::components::GlobalTransform) of all entities within this
|
||||||
/// this floating origin. There should always be exactly one entity marked with this component
|
/// [`BigSpace`] will be computed relative to this floating origin. There should always be exactly
|
||||||
/// within a [`BigSpace`].
|
/// one entity marked with this component within a [`BigSpace`].
|
||||||
#[derive(Component, Reflect)]
|
#[derive(Component, Reflect)]
|
||||||
pub struct FloatingOrigin;
|
pub struct FloatingOrigin;
|
||||||
|
|
||||||
@ -19,8 +23,9 @@ pub struct FloatingOrigin;
|
|||||||
/// `ReferenceFrame`s, but only one `BigSpace`, at the root.
|
/// `ReferenceFrame`s, but only one `BigSpace`, at the root.
|
||||||
///
|
///
|
||||||
/// Your world can have multiple [`BigSpace`]s, and they will remain completely independent. Each
|
/// Your world can have multiple [`BigSpace`]s, and they will remain completely independent. Each
|
||||||
/// big space uses the floating origin contained within it to compute the [`GlobalTransform`] of all
|
/// big space uses the floating origin contained within it to compute the
|
||||||
/// spatial entities within that `BigSpace`.
|
/// [`GlobalTransform`](bevy_transform::components::GlobalTransform) of all spatial entities within
|
||||||
|
/// that `BigSpace`.
|
||||||
#[derive(Debug, Default, Component, Reflect)]
|
#[derive(Debug, Default, Component, Reflect)]
|
||||||
pub struct BigSpace {
|
pub struct BigSpace {
|
||||||
/// Set the entity to use as the floating origin within this high precision hierarchy.
|
/// Set the entity to use as the floating origin within this high precision hierarchy.
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
//! Contains the grid cell implementation
|
//! Contains the grid cell implementation
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
|
use bevy_reflect::prelude::*;
|
||||||
|
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
|
|||||||
16
src/lib.rs
16
src/lib.rs
@ -1,5 +1,5 @@
|
|||||||
//! This [`bevy`] plugin makes it possible to build high-precision worlds that exceed the size of
|
//! This `bevy` plugin makes it possible to build high-precision worlds that exceed the size of the
|
||||||
//! the observable universe, with no added dependencies, while remaining largely compatible with the
|
//! observable universe, with no added dependencies, while remaining largely compatible with the
|
||||||
//! rest of the Bevy ecosystem.
|
//! rest of the Bevy ecosystem.
|
||||||
//!
|
//!
|
||||||
//! The next section explains the problem this solves in more detail, how this plugin works, and a
|
//! The next section explains the problem this solves in more detail, how this plugin works, and a
|
||||||
@ -55,9 +55,9 @@
|
|||||||
//! multiplayer - the server needs a source of truth for position that doesn't drift over time.
|
//! multiplayer - the server needs a source of truth for position that doesn't drift over time.
|
||||||
//! - Virtually limitless volume and scale; you can work at the scale of subatomic particles, across
|
//! - Virtually limitless volume and scale; you can work at the scale of subatomic particles, across
|
||||||
//! the width of the observable universe. Double precision is downright suffocating in comparison.
|
//! the width of the observable universe. Double precision is downright suffocating in comparison.
|
||||||
//! - Uniform precision across the play area. Unlike double precision, the available precision
|
//! - Uniform precision across the play area. Unlike double precision, the available precision does
|
||||||
//! does not decrease as you move to the edge of the play area, it is instead relative to the
|
//! not decrease as you move to the edge of the play area, it is instead relative to the distance
|
||||||
//! distance from the origin of the current grid cell.
|
//! from the origin of the current grid cell.
|
||||||
//! - High precision coordinates are invisible if you don't need them. You can move objects using
|
//! - High precision coordinates are invisible if you don't need them. You can move objects using
|
||||||
//! their `Transform` alone, which results in decent ecosystem compatibility.
|
//! their `Transform` alone, which results in decent ecosystem compatibility.
|
||||||
//! - High precision is completely opt-in. If you don't add the `GridCell` component to an entity,
|
//! - High precision is completely opt-in. If you don't add the `GridCell` component to an entity,
|
||||||
@ -179,6 +179,10 @@
|
|||||||
#![allow(clippy::type_complexity)]
|
#![allow(clippy::type_complexity)]
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
|
use bevy_ecs::prelude::*;
|
||||||
|
use bevy_hierarchy::prelude::*;
|
||||||
|
use bevy_transform::prelude::*;
|
||||||
|
|
||||||
pub mod bundles;
|
pub mod bundles;
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
pub mod floating_origins;
|
pub mod floating_origins;
|
||||||
@ -196,8 +200,6 @@ pub mod debug;
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
|
||||||
|
|
||||||
pub use bundles::{BigReferenceFrameBundle, BigSpaceRootBundle, BigSpatialBundle};
|
pub use bundles::{BigReferenceFrameBundle, BigSpaceRootBundle, BigSpatialBundle};
|
||||||
pub use commands::{BigSpaceCommands, ReferenceFrameCommands, SpatialEntityCommands};
|
pub use commands::{BigSpaceCommands, ReferenceFrameCommands, SpatialEntityCommands};
|
||||||
pub use floating_origins::{BigSpace, FloatingOrigin};
|
pub use floating_origins::{BigSpace, FloatingOrigin};
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
//! The bevy plugin for big_space.
|
//! The bevy plugin for big_space.
|
||||||
|
|
||||||
use bevy::{prelude::*, transform::TransformSystem};
|
use bevy_app::prelude::*;
|
||||||
|
use bevy_ecs::prelude::*;
|
||||||
|
use bevy_reflect::prelude::*;
|
||||||
|
use bevy_transform::{prelude::*, TransformSystem};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -100,16 +103,16 @@ impl<P: GridPrecision + Reflect + FromReflect + TypePath> Plugin for BigSpacePlu
|
|||||||
.add_systems(
|
.add_systems(
|
||||||
PostStartup,
|
PostStartup,
|
||||||
(
|
(
|
||||||
bevy::transform::systems::sync_simple_transforms,
|
bevy_transform::systems::sync_simple_transforms,
|
||||||
bevy::transform::systems::propagate_transforms,
|
bevy_transform::systems::propagate_transforms,
|
||||||
)
|
)
|
||||||
.in_set(TransformSystem::TransformPropagate),
|
.in_set(TransformSystem::TransformPropagate),
|
||||||
)
|
)
|
||||||
.add_systems(
|
.add_systems(
|
||||||
PostUpdate,
|
PostUpdate,
|
||||||
(
|
(
|
||||||
bevy::transform::systems::sync_simple_transforms,
|
bevy_transform::systems::sync_simple_transforms,
|
||||||
bevy::transform::systems::propagate_transforms,
|
bevy_transform::systems::propagate_transforms,
|
||||||
)
|
)
|
||||||
.in_set(TransformSystem::TransformPropagate),
|
.in_set(TransformSystem::TransformPropagate),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use std::{hash::Hash, ops::Add};
|
use std::{hash::Hash, ops::Add};
|
||||||
|
|
||||||
use bevy::reflect::Reflect;
|
use bevy_reflect::Reflect;
|
||||||
|
|
||||||
/// Used to make the floating origin plugin generic over many grid sizes.
|
/// Used to make the floating origin plugin generic over many grid sizes.
|
||||||
///
|
///
|
||||||
|
|||||||
@ -2,19 +2,17 @@
|
|||||||
//! frames, and used to compute the floating origin's position relative to each reference frame. See
|
//! frames, and used to compute the floating origin's position relative to each reference frame. See
|
||||||
//! [`LocalFloatingOrigin`].
|
//! [`LocalFloatingOrigin`].
|
||||||
|
|
||||||
use bevy::{
|
use bevy_ecs::{
|
||||||
ecs::{
|
prelude::*,
|
||||||
prelude::*,
|
system::{
|
||||||
system::{
|
lifetimeless::{Read, Write},
|
||||||
lifetimeless::{Read, Write},
|
SystemParam,
|
||||||
SystemParam,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
hierarchy::prelude::*,
|
|
||||||
log::prelude::*,
|
|
||||||
math::{prelude::*, DAffine3, DQuat},
|
|
||||||
transform::prelude::*,
|
|
||||||
};
|
};
|
||||||
|
use bevy_hierarchy::prelude::*;
|
||||||
|
use bevy_log::prelude::*;
|
||||||
|
use bevy_math::{prelude::*, DAffine3, DQuat};
|
||||||
|
use bevy_transform::prelude::*;
|
||||||
|
|
||||||
pub use inner::LocalFloatingOrigin;
|
pub use inner::LocalFloatingOrigin;
|
||||||
|
|
||||||
@ -24,17 +22,15 @@ use super::ReferenceFrame;
|
|||||||
|
|
||||||
/// A module kept private to enforce use of setters and getters within the parent module.
|
/// A module kept private to enforce use of setters and getters within the parent module.
|
||||||
mod inner {
|
mod inner {
|
||||||
use bevy::{
|
use bevy_math::{prelude::*, DAffine3, DMat3, DQuat};
|
||||||
math::{prelude::*, DAffine3, DMat3, DQuat},
|
use bevy_reflect::prelude::*;
|
||||||
reflect::prelude::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{precision::GridPrecision, GridCell};
|
use crate::{precision::GridPrecision, GridCell};
|
||||||
|
|
||||||
/// An isometry that describes the location of the floating origin's grid cell's origin, in the
|
/// An isometry that describes the location of the floating origin's grid cell's origin, in the
|
||||||
/// local reference frame.
|
/// local reference frame.
|
||||||
///
|
///
|
||||||
/// Used to compute the [`GlobalTransform`](bevy::transform::components::GlobalTransform) of
|
/// Used to compute the [`GlobalTransform`](bevy_transform::components::GlobalTransform) of
|
||||||
/// every entity within a reference frame. Because this tells us where the floating origin cell
|
/// every entity within a reference frame. Because this tells us where the floating origin cell
|
||||||
/// is located in the local frame, we can compute the inverse transform once, then use it to
|
/// is located in the local frame, we can compute the inverse transform once, then use it to
|
||||||
/// transform every entity relative to the floating origin.
|
/// transform every entity relative to the floating origin.
|
||||||
@ -633,7 +629,7 @@ mod tests {
|
|||||||
Vec3::new(5.0, 5.0, 0.0),
|
Vec3::new(5.0, 5.0, 0.0),
|
||||||
DQuat::from_rotation_z(-std::f64::consts::FRAC_PI_2),
|
DQuat::from_rotation_z(-std::f64::consts::FRAC_PI_2),
|
||||||
),
|
),
|
||||||
..default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
.id();
|
.id();
|
||||||
|
|||||||
@ -2,12 +2,10 @@
|
|||||||
//! through space together, like entities on a planet, rotating about the planet's axis, and,
|
//! through space together, like entities on a planet, rotating about the planet's axis, and,
|
||||||
//! orbiting a star.
|
//! orbiting a star.
|
||||||
|
|
||||||
use bevy::{
|
use bevy_ecs::prelude::*;
|
||||||
ecs::prelude::*,
|
use bevy_math::{prelude::*, Affine3A, DAffine3, DVec3};
|
||||||
math::{Affine3A, DAffine3, DVec3, Vec3},
|
use bevy_reflect::prelude::*;
|
||||||
reflect::Reflect,
|
use bevy_transform::prelude::*;
|
||||||
transform::prelude::*,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{precision::GridPrecision, GridCell};
|
use crate::{precision::GridPrecision, GridCell};
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
//! Logic for propagating transforms through the hierarchy of reference frames.
|
//! Logic for propagating transforms through the hierarchy of reference frames.
|
||||||
|
|
||||||
|
use bevy_ecs::prelude::*;
|
||||||
|
use bevy_hierarchy::prelude::*;
|
||||||
|
use bevy_transform::prelude::*;
|
||||||
|
|
||||||
use crate::{precision::GridPrecision, reference_frame::ReferenceFrame, GridCell};
|
use crate::{precision::GridPrecision, reference_frame::ReferenceFrame, GridCell};
|
||||||
use bevy::prelude::*;
|
|
||||||
|
|
||||||
impl<P: GridPrecision> ReferenceFrame<P> {
|
impl<P: GridPrecision> ReferenceFrame<P> {
|
||||||
/// Update the `GlobalTransform` of entities with a [`GridCell`], using the [`ReferenceFrame`]
|
/// Update the `GlobalTransform` of entities with a [`GridCell`], using the [`ReferenceFrame`]
|
||||||
|
|||||||
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy::utils::HashMap;
|
use bevy_hierarchy::prelude::*;
|
||||||
|
use bevy_log::prelude::*;
|
||||||
|
use bevy_transform::prelude::*;
|
||||||
|
use bevy_utils::HashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
precision::GridPrecision, reference_frame::ReferenceFrame, BigSpace, FloatingOrigin, GridCell,
|
precision::GridPrecision, reference_frame::ReferenceFrame, BigSpace, FloatingOrigin, GridCell,
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
//! A helper query argument that ensures you don't forget to handle
|
//! A helper query argument that ensures you don't forget to handle
|
||||||
//! the [`GridCell`] when you work with a [`Transform`].
|
//! the [`GridCell`] when you work with a [`Transform`].
|
||||||
|
|
||||||
use bevy::ecs::query::QueryData;
|
use bevy_ecs::query::QueryData;
|
||||||
use bevy::math::DVec3;
|
use bevy_math::{prelude::*, DVec3};
|
||||||
use bevy::prelude::*;
|
use bevy_transform::prelude::*;
|
||||||
|
|
||||||
use crate::GridCell;
|
use crate::GridCell;
|
||||||
use crate::{precision::GridPrecision, reference_frame::ReferenceFrame};
|
use crate::{precision::GridPrecision, reference_frame::ReferenceFrame};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user