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

add a Debug impl for SharedShape #179

Merged
merged 3 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
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
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
10 changes: 9 additions & 1 deletion src/shape/shared_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ use crate::shape::ConvexPolygon;
use crate::shape::DeserializableTypedShape;
use crate::shape::{
Ball, Capsule, Compound, Cuboid, HalfSpace, HeightField, Polyline, RoundShape, Segment, Shape,
TriMesh, TriMeshFlags, Triangle,
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;

Expand All @@ -31,6 +32,13 @@ impl AsRef<dyn Shape> for SharedShape {
}
}

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

impl SharedShape {
/// Wraps the given shape as a shared shape.
pub fn new(shape: impl Shape) -> Self {
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<Storage: TriMeshStorage> fmt::Debug for GenericTriMesh<Storage> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "GenericTriMesh")
}
}

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