Skip to content

Commit

Permalink
Implemented Debug for TypedShape by deriving Debug on enum variants, …
Browse files Browse the repository at this point in the history
…except TriMesh which has a dummy implementation.
  • Loading branch information
whatf0xx authored and sebcrozet committed Mar 24, 2024
1 parent 1be67e5 commit e18dc38
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/shape/compound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::utils::DefaultStorage;
/// the main way of creating a concave shape from convex parts. Each parts can have its own
/// delta transformation to shift or rotate it with regard to the other shapes.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct Compound {
shapes: Vec<(Isometry<Real>, SharedShape)>,
qbvh: Qbvh<u32>,
Expand Down
2 changes: 1 addition & 1 deletion src/shape/polyline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::utils::DefaultStorage;
#[cfg(not(feature = "std"))]
use na::ComplexField; // for .abs()

#[derive(Clone)]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
#[cfg_attr(
feature = "rkyv",
Expand Down
2 changes: 1 addition & 1 deletion src/shape/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub enum ShapeType {
Custom,
}

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize))]
/// Enum representing the shape with its actual type
pub enum TypedShape<'a> {
Expand Down
8 changes: 4 additions & 4 deletions src/shape/shared_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ use crate::shape::ConvexPolygon;
use crate::shape::DeserializableTypedShape;
use crate::shape::{
Ball, Capsule, Compound, Cuboid, HalfSpace, HeightField, Polyline, RoundShape, Segment, Shape,
TriMesh, TriMeshFlags, Triangle, ShapeType
TriMesh, TriMeshFlags, Triangle, TypedShape,
};
#[cfg(feature = "dim3")]
use crate::shape::{Cone, ConvexPolyhedron, Cylinder};
use crate::transformation::vhacd::{VHACDParameters, VHACD};
use na::Unit;
use std::fmt;
use std::ops::Deref;
use std::sync::Arc;
use std::fmt;

/// The shape of a collider.
#[derive(Clone)]
Expand All @@ -34,8 +34,8 @@ impl AsRef<dyn Shape> for SharedShape {

impl fmt::Debug for SharedShape {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let shape_type: ShapeType = (*self.0).shape_type();
write!(f, "SharedShape ( Arc<{:?}> )", shape_type)
let typed_shape: TypedShape = (*self.0).as_typed_shape();
write!(f, "SharedShape ( Arc<{:?}> )", typed_shape)
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/shape/trimesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::partitioning::QbvhStorage;
use crate::partitioning::{GenericQbvh, Qbvh};
use crate::shape::trimesh_storage::TriMeshStorage;
use crate::shape::{FeatureId, Shape, Triangle, TypedSimdCompositeShape};
use std::fmt;

use crate::utils::{Array1, DefaultStorage, HashablePartialEq};
#[cfg(feature = "dim3")]
Expand Down Expand Up @@ -358,6 +359,12 @@ pub struct GenericTriMesh<Storage: TriMeshStorage> {
flags: TriMeshFlags,
}

impl fmt::Debug for GenericTriMesh<DefaultStorage> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "GenericTriMesh<DefaultStorage>")
}
}

/// A triangle-mesh.
pub type TriMesh = GenericTriMesh<DefaultStorage>;
#[cfg(feature = "cuda")]
Expand Down

0 comments on commit e18dc38

Please sign in to comment.