Add cone support.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use crate::dynamics::{MassProperties, RigidBodyHandle, RigidBodySet};
|
||||
#[cfg(feature = "dim3")]
|
||||
use crate::geometry::PolygonalFeatureMap;
|
||||
use crate::geometry::{
|
||||
Ball, Capsule, ColliderGraphIndex, Contact, Cuboid, Cylinder, HeightField, InteractionGraph,
|
||||
Polygon, Proximity, Ray, RayIntersection, Shape, ShapeType, Triangle, Trimesh,
|
||||
Ball, Capsule, ColliderGraphIndex, Contact, Cuboid, HeightField, InteractionGraph, Polygon,
|
||||
Proximity, Ray, RayIntersection, Shape, ShapeType, Triangle, Trimesh,
|
||||
};
|
||||
#[cfg(feature = "dim3")]
|
||||
use crate::geometry::{Cone, Cylinder, PolygonalFeatureMap};
|
||||
use crate::math::{AngVector, Isometry, Point, Rotation, Vector};
|
||||
use downcast_rs::{impl_downcast, DowncastSync};
|
||||
use erased_serde::Serialize;
|
||||
@@ -40,6 +40,13 @@ impl ColliderShape {
|
||||
ColliderShape(Arc::new(Cylinder::new(half_height, radius)))
|
||||
}
|
||||
|
||||
/// Initialize a cone shape defined by its half-height
|
||||
/// (along along the y axis) and its basis radius.
|
||||
#[cfg(feature = "dim3")]
|
||||
pub fn cone(half_height: f32, radius: f32) -> Self {
|
||||
ColliderShape(Arc::new(Cone::new(half_height, radius)))
|
||||
}
|
||||
|
||||
/// Initialize a cuboid shape defined by its half-extents.
|
||||
pub fn cuboid(half_extents: Vector<f32>) -> Self {
|
||||
ColliderShape(Arc::new(Cuboid::new(half_extents)))
|
||||
@@ -171,6 +178,13 @@ impl<'de> serde::Deserialize<'de> for ColliderShape {
|
||||
.ok_or_else(|| serde::de::Error::invalid_length(0, &self))?;
|
||||
Arc::new(shape) as Arc<dyn Shape>
|
||||
}
|
||||
#[cfg(feature = "dim3")]
|
||||
Some(ShapeType::Cone) => {
|
||||
let shape: Cone = seq
|
||||
.next_element()?
|
||||
.ok_or_else(|| serde::de::Error::invalid_length(0, &self))?;
|
||||
Arc::new(shape) as Arc<dyn Shape>
|
||||
}
|
||||
None => {
|
||||
return Err(serde::de::Error::custom(
|
||||
"found invalid shape type to deserialize",
|
||||
@@ -328,6 +342,13 @@ impl ColliderBuilder {
|
||||
Self::new(ColliderShape::cylinder(half_height, radius))
|
||||
}
|
||||
|
||||
/// Initialize a new collider builder with a cone shape defined by its half-height
|
||||
/// (along along the y axis) and its basis radius.
|
||||
#[cfg(feature = "dim3")]
|
||||
pub fn cone(half_height: f32, radius: f32) -> Self {
|
||||
Self::new(ColliderShape::cone(half_height, radius))
|
||||
}
|
||||
|
||||
/// Initialize a new collider builder with a cuboid shape defined by its half-extents.
|
||||
#[cfg(feature = "dim2")]
|
||||
pub fn cuboid(hx: f32, hy: f32) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user