Skip to content

Commit 7270af1

Browse files
committed
Replace validate_parent_has_component on InheritedVisibility and GlobalTransform.
1 parent 8243b57 commit 7270af1

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

crates/bevy_camera/src/visibility/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ use derive_more::derive::{Deref, DerefMut};
1010
pub use range::*;
1111
pub use render_layers::*;
1212

13-
use bevy_app::{Plugin, PostUpdate};
13+
use bevy_app::{Plugin, PostUpdate, ValidateParentHasComponentPlugin};
1414
use bevy_asset::prelude::AssetChanged;
1515
use bevy_asset::{AssetEventSystems, Assets};
16-
use bevy_ecs::{hierarchy::validate_parent_has_component, prelude::*};
16+
use bevy_ecs::prelude::*;
1717
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
1818
use bevy_transform::{components::GlobalTransform, TransformSystems};
1919
use bevy_utils::{Parallel, TypeIdMap};
@@ -113,7 +113,6 @@ impl PartialEq<&Visibility> for Visibility {
113113
/// [`VisibilityPropagate`]: VisibilitySystems::VisibilityPropagate
114114
#[derive(Component, Deref, Debug, Default, Clone, Copy, Reflect, PartialEq, Eq)]
115115
#[reflect(Component, Default, Debug, PartialEq, Clone)]
116-
#[component(on_insert = validate_parent_has_component::<Self>)]
117116
pub struct InheritedVisibility(bool);
118117

119118
impl InheritedVisibility {
@@ -394,7 +393,8 @@ impl Plugin for VisibilityPlugin {
394393
fn build(&self, app: &mut bevy_app::App) {
395394
use VisibilitySystems::*;
396395

397-
app.register_required_components::<Mesh3d, Visibility>()
396+
app.add_plugins(ValidateParentHasComponentPlugin::<InheritedVisibility>::default())
397+
.register_required_components::<Mesh3d, Visibility>()
398398
.register_required_components::<Mesh3d, VisibilityClass>()
399399
.register_required_components::<Mesh2d, Visibility>()
400400
.register_required_components::<Mesh2d, VisibilityClass>()

crates/bevy_transform/src/components/global_transform.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use derive_more::derive::From;
88
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
99

1010
#[cfg(feature = "bevy-support")]
11-
use bevy_ecs::{component::Component, hierarchy::validate_parent_has_component};
11+
use bevy_ecs::component::Component;
1212

1313
#[cfg(feature = "bevy_reflect")]
1414
use {
@@ -47,11 +47,7 @@ use {
4747
/// [transform_example]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/transform.rs
4848
#[derive(Debug, PartialEq, Clone, Copy, From)]
4949
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
50-
#[cfg_attr(
51-
feature = "bevy-support",
52-
derive(Component),
53-
component(on_insert = validate_parent_has_component::<GlobalTransform>)
54-
)]
50+
#[cfg_attr(feature = "bevy-support", derive(Component))]
5551
#[cfg_attr(
5652
feature = "bevy_reflect",
5753
derive(Reflect),

crates/bevy_transform/src/plugins.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
use crate::systems::{
2-
mark_dirty_trees, propagate_parent_transforms, sync_simple_transforms,
3-
StaticTransformOptimizations,
1+
use crate::{
2+
prelude::GlobalTransform,
3+
systems::{
4+
mark_dirty_trees, propagate_parent_transforms, sync_simple_transforms,
5+
StaticTransformOptimizations,
6+
},
47
};
5-
use bevy_app::{App, Plugin, PostStartup, PostUpdate};
8+
use bevy_app::{App, Plugin, PostStartup, PostUpdate, ValidateParentHasComponentPlugin};
69
use bevy_ecs::schedule::{IntoScheduleConfigs, SystemSet};
710

811
/// Set enum for the systems relating to transform propagation
@@ -18,7 +21,8 @@ pub struct TransformPlugin;
1821

1922
impl Plugin for TransformPlugin {
2023
fn build(&self, app: &mut App) {
21-
app.init_resource::<StaticTransformOptimizations>()
24+
app.add_plugins(ValidateParentHasComponentPlugin::<GlobalTransform>::default())
25+
.init_resource::<StaticTransformOptimizations>()
2226
// add transform systems to startup so the first update is "correct"
2327
.add_systems(
2428
PostStartup,

0 commit comments

Comments
 (0)