diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 5ee5fec9..00000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,12 +0,0 @@ -# These are supported funding model platforms - -github: [ "dimforge" ] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index c7ecf5ea..00000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: 2 -updates: - - package-ecosystem: cargo - directory: / - schedule: - interval: weekly - - package-ecosystem: github-actions - directory: / - schedule: - interval: weekly diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml deleted file mode 100644 index 7d82826e..00000000 --- a/.github/workflows/dependencies.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Dependencies -on: - push: - branches-ignore: - - "dependabot/**" - - "releases/**" - paths: - - "Cargo.toml" - - "deny.toml" - pull_request: - paths: - - "Cargo.toml" - - "deny.toml" - schedule: - - cron: "0 0 * * 0" -env: - CARGO_TERM_COLOR: always -jobs: - dependencies: - name: Check dependencies - runs-on: ubuntu-latest - steps: - - name: Clone repo - uses: actions/checkout@v4 - - - name: Check dependencies - uses: EmbarkStudios/cargo-deny-action@v2 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 5cc855c1..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Rust - -on: - push: - branches: [master] - pull_request: - branches: [master] - -env: - CARGO_TERM_COLOR: always - RUST_CACHE_KEY: rust-cache-20240701 - CARGO_PROFILE_DEV_DEBUG: none - -jobs: - check-fmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - components: rustfmt - - name: Check formatting - run: cargo fmt -- --check - doc: - runs-on: ubuntu-latest - env: - RUSTDOCFLAGS: -D warnings - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - with: - prefix-key: ${{ env.RUST_CACHE_KEY }} - - run: sudo apt update && sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev - - name: Cargo doc - run: cargo doc --no-deps - test: - runs-on: ubuntu-latest - env: - RUSTFLAGS: -D warnings - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - - uses: Swatinem/rust-cache@v2 - with: - prefix-key: ${{ env.RUST_CACHE_KEY }} - - run: sudo apt update && sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev - - run: cargo install cargo-all-features - - name: Clippy for bevy_rapier2d - run: cargo clippy --verbose -p bevy_rapier2d --examples - - name: Clippy for bevy_rapier3d - run: cargo clippy --verbose -p bevy_rapier3d --examples - - name: Clippy for bevy_rapier2d (debug-render, simd, serde) - run: cargo clippy --verbose -p bevy_rapier2d --features debug-render-2d,simd8,serde-serialize,picking-backend - - name: Clippy for bevy_rapier3d (debug-render, simd, serde) - run: cargo clippy --verbose -p bevy_rapier3d --features debug-render-3d,simd8,serde-serialize,picking-backend - - name: Test for bevy_rapier2d - run: cargo test --verbose -p bevy_rapier2d - - name: Test for bevy_rapier3d - run: cargo test --verbose -p bevy_rapier3d - - name: Test for no conflicting system order ambiguity - run: cargo run --bin ambiguity_detection - - name: Check all features individually - run: cargo check-all-features - test-wasm: - runs-on: ubuntu-latest - env: - RUSTFLAGS: -D warnings - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy - targets: wasm32-unknown-unknown - - uses: Swatinem/rust-cache@v2 - with: - prefix-key: ${{ env.RUST_CACHE_KEY }} - - name: Clippy bevy_rapier2d - run: cd bevy_rapier2d && cargo clippy --verbose --features bevy/webgl2 --target wasm32-unknown-unknown - - name: Clippy bevy_rapier3d - run: cd bevy_rapier3d && cargo clippy --verbose --features bevy/webgl2 --target wasm32-unknown-unknown diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 224af64d..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "lldb", - "request": "launch", - "name": "Debug", - "program": "${workspaceFolder}/", - "args": [], - "cwd": "${workspaceFolder}" - } - ] -} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index faf5ff73..00000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "type": "cargo", - "command": "check", - "problemMatcher": [ - "$rustc" - ], - "group": "build", - "label": "rust: cargo check", - "presentation": { - "clear": true - } - }, - { - "type": "cargo", - "command": "run", - "args": [ - "--release", - "--example", - "boxes3" - ], - "problemMatcher": [ - "$rustc" - ], - "group": "build", - "label": "dim3/boxes3", - "presentation": { - "clear": true - } - }, - { - "type": "cargo", - "command": "run", - "args": [ - "--release", - "--example", - "boxes2" - ], - "problemMatcher": [ - "$rustc" - ], - "group": "build", - "label": "dim2/boxes2", - "presentation": { - "clear": true - } - } - ] -} diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index ba6707c5..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,698 +0,0 @@ -# Changelog - -## Unreleased - -### Modified - -- Update from rapier `0.33.0-alpha` to rapier `0.35.0-glamx0.2`. - See [rapier's changelog](https://github.com/dimforge/rapier/blob/master/CHANGELOG.md) for details. - - Removed the `simd-stable` and `simd-nightly` features: SIMD is now always enabled in rapier. - The new `simd8` feature widens the solver’s SIMD from 4 to 8 lanes (f32 only, incompatible - with `enhanced-determinism`). - - `SolverContactView::{friction, restitution}` now read from the contact manifold data (rapier - stores them per-manifold), and `SolverContactView::point` is reconstructed from the body-local - contact anchors; the public API is preserved. - - Custom event handlers assigned to `RapierContextSimulation` must now be `Send + Sync`. -- Known issue: the `enhanced-determinism` feature currently fails to compile with bevy, because - parry enables `glam/scalar-math` which removes the serde impls of `glam::BVec3A`/`BVec4A` that - `bevy_reflect` requires unconditionally. - -## v0.35.0 (12 July 2026) - -### Modified - -- Update to bevy 0.19. - -## v0.34.0 (14 May 2026) - -### Added - -- New `change_contexts3` 3D example demonstrating how to move an entity between physics contexts. - [#684](https://github.com/dimforge/bevy_rapier/pull/684) - -### Modified - -- Update from rapier `0.31` to rapier `0.32`. [#692](https://github.com/dimforge/bevy_rapier/pull/692) - See [rapier's changelog](https://github.com/dimforge/rapier/blob/master/CHANGELOG.md) for details. - - Most `Collider`, joint, and query-pipeline APIs now take `glam` vectors/rotations directly instead of - nalgebra `Point`s/`Isometry`s. For example, `Collider::capsule`, `Collider::segment`, - `Collider::triangle`, `Collider::voxels`, `RapierQueryPipeline::cast_ray`, `project_point`, - `intersect_shape`, `cast_shape`, etc. no longer require `.into()` conversions on input vectors. - - `TransformInterpolation::{start, end}` are now `Option` instead of `Option>`. - - `iso_to_transform` now takes a `&Pose` instead of `&Isometry`. - - `SolverContactView::is_new` now compares an internal float; the public boolean API is preserved. - - `ContactPairView::has_any_active_contact` is now a method call on the underlying contact pair. -- Renamed `Velocity` fields: `linvel` → `linear` and `angvel` → `angular`. - [#690](https://github.com/dimforge/bevy_rapier/pull/690) - -### Fix - -- Fix context swapping failing when physics runs in a schedule other than `PostUpdate`: a stray run - of `sync_removals` was removing handles that had just been added. - [#684](https://github.com/dimforge/bevy_rapier/pull/684) - -## v0.33.0 (06 March 2026) - -### Modified - -- Update Bevy to `0.18`. [#686](https://github.com/dimforge/bevy_rapier/pull/686) - - Examples now require the `bevy_gizmos_render` feature. - - The testbed examples moved their UI systems to the new `EguiPrimaryContextPass` schedule. - -## v0.32.0 (24 February 2026) - -### Added - -- Reflection support for `SpringCoefficients` (used by the new contact softness parameters) and, in 3D, - for `FrictionModel` (`Simplified` / `Coulomb`). [#680](https://github.com/dimforge/bevy_rapier/pull/680) -- New `voxels2_no_collider` 2D example demonstrating `Voxels` shapes without a collider. - [#680](https://github.com/dimforge/bevy_rapier/pull/680) - -### Modified - -- Update Bevy to `0.17.3`. [#680](https://github.com/dimforge/bevy_rapier/pull/680) - - Migrated from Bevy's `Event`/`Events`/`EventReader`/`EventWriter` to the new - `Message`/`Messages`/`MessageReader`/`MessageWriter` API. `CollisionEvent`, `ContactForceEvent`, - and `MassModifiedEvent` now derive `Message` instead of `Event`. - - Renamed `TransformSystem::TransformPropagate` usages to `TransformSystems::Propagate`. - - `PickSet` → `PickingSystems` for the picking backend. -- Update from rapier `0.27` to rapier `0.31`. [#680](https://github.com/dimforge/bevy_rapier/pull/680) - See [rapier's changelog](https://github.com/dimforge/rapier/blob/master/CHANGELOG.md) for details. - - `IntegrationParametersWrapper` reflection now exposes `contact_softness` (a `SpringCoefficients`), - `warmstart_coefficient`, and `length_unit`, replacing the previous `contact_damping_ratio` and - `contact_natural_frequency` fields. - -## v0.31.0 (04 August 2025) - -### Added - -- Expose `RapierBevyComponentApply`, to help with creating your own schedules when you set `default_system_setup` to `false`. -- Add `set_local_axis1` and `set_local_axis2` to `RevoluteJoint` and `RevoluteJointBuilder`. [#666](https://github.com/dimforge/bevy_rapier/pull/666) - -### Modified - -- Update from rapier `0.25` to rapier `0.27`, - see [rapier's changelog](https://github.com/dimforge/rapier/blob/master/CHANGELOG.md). - - `RapierQueryPipeline` is no longer a component. - - Migration: Use `RapierContext` or retrieve the needed components to pass to `RapierQueryPipeline::new_scoped` and make your logic in a scoped function. This function allows capturing and returning information. - - a new `QueryPipelineMut` to provide the same API as rapier. It's currently used for the character controller. - -### Fix - -- Fix scale being applied with a frame delay. [#659](https://github.com/dimforge/bevy_rapier/pull/659) - -## v0.30.0 (15 May 2025) - -### Added - -- Added a serialization `serialization2` example for `bevy_rapier2d`. -- Added reflection for `Default` in addition to `Component`. [#649](https://github.com/dimforge/bevy_rapier/pull/649) - -### Modified - -- Update Bevy to `0.16`. -- Update from rapier `0.23` to rapier `0.25`, - see [rapier's changelog](https://github.com/dimforge/rapier/blob/master/CHANGELOG.md). - - Notably, support and examples for parry's new `Voxels` shape have been added. -- `RapierContextInitialization::InitializeDefaultRapierContext` now has more fields for better control over default physics context. -- `ContactPairView::collider1` and `ContactPairView::collider2` now return an `Option`. - -### Fix - -- Fix position being incorrect when a rigidbody bevy entity has a scaled parent. [#646](https://github.com/dimforge/bevy_rapier/pull/646) - -## v0.29.0 (18 February 2025) - -### Added - -- Added optional feature `picking-backend` to support bevy_picking. - - See `picking_backend` module documentation for more details. -- Added `geometry::to_bevy_mesh` module behind the feature `to-bevy-mesh` to help with converting parry shapes into bevy meshes (#628). - - Lines, round and custom shapes are not implemented. - -### Modified - -- Update from rapier `0.22` to rapier `0.23`, - see [rapier's changelog](https://github.com/dimforge/rapier/blob/master/CHANGELOG.md). -- `Collider::trimesh` and `Collider::trimesh_with_flags` now return a `Result`. -- Under the feature `async-collider`, The `RapierPhysicsPlugin` now adds - `AssetPlugin`, `MeshPlugin` and `ScenePlugin` if these were not added, to circumvent a runtime crash - over missing required resources. -- `RapierPhysicsPlugin` can be customized through `with_physics_sets_systems` to opt out of default systems from `PhysicsSet`. -- `RapierContext` has been split in multiple `Component`s: - - `RapierContextColliders` - - `RapierContextJoints` - - `RapierContextSimulation` - - `RapierRigidBodySet` -- Renamed `DefaultReadRapierContext` to `ReadRapierContext` and `DefaultWriteRapierContext` to `WriteRapierContext`. - They have a new `bevy::QueryFilter` type parameter, defaulting to `With`. - -## v0.28.0 (09 December 2024) - -### Modified - -- Update from rapier `0.21` to rapier `0.22`, - see [rapier's changelog](https://github.com/dimforge/rapier/blob/master/CHANGELOG.md). -- Update bevy to 0.15. -- `RapierContext`, `RapierConfiguration` and `SimulationToRenderTime` are now a `Component` instead of resources. - - Rapier now supports multiple independent physics worlds, see example `multi_world3` for usage details. - - Migration guide: - - `ResMut` -> `WriteDefaultRapierContext` - - `Res` -> `ReadDefaultRapierContext` - - Access to `RapierConfiguration` and `SimulationToRenderTime` should query for it -on the responsible entity owning the `RenderContext`. - - If you are building a library on top of `bevy_rapier` and would want to support multiple independent physics worlds too, -you can check out the details of [#545](https://github.com/dimforge/bevy_rapier/pull/545) -to get more context and information. -- `colliders_with_aabb_intersecting_aabb` now takes `bevy::math::bounding::Aabb3d` (or `[..]::Aabb2d` in 2D) as parameter. - - it is now accessible with `headless` feature enabled. - -### Fix - -- Fix a crash when using `TimestepMode::Interpolated` and removing colliders -during a frame which would not run a simulation step. - -### Added - -- Added a `TriMeshFlags` parameter for `ComputedColliderShape`, -its default value is `TriMeshFlags::MERGE_DUPLICATE_VERTICES`, -which was its hardcoded behaviour. -- Added a way to configure which colliders should be debug rendered: `global` parameter for both - `RapierDebugColliderPlugin` and `DebugRenderContext`, as well as individual collider setup via - a `ColliderDebug` component. - -## v0.27.0 (07 July 2024) - -**This is an update from rapier 0.19 to Rapier 0.21 which includes several stability improvements -and new features. Please have a look at the -[0.20 and 0.21 changelogs](https://github.com/dimforge/rapier/blob/master/CHANGELOG.md) of Rapier.** - -### Modified - -- Update from rapier `0.19` to rapier `0.21`. -- Update to nalgebra `0.33`. -- Update to bevy `0.14`. -- Renamed `has_any_active_contacts` to `has_any_active_contact` for better consistency with rapier. -- `ColliderDebugColor`'s property is now a `bevy::color::Hsla`. -- `ImpulseJoint::data` and `MultibodyJoint::data` are now a more detailed enum `TypedJoint` instead of a `GenericJoint`. -You can still access its inner `GenericJoint` with `.as_ref()` or `as_mut()`. -- `data` fields from all joints (`FixedJoint`, …) are now public, and their getters removed. - -### Added - -- Derive `Debug` for `LockedAxes`. -- Expose `is_sliding_down_slope` to both `MoveShapeOutput` and `KinematicCharacterControllerOutput`. -- Added a First Person Shooter `character_controller` example for `bevy_rapier3d`. -- Added serialization support for `CollisionGroups`, `SolverGroups`, `ContactForceEventThreshold`, `ContactSkin`. -- Added `RapierContext::context.impulse_revolute_joint_angle` to compute the angle along a revolute joint’s principal axis. - -### Fix - -- Fix rigidbodies never going to sleep when a scale was applied to their `Transform`. -- Fix losing information about hit details when converting from `ShapeCastHit` in parry to `ShapeCastHit` in bevy_rapier - -## v0.26.0 (05 May 2024) - -**This is an update to Rapier 0.19 which includes several stability improvements -and character-controller fix. Please have a look at the -[0.19 changelog](https://github.com/dimforge/rapier/blob/master/CHANGELOG.md) of Rapier.** - -### Modified - -- Renamed `Toi/ToiDetails` to `ShapeCastHit/ShapeCastHitDetails`. -- Switch to rapier’s built-in `length_unit` instead of explicitly scaling shapes with `physics_scale`. -- Linear shape-casting functions now take a `ShapeCastOptions` parameter that describes how the shape-cast should - behave on special-cases (like toi == 0). -- Internal edge correction is now opt-in with the `TriMeshFlags::FIX_INTERNAL_EDGES` and - `HeightFieldFlags::FIX_INTERNAL_EDGES` flags. -- Rename `RayIntersection::toi` to `RayIntersection::time_of_impact`. - -### Fix - -- Fix character controller occasionally getting stuck against vertical walls. - -### Added - -- Add the `SoftCcd` (for rigid-bodies) and `ContactSkin` (for colliders) components. See - [rapier#625](https://github.com/dimforge/rapier/pull/625) for details on the features they enable. - -## v0.25.0 (19 Feb. 2024) - -### Modified - -- Update to bevy `0.13`. - -## v0.24.0 (27 Jan. 2024) - -The main highlight of this release is the implementation of a new non-linear constraints solver for better stability -and increased convergence rates. See [#579](https://github.com/dimforge/rapier/pull/579) for additional information. - -In order to adjust the number of iterations of the new solver, simply -adjust `IntegrationParameters::num_solver_iterations`. -If recovering the old solver behavior is useful to you, call `IntegrationParameters::switch_to_standard_pgs_solver()`. - -It is now possible to specify some additional solver iteration for specific rigid-bodies (and everything interacting -with it directly or indirectly through contacts and joints) by adding the `AdditionalSolverIterations` component to the -same entity as the rigid-body. This allows for higher-accuracy on subsets of the physics scene without affecting -performance of the other parts of the simulation. - -### Fix - -- Fix bug causing angular joint limits and motor to sometimes only take into account half of the angles specified by the - user. -- Fix bug where collisions would not be re-computed after a collider was re-enabled. - -### Added - -- Add a `SpringJoint` and `SpringJointBuilder` for simulating springs with customizable stiffness and damping - coefficients. -- Fix incorrect update of angular degrees-of-freedoms on spherical multibody joints. -- Fix debug-renderer showing moved kinematic rigid-bodies only at their initial position. - -### Modified - -- Rename `RapierContext::contacts_with` to `RapierContext::contact_pairs_with`. -- Rename `RapierContext::intersections_with` to `RapierContext::intersection_pairs_with`. -- Collisions between the character controller and sensors are now disabled by default. - -## 0.23.0 - -### Modified - -- Update to Bevy 0.12 - -### Added - -- `ColliderView::as_typed_shape` and `::to_shared_shape` to convert a `ColliderView` to a parry’s - `TypedShape` or `SharedShape`. The `From` trait has also been implemented accordingly. -- Implement `Copy` for `ColliderView` and all the other non-mut shape views. -- Add `RapierContext::rigid_body_colliders` to retrieve all collider entities attached to this rigid-body. -- Add `RapierPhysicsPlugin::in_fixed_schedule`/`::in_schedude` to add rapier’s systems to a fixed/custom - schedule. -- Re-export `JointAxesMask`, `JointAxis`, `MotorModel`. -- Implement `Deref` for `ReadMassProperties`. -- Expose the `stop_at_penetration` parameter of shape-casting, to enable or ignore overlaps at the initial position - of the shape. - -### Fix - -- Fix `RapierContext::integration_parameters::dt` not being updated on non-fixed timestep modes. -- Fix debug-renderer lagging one frame behind. -- Fix Collider `Transform` rotation change not being taken into account by the physics engine. -- Fix automatic update of `ReadMassProperties`. - -## 0.22.0 (10 July 2023) - -### Modified - -- Update to Bevy 0.11. -- Disabled rigid-bodies are no longer synchronized with the rapier backend. -- Switch to bevy’s gizmo system for the debug-renderer. This removes the vendored debug lines plugin. - -### Added - -- Add a joint for simulating ropes: the `RopeJoint`. -- Add `Velocity::linear_velocity_at_point` to calculate the linear velocity at the given world-space point. -- Add the `ComputedColliderShape::ConvexHull` variant to automatically calculate the convex-hull of an imported mesh. -- Implement `Reflect` for the debug-renderer. - -### Fix - -- Fix broken interpolation for rigid-bodies with the `TransformInterpolation` component. -- Fix compilation when `bevy_rapier` is being used with headless bevy. -- Improved performance of the writeback system by not iterating on non-rigid-body entities. -- Fix typo by renaming `CuboidViewMut::sed_half_extents` to `set_half_extents`. -- Properly scale parented collider’s offset based on changes on its `ColliderScale`. - -## 0.21.0 (07 March 2023) - -### Modified - -- Update to Bevy 0.10. -- The `PhysicsHooksWithQuery` trait has been renamed to by the `BevyPhysicsHooks`. -- Bevy resources and queries accessed by the physics hook are now specified by the implementer of `BevyPhysicsHooks` - which must derive Bevy’s `SystemParam` trait. This implies that the physics hook’s `filter_contact_pair` (and - all its other methods) no longer take the Bevy `Query` as argument. Queries and resources are accessed through - `self`. -- Rename `PhysicsStages` to `PhysicsSet`. - -## 0.20.0 (15 Jan. 2023) - -### Added - -- Add the `RigidBodyDisabled` and `ColliderDisabled` component that can be inserted to disable a rigid-body - or collider without removing it from the scene. - -### Fix - -- Fix spawn position of colliders without rigid bodies. -- Fix overriding enabled flag in debug render. - -### Modified - -- Make debug-rendering enabled by default when inserting the `RapierDebugRenderPlugin` plugin with its default - configuration. -- The `debug-render` feature has been replaced by two features: `debug-render-2d` and `debug-render-3d`. For example, - using `debug-render-2d` with `bevy_rapier3d`, the debug-render will work with 2D cameras (useful, e.g., for top-down - games - with 3D graphics). -- In order to facilitate the use of `bevy_rapier` in headless mode, the `AsyncCollider` and `AsyncSceneCollider` - components were moved behind the `async-collider` feature (enabled by default). Disabling that feature will - make `bevy_rapier` work even with the `MinimalPlugins` inserted instead of the `DefaultPlugins`. -- Corrected an API inconsistency where `bevy_rapier` components would sometimes require an `InteracitonGroup` type - defined in - `rapier`. It has been replaced by the `CollisionGroup` type (defined in `bevy_rapier`). -- `Velocity::zero,linear,angular` are now const-fn. - -## 0.19.0 (18 Nov. 2022) - -### Modified - -- Update to Bevy 0.9 - -## 0.18.0 (30 Oct. 2022) - -### Added - -- Add the accessor `RapierContext::physics_scale()` to read the physics scale - that was set when initializing the plugin. -- Add `RapierConfiguration::force_update_from_transform_changes` to force the transform - updates even if it is equal to the transform that was previously set. Useful for - rollback in networked applications described in [#261](https://github.com/dimforge/bevy_rapier/pull/261). -- Add `Collider::trimesh_with_flags` to create a triangle mesh collider with custom pre-processing - flags. - -### Fix - -- Reset the `ExternalImpulse` component after each step automatically. -- Fix `transform_to_iso` to preserve identical rotations instead of - converting to an intermediate axis-angle representation. -- Fix **internal edges** of 3D triangle meshes or 3D heightfields generating invalid contacts - preventing balls from moving straight. Be sure to set the triangle mesh flag - `TriMeshFlags::MERGE_DUPLICATE_VERTICES` when creating the collider if your mesh have duplicated - vertices. - -### Modified - -- Rename `AABB` to `Aabb` to comply with Rust’s style guide. - -## 0.17.0 (02 Oct. 2022) - -### Added - -- Add a **kinematic character controller** implementation. This feature is accessible in two different ways: - 1. The first approach is to insert the `KinematicCharacterController` component to an entity. If the - `KinematicCharacterController::custom_shape` field is set, then this shape is used for the character control. - If this field is `None` then the `Collider` attached to the same entity as the character controller is used. - The character controller will be automatically updated when the `KinematicCharacterController::movement` is set. - The result position is written to the `Transform` of the character controller’s entity. - 2. The second, lower level, approach, is to call `RapierContext::move_shape` to compute the possible movement - of a shape, taking obstacle and sliding into account. -- Add implementations of `Add`, `AddAssign`, `Sub`, `SubAssign` to `ExternalForce` and `ExternalImpulse`. -- Add `ExternalForce::at_point` and `ExternalImpulse::at_point` to apply a force/impulse at a specific point - of a rigid-body. - -### Fix - -- Fix shapes quickly switching between scaled and non-scaled versions due to rounding errors in the scaling extraction - from bevy’s global affine transform. - -## 0.16.2 (23 August 2022) - -### Added - -- Implement `Debug` for `Collider` and `ColliderView`. -- Add the missing `ActiveEvent::CONTACT_FORCE_EVENTS` to enable contact force events on a collider. - -## 0.16.1 (19 August 2022) - -### Fixed - -- Fix crash of the 2D debug-render on certain platforms (including Metal/MacOS). -- Fix bug where collision events and contact force events were not cleared automatically. -- Implement `Reflect` for `AsyncCollider`. - -## 0.16.0 (31 July 2022) - -### Modified - -- Switch to Bevy 0.8. - -## 0.15.0 (10 July 2022) - -### Fixed - -- Fix unpredictable broad-phase panic when using small colliders in the simulation. -- Fix collision events being incorrectly generated for any shape that produces multiple - contact manifolds (like triangle meshes). -- Fix transform hierarchies not being properly taken into account for colliders with a - parent rigid-body. -- Fix force and impulse application when the `ExternalImpulse` or `ExternalForce` components were added - at the same time as the rigid-body creation. -- Fix sleeping threshold application when these thresholds are set at the same time as the rigid-body - creation. - -### Added - -- Add the `ColliderMassProperties::Mass` variant to let the user specify a collider’s mass directly (instead of its - density). - As a result the collider’s angular inertia tensor will be automatically be computed based on this mass and its shape. -- Add the `ContactForceEvent` event. It can be read by a bevy system with the `EventReader`. This - event is useful to read contact forces. A `ContactForceEvent` is generated whenever the sum of the magnitudes of the - forces applied by contacts between two colliders exceeds the value specified by the `ContactForceEventThreshold` - component. -- Add the `QueryFilter` struct that is now used by all the scene queries instead of the `CollisionGroups` and - `Fn(Entity) -> bool` closure. This `QueryFilter` provides easy access to most common filtering strategies - (e.g. dynamic bodies only, excluding one particular entity, etc.) for scene queries. -- Added some missing serialization of joints. -- Implement `Default` for `Collider`. It defaults to a `Ball` with radius 0.5. -- Added a `contacts_enabled` flag to all the joints. If this flag is set to `false` for a joint, no contact will be - computed between two colliders attached to rigid-bodies liked by that joint. - -### Modified - -- The `MassProperties` struct is no longer a `Component`. A common mistake was to assume that `MassProperties` could - be used to initialize the mass/angular inertia tensor of a rigid-body. It is not the case. Instead, the user should - use the `AdditionalMassProperties` component. The `ReadMassProperties` component has been added to read the mass - properties of a rigid-body. -- The `Sensor` component is now a marker component: if it exists the related collider is a sensor, otherwise it is - a solid collider. - -## 0.14.1 (01 June 2022) - -### Fixed - -- Add the missing `init_async_scene_colliders` to the list of the plugin systems. - -## 0.14.0 (31 May 2022) - -### Added - -- Add the `AsyncSceneCollider` component to generate collision for scene meshes similar to `AsyncCollider`. -- Add calls to `App::register_type` for the types implementing `Reflect`. - -### Modified - -- `Collider::bevy_mesh`, `Collider::bevy_mesh_convex_decomposition` - and `Collider::bevy_mesh_convex_decomposition_with_params` was replaced with single `Collider::from_bevy_mesh` - function which accepts `ComputedColliderShape`. -- `AsyncCollider` is now a struct which contains a mesh handle and `ComputedColliderShape`. -- The physics systems are now running after `CoreStage::Update` but before `CoreStage::PostUpdate`. -- The collider and rigid-body positions are read from the `GlobalTransform` instead of `Transform` (the - transforms modified by Rapier are written back to the `Transform` component). It is therefore important - to insert both a `Transform` and `GlobalTransform` component (or the `TransformBundle` bundle). -- It is now possible to prevent the plugin from registering its system thanks - to `RapierPhysicsPlugin::with_default_system_setup(false)`. - If that’s the case, the `RapierPhysicsPlugin::get_systems` method can be called to retrieve the relevant `SystemSet` - that can be added to your own stages in order to apply your own scheduling. - -### Fixed - -- Fixed issues where contact regularization (using compliance) would result in tunnelling despite tunnelling - being enabled. -- Don’t overwrite the user’s `RapierConfiguration` if one already exists before initializing the plugin. - -## 0.13.2 (5 May 2022) - -### Modified - -- The `TimestepMode` and `SimulationToRenderTime` structures are now public. - -### Fixed - -- Fixed colors rendered by the debug-renderer. -- Fix issue where the debug-renderer would sometimes render lines behind the user’s meshes/sprites. - -## 0.13.1 (1 May 2022) - -### Added - -- Add the `CollidingEntities` components which tracks the set of entities colliding - with a given entity. -- Add constructors `Velocity::linear`, `Velocity::angular`, `Ccd::enabled()`, `Ccd::disabled()`, - `Dominance::group`, `Friction::coefficient`, `Restitution::coefficient`, `CollisionGroups::new`, - `SolverGroups::new`. -- Add `RapierContext::collider_parent` that returns the entity containing the parent `RigidBody` - of a collider. - -### Modified - -- Switched to linear ordering to order our systems. -- Make the `plugin::systems` module public. - -## 0.13.0 (30 Apr. 2022) - -This is a **complete rewrite of the plugin** (mostly likely the last large redesign this plugin -will be subject to). It switches to `rapier` 0.12 and `bevy` 0.7. The focus of this rewrite was -to significantly improve ergonomics while simplifying the codebase and adding new features. - -Refer to [#138](https://github.com/dimforge/bevy_rapier/pull/138) for extensive details -on this change. See the folders `bevy_rapier2d/examples` and `bevy_rapier3d/examples` -for some examples. - -## 0.12.0 - -### Modified - -- Switch to `rapier` 0.12.0-alpha.0 and `nalgebra` 0.30. -- Switch to `bevy` 0.6. -- All the Rapier components have been wrapped into wrapper types (for example `ColliderPosition` - has been wrapped into `ColliderPositionComponent`). These wrapper types are the ones that need - to be used as bevy components. To convert a Rapier component to it’s corresponding Bevy component, - simply use `.into()`. See the examples in `bevy_rapier2d/examples` and `bevy_rapier3d/examples` - for details. - -## 0.11.0 - -### Modified - -- Switch to `Rapier` 0.11 and `nalgebra` 0.29. -- Add labels to each system from `bevy-rapier`. - -### Fixed - -- Fix panics when despawning joints or colliders. -- Fix a panic where adding a collider. -- Don’t let the plugin overwrite the user’s `PhysicsHooksWithQueryObject` if it was already - present before inserting the plugin. - -## 0.10.2 - -### Fixed - -- Fix build when targeting WASM. - -## 0.10.1 - -### Fixed - -- Fix joint removal when despawning its entity. - -## 0.10.0 - -A new, exhaustive, user-guide for bevy_rapier has been uploaded to rapier.rs. - -This version is a complete rewrite of the plugin. Rigid-bodies and -colliders are now split into components that can be queried like any other -components. They are created by inserting a `RigidBodyBundle` and/or a `ColliderBundle`. - -In addition, the `Entity` type and `ColliderHandle/RigidBodyHandle` type can now be -converted directly using `entity.handle()` or `handle.entity()`. - -Finally, there is now a prelude: `use bevy_rapier2d::prelude::*`. - -## 0.9.0 - -### Added - -- The `ColliderDebugRender` component must be added to an entity - containing a collider shape in order to render it. - -## 0.8.0 - -### Changed - -- Use the version 0.5.0 of Rapier. - -### Added - -- The debug rendering of 3D trimesh now work. -- The debug rendering won't crash any more if a not-yet-supported shape - is used. It will silently ignore the shape instead. -- The crate has now a `render` feature that allows building it without any - rendering support (avoiding some dependencies that may not compile when - targeting WASM). - -## 0.7.0 - -### Changed - -- Use the version 0.4.0 of Bevy. - -## 0.6.2 - -### Changed - -- Fix the rendering of colliders attached to an entity children of another - entity containing the rigid-body it is attached to. - -## 0.6.1 - -### Changed - -- The adaptive change of number of timesteps executed during each render loop - (introduced in the version 0.4.0 with position interpolation) is - now disabled by default. It needs to be enabled explicitly by setting - `RapierConfiguration.time_dependent_number_of_timesteps` to `true`. - -## 0.6.0 - -### Added - -- It is now possible to attach multiple colliders to a single - rigid-body by using Bevy hierarchy: an entity contains - the `RigidBodyBuilder` whereas its children contain the `ColliderBuilder`. - -### Changed - -- We now use the latest version of Rapier: 0.4.0. See the - [Rapier changelog](https://github.com/dimforge/rapier/blob/master/CHANGELOG.md#v040) - for details. In particular, this includes the ability to lock the rotations of a rigid-body. - -## 0.5.0 - -### Changed - -- We now use the latest version of Bevy: 0.3.0 - -### Added - -- Rigid-bodies, colliders, and joints, will automatically removed from the Rapier - sets when their corresponding Bevy components are removed. - -## 0.4.0 - -This release update the plugin to the latest version of Rapier, which itself -includes lots of new features. Refer to the Rapier changelogs for details. - -### Added - -- A `InteractionPairFilters` resource where you can your own filters for contact pair - and proximity pair filtering. Before considering the use of a custom filter, consider - using collision groups instead (as it is faster, but less versatile). - -### Changed - -- The stepping system now applies interpolation between two physics state at render time. - Refer to [that issue](https://github.com/dimforge/bevy_rapier/pull/19) and the following - blog post article for details: https://www.gafferongames.com/post/fix_your_timestep/ - -## 0.3.1 - -### Changed - -- Rapier configuration - - Replaced `Gravity` and `RapierPhysicsScale` resources with a unique `RapierConfiguration` resource. - - Added an `physics_pipeline_active` attribute to `RapierConfiguration` allowing to pause the physic simulation. - - Added a `query_pipeline_active` attribute to `RapierConfiguration` allowing to pause the query pipeline update. - diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index 8bc02b26..00000000 --- a/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[workspace] -members = ["bevy_rapier2d", "bevy_rapier3d", "bevy_rapier_benches3d", "ci"] -resolver = "2" - -[workspace.dependencies] -rapier2d = "=0.35.0-glamx0.2" -rapier3d = "=0.35.0-glamx0.2" - -[profile.dev] -# Use slightly better optimization by default, as examples otherwise seem laggy. -opt-level = 1 - -[profile.release] -codegen-units = 1 - -[patch.crates-io] -#nalgebra = { path = "../nalgebra" } -#parry2d = { path = "../parry/crates/parry2d" } -#parry3d = { path = "../parry/crates/parry3d" } -#rapier2d = { path = "../rapier/crates/rapier2d" } -#rapier3d = { path = "../rapier/crates/rapier3d" } -#nalgebra = { git = "https://github.com/dimforge/nalgebra", branch = "dev" } -#parry2d = { git = "https://github.com/dimforge/parry", branch = "master" } -#parry3d = { git = "https://github.com/dimforge/parry", branch = "master" } -#rapier2d = { git = "https://github.com/dimforge/rapier", branch = "character-controller" } -#rapier3d = { git = "https://github.com/dimforge/rapier", branch = "character-controller" } diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 97f4383a..00000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2020 Sébastien Crozet - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.md b/README.md index 03b3a143..f292b6f2 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,8 @@ -

