-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
Colliders from primitives #326
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
They added a lot of complexity and weren't working properly.
Jondolf
added
C-Enhancement
New feature or request
A-Collision
Relates to the broad phase, narrow phase, colliders, or other collision functionality
C-Breaking-Change
This change removes or changes behavior or APIs, requiring users to adapt
labels
Feb 17, 2024
Jondolf
added a commit
that referenced
this pull request
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-Breaking-Change
This change removes or changes behavior or APIs, requiring users to adapt
C-Enhancement
New feature or request
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Support creating colliders from the new geometric primitives in Bevy 0.13.
Solution
Add an
IntoCollider
trait and implement it for primitives. For now, tori and conical frusta are not supported, as they aren't as trivial to implement.Some new collider shapes are also supported: ellipses and regular polygons. These are implemented using custom shapes, as Parry doesn't have them built-in.
Collider::ball
is now alsoCollider::circle
in 2D andCollider::sphere
in 3D.Collider::cuboid
isCollider::rectangle
in 2D. This makes the naming consistent with Bevy.Migration Guide
Collider::ball
withCollider::circle
in 2D andCollider::sphere
in 3DCollider::cuboid
withCollider::rectangle
in 2D