Skip to content

Commit

Permalink
fix no-std build
Browse files Browse the repository at this point in the history
  • Loading branch information
sebcrozet committed Apr 28, 2024
1 parent d60378c commit 735d1df
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 32 deletions.
2 changes: 2 additions & 0 deletions src/bounding_volume/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ mod aabb_convex_polygon;
mod aabb_convex_polyhedron;
mod aabb_cuboid;
mod aabb_halfspace;
#[cfg(feature = "std")]
mod aabb_heightfield;
mod aabb_support_map;
mod aabb_triangle;
Expand All @@ -45,6 +46,7 @@ mod bounding_sphere_cuboid;
#[cfg(feature = "dim3")]
mod bounding_sphere_cylinder;
mod bounding_sphere_halfspace;
#[cfg(feature = "std")]
mod bounding_sphere_heightfield;
#[cfg(feature = "std")]
mod bounding_sphere_polyline;
Expand Down
1 change: 1 addition & 0 deletions src/partitioning/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub use self::visitor::{

/// A quaternary bounding-volume-hierarchy.
#[deprecated(note = "Renamed to Qbvh")]
#[cfg(feature = "std")]
pub type SimdQbvh<T> = Qbvh<T>;

#[cfg(feature = "std")]
Expand Down
6 changes: 6 additions & 0 deletions src/partitioning/visitor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use crate::math::{Real, SimdBool, SimdReal, SIMD_WIDTH};

#[cfg(feature = "std")]
use crate::partitioning::qbvh::QbvhNode;
#[cfg(feature = "std")]
use crate::partitioning::SimdNodeIndex;

/// The next action to be taken by a BVH traversal algorithm after having visited a node with some data.
Expand Down Expand Up @@ -116,6 +119,7 @@ pub trait SimdSimultaneousVisitor<T1, T2, SimdBV> {
*/

/// Trait implemented by visitor called during the parallel traversal of a spatial partitioning data structure.
#[cfg(feature = "std")]
pub trait ParallelSimdVisitor<LeafData>: Sync {
/// Execute an operation on the content of a node of the spatial partitioning structure.
///
Expand All @@ -129,6 +133,7 @@ pub trait ParallelSimdVisitor<LeafData>: Sync {
) -> SimdVisitStatus;
}

#[cfg(feature = "std")]
impl<F, LeafData> ParallelSimdVisitor<LeafData> for F
where
F: Sync + Fn(&QbvhNode, Option<[Option<&LeafData>; SIMD_WIDTH]>) -> SimdVisitStatus,
Expand All @@ -146,6 +151,7 @@ where
/// Trait implemented by visitor called during a parallel simultaneous spatial partitioning
/// data structure traversal.
#[cfg(feature = "parallel")]
#[cfg(feature = "std")]
pub trait ParallelSimdSimultaneousVisitor<LeafData1, LeafData2>: Sync {
/// Visitor state data that will be passed down the recursion.
type Data: Copy + Sync + Default;
Expand Down
4 changes: 2 additions & 2 deletions src/query/default_query_dispatcher.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::math::{Isometry, Point, Real, Vector};
use crate::query::contact_manifolds::NormalConstraints;
use crate::query::{
self, details::NonlinearTOIMode, ClosestPoints, Contact, NonlinearRigidMotion, QueryDispatcher,
Unsupported, TOI,
};
#[cfg(feature = "std")]
use crate::query::{
contact_manifolds::ContactManifoldsWorkspace, query_dispatcher::PersistentQueryDispatcher,
contact_manifolds::{ContactManifoldsWorkspace, NormalConstraints},
query_dispatcher::PersistentQueryDispatcher,
ContactManifold,
};
use crate::shape::{HalfSpace, Segment, Shape, ShapeType};
Expand Down
1 change: 1 addition & 0 deletions src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ mod ray;
pub mod sat;
mod split;
mod time_of_impact;
#[cfg(feature = "std")]
pub mod visitors;

/// Queries dedicated to specific pairs of shapes.
Expand Down
2 changes: 2 additions & 0 deletions src/query/point/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ mod point_aabb;
mod point_ball;
mod point_bounding_sphere;
mod point_capsule;
#[cfg(feature = "std")]
mod point_composite_shape;
#[cfg(feature = "dim3")]
mod point_cone;
mod point_cuboid;
#[cfg(feature = "dim3")]
mod point_cylinder;
mod point_halfspace;
#[cfg(feature = "std")]
mod point_heightfield;
#[doc(hidden)]
pub mod point_query;
Expand Down
4 changes: 0 additions & 4 deletions src/query/point/point_composite_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ use crate::shape::{
use na;
use simba::simd::{SimdBool as _, SimdPartialOrd, SimdValue};

#[cfg(feature = "std")]
use crate::shape::{Compound, Polyline};

#[cfg(feature = "std")]
impl PointQuery for Polyline {
#[inline]
fn project_local_point(&self, point: &Point<Real>, solid: bool) -> PointProjection {
Expand Down Expand Up @@ -100,7 +98,6 @@ impl PointQuery for TriMesh {
}
}

#[cfg(feature = "std")]
impl PointQuery for Compound {
#[inline]
fn project_local_point(&self, point: &Point<Real>, solid: bool) -> PointProjection {
Expand All @@ -124,7 +121,6 @@ impl PointQuery for Compound {
}
}

#[cfg(feature = "std")]
impl PointQueryWithLocation for Polyline {
type Location = (u32, SegmentPointLocation);

Expand Down
6 changes: 4 additions & 2 deletions src/query/query_dispatcher.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::math::{Isometry, Real, Vector};
use crate::query::contact_manifolds::NormalConstraints;
#[cfg(feature = "std")]
use crate::query::{contact_manifolds::ContactManifoldsWorkspace, ContactManifold};
use crate::query::{
contact_manifolds::{ContactManifoldsWorkspace, NormalConstraints},
ContactManifold,
};
use crate::query::{ClosestPoints, Contact, NonlinearRigidMotion, Unsupported, TOI};
use crate::shape::Shape;

Expand Down
1 change: 1 addition & 0 deletions src/query/ray/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mod ray_bounding_sphere;
mod ray_composite_shape;
mod ray_cuboid;
mod ray_halfspace;
#[cfg(feature = "std")]
mod ray_heightfield;
mod ray_round_shape;
mod ray_support_map;
Expand Down
12 changes: 0 additions & 12 deletions src/query/visitors/mod.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
//! Visitors for performing geometric queries exploiting spatial partitioning data structures.
#[cfg(feature = "std")]
pub use self::aabb_sets_interferences_collector::AabbSetsInterferencesCollector;
#[cfg(feature = "std")]
pub use self::bounding_volume_intersections_simultaneous_visitor::BoundingVolumeIntersectionsSimultaneousVisitor;
#[cfg(feature = "std")]
pub use self::bounding_volume_intersections_visitor::BoundingVolumeIntersectionsVisitor;
#[cfg(feature = "std")]
pub use self::composite_closest_point_visitor::CompositeClosestPointVisitor;
pub use self::composite_point_containment_test::CompositePointContainmentTest;
#[cfg(feature = "std")]
pub use self::point_intersections_visitor::PointIntersectionsVisitor;
#[cfg(feature = "std")]
pub use self::ray_intersections_visitor::RayIntersectionsVisitor;

#[cfg(feature = "std")]
mod aabb_sets_interferences_collector;
#[cfg(feature = "std")]
mod bounding_volume_intersections_simultaneous_visitor;
#[cfg(feature = "std")]
mod bounding_volume_intersections_visitor;
#[cfg(feature = "std")]
mod composite_closest_point_visitor;
mod composite_point_containment_test;
#[cfg(feature = "std")]
mod point_intersections_visitor;
#[cfg(feature = "std")]
mod ray_intersections_visitor;
1 change: 1 addition & 0 deletions src/shape/composite_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub trait SimdCompositeShape {
fn qbvh(&self) -> &Qbvh<u32>;
}

#[cfg(feature = "std")]
pub trait TypedSimdCompositeShape {
type PartShape: ?Sized + Shape;
type PartNormalConstraints: ?Sized + NormalConstraints;
Expand Down
13 changes: 10 additions & 3 deletions src/shape/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
pub use self::ball::Ball;
pub use self::capsule::Capsule;
#[doc(inline)]
pub use self::composite_shape::TypedSimdCompositeShape;
pub use self::cuboid::Cuboid;
pub use self::feature_id::{FeatureId, PackedFeatureId};
pub use self::half_space::HalfSpace;
Expand All @@ -20,14 +18,17 @@ pub use self::triangle::{Triangle, TriangleOrientation, TrianglePointLocation};

#[cfg(feature = "std")]
pub use self::{
composite_shape::SimdCompositeShape, compound::Compound, polyline::Polyline,
composite_shape::{SimdCompositeShape, TypedSimdCompositeShape},
compound::Compound,
polyline::Polyline,
shared_shape::SharedShape,
};

#[cfg(feature = "dim2")]
#[cfg(feature = "std")]
pub use self::convex_polygon::ConvexPolygon;
#[cfg(feature = "dim2")]
#[cfg(feature = "std")]
pub use self::heightfield2::*;
#[cfg(feature = "dim2")]
pub use self::polygonal_feature2d::PolygonalFeature;
Expand All @@ -40,12 +41,14 @@ pub use self::convex_polyhedron::ConvexPolyhedron;
#[cfg(feature = "dim3")]
pub use self::cylinder::Cylinder;
#[cfg(feature = "dim3")]
#[cfg(feature = "std")]
pub use self::heightfield3::*;
#[cfg(feature = "dim3")]
pub use self::polygonal_feature3d::PolygonalFeature;
#[cfg(feature = "dim3")]
pub use self::tetrahedron::{Tetrahedron, TetrahedronPointLocation};
pub use self::triangle_pseudo_normals::TrianglePseudoNormals;
#[cfg(feature = "std")]
pub use self::trimesh::*;

/// A cylinder dilated by a sphere (so it has round corners).
Expand All @@ -69,6 +72,7 @@ pub type RoundConvexPolygon = RoundShape<ConvexPolygon>;

mod ball;
mod capsule;
#[cfg(feature = "std")]
#[doc(hidden)]
pub mod composite_shape;
#[cfg(feature = "std")]
Expand All @@ -89,6 +93,7 @@ mod triangle;
#[cfg(feature = "std")]
mod convex_polygon;
#[cfg(feature = "dim2")]
#[cfg(feature = "std")]
mod heightfield2;

#[cfg(feature = "dim3")]
Expand All @@ -99,12 +104,14 @@ mod convex_polyhedron;
#[cfg(feature = "dim3")]
mod cylinder;
#[cfg(feature = "dim3")]
#[cfg(feature = "std")]
mod heightfield3;
#[cfg(feature = "dim3")]
mod polygonal_feature3d;
mod polygonal_feature_map;
#[cfg(feature = "dim3")]
mod tetrahedron;
#[cfg(feature = "std")]
pub(crate) mod trimesh;
// TODO: move this elsewhere?
mod feature_id;
Expand Down
5 changes: 4 additions & 1 deletion src/shape/triangle_pseudo_normals.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::math::{Real, UnitVector, Vector};
use crate::query::details::NormalConstraints;
use na::Vector3;

#[cfg(feature = "std")]
use crate::query::details::NormalConstraints;

// NOTE: ideally, the normal cone should take into account the point where the normal cone is
// considered. But as long as we assume that the triangles are one-way we can get away with
// just relying on the normal directions.
Expand All @@ -26,6 +28,7 @@ pub struct TrianglePseudoNormals {
pub edges: [UnitVector<Real>; 3],
}

#[cfg(feature = "std")]
impl NormalConstraints for TrianglePseudoNormals {
/// Projects the given direction to it is contained in the polygonal
/// cone defined `self`.
Expand Down
9 changes: 1 addition & 8 deletions src/shape/trimesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ use crate::utils::HashablePartialEq;
#[cfg(feature = "dim3")]
use {crate::shape::Cuboid, crate::utils::SortedPair, na::Unit};

#[cfg(feature = "std")]
use {
crate::shape::composite_shape::SimdCompositeShape,
crate::utils::hashmap::{Entry, HashMap},
std::collections::HashSet,
};

#[cfg(all(feature = "dim2", feature = "std"))]
#[cfg(feature = "dim2")]
use crate::transformation::ear_clipping::triangulate_ear_clipping;

use crate::query::details::NormalConstraints;
Expand All @@ -38,7 +37,6 @@ pub enum TopologyError {
},
}

#[cfg(feature = "std")]
impl std::fmt::Display for TopologyError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Expand All @@ -54,7 +52,6 @@ impl std::fmt::Display for TopologyError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for TopologyError {}

/// The set of pseudo-normals of a triangle mesh.
Expand Down Expand Up @@ -269,7 +266,6 @@ impl fmt::Debug for TriMesh {
}
}

#[cfg(feature = "std")]
impl TriMesh {
/// Creates a new triangle mesh from a vertex buffer and an index buffer.
pub fn new(vertices: Vec<Point<Real>>, indices: Vec<[u32; 3]>) -> Self {
Expand Down Expand Up @@ -973,7 +969,6 @@ impl TriMesh {
}

#[cfg(feature = "dim3")]
#[cfg(feature = "std")]
impl From<crate::shape::HeightField> for TriMesh {
fn from(heightfield: crate::shape::HeightField) -> Self {
let (vtx, idx) = heightfield.to_trimesh();
Expand All @@ -982,15 +977,13 @@ impl From<crate::shape::HeightField> for TriMesh {
}

#[cfg(feature = "dim3")]
#[cfg(feature = "std")]
impl From<Cuboid> for TriMesh {
fn from(cuboid: Cuboid) -> Self {
let (vtx, idx) = cuboid.to_trimesh();
TriMesh::new(vtx, idx)
}
}

#[cfg(feature = "std")]
impl SimdCompositeShape for TriMesh {
fn map_part_at(
&self,
Expand Down

0 comments on commit 735d1df

Please sign in to comment.