Skip to content

Commit dd60e07

Browse files
authored
Merge branch 'main' into impl-reflect-indexmap
2 parents 989027f + 2ee58ee commit dd60e07

File tree

141 files changed

+869
-735
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+869
-735
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ bevy_sprite_render = [
281281
]
282282

283283
# Provides text functionality
284-
bevy_text = ["bevy_internal/bevy_text", "bevy_asset", "bevy_sprite"]
284+
bevy_text = ["bevy_internal/bevy_text", "bevy_asset"]
285285

286286
# A custom ECS-driven UI framework
287287
bevy_ui = [

benches/benches/bevy_ecs/observers/propagation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ fn add_listeners_to_hierarchy<const DENSITY: usize, const N: usize>(
113113
}
114114
}
115115

116-
fn empty_listener<const N: usize>(trigger: On<TestEvent<N>>) {
117-
black_box(trigger);
116+
fn empty_listener<const N: usize>(event: On<TestEvent<N>>) {
117+
black_box(event);
118118
}

benches/benches/bevy_ecs/observers/simple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ pub fn observe_simple(criterion: &mut Criterion) {
4646
group.finish();
4747
}
4848

49-
fn empty_listener_base(trigger: On<EventBase>) {
50-
black_box(trigger);
49+
fn empty_listener_base(event: On<EventBase>) {
50+
black_box(event);
5151
}
5252

5353
fn send_base_event(world: &mut World, entities: impl TriggerTargets) {

benches/benches/bevy_picking/ray_mesh_intersection.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use core::hint::black_box;
22
use std::time::Duration;
33

44
use benches::bench;
5-
use bevy_math::{Dir3, Mat4, Ray3d, Vec3};
5+
use bevy_math::{Affine3A, Dir3, Ray3d, Vec3};
66
use bevy_picking::mesh_picking::ray_cast::{self, Backfaces};
77
use criterion::{criterion_group, AxisScale, BenchmarkId, Criterion, PlotConfiguration};
88

@@ -103,8 +103,8 @@ impl Benchmarks {
103103
)
104104
}
105105

106-
fn mesh_to_world(&self) -> Mat4 {
107-
Mat4::IDENTITY
106+
fn mesh_to_world(&self) -> Affine3A {
107+
Affine3A::IDENTITY
108108
}
109109

110110
fn backface_culling(&self) -> Backfaces {

crates/bevy_app/src/app.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,8 +1332,8 @@ impl App {
13321332
/// # struct Friend;
13331333
/// #
13341334
///
1335-
/// app.add_observer(|trigger: On<Party>, friends: Query<Entity, With<Friend>>, mut commands: Commands| {
1336-
/// if trigger.event().friends_allowed {
1335+
/// app.add_observer(|event: On<Party>, friends: Query<Entity, With<Friend>>, mut commands: Commands| {
1336+
/// if event.friends_allowed {
13371337
/// for friend in friends.iter() {
13381338
/// commands.trigger_targets(Invite, friend);
13391339
/// }

crates/bevy_asset/src/io/file/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl FileAssetReader {
5252
/// Returns the base path of the assets directory, which is normally the executable's parent
5353
/// directory.
5454
///
55-
/// To change this, set [`AssetPlugin.file_path`].
55+
/// To change this, set [`AssetPlugin::file_path`][crate::AssetPlugin::file_path].
5656
pub fn get_base_path() -> PathBuf {
5757
get_base_path()
5858
}

crates/bevy_camera/src/camera.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use bevy_asset::Handle;
88
use bevy_derive::Deref;
99
use bevy_ecs::{component::Component, entity::Entity, reflect::ReflectComponent};
1010
use bevy_image::Image;
11-
use bevy_math::{ops, Dir3, FloatOrd, Mat4, Ray3d, Rect, URect, UVec2, Vec2, Vec3};
11+
use bevy_math::{ops, Dir3, FloatOrd, Mat4, Ray3d, Rect, URect, UVec2, Vec2, Vec3, Vec3A};
1212
use bevy_reflect::prelude::*;
1313
use bevy_transform::components::{GlobalTransform, Transform};
1414
use bevy_window::{NormalizedWindowRef, WindowRef};
@@ -509,10 +509,10 @@ impl Camera {
509509
.ok_or(ViewportConversionError::InvalidData)?;
510510
// NDC z-values outside of 0 < z < 1 are outside the (implicit) camera frustum and are thus not in viewport-space
511511
if ndc_space_coords.z < 0.0 {
512-
return Err(ViewportConversionError::PastNearPlane);
512+
return Err(ViewportConversionError::PastFarPlane);
513513
}
514514
if ndc_space_coords.z > 1.0 {
515-
return Err(ViewportConversionError::PastFarPlane);
515+
return Err(ViewportConversionError::PastNearPlane);
516516
}
517517

518518
// Flip the Y co-ordinate origin from the bottom to the top.
@@ -547,10 +547,10 @@ impl Camera {
547547
.ok_or(ViewportConversionError::InvalidData)?;
548548
// NDC z-values outside of 0 < z < 1 are outside the (implicit) camera frustum and are thus not in viewport-space
549549
if ndc_space_coords.z < 0.0 {
550-
return Err(ViewportConversionError::PastNearPlane);
550+
return Err(ViewportConversionError::PastFarPlane);
551551
}
552552
if ndc_space_coords.z > 1.0 {
553-
return Err(ViewportConversionError::PastFarPlane);
553+
return Err(ViewportConversionError::PastNearPlane);
554554
}
555555

556556
// Stretching ndc depth to value via near plane and negating result to be in positive room again.
@@ -686,10 +686,10 @@ impl Camera {
686686
Ok(world_near_plane.truncate())
687687
}
688688

689-
/// Given a position in world space, use the camera's viewport to compute the Normalized Device Coordinates.
689+
/// Given a point in world space, use the camera's viewport to compute the Normalized Device Coordinates of the point.
690690
///
691-
/// When the position is within the viewport the values returned will be between -1.0 and 1.0 on the X and Y axes,
692-
/// and between 0.0 and 1.0 on the Z axis.
691+
/// When the point is within the viewport the values returned will be between -1.0 (bottom left) and 1.0 (top right)
692+
/// on the X and Y axes, and between 0.0 (far) and 1.0 (near) on the Z axis.
693693
/// To get the coordinates in the render target's viewport dimensions, you should use
694694
/// [`world_to_viewport`](Self::world_to_viewport).
695695
///
@@ -699,17 +699,16 @@ impl Camera {
699699
/// # Panics
700700
///
701701
/// Will panic if the `camera_transform` contains `NAN` and the `glam_assert` feature is enabled.
702-
pub fn world_to_ndc(
702+
pub fn world_to_ndc<V: Into<Vec3A> + From<Vec3A>>(
703703
&self,
704704
camera_transform: &GlobalTransform,
705-
world_position: Vec3,
706-
) -> Option<Vec3> {
707-
// Build a transformation matrix to convert from world space to NDC using camera data
708-
let clip_from_world: Mat4 =
709-
self.computed.clip_from_view * camera_transform.to_matrix().inverse();
710-
let ndc_space_coords: Vec3 = clip_from_world.project_point3(world_position);
705+
world_point: V,
706+
) -> Option<V> {
707+
let view_from_world = camera_transform.affine().inverse();
708+
let view_point = view_from_world.transform_point3a(world_point.into());
709+
let ndc_point = self.computed.clip_from_view.project_point3a(view_point);
711710

712-
(!ndc_space_coords.is_nan()).then_some(ndc_space_coords)
711+
(!ndc_point.is_nan()).then_some(ndc_point.into())
713712
}
714713

715714
/// Given a position in Normalized Device Coordinates,

crates/bevy_camera/src/projection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub trait CameraProjection {
6868
/// This code is called by [`update_frusta`](crate::visibility::update_frusta) system
6969
/// for each camera to update its frustum.
7070
fn compute_frustum(&self, camera_transform: &GlobalTransform) -> Frustum {
71-
let clip_from_world = self.get_clip_from_view() * camera_transform.to_matrix().inverse();
71+
let clip_from_world = self.get_clip_from_view() * camera_transform.affine().inverse();
7272
Frustum::from_clip_from_world_custom_far(
7373
&clip_from_world,
7474
&camera_transform.translation(),

crates/bevy_color/src/laba.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl From<Xyza> for Laba {
275275
} else {
276276
(Laba::CIE_KAPPA * yr + 16.0) / 116.0
277277
};
278-
let fz = if yr > Laba::CIE_EPSILON {
278+
let fz = if zr > Laba::CIE_EPSILON {
279279
ops::cbrt(zr)
280280
} else {
281281
(Laba::CIE_KAPPA * zr + 16.0) / 116.0

crates/bevy_core_pipeline/src/skybox/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@ impl ExtractComponent for Skybox {
122122
skybox.clone(),
123123
SkyboxUniforms {
124124
brightness: skybox.brightness * exposure,
125-
transform: Transform::from_rotation(skybox.rotation)
126-
.to_matrix()
127-
.inverse(),
125+
transform: Transform::from_rotation(skybox.rotation.inverse()).to_matrix(),
128126
#[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))]
129127
_wasm_padding_8b: 0,
130128
#[cfg(all(feature = "webgl", target_arch = "wasm32", not(feature = "webgpu")))]

0 commit comments

Comments
 (0)