- crates.io -

-

- - - - - Build status - - - crates.io - - - crates.io - - - - -

-

- - Website | Documentation -

+**⛔ The official Rapier plugin for Bevy has been moved to the main Rapier repository: https://github.com/dimforge/rapier/bindings/bevy_rapier ⛔** +This move makes it easier to keep `bevy_rapier` up to date with the latest Rapier features, and will make it easier to keep our user-guide up-to-date for `bevy_rapier` too. ------ +If you currently depend on the git version of `bevy_rapier`, update the dependency url: -

-2D and 3D physics engines -for the Bevy game engine. -

- ------ +```toml +bevy_rapier3d = { git = "https://github.com/dimforge/rapier" } +``` \ No newline at end of file diff --git a/assets/FiraSans-Bold.ttf b/assets/FiraSans-Bold.ttf deleted file mode 100644 index 95e16602..00000000 Binary files a/assets/FiraSans-Bold.ttf and /dev/null differ diff --git a/bevy_rapier2d/Cargo.toml b/bevy_rapier2d/Cargo.toml deleted file mode 100644 index 8660dc2b..00000000 --- a/bevy_rapier2d/Cargo.toml +++ /dev/null @@ -1,118 +0,0 @@ -[package] -name = "bevy_rapier2d" -version = "0.36.0" -authors = ["Sébastien Crozet "] -description = "2-dimensional physics engine in Rust, official Bevy plugin." -documentation = "http://docs.rs/bevy_rapier2d" -homepage = "http://rapier.rs" -repository = "https://github.com/dimforge/bevy_rapier" -readme = "../README.md" -keywords = ["physics", "dynamics", "rigid", "real-time", "joints"] -license = "Apache-2.0" -edition = "2021" - - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -path = "../src/lib.rs" -required-features = ["dim2"] - -[lints] -rust.unexpected_cfgs = { level = "warn", check-cfg = [ - 'cfg(feature, values("dim3"))', -] } -clippy = { needless_lifetimes = "allow" } - -[features] -default = [ - "dim2", - "async-collider", - "debug-render-2d", - "picking-backend", - "to-bevy-mesh", -] -dim2 = [] -debug-render-2d = [ - "bevy/bevy_core_pipeline", - "bevy/bevy_sprite", - "bevy/bevy_gizmos", - "rapier2d/debug-render", - "bevy/bevy_asset", -] -debug-render-3d = [ - "bevy/bevy_core_pipeline", - "bevy/bevy_pbr", - "bevy/bevy_gizmos", - "rapier2d/debug-render", - "bevy/bevy_asset", -] -rapier-debug-render = ["rapier2d/debug-render"] - -parallel = ["rapier2d/parallel"] -simd8 = ["rapier2d/simd8"] -serde-serialize = ["rapier2d/serde-serialize", "bevy/serialize", "serde"] -enhanced-determinism = ["rapier2d/enhanced-determinism"] -headless = [] -picking-backend = ["bevy/bevy_picking", "bevy/bevy_render"] -async-collider = [ - "bevy/bevy_asset", - "bevy/bevy_world_serialization", - "bevy/bevy_render", - "bevy/bevy_image", -] -to-bevy-mesh = ["bevy/bevy_render", "bevy/bevy_asset"] - -[dependencies] -bevy = { version = "0.19.0", default-features = false, features = ["std"] } -nalgebra = { version = "0.34.2", features = ["convert-glam032"] } -rapier2d = { workspace = true } -bitflags = "2.10.0" -log = "0.4" -serde = { version = "1", features = ["derive"], optional = true } - -[dev-dependencies] -bevy = { version = "0.19.0", default-features = false, features = [ - "x11", - "bevy_state", - "bevy_window", - "bevy_debug_stepping", - "bevy_log", - "bevy_text", - "default_font", - "bevy_winit", - "bevy_render", - "bevy_core_pipeline", - "bevy_sprite", - "bevy_sprite_render", - "bevy_gizmos", - "bevy_gizmos_render", - "bevy_color", - "bevy_camera", -] } -oorandom = "11" -approx = "0.5.1" -glam = { version = "0.32.1", features = ["approx"] } -bevy-inspector-egui = "0.37.0" -bevy_egui = "0.40.0" -bevy_mod_debugdump = "0.16.0" -serde_json = "1.0" - -[package.metadata.docs.rs] -# Enable all the features when building the docs on docs.rs -features = ["debug-render-2d", "serde-serialize"] - -[package.metadata.cargo-all-features] - -# `enhanced-determinism` enables `glam/scalar-math` (through parry), which removes the serde -# impls of `glam::BVec3A`/`BVec4A` that `bevy_reflect` requires unconditionally. -denylist = ["enhanced-determinism"] - -# Features "dim2" and "dim3" are incompatible, so skip permutations including them -skip_feature_sets = [["enhanced-determinism", "simd8"]] - -always_include_features = ["dim2"] - -# The maximum number of features to try at once. Does not count features from `always_include_features`. -# This is useful for reducing the number of combinations run for a crate with a large amount of features, -# since in most cases a bug just needs a small set of 2-3 features to reproduce. -max_combination_size = 1 diff --git a/bevy_rapier2d/examples/boxes2.rs b/bevy_rapier2d/examples/boxes2.rs deleted file mode 100644 index aa986331..00000000 --- a/bevy_rapier2d/examples/boxes2.rs +++ /dev/null @@ -1,62 +0,0 @@ -use bevy::prelude::*; -use bevy_rapier2d::prelude::*; - -fn main() { - App::new() - .insert_resource(ClearColor(Color::srgb( - 0xF9 as f32 / 255.0, - 0xF9 as f32 / 255.0, - 0xFF as f32 / 255.0, - ))) - .add_plugins(( - DefaultPlugins, - RapierPhysicsPlugin::::pixels_per_meter(100.0), - RapierDebugRenderPlugin::default(), - )) - .add_systems(Startup, (setup_graphics, setup_physics)) - .run(); -} - -pub fn setup_graphics(mut commands: Commands) { - commands.spawn((Camera2d, Transform::from_xyz(0.0, 20.0, 0.0))); -} - -pub fn setup_physics(mut commands: Commands) { - /* - * Ground - */ - let ground_size = 500.0; - let ground_height = 10.0; - - commands.spawn(( - Transform::from_xyz(0.0, 0.0 * -ground_height, 0.0), - Collider::cuboid(ground_size, ground_height), - )); - - /* - * Create the cubes - */ - let num = 8; - let rad = 10.0; - - let shift = rad * 2.0 + rad; - let centerx = shift * (num / 2) as f32; - let centery = shift / 2.0; - - let mut offset = -(num as f32) * (rad * 2.0 + rad) * 0.5; - - for j in 0usize..20 { - for i in 0..num { - let x = i as f32 * shift - centerx + offset; - let y = j as f32 * shift + centery + 30.0; - - commands.spawn(( - Transform::from_xyz(x, y, 0.0), - RigidBody::Dynamic, - Collider::cuboid(rad, rad), - )); - } - - offset -= 0.05 * rad * (num as f32 - 1.0); - } -} diff --git a/bevy_rapier2d/examples/contact_filter2.rs b/bevy_rapier2d/examples/contact_filter2.rs deleted file mode 100644 index d10cca1b..00000000 --- a/bevy_rapier2d/examples/contact_filter2.rs +++ /dev/null @@ -1,98 +0,0 @@ -use bevy::{ecs::system::SystemParam, prelude::*}; -use bevy_rapier2d::prelude::*; - -#[derive(PartialEq, Eq, Clone, Copy, Component)] -enum CustomFilterTag { - GroupA, - GroupB, -} - -// A custom filter that allows contacts only between rigid-bodies with the -// same user_data value. -// Note that using collision groups would be a more efficient way of doing -// this, but we use custom filters instead for demonstration purpose. -#[derive(SystemParam)] -struct SameUserDataFilter<'w, 's> { - tags: Query<'w, 's, &'static CustomFilterTag>, -} - -impl BevyPhysicsHooks for SameUserDataFilter<'_, '_> { - fn filter_contact_pair(&self, context: PairFilterContextView) -> Option { - if self.tags.get(context.collider1()).ok().copied() - == self.tags.get(context.collider2()).ok().copied() - { - Some(SolverFlags::COMPUTE_IMPULSES) - } else { - None - } - } -} - -fn main() { - App::new() - .insert_resource(ClearColor(Color::srgb( - 0xF9 as f32 / 255.0, - 0xF9 as f32 / 255.0, - 0xFF as f32 / 255.0, - ))) - .add_plugins(( - DefaultPlugins, - RapierPhysicsPlugin::::pixels_per_meter(100.0), - RapierDebugRenderPlugin::default(), - )) - .add_systems(Startup, (setup_graphics, setup_physics)) - .run(); -} - -fn setup_graphics(mut commands: Commands) { - commands.spawn((Camera2d, Transform::from_xyz(0.0, 20.0, 0.0))); -} - -pub fn setup_physics(mut commands: Commands) { - /* - * Ground - */ - let ground_size = 100.0; - - commands.spawn(( - Transform::from_xyz(0.0, -100.0, 0.0), - Collider::cuboid(ground_size, 12.0), - CustomFilterTag::GroupA, - )); - - commands.spawn(( - Transform::from_xyz(0.0, 0.0, 0.0), - Collider::cuboid(ground_size, 12.0), - CustomFilterTag::GroupB, - )); - - /* - * Create the cubes - */ - let num = 4; - let rad = 5.0; - - let shift = rad * 2.0; - let centerx = shift * (num as f32) / 2.0; - let centery = shift / 2.0; - let mut group_id = 0; - let tags = [CustomFilterTag::GroupA, CustomFilterTag::GroupB]; - let colors = [Hsla::hsl(220.0, 1.0, 0.3), Hsla::hsl(260.0, 1.0, 0.7)]; - - for i in 0..num { - for j in 0usize..num * 5 { - let x = (i as f32 + j as f32 * 0.2) * shift - centerx; - let y = j as f32 * shift + centery + 20.0; - group_id += 1; - - commands.spawn(( - Transform::from_xyz(x, y, 0.0), - RigidBody::Dynamic, - Collider::cuboid(rad, rad), - ActiveHooks::FILTER_CONTACT_PAIRS, - tags[group_id % 2], - ColliderDebugColor(colors[group_id % 2]), - )); - } - } -} diff --git a/bevy_rapier2d/examples/custom_system_setup2.rs b/bevy_rapier2d/examples/custom_system_setup2.rs deleted file mode 100644 index 26a8e0ab..00000000 --- a/bevy_rapier2d/examples/custom_system_setup2.rs +++ /dev/null @@ -1,105 +0,0 @@ -use bevy::{diagnostic::FrameCount, prelude::*}; -use bevy_rapier2d::prelude::*; - -fn main() { - let mut app = App::new(); - - app.insert_resource(ClearColor(Color::srgb( - 0xF9 as f32 / 255.0, - 0xF9 as f32 / 255.0, - 0xFF as f32 / 255.0, - ))) - .add_plugins(( - DefaultPlugins, - RapierPhysicsPlugin::::pixels_per_meter(100.0).with_default_system_setup(false), - RapierDebugRenderPlugin::default(), - )) - .add_systems(Startup, (setup_graphics, setup_physics)); - - app.configure_sets( - PostUpdate, - ( - PhysicsSet::SyncBackend, - PhysicsSet::StepSimulation, - PhysicsSet::Writeback, - ) - .chain() - .before(TransformSystems::Propagate), - ); - - app.add_systems( - PostUpdate, - ( - RapierPhysicsPlugin::::get_systems(PhysicsSet::SyncBackend) - .in_set(PhysicsSet::SyncBackend), - ( - RapierPhysicsPlugin::::get_systems(PhysicsSet::StepSimulation), - despawn_one_box, - ) - .in_set(PhysicsSet::StepSimulation), - RapierPhysicsPlugin::::get_systems(PhysicsSet::Writeback) - .in_set(PhysicsSet::Writeback), - ), - ); - - app.run(); -} - -fn despawn_one_box( - mut commands: Commands, - frame_count: ResMut, - query: Query, With)>, -) { - // Delete a box every 10 frames - if frame_count.0.is_multiple_of(10) && !query.is_empty() { - let len = query.iter().len(); - // Get a "random" box to make sim interesting - if let Some(entity) = query.iter().nth(frame_count.0 as usize % len) { - commands.entity(entity).despawn(); - } - } -} - -fn setup_graphics(mut commands: Commands) { - commands.spawn((Camera2d, Transform::from_xyz(0.0, 20.0, 0.0))); -} - -pub fn setup_physics(mut commands: Commands) { - /* - * Ground - */ - let ground_size = 500.0; - let ground_height = 10.0; - - commands.spawn(( - Transform::from_xyz(0.0, 0.0 * -ground_height, 0.0), - Collider::cuboid(ground_size, ground_height), - )); - - /* - * Create the cubes - */ - let num = 8; - let rad = 10.0; - - let shift = rad * 2.0 + rad; - let centerx = shift * (num / 2) as f32; - let centery = shift / 2.0; - - let mut offset = -(num as f32) * (rad * 2.0 + rad) * 0.5; - - for j in 0usize..20 { - for i in 0..num { - let x = i as f32 * shift - centerx + offset; - let y = j as f32 * shift + centery + 30.0; - - commands.spawn(( - Transform::from_xyz(x, y, 0.0), - RigidBody::Dynamic, - Collider::cuboid(rad, rad), - )); - } - - offset -= 0.05 * rad * (num as f32 - 1.0); - } -} diff --git a/bevy_rapier2d/examples/debug_despawn2.rs b/bevy_rapier2d/examples/debug_despawn2.rs deleted file mode 100644 index a26cd25f..00000000 --- a/bevy_rapier2d/examples/debug_despawn2.rs +++ /dev/null @@ -1,266 +0,0 @@ -// NOTE: this demo is great for debugging despawning. -// It was extracted for one of the debug branch from @audunhalland -// in https://github.com/dimforge/bevy_rapier/issues/75 - -use bevy::prelude::*; -use bevy_rapier2d::prelude::*; - -fn main() { - App::new() - .init_resource::() - .insert_resource(ClearColor(Color::srgb(0.0, 0.0, 0.0))) - .add_plugins(( - DefaultPlugins, - RapierPhysicsPlugin::::pixels_per_meter(100.0), - RapierDebugRenderPlugin::default(), - )) - .add_systems(Startup, setup_game) - .add_systems(Update, cube_sleep_detection) - .run(); -} - -#[derive(Default)] -struct Stats { - generated_blocks: i32, - cleared_blocks: i32, - lost_blocks: i32, - lost_cube: bool, -} - -impl Stats { - fn health(&self) -> f32 { - if self.lost_cube { - 0.0 - } else if self.cleared_blocks == 0 { - if self.lost_blocks > 0 { - 0.0 - } else { - 1.0 - } - } else { - let lost_ratio = self.lost_blocks as f32 / self.cleared_blocks as f32; - - 1.0 - lost_ratio - } - } -} - -#[derive(Resource)] -pub struct Game { - n_lanes: usize, - n_rows: usize, - stats: Stats, - cube_colors: Vec, - current_cube_joints: Vec, -} - -impl Game { - fn floor_y(&self) -> f32 { - -(self.n_rows as f32) * 0.5 - } - fn left_wall_x(&self) -> f32 { - -(self.n_lanes as f32) * 0.5 - } -} - -impl Default for Game { - fn default() -> Self { - Self { - n_lanes: 10, - n_rows: 20, - stats: Stats::default(), - cube_colors: vec![], - current_cube_joints: vec![], - } - } -} - -fn byte_rgb(r: u8, g: u8, b: u8) -> Color { - Color::srgb(r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0) -} - -pub fn setup_game(mut commands: Commands, mut game: ResMut) { - game.current_cube_joints = vec![]; - - game.cube_colors = vec![ - byte_rgb(0, 244, 243), - byte_rgb(238, 243, 0), - byte_rgb(177, 0, 254), - byte_rgb(27, 0, 250), - byte_rgb(252, 157, 0), - byte_rgb(0, 247, 0), - byte_rgb(255, 0, 0), - ]; - - commands.spawn(Camera2d); - - setup_board(&mut commands, &game); - - // initial cube - spawn_cube(&mut commands, &mut game); -} - -#[derive(Clone, Copy, Debug)] -enum CubeKind { - I, -} - -impl CubeKind { - fn random() -> Self { - Self::I - } - - fn layout(&self) -> CubeLayout { - CubeLayout { - coords: [(1, 1), (1, 0), (1, -1), (1, -2)], - joints: vec![(0, 1), (1, 2), (2, 3)], - } - } -} - -struct CubeLayout { - coords: [(i32, i32); 4], - joints: Vec<(usize, usize)>, -} - -#[derive(Component)] -struct Block; - -fn setup_board(commands: &mut Commands, game: &Game) { - let floor_y = game.floor_y(); - - // Add floor - commands.spawn(( - Sprite { - color: Color::srgb(0.5, 0.5, 0.5), - custom_size: Some(Vec2::new(game.n_lanes as f32 * 30.0, 60.0)), - ..Default::default() - }, - Transform::from_xyz(0.0, floor_y - 30.0 * 0.5, 0.0), - RigidBody::Fixed, - Collider::cuboid(game.n_lanes as f32 * 30.0 / 2.0, 60.0 / 2.0), - )); -} - -fn spawn_cube(commands: &mut Commands, game: &mut Game) { - let kind = CubeKind::random(); - let CubeLayout { coords, joints } = kind.layout(); - - let block_entities: Vec = coords - .iter() - .map(|(x, y)| { - let lane = (game.n_lanes as i32 / 2) - 1 + x; - let row = game.n_rows as i32 - 1 + y; - spawn_block(commands, game, kind, lane, row) - }) - .collect(); - - game.current_cube_joints.clear(); - for (i, j) in &joints { - let x_dir = coords[*j].0 as f32 - coords[*i].0 as f32; - let y_dir = coords[*j].1 as f32 - coords[*i].1 as f32; - - let anchor_1 = Vec2::new(x_dir * 0.5, y_dir * 0.5); - let anchor_2 = Vec2::new(x_dir * -0.5, y_dir * -0.5); - - commands - .entity(block_entities[*j]) - .with_children(|children| { - let id = children - .spawn(ImpulseJoint::new( - block_entities[*i], - RevoluteJointBuilder::new() - .local_anchor1(anchor_1) - .local_anchor2(anchor_2), - )) - .id(); - game.current_cube_joints.push(id); - }); - } - - game.stats.generated_blocks += block_entities.len() as i32; -} - -fn spawn_block( - commands: &mut Commands, - game: &Game, - kind: CubeKind, - lane: i32, - row: i32, -) -> Entity { - // x, y is the center of the block - let x = game.left_wall_x() + lane as f32 + 0.5; - let y = game.floor_y() + row as f32 + 0.5; - - // Game gets more difficult when this is lower: - let linear_damping = 3.0; - - commands - .spawn(( - Sprite { - color: game.cube_colors[kind as usize], - custom_size: Some(Vec2::new(30.0, 30.0)), - ..Default::default() - }, - Transform::from_xyz(x, y, 0.0), - RigidBody::Dynamic, - Damping { - linear_damping, - angular_damping: 0.0, - }, - Collider::cuboid(30.0 / 2.0, 30.0 / 2.0), - Block, - )) - .id() -} - -pub fn cube_sleep_detection( - mut commands: Commands, - mut game: ResMut, - block_query: Query<(Entity, &GlobalTransform)>, -) { - let all_blocks_sleeping = true; - - if all_blocks_sleeping { - for joint in &game.current_cube_joints { - commands.entity(*joint).despawn(); - } - - clear_filled_rows(&mut commands, &mut game, block_query); - - if game.stats.health() > 0.0 { - spawn_cube(&mut commands, &mut game); - } - } -} - -fn clear_filled_rows( - commands: &mut Commands, - game: &mut Game, - block_query: Query<(Entity, &GlobalTransform)>, -) { - let mut blocks_per_row: Vec> = (0..game.n_rows).map(|_| vec![]).collect(); - - let floor_y = game.floor_y(); - - for (block_entity, position) in block_query.iter() { - let floor_distance = position.translation().y - floor_y; - - // The center of a block on the floor is 0.5 above the floor, so .floor() the number ;) - let row = floor_distance.floor() as i32; - - if row >= 0 && row < game.n_rows as i32 { - blocks_per_row[row as usize].push(block_entity); - } - } - - for row_blocks in blocks_per_row { - if row_blocks.len() == game.n_lanes { - game.stats.cleared_blocks += game.n_lanes as i32; - - for block_entity in row_blocks { - commands.entity(block_entity).despawn(); - } - } - } -} diff --git a/bevy_rapier2d/examples/debug_toggle2.rs b/bevy_rapier2d/examples/debug_toggle2.rs deleted file mode 100644 index a5b1e1e0..00000000 --- a/bevy_rapier2d/examples/debug_toggle2.rs +++ /dev/null @@ -1,114 +0,0 @@ -use std::time::Duration; - -pub use bevy::input::common_conditions::input_just_pressed; -use bevy::prelude::*; -use bevy_rapier2d::prelude::*; - -fn main() { - App::new() - .insert_resource(ClearColor(Color::srgb( - 0xF9 as f32 / 255.0, - 0xF9 as f32 / 255.0, - 0xFF as f32 / 255.0, - ))) - .add_plugins(( - DefaultPlugins, - RapierPhysicsPlugin::::default(), - RapierDebugRenderPlugin::default(), - )) - .add_systems(Startup, (setup_graphics, setup_physics)) - .add_systems( - Update, - ( - toggle_debug, - (|mut debug_render_context: ResMut| { - debug_render_context.enabled = !debug_render_context.enabled; - }) - .run_if(input_just_pressed(KeyCode::KeyV)), - ), - ) - .run(); -} - -pub fn setup_graphics(mut commands: Commands) { - commands.spawn(( - Camera3d::default(), - Transform::from_xyz(-30.0, 30.0, 100.0).looking_at(Vec3::new(0.0, 10.0, 0.0), Vec3::Y), - )); -} - -#[derive(Component)] -pub struct DebugCooldown(pub Timer); - -pub fn setup_physics(mut commands: Commands) { - /* - * Ground - */ - let ground_size = 200.1; - let ground_height = 0.1; - - commands.spawn(( - Transform::from_xyz(0.0, -ground_height, 0.0), - Collider::cuboid(ground_size, ground_height), - )); - - /* - * Create the cubes - */ - let num = 8; - let rad = 1.0; - - let shift = rad * 2.0 + rad; - let centerx = shift * (num / 2) as f32; - let centery = shift / 2.0; - let centerz = shift * (num / 2) as f32; - - let mut offset = -(num as f32) * (rad * 2.0 + rad) * 0.5; - let mut color = 0; - let colors = [ - Hsla::hsl(220.0, 1.0, 0.3), - Hsla::hsl(180.0, 1.0, 0.3), - Hsla::hsl(260.0, 1.0, 0.7), - ]; - - for j in 0usize..20 { - for i in 0..num { - for k in 0usize..num { - let x = i as f32 * shift - centerx + offset; - let y = j as f32 * shift + centery + 3.0; - let z = k as f32 * shift - centerz + offset; - color += 1; - - commands - .spawn(Transform::from_rotation(Quat::from_rotation_x(0.2))) - .with_children(|child| { - child.spawn(( - Transform::from_xyz(x, y, z), - RigidBody::Dynamic, - Collider::cuboid(rad, rad), - ColliderDebugColor(colors[color % 3]), - ColliderDebug::AlwaysRender, - DebugCooldown(Timer::new( - Duration::from_secs_f32(0.4f32 + (i % 3 + (j + 1) % 3) as f32), - TimerMode::Repeating, - )), - )); - }); - } - } - - offset -= 0.05 * rad * (num as f32 - 1.0); - } -} - -pub fn toggle_debug(time: Res