2d collision test for game-development in rust (with optional integration and example for bevy)

Overview

impacted

License Crates.io Docs Build

2d collision test for game-development in rust (with optional integration and example for bevy)

This provides a low-level "narrow-phase" collision-detection logic, with some integration for the bevy game engine (behind feature flag).

If you want to pair it with a broad-phase, you may look at bvh-arena or broccoli.

Roadmap

  • collision test (GJK implementation)
  • collision shapes
    • circle
    • rectangle
    • convex-hull
    • capsule
  • contact generation (EPA implementation)

Usage example

use impacted::{CollisionShape, Transform};
use glam::Vec2; // <-- use any math library you like

// Create a circle
let circle = CollisionShape::new_circle(1.0);

// Create a rectangle
let mut rect = CollisionShape::new_rectangle(4.0, 4.0)
    .with_transform(Transform::from_translation(Vec2::new(2.0, 0.0)));

// Test for collision
assert!(circle.is_collided_with(&rect));

You may also look in the examples directory for more complete/concrete usage examples (e.g. using the bevy engine)

Installation

[dependencies]
impacted = "1.4.0"

For bevy users

[dependencies]
impacted = { version = "1.4.0", features = ["bevy-07"] }

Cargo features

  • std (enabled by default) Allow to use the standard library (need to be disabled for no_std crates)
  • bvh-arena Interoperability with bvh-arena bounding volumes
  • bevy-07 All bevy 0.7 interop (alias for ["bevy-transform-07", "bevy-ecs-07"])
  • bevy-06 All bevy 0.6 interop (alias for ["bevy-transform-06", "bevy-ecs-06"])
  • bevy-transform-07 Interoperability with bevy_transform 0.7
  • bevy-transform-06 Interoperability with bevy_transform 0.6
  • bevy-ecs-07 Interoperability with bevy_ecs 0.7
  • bevy-ecs-06 Interoperability with bevy_ecs 0.6

MSRV

The minimum supported rust version is currently: 1.58

It may be increased to a newer stable version in a minor release.

It will be increased to the latest stable version in a major release.

Unlicense

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

