-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The GlobalTransform
did not get updated when Parent
was removed
#7263
Comments
Bevy 0.10 will have new commands to update parent while updating the transform, see |
I may have misunderstood the issue. Could you provide a minimal reproducible example or at least try with the last |
Here is a simple test case for this. #[test]
fn correct_parent_removed() {
ComputeTaskPool::init(TaskPool::default);
let mut world = World::default();
let mut update_stage = SystemStage::parallel();
update_stage.add_system(sync_simple_transforms);
update_stage.add_system(propagate_transforms);
let mut schedule = Schedule::default();
schedule.add_stage(Update, update_stage);
let (root, parent, child) = {
let mut command_queue = CommandQueue::default();
let mut commands = Commands::new(&mut command_queue, &world);
let root = commands.spawn(TransformBundle::from_transform(Transform::from_xyz(1.0, 0.0, 0.0))).id();
let parent = commands.spawn(TransformBundle::IDENTITY).id();
let child = commands.spawn(TransformBundle::IDENTITY).id();
commands.entity(parent).set_parent(root);
commands.entity(child).set_parent(parent);
command_queue.apply(&mut world);
schedule.run(&mut world);
(root, parent, child)
};
assert_ne!(
world.get::<GlobalTransform>(parent).unwrap(),
&GlobalTransform::from(Transform::IDENTITY)
);
// Remove parent of `parent`
{
let mut command_queue = CommandQueue::default();
let mut commands = Commands::new(&mut command_queue, &world);
commands.entity(parent).remove_parent();
command_queue.apply(&mut world);
schedule.run(&mut world);
}
assert_eq!(
world.get::<GlobalTransform>(parent).unwrap(),
&GlobalTransform::from(Transform::IDENTITY)
);
} |
yeah I can reproduce. I've a fix working, I'll open a PR shortly |
What problem does this solve or what need does it fill?
The
GlobalTransform
did not get updated (it should be) whenParent
was removed.What solution would you like?
GlobalTransform
thenset_if_neq
.Or use
RemovedComponents<Parent>
, which may have poor performance if there have so many entities withoutTransform
.Or use
Removed
change detection, but does not exist currently.What alternative(s) have you considered?
none
Additional context
none
The text was updated successfully, but these errors were encountered: