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

Feature Request: Add ellipse collider. #317

Closed
443eb9 opened this issue Jan 30, 2024 · 1 comment · Fixed by #315
Closed

Feature Request: Add ellipse collider. #317

443eb9 opened this issue Jan 30, 2024 · 1 comment · Fixed by #315
Labels
A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality C-Enhancement New feature or request

Comments

@443eb9
Copy link

443eb9 commented Jan 30, 2024

Ellipse is also a common shape.

@443eb9 443eb9 changed the title Feature Request: Add eclipse collider. Feature Request: Add ellipse collider. Jan 30, 2024
@Jondolf Jondolf added C-Enhancement New feature or request A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality labels Jan 30, 2024
@Jondolf Jondolf added this to the 0.4 milestone Jan 30, 2024
@Jondolf
Copy link
Owner

Jondolf commented Jan 30, 2024

Ellipses aren't supported as a built-in shape in the Parry collision detection library, but it should support custom colliders, so I'll try to implement it for next release. Bevy is getting geometric primitives for 0.13, which includes ellipses and more exotic shapes like conical frusta, and I'm trying to add support for all of these shapes (and also regular polygon colliders which are currently missing).

@Jondolf Jondolf linked a pull request Feb 18, 2024 that will close this issue
5 tasks
@Jondolf Jondolf mentioned this issue Feb 20, 2024
5 tasks
Jondolf added a commit that referenced this issue Feb 20, 2024
# Objective

Closes #314 and #317.

This PR will be merged once Bevy 0.13 is released. Feel free to use this `bevy-main` branch in the meantime if you want to use the main branch of Bevy with `bevy_xpbd`.

## Solution

Update to the latest Bevy version.

For the 0.13 migration, I will be trying to implement various changes, mostly surrounding the new geometric primitives and ray structs. I will probably do these in PRs that I merge into this one, and it will all be merged into main once 0.13 is actually released.

- [x] Combine `PhysicsDebugRenderer` and `PhysicsDebugConfig` into `PhysicsGizmos` gizmo configuration group
- [x] Support creating colliders from primitives #326
- [x] Support ellipses and regular polygons as colliders (conical frusta and tori later) #326
- [x] Support creating `ShapeCaster`s with primitive shapes
- [x] Use `Direction2d`/`Direction3d` in spatial query APIs #329

---

## Migration Guide

### Debug rendering

The `PhysicsDebugConfig` resource and `PhysicsDebugRenderer` system parameter have been removed in favor of the new `PhysicsGizmos` [gizmo configuration group](https://bevyengine.org/news/bevy-0-13/#multiple-gizmo-configurations).

Before:

```rust
fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins,
            PhysicsPlugins::default(),
            PhysicsDebugPlugin::default(),
        ))
        // Configure physics debug rendering
        .insert_resource(PhysicsDebugConfig {
            aabb_color: Some(Color::WHITE),
            ..default()
        })
        .run();
}
```

After:

```rust
fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins,
            PhysicsPlugins::default(),
            PhysicsDebugPlugin::default(),
        ))
        // Configure physics debug rendering
        .insert_gizmo_group(
            PhysicsGizmos {
                aabb_color: Some(Color::WHITE),
                ..default()
            },
            GizmoConfig::default(),
        )
        .run();
}
```

This also allows you to configure e.g. line width for just physics gizmos by configuring their `GizmoConfig`.

### Renamed `Collider` constructors (#326)

- Replace `Collider::ball` with `Collider::circle` in 2D and `Collider::sphere` in 3D
- Replace `Collider::cuboid` with `Collider::rectangle` in 2D

### Ray and shape casting (#329)

For spatial queries, replace `Vec2`/`Vec3` directions with [`Direction2d`](https://docs.rs/bevy/0.13.0/bevy/math/primitives/struct.Direction2d.html)/[`Direction3d`](https://docs.rs/bevy/0.13.0/bevy/math/primitives/struct.Direction3d.html).

```rust
// Before
let caster = RayCaster::new(Vec3::ZERO, Vec3::X);

// After
let caster = RayCaster::new(Vec3::ZERO, Direction3d::X);
```

This applies to `RayCaster`, `ShapeCaster`, `SpatialQuery` methods like `cast_ray`, and many other methods that use directions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Collision Relates to the broad phase, narrow phase, colliders, or other collision functionality C-Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants