Don't sync transforms with a ColliderPosition, and also don't sync if they're already equal.

This commit is contained in:
Nolan Darilek 2021-07-20 10:53:44 -05:00
parent a591326734
commit 2abeb3b08c

View File

@ -548,11 +548,20 @@ fn setup(core_config: Res<CoreConfig>, mut rapier_config: ResMut<RapierConfigura
fn copy_coordinates_to_transform(
config: Res<CoreConfig>,
mut query: Query<(&Coordinates, &mut Transform), Without<RigidBodyPosition>>,
mut query: Query<
(&Coordinates, &mut Transform),
(Without<RigidBodyPosition>, Without<ColliderPosition>),
>,
) {
for (coordinates, mut transform) in query.iter_mut() {
transform.translation.x = coordinates.0 .0 * config.pixels_per_unit as f32;
transform.translation.y = coordinates.0 .1 * config.pixels_per_unit as f32;
let x = coordinates.0 .0 * config.pixels_per_unit as f32;
if transform.translation.x != x {
transform.translation.x = x;
}
let y = coordinates.0 .1 * config.pixels_per_unit as f32;
if transform.translation.y != y {
transform.translation.y = y;
}
}
}
@ -589,7 +598,6 @@ impl Plugin for CorePlugin {
}
app.register_type::<Coordinates>()
.add_startup_system(setup.system())
.add_system(copy_coordinates_to_transform.system())
.add_system_to_stage(
CoreStage::PostUpdate,
copy_coordinates_to_transform