Skip to content

Commit

Permalink
Expose transform propagate systems (bevyengine#7145)
Browse files Browse the repository at this point in the history
# Objective

- I tried to create a fork of bevy_rapier to track latest bevy main branch. But bevy_rapier depends on bevy internal `propagate_transforms` system (see https://github.com/dimforge/bevy_rapier/blob/master/src/plugin/plugin.rs#L64).
- `propagate_transforms` system was changed to private in bevyengine#4775.

I don't know if it's reasonable that making `propagate_transforms` public. I also created an issue to bevy_rapier dimforge/bevy_rapier#307 to see how offical team will solve this issue.

## Solution

- make `propagate_transforms` system public.
  • Loading branch information
lewiszlw authored and alradish committed Jan 22, 2023
1 parent a77d614 commit d41edc6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/bevy_transform/src/components/global_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ use bevy_reflect::{std_traits::ReflectDefault, FromReflect, Reflect};
/// update the [`Transform`] of an entity in this stage or after, you will notice a 1 frame lag
/// before the [`GlobalTransform`] is updated.
///
/// Third party plugins should use [`transform_propagate_system_set`](crate::transform_propagate_system_set)
/// to control when transforms are propagated from parents to children.
///
/// # Examples
///
/// - [`transform`]
Expand Down
7 changes: 7 additions & 0 deletions crates/bevy_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ pub enum TransformSystem {
TransformPropagate,
}

/// Transform propagation system set for third party plugins use
pub fn transform_propagate_system_set() -> SystemSet {
SystemSet::new()
.with_system(systems::sync_simple_transforms)
.with_system(systems::propagate_transforms)
}

/// The base plugin for handling [`Transform`] components
#[derive(Default)]
pub struct TransformPlugin;
Expand Down
6 changes: 6 additions & 0 deletions crates/bevy_transform/src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use bevy_ecs::prelude::{Changed, Entity, Query, With, Without};
use bevy_hierarchy::{Children, Parent};

/// Update [`GlobalTransform`] component of entities that aren't in the hierarchy
///
/// Third party plugins should use [`transform_propagate_system_set`](crate::transform_propagate_system_set)
/// to propagate transforms correctly.
pub fn sync_simple_transforms(
mut query: Query<
(&Transform, &mut GlobalTransform),
Expand All @@ -16,6 +19,9 @@ pub fn sync_simple_transforms(

/// Update [`GlobalTransform`] component of entities based on entity hierarchy and
/// [`Transform`] component.
///
/// Third party plugins should use [`transform_propagate_system_set`](crate::transform_propagate_system_set)
/// to propagate transforms correctly.
pub fn propagate_transforms(
mut root_query: Query<
(
Expand Down

0 comments on commit d41edc6

Please sign in to comment.