Comments
  • feat: add type `Bounds`

    feat: add type `Bounds`

    Adds a new type Bounds which can be used with CollisionShape.bounds() for retrieving bounding box of a shape.

    The methods new, center, min, max, size and expand all make use of glam::Vec2. Is this a problem? Should it all be changed to [f32; 2] instead?

    If bounds is not in the scope of this package, feel free to reject the PR, but from my experience it has been a useful feature.

    This PR does not include any tests for bounds.

    enhancement design need-use-case 
    opened by tqwewe 2
  • chore(deps): update rust crate rstest to 0.16.0

    chore(deps): update rust crate rstest to 0.16.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | rstest | dev-dependencies | minor | 0.15.0 -> 0.16.0 |


    Release Notes

    la10736/rstest

    v0.16.0

    Compare Source

    Changed
    • Show TEST START banner only when trace some argument: See #โ€‹158 for details.
    • Add values to test name: See #โ€‹160 for details.
    Fixed
    • Updated test fixtures to 1.64.0 compiler's error messages.

    Configuration

    ๐Ÿ“… Schedule: Branch creation - "every weekend" (UTC), Automerge - At any time (no schedule defined).

    ๐Ÿšฆ Automerge: Enabled.

    โ™ป Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    ๐Ÿ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    released 
    opened by renovate[bot] 1
  • chore(deps): update rust crate smallvec to 1.10

    chore(deps): update rust crate smallvec to 1.10

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | smallvec | dependencies | minor | 1.9 -> 1.10 |


    Release Notes

    servo/rust-smallvec

    v1.10.0

    Compare Source


    Configuration

    ๐Ÿ“… Schedule: Branch creation - "every weekend" (UTC), Automerge - At any time (no schedule defined).

    ๐Ÿšฆ Automerge: Disabled by config. Please merge this manually once you are satisfied.

    โ™ป Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    ๐Ÿ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, check this box

    This PR has been generated by Mend Renovate. View repository job log here.

    released 
    opened by renovate[bot] 1
  • chore(deps): update rust crate smallvec to 1.9

    chore(deps): update rust crate smallvec to 1.9

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | smallvec | dependencies | minor | 1.8 -> 1.9 |


    Release Notes

    servo/rust-smallvec

    v1.9.0

    Compare Source

    • Add retain_mut as an alias for retain, for compatibility with std::vec::Vec (#โ€‹283).

    v1.8.1

    Compare Source

    • Optimize inserts at the end of the vector (#โ€‹282).
    • Fix possible aliasing issues with raw pointers (#โ€‹277).
    • Fix format of license field in Cargo manifest (#โ€‹278).

    Configuration

    ๐Ÿ“… Schedule: Branch creation - "every weekend" (UTC), Automerge - At any time (no schedule defined).

    ๐Ÿšฆ Automerge: Disabled by config. Please merge this manually once you are satisfied.

    โ™ป Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    ๐Ÿ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

    released 
    opened by renovate[bot] 1
  • chore(deps): update rust crate rstest to 0.15.0

    chore(deps): update rust crate rstest to 0.15.0

    Mend Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | rstest | dev-dependencies | minor | 0.13.0 -> 0.15.0 |


    Release Notes

    la10736/rstest

    v0.15.0

    Compare Source

    Fixed
    • Timeout not compile if one of its test arguments il not a copy type [see #โ€‹154]

    v0.14.0

    Compare Source

    Changed
    • Feature gated async timeout via async-timeout feature [see #โ€‹148]
    Fixed

    Configuration

    ๐Ÿ“… Schedule: Branch creation - "every weekend" (UTC), Automerge - At any time (no schedule defined).

    ๐Ÿšฆ Automerge: Enabled.

    โ™ป Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    ๐Ÿ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by Mend Renovate. View repository job log here.

    released 
    opened by renovate[bot] 1
  • chore(deps): update rust crate bvh-arena to 1.1

    chore(deps): update rust crate bvh-arena to 1.1

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | bvh-arena | dependencies | minor | 1.0 -> 1.1 |


    Release Notes

    jcornaz/bvh-arena

    v1.1.0

    Compare Source

    Features
    • make 'std' feature explicit (6a69a48)

    Configuration

    ๐Ÿ“… Schedule: At any time (no schedule defined).

    ๐Ÿšฆ Automerge: Disabled by config. Please merge this manually once you are satisfied.

    โ™ป Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    ๐Ÿ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    released 
    opened by renovate[bot] 1
  • chore(deps): update rust crate rstest to 0.13.0

    chore(deps): update rust crate rstest to 0.13.0

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | rstest | dev-dependencies | minor | 0.12.0 -> 0.13.0 |


    Release Notes

    la10736/rstest

    v0.13.0

    Compare Source

    Add
    • #[timeout(duration)] test implementation for both sync and async tests (See #โ€‹136)
    Changed
    • Split rstest in separated crates for macro and libs (See #โ€‹32)

    Configuration

    ๐Ÿ“… Schedule: "every weekend" (UTC).

    ๐Ÿšฆ Automerge: Enabled.

    โ™ป Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    ๐Ÿ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    released 
    opened by renovate[bot] 1
  • chore(deps): update google-github-actions/release-please-action action to v3.2

    chore(deps): update google-github-actions/release-please-action action to v3.2

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | google-github-actions/release-please-action | action | minor | v3.1 -> v3.2 |


    Release Notes

    google-github-actions/release-please-action

    v3.2

    Compare Source


    Configuration

    ๐Ÿ“… Schedule: "every weekend" (UTC).

    ๐Ÿšฆ Automerge: Disabled by config. Please merge this manually once you are satisfied.

    โ™ป Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    ๐Ÿ”• Ignore: Close this PR and you won't be reminded about this update again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    released 
    opened by renovate[bot] 1
  • chore(deps): update rust crate glam to 0.20.5

    chore(deps): update rust crate glam to 0.20.5

    WhiteSource Renovate

    This PR contains the following updates:

    | Package | Type | Update | Change | |---|---|---|---| | glam | dev-dependencies | patch | 0.20.2 -> 0.20.5 | | glam | dependencies | patch | 0.20.2 -> 0.20.5 |


    Release Notes

    bitshifter/glam-rs

    v0.20.5

    Compare Source

    Fixed
    • Fixed a bug in the scalar implemetation of 4D vector max_element method where the w element check was incorrect.

    v0.20.4

    Compare Source

    Fixed
    • Fixed a bug with quaternion slerp with a rotation of tau.

    v0.20.3

    Compare Source

    Added
    • Added to_array() to Quat and DQuat.
    • Added mul_add method to all vector types - note that this will be slower without hardware support enabled.
    • Added the fast-math flag which will sacrifice some float determinism for speed.
    Fixed
    • Fixed a bug in the sse2 and wasm32 implementations of Mat4::determinant().

    Configuration

    ๐Ÿ“… Schedule: "every weekend" (UTC).

    ๐Ÿšฆ Automerge: Enabled.

    โ™ป Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

    ๐Ÿ”• Ignore: Close this PR and you won't be reminded about these updates again.


    • [ ] If you want to rebase/retry this PR, click this checkbox.

    This PR has been generated by WhiteSource Renovate. View repository job log here.

    released 
    opened by renovate[bot] 1
  • chore: configure renovate

    chore: configure renovate

    WhiteSource Renovate

    Welcome to Renovate! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

    ๐Ÿšฆ To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.


    Detected Package Files

    • Cargo.toml (cargo)
    • .github/workflows/build.yml (github-actions)
    • .github/workflows/look-ahead.yml (github-actions)
    • .github/workflows/pr-lints.yml (github-actions)

    Configuration

    ๐Ÿ”ก Renovate has detected a custom config for this PR. Feel free to ask for help if you have any doubts and would like it reviewed.

    Important: Now that this branch is edited, Renovate can't rebase it from the base branch any more. If you make changes to the base branch that could impact this onboarding PR, please merge them manually.

    What to Expect

    With your current configuration, Renovate will create 2 Pull Requests:

    chore(deps): update rust crate glam to 0.20.5
    • Schedule: ["every weekend"]
    • Branch name: renovate/glam-0.20.x
    • Merge into: main
    • Upgrade glam to 0.20.5
    chore(deps): update google-github-actions/release-please-action action to v3.2

    โ“ Got questions? Check out Renovate's Docs, particularly the Getting Started section. If you need any further assistance then you can also request help here.


    This PR has been generated by WhiteSource Renovate. View repository job log here.

    released 
    opened by renovate[bot] 1
  • chore(main): release 1.4.0

    chore(main): release 1.4.0

    :robot: I have created a release beep boop

    1.4.0 (2022-04-15)

    Features

    • interoperabiliby with bevy transform 0.7 (1c394f7)
    • interoperability with bevy ecs 0.7 (8bff495)

    Documentation


    This PR was generated with Release Please. See documentation.

    autorelease: tagged 
    opened by github-actions[bot] 1
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    This repository currently has no open or pending branches.

    Detected dependencies

    cargo
    Cargo.toml
    • bvh-arena 1.1
    • glam 0.22.0
    • thiserror 1.0
    • smallvec 1.10
    • rstest 0.16.0
    • glam 0.22.0
    • approx 0.5.1
    • rustc_version 0.4.0
    github-actions
    .github/workflows/check.yml
    • actions/checkout v3
    • Swatinem/rust-cache v2
    • taiki-e/install-action v2
    • actions/checkout v3
    • Swatinem/rust-cache v2
    • taiki-e/install-action v2
    .github/workflows/release.yml
    • actions/checkout v3
    • taiki-e/install-action v2
    • actions/setup-node v3

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 0
Releases(v1.5.4)
Owner
Jonathan Cornaz
Loving Kotlin and Rust!
Jonathan Cornaz
An asset that provides 2d collision detector and kinematics, build from scratch in bevy

Busturi A physics engine An asset that provides 2d collision detector and kinematics, build from scratch in bevy How to use Add PhysicsPlugin to the p

NemuiSen 2 Jun 22, 2022
Integration layer between Bevy, puffin and tracing libraries

bevy_puffin This crate integrates the puffin library into Bevy. It provides PuffinTracePlugin to use as a replacement for the Bevy's default LogPlugin

Vladyslav Batyrenko 12 Jul 15, 2022
A plugin for Egui integration into Bevy

bevy_egui This crate provides a Egui integration for the Bevy game engine. Features: Desktop and web (bevy_webgl2) platforms support Clipboard (web su

Vladyslav Batyrenko 453 Jan 3, 2023
A real-time raytracing engine, with extra Bevy integration

strolle Strolle (from strรฅlspรฅrning) is a real-time raytracing engine written entirely in Rust, running on CPU & GPU: It comes integrated with Bevy, b

Patryk Wychowaniec 72 Jan 1, 2023
Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.

vx_bevy A voxel engine prototype made using the Bevy game engine. Goals and features Very basic worldgen Animated chunk loading (ala cube world) Optim

Lucas Arriesse 125 Dec 31, 2022
Bevy Simple Portals is a Bevy game engine plugin aimed to create portals.

Portals for Bevy Bevy Simple Portals is a Bevy game engine plugin aimed to create portals. Those portals are (for now) purely visual and can be used t

Sรฉlรจne Amanita 11 May 28, 2023
A game of snake written in Rust using the Bevy game engine, targeting WebGL2

Snake using the Bevy Game Engine Prerequisites cargo install cargo-make Build and serve WASM version Set your local ip address in Makefile.toml (loca

Michael Dorst 0 Dec 26, 2021
2d Endless Runner Game made with Bevy Game Engine

Cute-runner A 2d Endless Runner Game made with Bevy Game Engine. Table of contents Project Infos Usage Screenshots Disclaimer Project Infos Date: Sept

JoaoMarinho 2 Jul 15, 2022
A game made in one week for the Bevy engine's first game jam

ยฟQuien es el MechaBurro? An entry for the first Bevy game jam following the theme of "Unfair Advantage." It was made in one week using the wonderful B

mike 20 Dec 23, 2022
A Client/Server game networking plugin using QUIC, for the Bevy game engine.

Bevy Quinnet A Client/Server game networking plugin using QUIC, for the Bevy game engine. Bevy Quinnet QUIC as a game networking protocol Features Roa

Gilles Henaux 65 Feb 20, 2023
Solana Game Server is a decentralized game server running on Solana, designed for game developers

Solana Game Server* is the first decentralized Game Server (aka web3 game server) designed for game devs. (Think web3 SDK for game developers as a ser

Tardigrade Life Sciences, Inc 16 Dec 1, 2022
A simple example showcasing how to use Bevy to display a square with acceleration (controllable with your keyboard) that wraps around the screen!

Bevy Wrapping Square example A simple example showcasing how to use Bevy to display a square with acceleration (controllable with your keyboard) that

Luciano Mammino 3 Oct 23, 2022
Example implementation of a 3d hexagon tile-based map editor using bevy

bevy-hex-sandbox Example implementation of a 3d hexagon tile-based map editor using bevy v0.10. smol.mov This is not a maintained project. Instead, th

David M. Lary 4 Aug 5, 2023
A simple Rust and WebAssembly example implementing the Game of Life

rust-wasm-game-of-life rust-wasm-game-of-life is a simple Rust and WebAssembly example implementing the Game of Life based on Rust and WebAssembly boo

Chris Ohk 14 Nov 24, 2021
Coordination repository of the Game Development Working Group

Rust Game Development Working Group ??๏ธ The game development working group's main purpose is to make Rust a first-class option for game developers. Wh

Rust game development working group 448 Jan 2, 2023
Minecraft using Bevy and Bevy-Meshem

minecraft_bevy Minecraft_bevy was built to showcase bevy_meshem. After a week of developing it has: Chunk loading / unloading each chunk's mesh is bei

Adam 7 Oct 4, 2023
๐ŸŽฎ A Realtime Multiplayer Server/Client Game example built entirely with Rust ๐Ÿฆ€

Example of a ?? Realtime Multiplayer Web Game Server/Client built entirely using Rust ??

Nick Baker 5 Dec 17, 2022
bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy

Bevy Voxel Cone Tracing bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy. Bevy Version

็ ”็ฉถ็คพไบค 208 Dec 27, 2022
A simple extension for `bevy-editor-pls` to support tilemap editing right inside the bevy app.

What is this This is a simple tilemap editor plugin, that hooks right into bevy_editor_pls to work with bevy_ecs_tilemap. It works completely within i

null 3 May 8, 2023