Don't sync transforms with a ColliderPosition, and also don't sync if they're already equal.
This commit is contained in:
parent
a591326734
commit
2abeb3b08c
16
src/core.rs
16
src/core.rs
|
@ -548,11 +548,20 @@ fn setup(core_config: Res<CoreConfig>, mut rapier_config: ResMut<RapierConfigura
|
||||||
|
|
||||||
fn copy_coordinates_to_transform(
|
fn copy_coordinates_to_transform(
|
||||||
config: Res<CoreConfig>,
|
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() {
|
for (coordinates, mut transform) in query.iter_mut() {
|
||||||
transform.translation.x = coordinates.0 .0 * config.pixels_per_unit as f32;
|
let x = coordinates.0 .0 * config.pixels_per_unit as f32;
|
||||||
transform.translation.y = coordinates.0 .1 * 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>()
|
app.register_type::<Coordinates>()
|
||||||
.add_startup_system(setup.system())
|
.add_startup_system(setup.system())
|
||||||
.add_system(copy_coordinates_to_transform.system())
|
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
copy_coordinates_to_transform
|
copy_coordinates_to_transform
|
||||||
|
|
Loading…
Reference in New Issue
Block a user