Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
soqb committed Feb 5, 2023
1 parent 3b1054f commit 6663dfc
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_core/src/name.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use bevy_ecs::{
component::Component, entity::Entity, query::WorldQuery, reflect::ReflectComponent,
};
use bevy_reflect::Reflect;
use bevy_reflect::{std_traits::ReflectDefault, FromReflect};
use bevy_reflect::{PartialReflect, Reflect};
use bevy_utils::AHasher;
use std::{
borrow::Cow,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/core_2d/camera_2d.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{clear_color::ClearColorConfig, tonemapping::Tonemapping};
use bevy_ecs::prelude::*;
use bevy_reflect::{PartialReflect, Reflect};
use bevy_reflect::Reflect;
use bevy_render::{
camera::{Camera, CameraProjection, CameraRenderGraph, OrthographicProjection},
extract_component::ExtractComponent,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/core_3d/camera_3d.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{clear_color::ClearColorConfig, tonemapping::Tonemapping};
use bevy_ecs::prelude::*;
use bevy_reflect::{PartialReflect, Reflect, ReflectDeserialize, ReflectSerialize};
use bevy_reflect::{Reflect, ReflectDeserialize, ReflectSerialize};
use bevy_render::{
camera::{Camera, CameraRenderGraph, Projection},
extract_component::ExtractComponent,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_core_pipeline/src/tonemapping/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state;
use bevy_app::prelude::*;
use bevy_asset::{load_internal_asset, HandleUntyped};
use bevy_ecs::prelude::*;
use bevy_reflect::{PartialReflect, Reflect, TypeUuid};
use bevy_reflect::{Reflect, TypeUuid};
use bevy_render::camera::Camera;
use bevy_render::extract_component::{ExtractComponent, ExtractComponentPlugin};
use bevy_render::renderer::RenderDevice;
Expand Down
37 changes: 20 additions & 17 deletions crates/bevy_ecs/src/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use crate::{
},
};
use bevy_reflect::{
impl_from_reflect_value, impl_reflect_value, FromType, PartialReflect, Reflect,
ReflectDeserialize, ReflectSerialize,
impl_from_reflect_value, impl_reflect_value, FromType, PartialReflect, ReflectDeserialize,
ReflectSerialize,
};

/// A struct used to operate on reflected [`Component`] of a type.
Expand Down Expand Up @@ -45,25 +45,25 @@ pub struct ReflectComponent(ReflectComponentFns);
#[derive(Clone)]
pub struct ReflectComponentFns {
/// Function pointer implementing [`ReflectComponent::insert()`].
pub insert: fn(&mut EntityMut, &dyn Reflect),
pub insert: fn(&mut EntityMut, &dyn PartialReflect),
/// Function pointer implementing [`ReflectComponent::apply()`].
pub apply: fn(&mut EntityMut, &dyn Reflect),
pub apply: fn(&mut EntityMut, &dyn PartialReflect),
/// Function pointer implementing [`ReflectComponent::apply_or_insert()`].
pub apply_or_insert: fn(&mut EntityMut, &dyn Reflect),
pub apply_or_insert: fn(&mut EntityMut, &dyn PartialReflect),
/// Function pointer implementing [`ReflectComponent::remove()`].
pub remove: fn(&mut EntityMut),
/// Function pointer implementing [`ReflectComponent::contains()`].
pub contains: fn(EntityRef) -> bool,
/// Function pointer implementing [`ReflectComponent::reflect()`].
pub reflect: fn(EntityRef) -> Option<&dyn Reflect>,
pub reflect: fn(EntityRef) -> Option<&dyn PartialReflect>,
/// Function pointer implementing [`ReflectComponent::reflect_mut()`].
pub reflect_mut: for<'a> fn(&'a mut EntityMut<'_>) -> Option<Mut<'a, dyn Reflect>>,
pub reflect_mut: for<'a> fn(&'a mut EntityMut<'_>) -> Option<Mut<'a, dyn PartialReflect>>,
/// Function pointer implementing [`ReflectComponent::reflect_unchecked_mut()`].
///
/// # Safety
/// The function may only be called with an [`UnsafeWorldCellEntityRef`] that can be used to mutably access the relevant component on the given entity.
pub reflect_unchecked_mut:
unsafe fn(UnsafeWorldCellEntityRef<'_>) -> Option<Mut<'_, dyn Reflect>>,
unsafe fn(UnsafeWorldCellEntityRef<'_>) -> Option<Mut<'_, dyn PartialReflect>>,
/// Function pointer implementing [`ReflectComponent::copy()`].
pub copy: fn(&World, &mut World, Entity, Entity),
}
Expand All @@ -81,7 +81,7 @@ impl ReflectComponentFns {

impl ReflectComponent {
/// Insert a reflected [`Component`] into the entity like [`insert()`](crate::world::EntityMut::insert).
pub fn insert(&self, entity: &mut EntityMut, component: &dyn Reflect) {
pub fn insert(&self, entity: &mut EntityMut, component: &dyn PartialReflect) {
(self.0.insert)(entity, component);
}

Expand All @@ -90,12 +90,12 @@ impl ReflectComponent {
/// # Panics
///
/// Panics if there is no [`Component`] of the given type.
pub fn apply(&self, entity: &mut EntityMut, component: &dyn Reflect) {
pub fn apply(&self, entity: &mut EntityMut, component: &dyn PartialReflect) {
(self.0.apply)(entity, component);
}

/// Uses reflection to set the value of this [`Component`] type in the entity to the given value or insert a new one if it does not exist.
pub fn apply_or_insert(&self, entity: &mut EntityMut, component: &dyn Reflect) {
pub fn apply_or_insert(&self, entity: &mut EntityMut, component: &dyn PartialReflect) {
(self.0.apply_or_insert)(entity, component);
}

Expand All @@ -114,12 +114,15 @@ impl ReflectComponent {
}

/// Gets the value of this [`Component`] type from the entity as a reflected reference.
pub fn reflect<'a>(&self, entity: EntityRef<'a>) -> Option<&'a dyn Reflect> {
pub fn reflect<'a>(&self, entity: EntityRef<'a>) -> Option<&'a dyn PartialReflect> {
(self.0.reflect)(entity)
}

/// Gets the value of this [`Component`] type from the entity as a mutable reflected reference.
pub fn reflect_mut<'a>(&self, entity: &'a mut EntityMut<'_>) -> Option<Mut<'a, dyn Reflect>> {
pub fn reflect_mut<'a>(
&self,
entity: &'a mut EntityMut<'_>,
) -> Option<Mut<'a, dyn PartialReflect>> {
(self.0.reflect_mut)(entity)
}

Expand All @@ -131,7 +134,7 @@ impl ReflectComponent {
pub unsafe fn reflect_unchecked_mut<'a>(
&self,
entity: UnsafeWorldCellEntityRef<'a>,
) -> Option<Mut<'a, dyn Reflect>> {
) -> Option<Mut<'a, dyn PartialReflect>> {
// SAFETY: safety requirements deferred to caller
(self.0.reflect_unchecked_mut)(entity)
}
Expand Down Expand Up @@ -206,10 +209,10 @@ impl<C: Component + PartialReflect + FromWorld> FromType<C> for ReflectComponent
.entity_mut(destination_entity)
.insert(destination_component);
},
reflect: |entity| entity.get::<C>().map(|c| c as &dyn Reflect),
reflect: |entity| entity.get::<C>().map(|c| c as &dyn PartialReflect),
reflect_mut: |entity| {
entity.get_mut::<C>().map(|c| Mut {
value: c.value as &mut dyn Reflect,
value: c.value as &mut dyn PartialReflect,
ticks: c.ticks,
})
},
Expand All @@ -218,7 +221,7 @@ impl<C: Component + PartialReflect + FromWorld> FromType<C> for ReflectComponent
// `reflect_unchecked_mut` which must be called with an UnsafeWorldCellEntityRef with access to the the component `C` on the `entity`
unsafe {
entity.get_mut::<C>().map(|c| Mut {
value: c.value as &mut dyn Reflect,
value: c.value as &mut dyn PartialReflect,
ticks: c.ticks,
})
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/wireframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bevy_asset::{load_internal_asset, Handle, HandleUntyped};
use bevy_core_pipeline::core_3d::Opaque3d;
use bevy_ecs::{prelude::*, reflect::ReflectComponent};
use bevy_reflect::std_traits::ReflectDefault;
use bevy_reflect::{PartialReflect, Reflect, TypeUuid};
use bevy_reflect::{Reflect, TypeUuid};
use bevy_render::extract_component::{ExtractComponent, ExtractComponentPlugin};
use bevy_render::{
extract_resource::{ExtractResource, ExtractResourcePlugin},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::container_attributes::REFLECT_DEFAULT;
use crate::derive_data::ReflectEnum;
use crate::enum_utility::{get_variant_constructors, EnumVariantConstructors};
use crate::field_attributes::DefaultBehavior;
use crate::fq_std::{FQAny, FQClone, FQDefault, FQOption};
use crate::fq_std::{FQClone, FQDefault, FQOption};
use crate::utility::ident_or_index;
use crate::{ReflectMeta, ReflectStruct};
use proc_macro::TokenStream;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/primitives/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy_ecs::{component::Component, prelude::Entity, reflect::ReflectComponent};
use bevy_math::{Mat4, Vec3, Vec3A, Vec4, Vec4Swizzles};
use bevy_reflect::{FromReflect, PartialReflect, Reflect};
use bevy_reflect::{FromReflect, Reflect};
use bevy_utils::HashMap;

/// An axis-aligned bounding box.
Expand Down

0 comments on commit 6663dfc

Please sign in to comment.