Fix multiple warnings.

This commit is contained in:
Crozet Sébastien
2020-10-26 16:36:07 +01:00
parent ba6655be8e
commit 08930b1238
17 changed files with 23 additions and 51 deletions

View File

@@ -1,4 +1,4 @@
use na::{Point3, Vector3}; use na::Point3;
use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet}; use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
use rapier3d::geometry::{ColliderBuilder, ColliderSet}; use rapier3d::geometry::{ColliderBuilder, ColliderSet};
use rapier_testbed3d::Testbed; use rapier_testbed3d::Testbed;
@@ -40,7 +40,7 @@ pub fn init_world(testbed: &mut Testbed) {
let centery = shifty / 2.0; let centery = shifty / 2.0;
let centerz = shiftz * (num / 2) as f32; let centerz = shiftz * (num / 2) as f32;
let mut offset = -(num as f32) * (rad * 2.0 + rad) * 0.5; let offset = -(num as f32) * (rad * 2.0 + rad) * 0.5;
let x = -centerx + offset; let x = -centerx + offset;
let y = centery + 3.0; let y = centery + 3.0;

View File

@@ -1,4 +1,4 @@
use na::{Point3, Vector3}; use na::Point3;
use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet}; use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
use rapier3d::geometry::{ColliderBuilder, ColliderSet}; use rapier3d::geometry::{ColliderBuilder, ColliderSet};
use rapier_testbed3d::Testbed; use rapier_testbed3d::Testbed;

View File

