Skip to content

Commit

Permalink
Use entity Display in messages instead of Debug (#545)
Browse files Browse the repository at this point in the history
# Objective

- Using `Debug` on `Entity` in log messages looks weird

## Solution

- Switch to `Display` where possible
  • Loading branch information
NiseVoid authored Nov 4, 2024
1 parent 70f3cdb commit 7ccc9ac
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/collision/collider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ pub struct CollisionMargin(pub Scalar);
/// fn my_system(query: Query<(Entity, &CollidingEntities)>) {
/// for (entity, colliding_entities) in &query {
/// println!(
/// "{:?} is colliding with the following entities: {:?}",
/// "{} is colliding with the following entities: {:?}",
/// entity,
/// colliding_entities,
/// );
Expand Down
8 changes: 4 additions & 4 deletions src/collision/contact_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use bevy::prelude::*;
/// fn print_collisions(mut collision_event_reader: EventReader<Collision>) {
/// for Collision(contacts) in collision_event_reader.read() {
/// println!(
/// "Entities {:?} and {:?} are colliding",
/// "Entities {} and {} are colliding",
/// contacts.entity1,
/// contacts.entity2,
/// );
Expand Down Expand Up @@ -76,7 +76,7 @@ impl Plugin for ContactReportingPlugin {
/// fn print_collisions(mut collision_event_reader: EventReader<Collision>) {
/// for Collision(contacts) in collision_event_reader.read() {
/// println!(
/// "Entities {:?} and {:?} are colliding",
/// "Entities {} and {} are colliding",
/// contacts.entity1,
/// contacts.entity2,
/// );
Expand Down Expand Up @@ -107,7 +107,7 @@ pub struct Collision(pub Contacts);
/// fn print_started_collisions(mut collision_event_reader: EventReader<CollisionStarted>) {
/// for CollisionStarted(entity1, entity2) in collision_event_reader.read() {
/// println!(
/// "Entities {:?} and {:?} started colliding",
/// "Entities {} and {} started colliding",
/// entity1,
/// entity2,
/// );
Expand Down Expand Up @@ -138,7 +138,7 @@ pub struct CollisionStarted(pub Entity, pub Entity);
/// fn print_ended_collisions(mut collision_event_reader: EventReader<CollisionEnded>) {
/// for CollisionEnded(entity1, entity2) in collision_event_reader.read() {
/// println!(
/// "Entities {:?} and {:?} stopped colliding",
/// "Entities {} and {} stopped colliding",
/// entity1,
/// entity2,
/// );
Expand Down
8 changes: 4 additions & 4 deletions src/collision/narrow_phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,12 +724,12 @@ fn log_overlap_at_spawn(
if rb1.is_added() || rb2.is_added() {
// If the RigidBody entity has a name, use that for debug.
let debug_id1 = match name1 {
Some(n) => format!("{:?} ({n})", contacts.entity1),
None => format!("{:?}", contacts.entity1),
Some(n) => format!("{} ({n})", contacts.entity1),
None => format!("{}", contacts.entity1),
};
let debug_id2 = match name2 {
Some(n) => format!("{:?} ({n})", contacts.entity2),
None => format!("{:?}", contacts.entity2),
Some(n) => format!("{} ({n})", contacts.entity2),
None => format!("{}", contacts.entity2),
};
warn!(
"{debug_id1} and {debug_id2} are overlapping at spawn, which can result in explosive behavior.",
Expand Down
2 changes: 1 addition & 1 deletion src/dynamics/rigid_body/mass_properties/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub fn warn_missing_mass(
// Warn about dynamic bodies with no mass or inertia
if rb.is_dynamic() && !(is_mass_valid && is_inertia_valid) {
warn!(
"Dynamic rigid body {:?} has no mass or inertia. This can cause NaN values. Consider adding a `MassPropertiesBundle` or a `Collider` with mass.",
"Dynamic rigid body {} has no mass or inertia. This can cause NaN values. Consider adding a `MassPropertiesBundle` or a `Collider` with mass.",
entity
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/spatial_query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
//! // For the faster iterator that isn't sorted, use `.iter()`
//! for hit in hits.iter_sorted() {
//! println!(
//! "Hit entity {:?} at {} with normal {}",
//! "Hit entity {} at {} with normal {}",
//! hit.entity,
//! ray.origin + *ray.direction * hit.time_of_impact,
//! hit.normal,
Expand Down Expand Up @@ -115,7 +115,7 @@
//! fn print_hits(query: Query<(&ShapeCaster, &ShapeHits)>) {
//! for (shape_caster, hits) in &query {
//! for hit in hits.iter() {
//! println!("Hit entity {:?}", hit.entity);
//! println!("Hit entity {}", hit.entity);
//! }
//! }
//! }
Expand Down
4 changes: 2 additions & 2 deletions src/spatial_query/ray_caster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ use parry::query::{
/// // For the faster iterator that isn't sorted, use `.iter()`
/// for hit in hits.iter_sorted() {
/// println!(
/// "Hit entity {:?} at {} with normal {}",
/// "Hit entity {} at {} with normal {}",
/// hit.entity,
/// ray.origin + *ray.direction * hit.time_of_impact,
/// hit.normal,
Expand Down Expand Up @@ -364,7 +364,7 @@ fn on_add_ray_caster(mut world: DeferredWorld, entity: Entity, _component_id: Co
/// // For the faster iterator that isn't sorted, use `.iter()`
/// for hit in hits.iter_sorted() {
/// println!(
/// "Hit entity {:?} with time of impact {}",
/// "Hit entity {} with time of impact {}",
/// hit.entity,
/// hit.time_of_impact,
/// );
Expand Down
4 changes: 2 additions & 2 deletions src/spatial_query/shape_caster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use parry::query::{details::TOICompositeShapeShapeBestFirstVisitor, ShapeCastOpt
/// fn print_hits(query: Query<(&ShapeCaster, &ShapeHits)>) {
/// for (shape_caster, hits) in &query {
/// for hit in hits.iter() {
/// println!("Hit entity {:?}", hit.entity);
/// println!("Hit entity {}", hit.entity);
/// }
/// }
/// }
Expand Down Expand Up @@ -381,7 +381,7 @@ fn on_add_shape_caster(mut world: DeferredWorld, entity: Entity, _component_id:
/// for hits in &query {
/// for hit in hits.iter() {
/// println!(
/// "Hit entity {:?} with time of impact {}",
/// "Hit entity {} with time of impact {}",
/// hit.entity,
/// hit.time_of_impact,
/// );
Expand Down
12 changes: 6 additions & 6 deletions src/spatial_query/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ impl<'w, 's> SpatialQuery<'w, 's> {
/// spatial_query.point_intersections(Vec3::ZERO, SpatialQueryFilter::default());
///
/// for entity in intersections.iter() {
/// println!("Entity: {:?}", entity);
/// println!("Entity: {}", entity);
/// }
/// }
/// ```
Expand Down Expand Up @@ -641,7 +641,7 @@ impl<'w, 's> SpatialQuery<'w, 's> {
/// );
///
/// for entity in intersections.iter() {
/// println!("Entity: {:?}", entity);
/// println!("Entity: {}", entity);
/// }
/// }
/// ```
Expand Down Expand Up @@ -673,7 +673,7 @@ impl<'w, 's> SpatialQuery<'w, 's> {
/// let intersections = spatial_query.aabb_intersections_with_aabb(aabb);
///
/// for entity in intersections.iter() {
/// println!("Entity: {:?}", entity);
/// println!("Entity: {}", entity);
/// }
/// }
/// ```
Expand Down Expand Up @@ -707,7 +707,7 @@ impl<'w, 's> SpatialQuery<'w, 's> {
/// );
///
/// for entity in intersections.iter() {
/// println!("Entity: {:?}", entity);
/// println!("Entity: {}", entity);
/// }
/// }
/// ```
Expand Down Expand Up @@ -749,7 +749,7 @@ impl<'w, 's> SpatialQuery<'w, 's> {
/// );
///
/// for entity in intersections.iter() {
/// println!("Entity: {:?}", entity);
/// println!("Entity: {}", entity);
/// }
/// }
/// ```
Expand Down Expand Up @@ -801,7 +801,7 @@ impl<'w, 's> SpatialQuery<'w, 's> {
/// );
///
/// for entity in intersections.iter() {
/// println!("Entity: {:?}", entity);
/// println!("Entity: {}", entity);
/// }
/// }
/// ```
Expand Down

0 comments on commit 7ccc9ac

Please sign in to comment.