Skip to content

Commit c5634a5

Browse files
Adding change check before setting position (#593)
This prevents excess work from being done in step_simulation Fix #592 Co-authored-by: Thierry Berger <[email protected]>
1 parent 6b6e0c8 commit c5634a5

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/plugin/systems/collider.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,22 @@ pub fn apply_collider_user_changes(
159159
);
160160

161161
if let Some(co) = context_colliders.colliders.get_mut(handle.0) {
162-
co.set_position_wrt_parent(utils::transform_to_iso(&collider_position));
162+
let new_pos = utils::transform_to_iso(&collider_position);
163+
164+
if co
165+
.position_wrt_parent()
166+
.map(|pos| *pos != new_pos)
167+
.unwrap_or(true)
168+
{
169+
co.set_position_wrt_parent(new_pos);
170+
}
163171
}
164172
} else if let Some(co) = context_colliders.colliders.get_mut(handle.0) {
165-
co.set_position(utils::transform_to_iso(&transform.compute_transform()))
173+
let new_pos = utils::transform_to_iso(&transform.compute_transform());
174+
175+
if *co.position() != new_pos {
176+
co.set_position(utils::transform_to_iso(&transform.compute_transform()));
177+
}
166178
}
167179
}
168180

0 commit comments

Comments
 (0)