Extract 'dist_to_pos_xy' variable

This commit is contained in:
Dr. Dystopia 2022-02-25 21:56:03 +01:00
parent 019d619cf6
commit ee26778118

View File

@ -2296,13 +2296,13 @@ impl<'a> AgentData<'a> {
self.body,
read_data.bodies.get(entity),
) {
let dist_to_pos_xy = self.pos.0.xy().distance(pos.0.xy());
let spacing = body.spacing_radius() + other_body.spacing_radius();
if self.pos.0.xy().distance(pos.0.xy()) < spacing {
if dist_to_pos_xy < spacing {
sep_vec += (self.pos.0.xy() - pos.0.xy())
.try_normalized()
.unwrap_or_else(Vec2::zero)
* ((spacing - self.pos.0.xy().distance(pos.0.xy()))
/ spacing);
* ((spacing - dist_to_pos_xy) / spacing);
}
}
}