@@ -1,7 +1,7 @@
use crate::dynamics::MassProperties; use crate::dynamics::MassProperties;
use crate::math::Point;
#[cfg(feature = "dim3")] #[cfg(feature = "dim3")]
use crate::{geometry::Capsule, math::Rotation}; use crate::geometry::Capsule;
use crate::math::Point;
impl MassProperties { impl MassProperties {
pub(crate) fn from_capsule(density: f32, a: Point<f32>, b: Point<f32>, radius: f32) -> Self { pub(crate) fn from_capsule(density: f32, a: Point<f32>, b: Point<f32>, radius: f32) -> Self {

View File

@@ -1,5 +1,4 @@
use crate::dynamics::MassProperties; use crate::dynamics::MassProperties;
use crate::geometry::Cone;
use crate::math::{Point, PrincipalAngularInertia, Rotation, Vector}; use crate::math::{Point, PrincipalAngularInertia, Rotation, Vector};
impl MassProperties { impl MassProperties {

View File

@@ -1,10 +1,7 @@
use crate::dynamics::MassProperties; use crate::dynamics::MassProperties;
use crate::math::{PrincipalAngularInertia, Vector};
#[cfg(feature = "dim3")] #[cfg(feature = "dim3")]
use { use crate::math::{Point, Rotation};
crate::geometry::Capsule, use crate::math::{PrincipalAngularInertia, Vector};
crate::math::{Point, Rotation},
};
impl MassProperties { impl MassProperties {
pub(crate) fn cylinder_y_volume_unit_inertia( pub(crate) fn cylinder_y_volume_unit_inertia(

View File

@@ -4,7 +4,7 @@ use crate::geometry::{
Segment, Shape, ShapeType, Triangle, Trimesh, Segment, Shape, ShapeType, Triangle, Trimesh,
}; };
#[cfg(feature = "dim3")] #[cfg(feature = "dim3")]
use crate::geometry::{Cone, Cylinder, PolygonalFeatureMap, Rounded}; use crate::geometry::{Cone, Cylinder, Rounded};
use crate::math::{AngVector, Isometry, Point, Rotation, Vector}; use crate::math::{AngVector, Isometry, Point, Rotation, Vector};
use na::Point3; use na::Point3;
use ncollide::bounding_volume::AABB; use ncollide::bounding_volume::AABB;

View File

@@ -5,8 +5,6 @@ use crate::geometry::contact_generator::{
use crate::geometry::Capsule; use crate::geometry::Capsule;
use crate::geometry::{Collider, ContactManifold, HeightField, Shape, ShapeType}; use crate::geometry::{Collider, ContactManifold, HeightField, Shape, ShapeType};
use crate::ncollide::bounding_volume::BoundingVolume; use crate::ncollide::bounding_volume::BoundingVolume;
#[cfg(feature = "dim3")]
use crate::{geometry::Triangle, math::Point};
use std::any::Any; use std::any::Any;
use std::collections::hash_map::Entry; use std::collections::hash_map::Entry;
use std::collections::HashMap; use std::collections::HashMap;
@@ -111,7 +109,7 @@ fn do_generate_contacts(
heightfield1.map_elements_in_local_aabb(&ls_aabb2, &mut |i, part1, _| { heightfield1.map_elements_in_local_aabb(&ls_aabb2, &mut |i, part1, _| {
let position1 = collider1.position(); let position1 = collider1.position();
#[cfg(feature = "dim2")] #[cfg(feature = "dim2")]
let sub_shape1 = Capsule::new(part1.a, part1.b, 0.0); let sub_shape1 = Capsule::new(part1.a, part1.b, 0.0); // TODO: use a segment instead.
#[cfg(feature = "dim3")] #[cfg(feature = "dim3")]
let sub_shape1 = *part1; let sub_shape1 = *part1;

View File

@@ -1,9 +1,6 @@
use crate::geometry::contact_generator::PrimitiveContactGenerationContext; use crate::geometry::contact_generator::PrimitiveContactGenerationContext;
use crate::geometry::{ use crate::geometry::{KinematicsCategory, PolygonalFeatureMap, PolyhedronFace};
Contact, ContactManifold, KinematicsCategory, PolygonalFeatureMap, PolyhedronFace,
};
use crate::math::{Isometry, Vector}; use crate::math::{Isometry, Vector};
use crate::na::UnitQuaternion;
use na::Unit; use na::Unit;
use ncollide::query; use ncollide::query;
use ncollide::query::algorithms::{gjk::GJKResult, VoronoiSimplex}; use ncollide::query::algorithms::{gjk::GJKResult, VoronoiSimplex};
@@ -11,7 +8,6 @@ use ncollide::query::algorithms::{gjk::GJKResult, VoronoiSimplex};
pub struct PfmPfmContactManifoldGeneratorWorkspace { pub struct PfmPfmContactManifoldGeneratorWorkspace {
simplex: VoronoiSimplex<f32>, simplex: VoronoiSimplex<f32>,
last_gjk_dir: Option<Unit<Vector<f32>>>, last_gjk_dir: Option<Unit<Vector<f32>>>,
last_optimal_dir: Option<Unit<Vector<f32>>>,
feature1: PolyhedronFace, feature1: PolyhedronFace,
feature2: PolyhedronFace, feature2: PolyhedronFace,
} }
@@ -21,7 +17,6 @@ impl Default for PfmPfmContactManifoldGeneratorWorkspace {
Self { Self {
simplex: VoronoiSimplex::new(), simplex: VoronoiSimplex::new(),
last_gjk_dir: None, last_gjk_dir: None,
last_optimal_dir: None,
feature1: PolyhedronFace::new(), feature1: PolyhedronFace::new(),
feature2: PolyhedronFace::new(), feature2: PolyhedronFace::new(),
} }

View File

@@ -1,3 +1,5 @@
#![allow(dead_code)] // TODO: remove this once we support polygons.
use crate::geometry::contact_generator::PrimitiveContactGenerationContext; use crate::geometry::contact_generator::PrimitiveContactGenerationContext;
use crate::geometry::{sat, Contact, ContactManifold, KinematicsCategory, Polygon}; use crate::geometry::{sat, Contact, ContactManifold, KinematicsCategory, Polygon};
use crate::math::{Isometry, Point}; use crate::math::{Isometry, Point};

View File

@@ -1,3 +1,5 @@
#![allow(dead_code)] // TODO: remove this once we support polygons.
use crate::math::{Isometry, Point, Vector}; use crate::math::{Isometry, Point, Vector};
use ncollide::bounding_volume::AABB; use ncollide::bounding_volume::AABB;

View File

@@ -1,3 +1,5 @@
#![allow(dead_code)]
use crate::geometry::proximity_detector::PrimitiveProximityDetectionContext; use crate::geometry::proximity_detector::PrimitiveProximityDetectionContext;
use crate::geometry::{sat, Polygon, Proximity}; use crate::geometry::{sat, Polygon, Proximity};
use crate::math::Isometry; use crate::math::Isometry;

View File

@@ -4,6 +4,7 @@ use crate::utils::WSign;
use na::Unit; use na::Unit;
use ncollide::shape::{Segment, SupportMap}; use ncollide::shape::{Segment, SupportMap};
#[allow(dead_code)]
pub fn polygon_polygon_compute_separation_features( pub fn polygon_polygon_compute_separation_features(
p1: &Polygon, p1: &Polygon,
p2: &Polygon, p2: &Polygon,

View File

@@ -1,7 +1,6 @@
//! Miscellaneous utilities. //! Miscellaneous utilities.
use crate::dynamics::RigidBodyHandle; use crate::dynamics::RigidBodyHandle;
use crate::math::{Isometry, Point, Rotation, Vector};
#[cfg(all(feature = "enhanced-determinism", feature = "serde-serialize"))] #[cfg(all(feature = "enhanced-determinism", feature = "serde-serialize"))]
use indexmap::IndexMap as HashMap; use indexmap::IndexMap as HashMap;
use na::{Matrix2, Matrix3, Matrix3x2, Point2, Point3, Scalar, SimdRealField, Vector2, Vector3}; use na::{Matrix2, Matrix3, Matrix3x2, Point2, Point3, Scalar, SimdRealField, Vector2, Vector3};
@@ -1334,28 +1333,3 @@ pub(crate) fn other_handle(
pair.0 pair.0
} }
} }
/// Returns the rotation that aligns the y axis to the segment direction.
pub(crate) fn rotation_wrt_y(a: &Point<f32>, b: &Point<f32>) -> Rotation<f32> {
let mut dir = b - a;
if dir.y < 0.0 {
dir = -dir;
}
#[cfg(feature = "dim2")]
return Rotation::rotation_between(&Vector::y(), &dir);
#[cfg(feature = "dim3")]
return Rotation::rotation_between(&Vector::y(), &dir).unwrap_or(Rotation::identity());
}
// Return the transform that aligns the y axis to the segment and move the origin to the segment middle,
// and the capsule's half-height.
pub(crate) fn segment_to_capsule(a: &Point<f32>, b: &Point<f32>) -> (Isometry<f32>, f32) {
let rot = rotation_wrt_y(a, b);
let half_height = (b - a).norm() / 2.0;
let center = na::center(a, b);
let pos = Isometry::from_parts(center.coords.into(), rot);
(pos, half_height)
}

View File

@@ -5,7 +5,7 @@ use rapier::counters::Counters;
use rapier::dynamics::{ use rapier::dynamics::{
IntegrationParameters, JointParams, JointSet, RigidBodyHandle, RigidBodySet, IntegrationParameters, JointParams, JointSet, RigidBodyHandle, RigidBodySet,
}; };
use rapier::geometry::{Collider, ColliderSet, Shape}; use rapier::geometry::{Collider, ColliderSet};
use std::f32; use std::f32;
use wrapped2d::b2; use wrapped2d::b2;

View File

@@ -12,7 +12,7 @@ use rapier::counters::Counters;
use rapier::dynamics::{ use rapier::dynamics::{
IntegrationParameters, JointParams, JointSet, RigidBodyHandle, RigidBodySet, IntegrationParameters, JointParams, JointSet, RigidBodyHandle, RigidBodySet,
}; };
use rapier::geometry::{Collider, ColliderSet, Shape}; use rapier::geometry::{Collider, ColliderSet};
use rapier::math::Vector; use rapier::math::Vector;
use std::collections::HashMap; use std::collections::HashMap;
#[cfg(feature = "dim3")] #[cfg(feature = "dim3")]

View File

@@ -6,7 +6,7 @@ use rapier::counters::Counters;
use rapier::dynamics::{ use rapier::dynamics::{
IntegrationParameters, JointParams, JointSet, RigidBodyHandle, RigidBodySet, IntegrationParameters, JointParams, JointSet, RigidBodyHandle, RigidBodySet,
}; };
use rapier::geometry::{Collider, ColliderSet, Shape}; use rapier::geometry::{Collider, ColliderSet};
use rapier::utils::WBasis; use rapier::utils::WBasis;
use std::collections::HashMap; use std::collections::HashMap;

View File

@@ -21,7 +21,9 @@ use na::{self, Point2, Point3, Vector3};
use rapier::dynamics::{ use rapier::dynamics::{
ActivationStatus, IntegrationParameters, JointSet, RigidBodyHandle, RigidBodySet, ActivationStatus, IntegrationParameters, JointSet, RigidBodyHandle, RigidBodySet,
}; };
use rapier::geometry::{BroadPhase, ColliderSet, ContactEvent, NarrowPhase, ProximityEvent, Ray}; #[cfg(feature = "dim3")]
use rapier::geometry::Ray;
use rapier::geometry::{BroadPhase, ColliderSet, ContactEvent, NarrowPhase, ProximityEvent};
use rapier::math::Vector; use rapier::math::Vector;
use rapier::pipeline::{ChannelEventCollector, PhysicsPipeline, QueryPipeline}; use rapier::pipeline::{ChannelEventCollector, PhysicsPipeline, QueryPipeline};
#[cfg(feature = "fluids")] #[cfg(feature = "fluids")]