Skip to content

Commit

Permalink
Merge branch 'main' into capsule-2d-mesh
Browse files Browse the repository at this point in the history
  • Loading branch information
Jondolf authored Feb 1, 2024
2 parents 611f844 + 6f2eec8 commit f115448
Show file tree
Hide file tree
Showing 31 changed files with 857 additions and 403 deletions.
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/iteration/iter_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();

// TODO: batch this
for _ in 0..10_000 {
world.spawn((
world.spawn_batch(
std::iter::repeat((
Transform(Mat4::from_scale(Vec3::ONE)),
Position(Vec3::X),
Rotation(Vec3::X),
Velocity(Vec3::X),
));
}
))
.take(10_000),
);

let query = world.query::<(&Velocity, &mut Position)>();
Self(world, query)
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/iteration/iter_simple_foreach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();

// TODO: batch this
for _ in 0..10_000 {
world.spawn((
world.spawn_batch(
std::iter::repeat((
Transform(Mat4::from_scale(Vec3::ONE)),
Position(Vec3::X),
Rotation(Vec3::X),
Velocity(Vec3::X),
));
}
))
.take(10_000),
);

let query = world.query::<(&Velocity, &mut Position)>();
Self(world, query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();

// TODO: batch this
for _ in 0..10_000 {
world.spawn((
world.spawn_batch(
std::iter::repeat((
Transform(Mat4::from_scale(Vec3::ONE)),
Position(Vec3::X),
Rotation(Vec3::X),
Velocity(Vec3::X),
));
}
))
.take(10_000),
);

let query = world.query::<(&Velocity, &mut Position)>();
Self(world, query)
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/iteration/iter_simple_foreach_wide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();

// TODO: batch this
for _ in 0..10_000 {
world.spawn((
world.spawn_batch(
std::iter::repeat((
Transform(Mat4::from_scale(Vec3::ONE)),
Rotation(Vec3::X),
Position::<0>(Vec3::X),
Expand All @@ -48,8 +47,9 @@ impl<'w> Benchmark<'w> {
Velocity::<3>(Vec3::X),
Position::<4>(Vec3::X),
Velocity::<4>(Vec3::X),
));
}
))
.take(10_000),
);

let query = world.query();
Self(world, query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();

// TODO: batch this
for _ in 0..10_000 {
world.spawn((
world.spawn_batch(
std::iter::repeat((
Transform(Mat4::from_scale(Vec3::ONE)),
Rotation(Vec3::X),
Position::<0>(Vec3::X),
Expand All @@ -50,8 +49,9 @@ impl<'w> Benchmark<'w> {
Velocity::<3>(Vec3::X),
Position::<4>(Vec3::X),
Velocity::<4>(Vec3::X),
));
}
))
.take(10_000),
);

let query = world.query();
Self(world, query)
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/iteration/iter_simple_sparse_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();

// TODO: batch this
for _ in 0..10_000 {
world.spawn((
world.spawn_batch(
std::iter::repeat((
Transform(Mat4::from_scale(Vec3::ONE)),
Position(Vec3::X),
Rotation(Vec3::X),
Velocity(Vec3::X),
));
}
))
.take(10_000),
);

let query = world.query::<(&Velocity, &mut Position)>();
Self(world, query)
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/iteration/iter_simple_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ impl Benchmark {
pub fn new() -> Self {
let mut world = World::new();

// TODO: batch this
for _ in 0..10_000 {
world.spawn((
world.spawn_batch(
std::iter::repeat((
Transform(Mat4::from_scale(Vec3::ONE)),
Position(Vec3::X),
Rotation(Vec3::X),
Velocity(Vec3::X),
));
}
))
.take(10_000),
);

fn query_system(mut query: Query<(&Velocity, &mut Position)>) {
for (velocity, mut position) in &mut query {
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_ecs/iteration/iter_simple_wide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();

// TODO: batch this
for _ in 0..10_000 {
world.spawn((
world.spawn_batch(
std::iter::repeat((
Transform(Mat4::from_scale(Vec3::ONE)),
Rotation(Vec3::X),
Position::<0>(Vec3::X),
Expand All @@ -48,8 +47,9 @@ impl<'w> Benchmark<'w> {
Velocity::<3>(Vec3::X),
Position::<4>(Vec3::X),
Velocity::<4>(Vec3::X),
));
}
))
.take(10_000),
);

let query = world.query();
Self(world, query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ impl<'w> Benchmark<'w> {
pub fn new() -> Self {
let mut world = World::new();

// TODO: batch this
for _ in 0..10_000 {
world.spawn((
world.spawn_batch(
std::iter::repeat((
Transform(Mat4::from_scale(Vec3::ONE)),
Rotation(Vec3::X),
Position::<0>(Vec3::X),
Expand All @@ -50,8 +49,9 @@ impl<'w> Benchmark<'w> {
Velocity::<3>(Vec3::X),
Position::<4>(Vec3::X),
Velocity::<4>(Vec3::X),
));
}
))
.take(10_000),
);

let query = world.query();
Self(world, query)
Expand Down
11 changes: 10 additions & 1 deletion crates/bevy_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub mod prelude {
}

use bevy_app::prelude::*;
use bevy_ecs::component::{ComponentId, ComponentTicks, Tick};
use bevy_ecs::prelude::*;
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
use bevy_utils::{Duration, HashSet, Instant, Uuid};
Expand All @@ -40,13 +41,21 @@ pub struct TypeRegistrationPlugin;

impl Plugin for TypeRegistrationPlugin {
fn build(&self, app: &mut App) {
app.register_type::<Entity>().register_type::<Name>();
app.register_type::<Name>();

register_ecs_types(app);
register_rust_types(app);
register_math_types(app);
}
}

fn register_ecs_types(app: &mut App) {
app.register_type::<Entity>()
.register_type::<ComponentId>()
.register_type::<Tick>()
.register_type::<ComponentTicks>();
}

fn register_rust_types(app: &mut App) {
app.register_type::<Range<f32>>()
.register_type_data::<Range<f32>, ReflectSerialize>()
Expand Down
9 changes: 9 additions & 0 deletions crates/bevy_ecs/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use crate::{
};
pub use bevy_ecs_macros::Component;
use bevy_ptr::{OwningPtr, UnsafeCellDeref};
#[cfg(feature = "bevy_reflect")]
use bevy_reflect::Reflect;
use std::cell::UnsafeCell;
use std::{
alloc::Layout,
Expand Down Expand Up @@ -287,6 +289,11 @@ impl ComponentInfo {
/// from a `World` using [`World::component_id()`] or via [`Components::component_id()`]. Access
/// to the `ComponentId` for a [`Resource`] is available via [`Components::resource_id()`].
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
#[cfg_attr(
feature = "bevy_reflect",
derive(Reflect),
reflect(Debug, Hash, PartialEq)
)]
pub struct ComponentId(usize);

impl ComponentId {
Expand Down Expand Up @@ -670,6 +677,7 @@ impl Components {
/// A value that tracks when a system ran relative to other systems.
/// This is used to power change detection.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug, PartialEq))]
pub struct Tick {
tick: u32,
}
Expand Down Expand Up @@ -763,6 +771,7 @@ impl<'a> TickCells<'a> {

/// Records when a component was added and when it was last mutably dereferenced (or added).
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Debug))]
pub struct ComponentTicks {
pub(crate) added: Tick,
pub(crate) changed: Tick,
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_math/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ keywords = ["bevy"]
[dependencies]
glam = { version = "0.25", features = ["bytemuck"] }
serde = { version = "1", features = ["derive"], optional = true }
approx = { version = "0.5", optional = true }

[dev-dependencies]
approx = "0.5"

[features]
serialize = ["dep:serde", "glam/serde"]
# Enable approx for glam types to approximate floating point equality comparisons and assertions
approx = ["glam/approx"]
approx = ["dep:approx", "glam/approx"]
# Enable interoperation of glam types with mint-compatible libraries
mint = ["glam/mint"]
# Enable libm mathematical functions for glam types to ensure consistent outputs
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_math/src/bounding/raytest2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{Aabb2d, BoundingCircle, IntersectsVolume};
use crate::{primitives::Direction2d, Ray2d, Vec2};

/// A raycast intersection test for 2D bounding volumes
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct RayTest2d {
/// The ray for the test
pub ray: Ray2d,
Expand Down Expand Up @@ -99,7 +99,7 @@ impl IntersectsVolume<BoundingCircle> for RayTest2d {
}

/// An intersection test that casts an [`Aabb2d`] along a ray.
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct AabbCast2d {
/// The ray along which to cast the bounding volume
pub ray: RayTest2d,
Expand Down Expand Up @@ -136,7 +136,7 @@ impl IntersectsVolume<Aabb2d> for AabbCast2d {
}

/// An intersection test that casts a [`BoundingCircle`] along a ray.
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct BoundingCircleCast {
/// The ray along which to cast the bounding volume
pub ray: RayTest2d,
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_math/src/bounding/raytest3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{Aabb3d, BoundingSphere, IntersectsVolume};
use crate::{primitives::Direction3d, Ray3d, Vec3};

/// A raycast intersection test for 3D bounding volumes
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct RayTest3d {
/// The ray for the test
pub ray: Ray3d,
Expand Down Expand Up @@ -106,7 +106,7 @@ impl IntersectsVolume<BoundingSphere> for RayTest3d {
}

/// An intersection test that casts an [`Aabb3d`] along a ray.
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct AabbCast3d {
/// The ray along which to cast the bounding volume
pub ray: RayTest3d,
Expand Down Expand Up @@ -143,7 +143,7 @@ impl IntersectsVolume<Aabb3d> for AabbCast3d {
}

/// An intersection test that casts a [`BoundingSphere`] along a ray.
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct BoundingSphereCast {
/// The ray along which to cast the bounding volume
pub ray: RayTest3d,
Expand Down
Loading

0 comments on commit f115448

Please sign in to comment.