Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include entity Name in logged warning for overlapping colliders #227

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/plugins/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ struct ColliderQuery<'w> {
#[allow(clippy::type_complexity)]
fn penetration_constraints(
mut commands: Commands,
mut bodies: Query<(RigidBodyQuery, Option<&Sensor>, Option<&Sleeping>)>,
mut bodies: Query<(
RigidBodyQuery,
Option<&Name>,
Option<&Sensor>,
Option<&Sleeping>,
)>,
colliders: Query<ColliderQuery>,
mut penetration_constraints: ResMut<PenetrationConstraints>,
mut collisions: ResMut<Collisions>,
Expand Down Expand Up @@ -128,8 +133,8 @@ fn penetration_constraints(
contacts.during_current_substep = false;

if let Ok([bundle1, bundle2]) = bodies.get_many_mut([collider_parent1, collider_parent2]) {
let (mut body1, sensor1, sleeping1) = bundle1;
let (mut body2, sensor2, sleeping2) = bundle2;
let (mut body1, name1, sensor1, sleeping1) = bundle1;
let (mut body2, name2, sensor2, sleeping2) = bundle2;

let inactive1 = body1.rb.is_static() || sleeping1.is_some();
let inactive2 = body2.rb.is_static() || sleeping2.is_some();
Expand All @@ -156,10 +161,21 @@ fn penetration_constraints(
}

if body1.rb.is_added() || body2.rb.is_added() {
// if the RigidBody entity has a name, use that for debug.
let debug_id1 = match name1 {
Some(n) => format!("{:?} ({n})", body1.entity),
None => format!("{:?}", body1.entity),
};
let debug_id2 = match name2 {
Some(n) => format!("{:?} ({n})", body2.entity),
None => format!("{:?}", body2.entity),
};
warn!(
"{:?} and {:?} are overlapping at spawn, which can result in explosive behavior.",
body1.entity, body2.entity,
"{} and {} are overlapping at spawn, which can result in explosive behavior.",
debug_id1, debug_id2,
);
debug!("{} is at {}", debug_id1, body1.position.0);
debug!("{} is at {}", debug_id2, body2.position.0);
}

// Get combined friction and restitution coefficients of the colliders
Expand Down