Skip to content

Commit f8cac57

Browse files
#592 Adding change check before setting position
This prevents excess work from being done in step_simulation
1 parent f17bd5b commit f8cac57

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
@@ -122,10 +122,22 @@ pub fn apply_collider_user_changes(
122122
collider_offset(entity, &context, &parent_query, &transform_query);
123123

124124
if let Some(co) = context.colliders.get_mut(handle.0) {
125-
co.set_position_wrt_parent(utils::transform_to_iso(&collider_position));
125+
let new_pos = utils::transform_to_iso(&collider_position);
126+
127+
if co
128+
.position_wrt_parent()
129+
.map(|pos| *pos != new_pos)
130+
.unwrap_or(true)
131+
{
132+
co.set_position_wrt_parent(new_pos);
133+
}
126134
}
127135
} else if let Some(co) = context.colliders.get_mut(handle.0) {
128-
co.set_position(utils::transform_to_iso(&transform.compute_transform()))
136+
let new_pos = utils::transform_to_iso(&transform.compute_transform());
137+
138+
if *co.position() != new_pos {
139+
co.set_position(utils::transform_to_iso(&transform.compute_transform()));
140+
}
129141
}
130142
}
131143

0 commit comments

Comments
 (0)