impl Volumetric for Shape doesn't allow for your own shapes
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 120
- PR merge metrics
- No merged PRs in 30d
Description
I was implementing an Ellipsoid Shape, but when I got to the Volumetric trait, I realized that it is hardcoded for the specific Shapes that ship with nphysics:
```
macro_rules! dispatch(
($p: ty, $i: ty, $sself: ident.$name: ident($($argN: ident),*)) => {
{
if let Some(b) = $sself.as_shape::>() {
return b.$name($($argN,)*)
}
if let Some(c) = $sself.as_shape::>() {
return c.$name($($argN,)*)
}
// else if let Some(c) = $sself.as_shape::>() {
// (c as &Volumetric).$name($($argN,)*)
// }
#[cfg(feature = "dim3")]
{
if let Some(c) = $sself.as_shape::>() {
return c.$name($($argN,)*)
}
}
#[cfg(feature = "dim2")]
{
if let Some(c) = $sself.as_shape::>() {
return c.$name($($argN,)*)
}
}
if let Some(c) = $sself.as_shape::>() {
return c.$name($($argN,)*)
}
// if let Some(c) = $sself.as_shape::>() {
// return c.$name($($argN,)*)
// }
/*
* XXX: dispatch by custom type.
*/
panic!("The `Volumetric` is not implemented by the given shape.")
}
}
);
```
We need a way to implement Volumetric for crate-provided Shape structs.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.